changed table types to support implementing 'let', also integrated stdlib into repl

This commit is contained in:
Aidan 2020-06-21 12:46:25 -07:00
parent b01415d786
commit 9c25ac21f9
No known key found for this signature in database
GPG key ID: 327711E983899316
5 changed files with 16 additions and 58 deletions

View file

@ -28,7 +28,7 @@ type Function struct {
Args int // TODO: Make this a list of expected types (TAGs)
}
type FuncTable map[string]*Function
type FuncTable *map[string]*Function
// TODO: Currently only checks arg list length
func (f Function) ParseFunction(args *Token) bool {
@ -64,8 +64,8 @@ func (f Function) CallFunction(args *Token, vt VarTable, ft FuncTable) *Token {
return f.Function(args, vt, ft)
}
func (table FuncTable) GetFunction(arg string) *Function {
target, ok := table[arg]
func GetFunction(arg string, table FuncTable) *Function {
target, ok := (*table)[arg]
if !ok {
log.Log(log.DEBUG,
"function " + arg + " not found",