diff options
author | Shea Levy <shea@shealevy.com> | 2013-09-13T20·55-0400 |
---|---|---|
committer | Shea Levy <shea@shealevy.com> | 2013-12-31T17·45+0000 |
commit | 136f2f7046dfed18fde0b5f9933ddfafc1518ef5 (patch) | |
tree | 203804716694587a810096af3d75ea3a41c9bbe1 /src/libexpr/nixexpr.cc | |
parent | 5ba5993470a6ad532fc8e842084a574a88876b0a (diff) |
Add the ExprBuiltin Expr type to the AST
Certain desugaring schemes may require the parser to use some builtin function to do some of the work (e.g. currently `throw` is used to lazily cause an error if a `<>`-style path is not in the search path) Unfortunately, these names are not reserved keywords, so an expression that uses such a syntactic sugar will not see the expected behavior (see tests/lang/eval-okay-redefine-builtin.nix for an example). This adds the ExprBuiltin AST type, which when evaluated uses the value from the rootmost variable scope (which of course is initialized internally and can't shadow any of the builtins). Signed-off-by: Shea Levy <shea@shealevy.com>
Diffstat (limited to 'src/libexpr/nixexpr.cc')
-rw-r--r-- | src/libexpr/nixexpr.cc | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libexpr/nixexpr.cc b/src/libexpr/nixexpr.cc index f4b4295e290c..c7ac967968d7 100644 --- a/src/libexpr/nixexpr.cc +++ b/src/libexpr/nixexpr.cc @@ -121,6 +121,11 @@ void ExprOpNot::show(std::ostream & str) str << "! " << *e; } +void ExprBuiltin::show(std::ostream & str) +{ + str << "builtins." << name; +} + void ExprConcatStrings::show(std::ostream & str) { bool first = true; @@ -314,6 +319,10 @@ void ExprOpNot::bindVars(const StaticEnv & env) e->bindVars(env); } +void ExprBuiltin::bindVars(const StaticEnv & env) +{ +} + void ExprConcatStrings::bindVars(const StaticEnv & env) { foreach (vector<Expr *>::iterator, i, *es) |