From: Jérémie Astor Date: Mon, 16 Aug 2021 06:39:38 +0000 (+0200) Subject: :art: Keep track of string *delim* X-Git-Tag: nightly~470^2~83 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=fb0211694191710941d0b90437fca3b4e1e16518;p=gwion.git :art: Keep track of string *delim* --- diff --git a/ast b/ast index 83f85714..1279070b 160000 --- a/ast +++ b/ast @@ -1 +1 @@ -Subproject commit 83f857146706db6c97b5489152cded2be8083852 +Subproject commit 1279070bc5b6fe3ed22bef485c5e66bd85f50da7 diff --git a/fmt b/fmt index 2e1dfca4..03d98cb9 160000 --- a/fmt +++ b/fmt @@ -1 +1 @@ -Subproject commit 2e1dfca4383f2672dc524ca999a1c014a24f503c +Subproject commit 03d98cb98e0f51492f1b0e569debc01ddabd2167 diff --git a/src/emit/emit.c b/src/emit/emit.c index 4b348a8a..cede1865 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -713,13 +713,14 @@ ANN static m_bool emit_prim_char(const Emitter emit, const m_str *str) { return GW_OK; } -ANN static m_bool emit_prim_str(const Emitter emit, const m_str *str) { +ANN static m_bool emit_prim_str(const Emitter emit, const struct AstString *str) { const Value v = prim_self(str)->value; if (!v->d.obj) { - char c[strlen(*str) + 1]; - if (strlen(*str)) { - strcpy(c, *str); - CHECK_BB(escape_str(emit, c, prim_pos(str))); + const size_t sz = strlen(str->data); + char c[sz + 1]; + if (sz) { + strcpy(c, str->data); + CHECK_BB(escape_str(emit, c, prim_pos(str->data))); ; } else c[0] = '\0'; diff --git a/src/lib/string.c b/src/lib/string.c index 06814347..05c56d9a 100644 --- a/src/lib/string.c +++ b/src/lib/string.c @@ -45,8 +45,8 @@ describe_string_logical(eq, (!strcmp(STRING(lhs), STRING(rhs)))) return env->gwion->type[et_bool]; \ } -opck_str(eq, !strcmp(bin->lhs->d.prim.d.str, bin->rhs->d.prim.d.str)) - opck_str(neq, strcmp(bin->lhs->d.prim.d.str, bin->rhs->d.prim.d.str)) +opck_str(eq, !strcmp(bin->lhs->d.prim.d.string.data, bin->rhs->d.prim.d.string.data)) + opck_str(neq, strcmp(bin->lhs->d.prim.d.string.data, bin->rhs->d.prim.d.string.data)) static CTOR(string_ctor) { STRING(o) = _mp_calloc(shred->info->mp, 1); @@ -56,10 +56,11 @@ static DTOR(string_dtor) { free_mstr(shred->info->mp, STRING(o)); } ID_CHECK(check_funcpp) { ((Exp_Primary *)prim)->prim_type = ae_prim_str; - ((Exp_Primary *)prim)->d.str = env->func ? env->func->name + ((Exp_Primary *)prim)->d.string.data = env->func ? env->func->name : env->class_def ? env->class_def->name : env->name; - ((Exp_Primary *)prim)->value = global_string(env, prim->d.str); +// handle delim? + ((Exp_Primary *)prim)->value = global_string(env, prim->d.string.data); return prim->value->type; } diff --git a/src/parse/check.c b/src/parse/check.c index 17fe2b3a..217289bf 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -348,9 +348,9 @@ ANN static Type prim_id_non_res(const Env env, const Symbol *data) { return v->type; } -ANN Type check_prim_str(const Env env, const m_str *data) { +ANN Type check_prim_str(const Env env, const struct AstString *data) { if (!prim_self(data)->value) - prim_self(data)->value = global_string(env, *data); + prim_self(data)->value = global_string(env, data->data); return env->gwion->type[et_string]; // prim->value }