mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
It's bloody never-ending
This commit is contained in:
@@ -1625,7 +1625,7 @@ static bool execIndexAssign(Interpreter* interpreter) {
|
||||
LiteralArray arguments;
|
||||
initLiteralArray(&arguments);
|
||||
|
||||
pushLiteralArray(&arguments, compound);
|
||||
pushLiteralArray(&arguments, compound); //TODO: nested compounds?
|
||||
pushLiteralArray(&arguments, first);
|
||||
pushLiteralArray(&arguments, second);
|
||||
pushLiteralArray(&arguments, third);
|
||||
@@ -2267,7 +2267,7 @@ static void readInterpreterSections(Interpreter* interpreter) {
|
||||
if (AS_TYPE(typeLiteral).typeOf == LITERAL_ARRAY) {
|
||||
unsigned short vt = readShort(interpreter->bytecode, &interpreter->count);
|
||||
|
||||
TYPE_PUSH_SUBTYPE(&typeLiteral, interpreter->literalCache.literals[vt]);
|
||||
TYPE_PUSH_SUBTYPE(&typeLiteral, copyLiteral(interpreter->literalCache.literals[vt]));
|
||||
}
|
||||
|
||||
if (AS_TYPE(typeLiteral).typeOf == LITERAL_DICTIONARY) {
|
||||
|
||||
@@ -55,6 +55,10 @@ static bool checkType(Literal typeLiteral, Literal value) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (AS_TYPE(typeLiteral).typeOf == LITERAL_ARRAY && !IS_ARRAY(value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (IS_ARRAY(value)) {
|
||||
//check value's type
|
||||
if (AS_TYPE(typeLiteral).typeOf != LITERAL_ARRAY) {
|
||||
@@ -69,6 +73,10 @@ static bool checkType(Literal typeLiteral, Literal value) {
|
||||
}
|
||||
}
|
||||
|
||||
if (AS_TYPE(typeLiteral).typeOf == LITERAL_DICTIONARY && !IS_DICTIONARY(value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (IS_DICTIONARY(value)) {
|
||||
//check value's type
|
||||
if (AS_TYPE(typeLiteral).typeOf != LITERAL_DICTIONARY) {
|
||||
@@ -90,11 +98,8 @@ static bool checkType(Literal typeLiteral, Literal value) {
|
||||
}
|
||||
}
|
||||
|
||||
if (IS_FUNCTION(value)) {
|
||||
//check value's type
|
||||
if (AS_TYPE(typeLiteral).typeOf != LITERAL_FUNCTION) {
|
||||
return false;
|
||||
}
|
||||
if (AS_TYPE(typeLiteral).typeOf == LITERAL_FUNCTION && !IS_FUNCTION(value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (AS_TYPE(typeLiteral).typeOf == LITERAL_TYPE && !IS_TYPE(value)) {
|
||||
@@ -217,11 +222,13 @@ bool setScopeVariable(Scope* scope, Literal key, Literal value, bool constCheck)
|
||||
Literal typeLiteral = getLiteralDictionary(&scope->types, key);
|
||||
|
||||
if (!checkType(typeLiteral, value)) {
|
||||
freeLiteral(typeLiteral);
|
||||
return false;
|
||||
}
|
||||
|
||||
//const check
|
||||
if (constCheck && (AS_TYPE(typeLiteral).constant)) {
|
||||
freeLiteral(typeLiteral);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,4 +23,3 @@ bool setScopeVariable(Scope* scope, Literal key, Literal value, bool constCheck)
|
||||
bool getScopeVariable(Scope* scope, Literal key, Literal* value);
|
||||
|
||||
Literal getScopeType(Scope* scope, Literal key);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user