[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
10/118: Remove ExprBuiltin
From: |
Ludovic Courtès |
Subject: |
10/118: Remove ExprBuiltin |
Date: |
Tue, 19 May 2015 14:45:12 +0000 |
civodul pushed a commit to branch nix
in repository guix.
commit d8c061e044a07f7516d76df12bc6920f4f04e5ff
Author: Eelco Dolstra <address@hidden>
Date: Mon May 26 17:14:28 2014 +0200
Remove ExprBuiltin
It's slower than ExprVar since it doesn't compute a static
displacement. Since we're not using the throw primop in the
implementation of <...> anymore, it's also not really needed.
---
src/libexpr/eval.cc | 11 -----------
src/libexpr/nixexpr.cc | 9 ---------
src/libexpr/nixexpr.hh | 7 -------
src/libexpr/parser.y | 16 ++++++++--------
4 files changed, 8 insertions(+), 35 deletions(-)
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index b6b69c2..81ce7d9 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -1004,17 +1004,6 @@ void ExprOpNot::eval(EvalState & state, Env & env, Value
& v)
}
-void ExprBuiltin::eval(EvalState & state, Env & env, Value & v)
-{
- // Not a hot path at all, but would be nice to access state.baseEnv
directly
- Env *baseEnv = &env;
- while (baseEnv->up) baseEnv = baseEnv->up;
- Bindings::iterator binding = baseEnv->values[0]->attrs->find(name);
- assert(binding != baseEnv->values[0]->attrs->end());
- v = *binding->value;
-}
-
-
void ExprOpEq::eval(EvalState & state, Env & env, Value & v)
{
Value v1; e1->eval(state, env, v1);
diff --git a/src/libexpr/nixexpr.cc b/src/libexpr/nixexpr.cc
index d40250d..b916a26 100644
--- a/src/libexpr/nixexpr.cc
+++ b/src/libexpr/nixexpr.cc
@@ -123,11 +123,6 @@ 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;
@@ -342,10 +337,6 @@ 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)
diff --git a/src/libexpr/nixexpr.hh b/src/libexpr/nixexpr.hh
index 8826ad2..3df9dd4 100644
--- a/src/libexpr/nixexpr.hh
+++ b/src/libexpr/nixexpr.hh
@@ -272,13 +272,6 @@ struct ExprOpNot : Expr
COMMON_METHODS
};
-struct ExprBuiltin : Expr
-{
- Symbol name;
- ExprBuiltin(const Symbol & name) : name(name) { };
- COMMON_METHODS
-};
-
#define MakeBinOp(name, s) \
struct Expr##name : Expr \
{ \
diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y
index 134d68d..a27c530 100644
--- a/src/libexpr/parser.y
+++ b/src/libexpr/parser.y
@@ -328,13 +328,13 @@ expr_if
expr_op
: '!' expr_op %prec NOT { $$ = new ExprOpNot($2); }
-| '-' expr_op %prec NEGATE { $$ = new ExprApp(CUR_POS, new ExprApp(new
ExprBuiltin(data->symbols.create("sub")), new ExprInt(0)), $2); }
+ | '-' expr_op %prec NEGATE { $$ = new ExprApp(CUR_POS, new ExprApp(new
ExprVar(data->symbols.create("__sub")), new ExprInt(0)), $2); }
| expr_op EQ expr_op { $$ = new ExprOpEq($1, $3); }
| expr_op NEQ expr_op { $$ = new ExprOpNEq($1, $3); }
- | expr_op '<' expr_op { $$ = new ExprApp(CUR_POS, new ExprApp(new
ExprBuiltin(data->symbols.create("lessThan")), $1), $3); }
- | expr_op LEQ expr_op { $$ = new ExprOpNot(new ExprApp(CUR_POS, new
ExprApp(new ExprBuiltin(data->symbols.create("lessThan")), $3), $1)); }
- | expr_op '>' expr_op { $$ = new ExprApp(CUR_POS, new ExprApp(new
ExprBuiltin(data->symbols.create("lessThan")), $3), $1); }
- | expr_op GEQ expr_op { $$ = new ExprOpNot(new ExprApp(CUR_POS, new
ExprApp(new ExprBuiltin(data->symbols.create("lessThan")), $1), $3)); }
+ | expr_op '<' expr_op { $$ = new ExprApp(CUR_POS, new ExprApp(new
ExprVar(data->symbols.create("__lessThan")), $1), $3); }
+ | expr_op LEQ expr_op { $$ = new ExprOpNot(new ExprApp(CUR_POS, new
ExprApp(new ExprVar(data->symbols.create("__lessThan")), $3), $1)); }
+ | expr_op '>' expr_op { $$ = new ExprApp(CUR_POS, new ExprApp(new
ExprVar(data->symbols.create("__lessThan")), $3), $1); }
+ | expr_op GEQ expr_op { $$ = new ExprOpNot(new ExprApp(CUR_POS, new
ExprApp(new ExprVar(data->symbols.create("__lessThan")), $1), $3)); }
| expr_op AND expr_op { $$ = new ExprOpAnd(CUR_POS, $1, $3); }
| expr_op OR expr_op { $$ = new ExprOpOr(CUR_POS, $1, $3); }
| expr_op IMPL expr_op { $$ = new ExprOpImpl(CUR_POS, $1, $3); }
@@ -346,9 +346,9 @@ expr_op
l->push_back($3);
$$ = new ExprConcatStrings(CUR_POS, false, l);
}
- | expr_op '-' expr_op { $$ = new ExprApp(CUR_POS, new ExprApp(new
ExprBuiltin(data->symbols.create("sub")), $1), $3); }
- | expr_op '*' expr_op { $$ = new ExprApp(CUR_POS, new ExprApp(new
ExprBuiltin(data->symbols.create("mul")), $1), $3); }
- | expr_op '/' expr_op { $$ = new ExprApp(CUR_POS, new ExprApp(new
ExprBuiltin(data->symbols.create("div")), $1), $3); }
+ | expr_op '-' expr_op { $$ = new ExprApp(CUR_POS, new ExprApp(new
ExprVar(data->symbols.create("__sub")), $1), $3); }
+ | expr_op '*' expr_op { $$ = new ExprApp(CUR_POS, new ExprApp(new
ExprVar(data->symbols.create("__mul")), $1), $3); }
+ | expr_op '/' expr_op { $$ = new ExprApp(CUR_POS, new ExprApp(new
ExprVar(data->symbols.create("__div")), $1), $3); }
| expr_op CONCAT expr_op { $$ = new ExprOpConcatLists(CUR_POS, $1, $3); }
| expr_app
;
- 01/118: Provide a more useful error message when a dynamic attr lookup fails, (continued)
- 01/118: Provide a more useful error message when a dynamic attr lookup fails, Ludovic Courtès, 2015/05/19
- 08/118: Ensure that -I flags get included in nixPath, Ludovic Courtès, 2015/05/19
- 05/118: Shut up some signedness warnings, Ludovic Courtès, 2015/05/19
- 02/118: nix-store -l: Fetch build logs from the Internet, Ludovic Courtès, 2015/05/19
- 03/118: Disable parallel.sh test, Ludovic Courtès, 2015/05/19
- 07/118: Add constant ‘nixPath’, Ludovic Courtès, 2015/05/19
- 14/118: Use std::unordered_set, Ludovic Courtès, 2015/05/19
- 13/118: nix-build: --add-root also takes 1 parameter, Ludovic Courtès, 2015/05/19
- 16/118: Fix test, Ludovic Courtès, 2015/05/19
- 15/118: Sort nixPath attributes, Ludovic Courtès, 2015/05/19
- 10/118: Remove ExprBuiltin,
Ludovic Courtès <=
- 09/118: Make the Nix search path declarative, Ludovic Courtès, 2015/05/19
- 04/118: Ugly hack to allow --argstr values starting with a dash, Ludovic Courtès, 2015/05/19
- 19/118: Report daemon OOM better, Ludovic Courtès, 2015/05/19
- 06/118: Add primop ‘scopedImport’, Ludovic Courtès, 2015/05/19
- 21/118: Add autoloads, make code more concise & idiomatic, Ludovic Courtès, 2015/05/19
- 25/118: Fix bogus warnings about dumping large paths, Ludovic Courtès, 2015/05/19
- 20/118: == operator: Ignore string context, Ludovic Courtès, 2015/05/19
- 17/118: nix-env -qa --json: Generate valid JSON even if there are invalid meta attrs, Ludovic Courtès, 2015/05/19
- 23/118: findFile: Realise the context of the path attributes, Ludovic Courtès, 2015/05/19
- 11/118: Rephrase @ operator description, Ludovic Courtès, 2015/05/19