lang: funcs: vars: Include system package variables in the scope
This commit is contained in:
@@ -3433,10 +3433,13 @@ func (obj *StmtProg) importSystemScope(name string) (*interfaces.Scope, error) {
|
|||||||
// TODO: do we want to run Interpolate or SetScope?
|
// TODO: do we want to run Interpolate or SetScope?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: pass `data` into ast.VarPrefixToVariablesScope ?
|
||||||
|
variables := VarPrefixToVariablesScope(name) // strips prefix!
|
||||||
|
|
||||||
// initial scope, built from core golang code
|
// initial scope, built from core golang code
|
||||||
scope := &interfaces.Scope{
|
scope := &interfaces.Scope{
|
||||||
// TODO: we could use the core API for variables somehow...
|
// TODO: we could use the core API for variables somehow...
|
||||||
//Variables: make(map[string]interfaces.Expr),
|
Variables: variables,
|
||||||
Functions: functions, // map[string]interfaces.Expr
|
Functions: functions, // map[string]interfaces.Expr
|
||||||
// TODO: we could add a core API for classes too!
|
// TODO: we could add a core API for classes too!
|
||||||
//Classes: make(map[string]interfaces.Stmt),
|
//Classes: make(map[string]interfaces.Stmt),
|
||||||
|
|||||||
@@ -46,6 +46,11 @@ const (
|
|||||||
ResourceNamespace = "res"
|
ResourceNamespace = "res"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Value is a shortcut to using this type.
|
||||||
|
// XXX: Eventually we might get rid of this entirely and use types.Value instead
|
||||||
|
// of interfaces.Var which seems to be unnecessary at the moment.
|
||||||
|
type Value = interfaces.Var
|
||||||
|
|
||||||
// registeredVars is a global map of all possible vars which can be used. You
|
// registeredVars is a global map of all possible vars which can be used. You
|
||||||
// should never touch this map directly. Use methods like Register instead.
|
// should never touch this map directly. Use methods like Register instead.
|
||||||
var registeredVars = make(map[string]func() interfaces.Var) // must initialize
|
var registeredVars = make(map[string]func() interfaces.Var) // must initialize
|
||||||
@@ -63,9 +68,9 @@ func Register(name string, fn func() interfaces.Var) {
|
|||||||
|
|
||||||
// ModuleRegister is exactly like Register, except that it registers within a
|
// ModuleRegister is exactly like Register, except that it registers within a
|
||||||
// named module. This is a helper function.
|
// named module. This is a helper function.
|
||||||
//func ModuleRegister(module, name string, v func() interfaces.Var) {
|
func ModuleRegister(module, name string, v func() interfaces.Var) {
|
||||||
// Register(module+interfaces.ModuleSep+name, v)
|
Register(module+interfaces.ModuleSep+name, v)
|
||||||
//}
|
}
|
||||||
|
|
||||||
// resourceConstHelper is a helper function to manage the const topology.
|
// resourceConstHelper is a helper function to manage the const topology.
|
||||||
func resourceConstHelper(kind, param, field string) string {
|
func resourceConstHelper(kind, param, field string) string {
|
||||||
|
|||||||
Reference in New Issue
Block a user