aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/program.c12
-rw-r--r--src/value.c24
2 files changed, 20 insertions, 16 deletions
diff --git a/src/program.c b/src/program.c
index dc7fe8d..78533f6 100644
--- a/src/program.c
+++ b/src/program.c
@@ -61,6 +61,7 @@ static TslProgramResult tsl_value_create_from_stack_value(TslProgram *self, TslS
break;
}
case TSL_STACK_VALUE_TYPE_STRING: {
+ #if 0
TslString *str = GC_MALLOC_ATOMIC(sizeof(TslString));
str->data = GC_MALLOC_ATOMIC(src->data.str.size + 1);
if(!str) {
@@ -82,6 +83,9 @@ static TslProgramResult tsl_value_create_from_stack_value(TslProgram *self, TslS
dst->data.string = str;
dst->type = TSL_TYPE_STRING;
+ #endif
+ dst->data.string_ref = src->data.str;
+ dst->type = TSL_TYPE_STRING_REF;
break;
}
case TSL_STACK_VALUE_TYPE_FUNCTION: {
@@ -92,8 +96,8 @@ static TslProgramResult tsl_value_create_from_stack_value(TslProgram *self, TslS
case TSL_STACK_VALUE_TYPE_VARIABLE: {
TslValue *var;
TslValue map_key;
- map_key.type = TSL_TYPE_STRING_VIEW;
- map_key.data.string_view = src->data.str;
+ map_key.type = TSL_TYPE_STRING_REF;
+ map_key.data.string_ref = src->data.str;
var = tsl_hash_map_get(self->variables, &map_key);
if(!var) {
@@ -278,8 +282,8 @@ TslProgramResult tsl_program_run(TslProgram *self) {
TslStackValue *stack_value = tsl_buffer_pop(&self->stack_values, sizeof(TslStackValue));
TslValue map_key;
TslValue *map_value;
- map_key.type = TSL_TYPE_STRING_VIEW;
- map_key.data.string_view = instruction_type4->value;
+ map_key.type = TSL_TYPE_STRING_REF;
+ map_key.data.string_ref = instruction_type4->value;
map_value = tsl_hash_map_get_or_create(self->variables, &map_key);
cleanup_if_error(map_value);
diff --git a/src/value.c b/src/value.c
index c08048a..1a76880 100644
--- a/src/value.c
+++ b/src/value.c
@@ -18,9 +18,9 @@ uint64_t tsl_value_hash(const TslValue *key) {
case TSL_TYPE_NUMBER:
return *(uint64_t*)&key->data.number;
case TSL_TYPE_STRING:
- return hash_range(key->data.string->data, key->data.string->size);
- case TSL_TYPE_STRING_VIEW:
- return hash_range((uint8_t*)key->data.string_view.data, key->data.string_view.size);
+ return hash_range((uint8_t*)key->data.string->data, key->data.string->size);
+ case TSL_TYPE_STRING_REF:
+ return hash_range((uint8_t*)key->data.string_ref.data, key->data.string_ref.size);
case TSL_TYPE_BOOL:
return key->data.boolean;
case TSL_TYPE_LIST:
@@ -40,18 +40,18 @@ int tsl_value_equals(const TslValue *lhs, const TslValue *rhs) {
if(lhs->type == TSL_TYPE_STRING) {
return lhs->data.string->size == rhs->data.string->size
&& memcmp(lhs->data.string->data, rhs->data.string->data, lhs->data.string->size) == 0;
- } else if(lhs->type == TSL_TYPE_STRING_VIEW) {
- return lhs->data.string_view.size == rhs->data.string_view.size
- && memcmp(lhs->data.string_view.data, rhs->data.string_view.data, lhs->data.string_view.size) == 0;
+ } else if(lhs->type == TSL_TYPE_STRING_REF) {
+ return lhs->data.string_ref.size == rhs->data.string_ref.size
+ && memcmp(lhs->data.string_ref.data, rhs->data.string_ref.data, lhs->data.string_ref.size) == 0;
} else {
return *(uint64_t*)&lhs->data == *(uint64_t*)&rhs->data;
}
- } else if(lhs->type == TSL_TYPE_STRING && rhs->type == TSL_TYPE_STRING_VIEW) {
- return lhs->data.string->size == rhs->data.string_view.size
- && memcmp(lhs->data.string->data, rhs->data.string_view.data, lhs->data.string->size) == 0;
- } else if(lhs->type == TSL_TYPE_STRING_VIEW && rhs->type == TSL_TYPE_STRING) {
- return lhs->data.string_view.size == rhs->data.string->size
- && memcmp(lhs->data.string_view.data, rhs->data.string->data, lhs->data.string_view.size) == 0;
+ } else if(lhs->type == TSL_TYPE_STRING && rhs->type == TSL_TYPE_STRING_REF) {
+ return lhs->data.string->size == rhs->data.string_ref.size
+ && memcmp(lhs->data.string->data, rhs->data.string_ref.data, lhs->data.string->size) == 0;
+ } else if(lhs->type == TSL_TYPE_STRING_REF && rhs->type == TSL_TYPE_STRING) {
+ return lhs->data.string_ref.size == rhs->data.string->size
+ && memcmp(lhs->data.string_ref.data, rhs->data.string->data, lhs->data.string_ref.size) == 0;
} else {
return 0;
}