mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 23:04:08 +10:00
changed dot operator to access global functions
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user