diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-08-18 20:28:16 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-08-18 20:28:39 -0400 |
| commit | d804b09b02b9c4a6ea6b16ae85524a704796cbc1 (patch) | |
| tree | 3379d64b028a80825a892c87176b6bb6d6cc3484 /compile.c | |
| parent | c338c3f08c6a13242e975dd344bad63a3cec9eee (diff) | |
Added a .length field to arrays/sets/tables, added a .max_size field to
channels, and updated the API
Diffstat (limited to 'compile.c')
| -rw-r--r-- | compile.c | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -2630,13 +2630,27 @@ CORD compile(env_t *env, ast_t *ast) } code_err(ast, "The field '%s' is not a valid field name of %T", f->field, value_t); } + case ArrayType: { + if (streq(f->field, "length")) + return CORD_all("Int64_to_Int((", compile_to_pointer_depth(env, f->fielded, 0, false), ").length)"); + code_err(ast, "There is no %s field on arrays", f->field); + } + case ChannelType: { + if (streq(f->field, "max_size")) + return CORD_all("Int64_to_Int((", compile_to_pointer_depth(env, f->fielded, 0, false), ")->max_size)"); + code_err(ast, "There is no %s field on arrays", f->field); + } case SetType: { if (streq(f->field, "items")) return CORD_all("(", compile_to_pointer_depth(env, f->fielded, 0, false), ").entries"); + else if (streq(f->field, "length")) + return CORD_all("Int64_to_Int((", compile_to_pointer_depth(env, f->fielded, 0, false), ").entries.length)"); code_err(ast, "There is no '%s' field on sets", f->field); } case TableType: { - if (streq(f->field, "keys")) { + if (streq(f->field, "length")) { + return CORD_all("Int64_to_Int((", compile_to_pointer_depth(env, f->fielded, 0, false), ").entries.length)"); + } else if (streq(f->field, "keys")) { return CORD_all("(", compile_to_pointer_depth(env, f->fielded, 0, false), ").entries"); } else if (streq(f->field, "values")) { auto table = Match(value_t, TableType); |
