mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
Wrote scope docs
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# toy_refstring.h
|
||||
|
||||
This header defines the `Toy_RefString` structure, as well as all of the related utilities.
|
||||
This header defines the structure `Toy_RefString`, as well as all of the related utilities.
|
||||
|
||||
[refstring](https://github.com/Ratstail91/refstring) is a stand-alone utility written to reduce the amount of memory manipulation used within Toy. It was independantly written and tested, before being incorporated into Toy proper. As such it has it's own memory management API, which by default is tied into Toy's [core memory API](toy_memory_h.md).
|
||||
|
||||
|
||||
46
c-api/toy_scope_h.md
Normal file
46
c-api/toy_scope_h.md
Normal file
@@ -0,0 +1,46 @@
|
||||
# toy_scope.h
|
||||
|
||||
This header defines the `Toy_Scope` structure, which stores all of the variables used within a given block of code.
|
||||
|
||||
Scopes are arranged into a linked list of ancestors, each of which is reference counted. When a scope is popped off the end of the chain, every ancestor scope has it's reference counter reduced by 1 and, if any reach 0, they are freed.
|
||||
|
||||
## Defined Functions
|
||||
|
||||
### Toy_Scope* Toy_pushScope(Toy_Scope* scope)
|
||||
|
||||
This function creates a new `Toy_scope` with `scope` as it's ancestor, and returns it.
|
||||
|
||||
### Toy_Scope* Toy_popScope(Toy_Scope* scope)
|
||||
|
||||
This function frees the given `scope`, and returns it's ancestor.
|
||||
|
||||
### Toy_Scope* Toy_copyScope(Toy_Scope* original)
|
||||
|
||||
This function copies an existing scope, and returns the copy.
|
||||
|
||||
### bool Toy_declareScopeVariable(Toy_Scope* scope, Toy_Literal key, Toy_Literal type)
|
||||
|
||||
This function declares a new variable `key` within `scope`, giving it the type of `type`.
|
||||
|
||||
This function returns true on success, otherwise it returns failure (such as if the given key already exists).
|
||||
|
||||
### bool Toy_isDelcaredScopeVariable(Toy_Scope* scope, Toy_Literal key)
|
||||
|
||||
This function checks to see if a given variable with the name `key` has been previously declared.
|
||||
|
||||
### bool Toy_setScopeVariable(Toy_Scope* scope, Toy_Literal key, Toy_Literal value, bool constCheck)
|
||||
|
||||
This function sets an existing variable named `key` to the value of `value`. This function fails if `constCheck` is true and the given key's type has the constaant flag set. It also fails if the given key doesn't exist.
|
||||
|
||||
This function returns true on success, otherwise it returns false.
|
||||
|
||||
### bool Toy_getScopeVariable(Toy_Scope* scope, Toy_Literal key, Toy_Literal* value)
|
||||
|
||||
This function sets the literal pointed to by `value` to equal the variable named `key`.
|
||||
|
||||
This function returns true on success, otherwise it returns false.
|
||||
|
||||
### Toy_Literal Toy_getScopeType(Toy_Scope* scope, Toy_Literal key)
|
||||
|
||||
This function returns a new `Toy_Literal` representing the type of the variable named `key`.
|
||||
|
||||
Reference in New Issue
Block a user