make the garbage collector less terrible

This commit is contained in:
suchmememanyskill
2021-07-10 01:12:39 +02:00
parent 65a28d8ef6
commit 91af9b4437
6 changed files with 42 additions and 1 deletions

View File

@@ -47,12 +47,23 @@ ClassFunction(getStringLength) {
return newIntVariablePtr(strlen(s1));
}
ClassFunction(stringBytes) {
Variable_t v = { 0 };
v.variableType = ByteArrayClass;
u32 len = strlen(caller->string.value);
v.solvedArray.vector = newVec(1, len);
v.solvedArray.vector.count = len;
memcpy(v.solvedArray.vector.data, caller->string.value, len);
return copyVariableToPtr(v);
}
u8 oneStringArg[] = { StringClass };
ClassFunctionTableEntry_t stringFunctions[] = {
{"print", printStringVariable, 0, 0},
{"+", addStringVariables, 1, oneStringArg },
{"len", getStringLength, 0, 0},
{"bytes", stringBytes, 0, 0},
};
Variable_t getStringMember(Variable_t* var, char* memberName) {