changed dot operator to access global functions

This commit is contained in:
2022-09-08 01:18:20 +01:00
parent 8550f3141c
commit 5861602f23
11 changed files with 81 additions and 378 deletions

View File

@@ -913,70 +913,6 @@ int _index(Interpreter* interpreter, LiteralArray* arguments) {
return 1;
}
int _dot(Interpreter* interpreter, LiteralArray* arguments) {
//_dot(compound, first, assignValue, opcode)
Literal op = popLiteralArray(arguments);
Literal assign = popLiteralArray(arguments);
Literal first = popLiteralArray(arguments);
Literal compound = popLiteralArray(arguments);
Literal value = getLiteralDictionary(AS_DICTIONARY(compound), first);
//dictionary
if (IS_NULL(op)) {
pushLiteralArray(&interpreter->stack, value);
}
else if (!strcmp( AS_STRING(op), "=")) {
setLiteralDictionary(AS_DICTIONARY(compound), first, assign);
pushLiteralArray(&interpreter->stack, compound);
}
else if (!strcmp( AS_STRING(op), "+=")) {
Literal lit = addition(interpreter, value, assign);
setLiteralDictionary(AS_DICTIONARY(compound), first, lit);
freeLiteral(lit);
pushLiteralArray(&interpreter->stack, compound);
}
else if (!strcmp( AS_STRING(op), "-=")) {
Literal lit = subtraction(interpreter, value, assign);
setLiteralDictionary(AS_DICTIONARY(compound), first, lit);
freeLiteral(lit);
pushLiteralArray(&interpreter->stack, compound);
}
else if (!strcmp( AS_STRING(op), "*=")) {
Literal lit = multiplication(interpreter, value, assign);
setLiteralDictionary(AS_DICTIONARY(compound), first, lit);
freeLiteral(lit);
pushLiteralArray(&interpreter->stack, compound);
}
else if (!strcmp( AS_STRING(op), "/=")) {
Literal lit = division(interpreter, value, assign);
setLiteralDictionary(AS_DICTIONARY(compound), first, lit);
freeLiteral(lit);
pushLiteralArray(&interpreter->stack, compound);
}
else if (!strcmp( AS_STRING(op), "%=")) {
Literal lit = modulo(interpreter, value, assign);
setLiteralDictionary(AS_DICTIONARY(compound), first, lit);
freeLiteral(lit);
pushLiteralArray(&interpreter->stack, compound);
}
//cleanup
freeLiteral(op);
freeLiteral(assign);
freeLiteral(first);
freeLiteral(compound);
freeLiteral(value);
return 1;
}
int _set(Interpreter* interpreter, LiteralArray* arguments) {
//if wrong number of arguments, fail
if (arguments->count != 3) {