mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
This is an incomplete process. It's supposed to be robust enough to support the types of arrays and dictionaries, but arrays and dictionaries aren't implemented in the literals yet, so that's my next task. I'll come back to variable declarations later.
22 lines
542 B
C
22 lines
542 B
C
#pragma once
|
|
|
|
#include "common.h"
|
|
#include "literal_dictionary.h"
|
|
|
|
typedef struct Scope {
|
|
LiteralDictionary variables; //only allow identifiers as the keys
|
|
struct Scope* ancestor;
|
|
int references; //how many scopes point here
|
|
} Scope;
|
|
|
|
Scope* pushScope(Scope* scope);
|
|
Scope* popScope(Scope* scope);
|
|
|
|
//returns false if error
|
|
bool declareScopeVariable(Scope* scope, Literal key);
|
|
|
|
//return false if undefined
|
|
bool setScopeVariable(Scope* scope, Literal key, Literal value);
|
|
bool getScopeVariable(Scope* scope, Literal key, Literal* value);
|
|
|