mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 23:04:08 +10:00
Opaque type check added
This commit is contained in:
@@ -2316,7 +2316,6 @@ static void readInterpreterSections(Toy_Interpreter* interpreter) {
|
|||||||
|
|
||||||
//change the type to normal
|
//change the type to normal
|
||||||
interpreter->literalCache.literals[i] = TOY_TO_FUNCTION_LITERAL(bytes, size);
|
interpreter->literalCache.literals[i] = TOY_TO_FUNCTION_LITERAL(bytes, size);
|
||||||
TOY_AS_FUNCTION(interpreter->literalCache.literals[i]).scope = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -159,6 +159,10 @@ static bool checkType(Toy_Literal typeLiteral, Toy_Literal original, Toy_Literal
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (TOY_AS_TYPE(typeLiteral).typeOf == TOY_LITERAL_OPAQUE && !TOY_IS_OPAQUE(value)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,7 +189,7 @@ Toy_Scope* Toy_popScope(Toy_Scope* scope) {
|
|||||||
|
|
||||||
Toy_Scope* ret = scope->ancestor;
|
Toy_Scope* ret = scope->ancestor;
|
||||||
|
|
||||||
//BUGFIX: when freeing a scope, free the function's scopes manually
|
//BUGFIX: when freeing a scope, free the functions' scopes manually - I *think* this is related to the closure hack-in
|
||||||
for (int i = 0; i < scope->variables.capacity; i++) {
|
for (int i = 0; i < scope->variables.capacity; i++) {
|
||||||
//handle keys, just in case
|
//handle keys, just in case
|
||||||
if (TOY_IS_FUNCTION(scope->variables.entries[i].key)) {
|
if (TOY_IS_FUNCTION(scope->variables.entries[i].key)) {
|
||||||
@@ -286,7 +290,7 @@ bool Toy_setScopeVariable(Toy_Scope* scope, Toy_Literal key, Toy_Literal value,
|
|||||||
}
|
}
|
||||||
|
|
||||||
//actually assign
|
//actually assign
|
||||||
Toy_setLiteralDictionary(&scope->variables, key, value);
|
Toy_setLiteralDictionary(&scope->variables, key, value); //key & value are copied here
|
||||||
|
|
||||||
Toy_freeLiteral(typeLiteral);
|
Toy_freeLiteral(typeLiteral);
|
||||||
Toy_freeLiteral(original);
|
Toy_freeLiteral(original);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "toy_literal.h"
|
||||||
#include "toy_literal_array.h"
|
#include "toy_literal_array.h"
|
||||||
#include "toy_literal_dictionary.h"
|
#include "toy_literal_dictionary.h"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user