lang: ast: Implement lambdas
This is a big giant patch that implements the AST part of lambdas! I don't know how Sam is able to understand the AST so well, but he does, and we're all grateful for it. Most of this code was written by him. Co-authored-by: Samuel Gélineau <gelisam@gmail.com>
This commit is contained in:
1332
lang/ast/structs.go
1332
lang/ast/structs.go
File diff suppressed because it is too large
Load Diff
@@ -70,7 +70,19 @@ func FuncPrefixToFunctionsScope(prefix string) map[string]interfaces.Expr {
|
|||||||
}
|
}
|
||||||
exprs[name] = fn
|
exprs[name] = fn
|
||||||
}
|
}
|
||||||
return exprs
|
|
||||||
|
// Wrap every Expr in ExprPoly, so that the function can be used with
|
||||||
|
// different types. Those functions are all builtins, so they don't need to
|
||||||
|
// access the surrounding scope.
|
||||||
|
exprPolys := make(map[string]interfaces.Expr)
|
||||||
|
for name, expr := range exprs {
|
||||||
|
exprPolys[name] = &ExprPoly{
|
||||||
|
Definition: expr,
|
||||||
|
CapturedScope: interfaces.EmptyScope(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return exprPolys
|
||||||
}
|
}
|
||||||
|
|
||||||
// VarPrefixToVariablesScope is a helper function to return the variables
|
// VarPrefixToVariablesScope is a helper function to return the variables
|
||||||
|
|||||||
Reference in New Issue
Block a user