Toy 1.1.6
The Toy programming language is an imperative bytecode-intermediate embedded scripting language
Loading...
Searching...
No Matches
toy_scope.h
Go to the documentation of this file.
1
7#ifndef TOY_SCOPE_H_
8#define TOY_SCOPE_H_
9
10#include <stdbool.h>
11
12#include "toy_literal.h"
13#include "toy_literal_array.h"
15
21typedef struct Toy_Scope {
27
36
45
53TOY_API Toy_Scope* Toy_copyScope(Toy_Scope *original);
54
55//returns false if error
67
77
78//return false if undefined
90TOY_API bool Toy_setScopeVariable(Toy_Scope *scope, Toy_Literal key, Toy_Literal value, bool constCheck);
91
102TOY_API bool Toy_getScopeVariable(Toy_Scope *scope, Toy_Literal key, Toy_Literal *value);
103
113
114#endif /* TOY_SCOPE_H_ */
Definition: toy_literal_dictionary.h:31
Definition: toy_literal.h:85
Definition: toy_scope.h:21
struct Toy_Scope * ancestor
Definition: toy_scope.h:24
Toy_LiteralDictionary variables
Definition: toy_scope.h:22
int references
Definition: toy_scope.h:25
Toy_LiteralDictionary types
Definition: toy_scope.h:23
TOY_API bool Toy_declareScopeVariable(Toy_Scope *scope, Toy_Literal key, Toy_Literal type)
Declares a new variable key within scope, giving it the type of type. This function returns true on s...
TOY_API bool Toy_setScopeVariable(Toy_Scope *scope, Toy_Literal key, Toy_Literal value, bool constCheck)
Sets an existing variable named key to the value of value. This function fails if constCheck is true ...
TOY_API Toy_Scope * Toy_pushScope(Toy_Scope *scope)
Creates a new Toy_scope with scope as it's ancestor, and returns it.
TOY_API bool Toy_isDelcaredScopeVariable(Toy_Scope *scope, Toy_Literal key)
Checks to see if a given variable with the name key has been previously declared.
TOY_API Toy_Literal Toy_getScopeType(Toy_Scope *scope, Toy_Literal key)
Returns a new Toy_Literal representing the type of the variable named key.
TOY_API Toy_Scope * Toy_popScope(Toy_Scope *scope)
Frees the given scope, and returns it's ancestor.
TOY_API Toy_Scope * Toy_copyScope(Toy_Scope *original)
Copies an existing scope, and returns the copy.
TOY_API bool Toy_getScopeVariable(Toy_Scope *scope, Toy_Literal key, Toy_Literal *value)
Sets the literal pointed to by value to equal the variable named key. Returns true on success,...