mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 23:04:08 +10:00
Dummied out _index
This commit is contained in:
@@ -2,7 +2,10 @@
|
|||||||
|
|
||||||
#include "interpreter.h"
|
#include "interpreter.h"
|
||||||
|
|
||||||
|
//the _index function is a historical oddity - it's used whenever a compound is indexed
|
||||||
int _index(Interpreter* interpreter, LiteralArray* arguments);
|
int _index(Interpreter* interpreter, LiteralArray* arguments);
|
||||||
|
|
||||||
|
//globally available native functions
|
||||||
int _set(Interpreter* interpreter, LiteralArray* arguments);
|
int _set(Interpreter* interpreter, LiteralArray* arguments);
|
||||||
int _get(Interpreter* interpreter, LiteralArray* arguments);
|
int _get(Interpreter* interpreter, LiteralArray* arguments);
|
||||||
int _push(Interpreter* interpreter, LiteralArray* arguments);
|
int _push(Interpreter* interpreter, LiteralArray* arguments);
|
||||||
|
|||||||
@@ -1540,26 +1540,6 @@ static bool execIndex(Interpreter* interpreter, bool assignIntermediate) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//get the index function
|
|
||||||
Literal func = TO_NULL_LITERAL;
|
|
||||||
char* keyStr = "_index";
|
|
||||||
int keyStrLength = strlen(keyStr);
|
|
||||||
Literal key = TO_IDENTIFIER_LITERAL(createRefStringLength(keyStr, keyStrLength));
|
|
||||||
|
|
||||||
if (!getScopeVariable(interpreter->scope, key, &func) || !IS_FUNCTION_NATIVE(func)) {
|
|
||||||
interpreter->errorOutput("couldn't get the _index function\n");
|
|
||||||
freeLiteral(third);
|
|
||||||
freeLiteral(second);
|
|
||||||
freeLiteral(first);
|
|
||||||
freeLiteral(compound);
|
|
||||||
if (freeIdn) {
|
|
||||||
freeLiteral(idn);
|
|
||||||
}
|
|
||||||
freeLiteral(func);
|
|
||||||
freeLiteral(key);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//build the argument list
|
//build the argument list
|
||||||
LiteralArray arguments;
|
LiteralArray arguments;
|
||||||
initLiteralArray(&arguments);
|
initLiteralArray(&arguments);
|
||||||
@@ -1582,9 +1562,8 @@ static bool execIndex(Interpreter* interpreter, bool assignIntermediate) {
|
|||||||
pushLiteralArray(&interpreter->stack, third);
|
pushLiteralArray(&interpreter->stack, third);
|
||||||
}
|
}
|
||||||
|
|
||||||
//call the function
|
//call the _index function
|
||||||
NativeFn fn = (NativeFn)AS_FUNCTION(func).bytecode;
|
_index(interpreter, &arguments);
|
||||||
fn(interpreter, &arguments);
|
|
||||||
|
|
||||||
//clean up
|
//clean up
|
||||||
freeLiteral(third);
|
freeLiteral(third);
|
||||||
@@ -1594,8 +1573,6 @@ static bool execIndex(Interpreter* interpreter, bool assignIntermediate) {
|
|||||||
if (freeIdn) {
|
if (freeIdn) {
|
||||||
freeLiteral(idn);
|
freeLiteral(idn);
|
||||||
}
|
}
|
||||||
freeLiteral(func);
|
|
||||||
freeLiteral(key);
|
|
||||||
freeLiteralArray(&arguments);
|
freeLiteralArray(&arguments);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -1639,27 +1616,6 @@ static bool execIndexAssign(Interpreter* interpreter) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//get the index function
|
|
||||||
Literal func = TO_NULL_LITERAL;
|
|
||||||
char* keyStr = "_index";
|
|
||||||
int keyStrLength = strlen(keyStr);
|
|
||||||
Literal key = TO_IDENTIFIER_LITERAL(createRefStringLength(keyStr, keyStrLength));
|
|
||||||
|
|
||||||
if (!getScopeVariable(interpreter->scope, key, &func) || !IS_FUNCTION_NATIVE(func)) {
|
|
||||||
interpreter->errorOutput("couldn't get the _index function\n");
|
|
||||||
freeLiteral(assign);
|
|
||||||
freeLiteral(third);
|
|
||||||
freeLiteral(second);
|
|
||||||
freeLiteral(first);
|
|
||||||
freeLiteral(compound);
|
|
||||||
if (freeIdn) {
|
|
||||||
freeLiteral(idn);
|
|
||||||
}
|
|
||||||
freeLiteral(func);
|
|
||||||
freeLiteral(key);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//build the opcode
|
//build the opcode
|
||||||
unsigned char opcode = readByte(interpreter->bytecode, &interpreter->count);
|
unsigned char opcode = readByte(interpreter->bytecode, &interpreter->count);
|
||||||
char* opStr = "";
|
char* opStr = "";
|
||||||
@@ -1693,8 +1649,6 @@ static bool execIndexAssign(Interpreter* interpreter) {
|
|||||||
if (freeIdn) {
|
if (freeIdn) {
|
||||||
freeLiteral(idn);
|
freeLiteral(idn);
|
||||||
}
|
}
|
||||||
freeLiteral(func);
|
|
||||||
freeLiteral(key);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1705,16 +1659,15 @@ static bool execIndexAssign(Interpreter* interpreter) {
|
|||||||
LiteralArray arguments;
|
LiteralArray arguments;
|
||||||
initLiteralArray(&arguments);
|
initLiteralArray(&arguments);
|
||||||
|
|
||||||
pushLiteralArray(&arguments, compound); //TODO: nested compounds?
|
pushLiteralArray(&arguments, compound);
|
||||||
pushLiteralArray(&arguments, first);
|
pushLiteralArray(&arguments, first);
|
||||||
pushLiteralArray(&arguments, second);
|
pushLiteralArray(&arguments, second);
|
||||||
pushLiteralArray(&arguments, third);
|
pushLiteralArray(&arguments, third);
|
||||||
pushLiteralArray(&arguments, assign); //it expects an assignment command
|
pushLiteralArray(&arguments, assign); //it expects an assignment command
|
||||||
pushLiteralArray(&arguments, op); //it expects an assignment "opcode"
|
pushLiteralArray(&arguments, op); //it expects an assignment "opcode"
|
||||||
|
|
||||||
//call the function
|
//call the _index function
|
||||||
NativeFn fn = (NativeFn)AS_FUNCTION(func).bytecode;
|
if (_index(interpreter, &arguments) == -1) {
|
||||||
if (fn(interpreter, &arguments) == -1) {
|
|
||||||
//clean up
|
//clean up
|
||||||
freeLiteral(assign);
|
freeLiteral(assign);
|
||||||
freeLiteral(third);
|
freeLiteral(third);
|
||||||
@@ -1724,8 +1677,6 @@ static bool execIndexAssign(Interpreter* interpreter) {
|
|||||||
if (freeIdn) {
|
if (freeIdn) {
|
||||||
freeLiteral(idn);
|
freeLiteral(idn);
|
||||||
}
|
}
|
||||||
freeLiteral(func);
|
|
||||||
freeLiteral(key);
|
|
||||||
freeLiteral(op);
|
freeLiteral(op);
|
||||||
freeLiteralArray(&arguments);
|
freeLiteralArray(&arguments);
|
||||||
|
|
||||||
@@ -1764,7 +1715,7 @@ static bool execIndexAssign(Interpreter* interpreter) {
|
|||||||
pushLiteralArray(&arguments, result);
|
pushLiteralArray(&arguments, result);
|
||||||
pushLiteralArray(&arguments, op);
|
pushLiteralArray(&arguments, op);
|
||||||
|
|
||||||
fn(interpreter, &arguments);
|
_index(interpreter, &arguments);
|
||||||
|
|
||||||
freeLiteral(result);
|
freeLiteral(result);
|
||||||
result = popLiteralArray(&interpreter->stack);
|
result = popLiteralArray(&interpreter->stack);
|
||||||
@@ -1789,8 +1740,6 @@ static bool execIndexAssign(Interpreter* interpreter) {
|
|||||||
if (freeIdn) {
|
if (freeIdn) {
|
||||||
freeLiteral(idn);
|
freeLiteral(idn);
|
||||||
}
|
}
|
||||||
freeLiteral(func);
|
|
||||||
freeLiteral(key);
|
|
||||||
freeLiteral(op);
|
freeLiteral(op);
|
||||||
freeLiteralArray(&arguments);
|
freeLiteralArray(&arguments);
|
||||||
freeLiteral(result);
|
freeLiteral(result);
|
||||||
@@ -1806,8 +1755,6 @@ static bool execIndexAssign(Interpreter* interpreter) {
|
|||||||
if (freeIdn) {
|
if (freeIdn) {
|
||||||
freeLiteral(idn);
|
freeLiteral(idn);
|
||||||
}
|
}
|
||||||
freeLiteral(func);
|
|
||||||
freeLiteral(key);
|
|
||||||
freeLiteral(op);
|
freeLiteral(op);
|
||||||
freeLiteralArray(&arguments);
|
freeLiteralArray(&arguments);
|
||||||
freeLiteral(result);
|
freeLiteral(result);
|
||||||
@@ -2430,7 +2377,6 @@ void resetInterpreter(Interpreter* interpreter) {
|
|||||||
interpreter->scope = pushScope(NULL);
|
interpreter->scope = pushScope(NULL);
|
||||||
|
|
||||||
//globally available functions
|
//globally available functions
|
||||||
injectNativeFn(interpreter, "_index", _index);
|
|
||||||
injectNativeFn(interpreter, "_set", _set);
|
injectNativeFn(interpreter, "_set", _set);
|
||||||
injectNativeFn(interpreter, "_get", _get);
|
injectNativeFn(interpreter, "_get", _get);
|
||||||
injectNativeFn(interpreter, "_push", _push);
|
injectNativeFn(interpreter, "_push", _push);
|
||||||
|
|||||||
Reference in New Issue
Block a user