From 5fe9222b36ad49d74c84edb04d6bc4a7d844be01 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 26 Oct 2004 22:54:26 +0000 Subject: * Don't use ATmake / ATmatch anymore, nor the ATMatcher class. Instead we generate data bindings (build and match functions) for the constructors specified in `constructors.def'. In particular this removes the conversions between AFuns and strings, and Nix expression evaluation now seems 3 to 4 times faster. --- src/libexpr/parser.cc | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'src/libexpr/parser.cc') diff --git a/src/libexpr/parser.cc b/src/libexpr/parser.cc index 763faacf7be3..a0a6c01df762 100644 --- a/src/libexpr/parser.cc +++ b/src/libexpr/parser.cc @@ -7,6 +7,7 @@ #include "aterm.hh" #include "parser.hh" +#include "constructors.hh" struct ParseData @@ -45,28 +46,24 @@ void parseError(ParseData * data, char * error, int line, int column) ATerm fixAttrs(int recursive, ATermList as) { - ATMatcher m; ATermList bs = ATempty, cs = ATempty; ATermList * is = recursive ? &cs : &bs; for (ATermIterator i(as); i; ++i) { ATermList names; Expr src; ATerm pos; - if (atMatch(m, *i) >> "Inherit" >> src >> names >> pos) { - bool fromScope = atMatch(m, src) >> "Scope"; + if (matchInherit(*i, src, names, pos)) { + bool fromScope = matchScope(src); for (ATermIterator j(names); j; ++j) { - Expr rhs = fromScope - ? ATmake("Var()", *j) - : ATmake("Select(, )", src, *j); - *is = ATinsert(*is, ATmake("Bind(, , )", - *j, rhs, pos)); + Expr rhs = fromScope ? makeVar(*j) : makeSelect(src, *j); + *is = ATinsert(*is, makeBind(*j, rhs, pos)); } } else bs = ATinsert(bs, *i); } if (recursive) - return ATmake("Rec(, )", bs, cs); + return makeRec(bs, cs); else - return ATmake("Attrs()", bs); + return makeAttrs(bs); } const char * getPath(ParseData * data) -- cgit 1.4.1