mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 23:04:08 +10:00
Added scopes using '{}' symbols, read more
I've also added a new literal type called 'identifier'. This will be used for variable names, and has a type mask embedded in it.
This commit is contained in:
21
source/scope.h
Normal file
21
source/scope.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include "common.h"
|
||||
#include "literal_dictionary.h"
|
||||
|
||||
typedef struct Scope {
|
||||
LiteralDictionary variables;
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user