mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-19 16:54:08 +10:00
Variables now persist between statements
This commit is contained in:
@@ -44,17 +44,17 @@ Scope* popScope(Scope* scope) {
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#include <stdio.h>
|
||||
//returns false if error
|
||||
bool declareScopeVariable(Scope* scope, Literal key, Literal type) {
|
||||
//store the type, for later checking on assignment
|
||||
setLiteralDictionary(&scope->types, key, type);
|
||||
|
||||
//don't redefine a variable within this scope
|
||||
if (existsLiteralDictionary(&scope->variables, key)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//store the type, for later checking on assignment
|
||||
setLiteralDictionary(&scope->types, key, type);
|
||||
|
||||
setLiteralDictionary(&scope->variables, key, TO_NULL_LITERAL);
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user