about summary refs log tree commit diff
path: root/src/fstate.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2003-08-15T12·32+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2003-08-15T12·32+0000
commit555347744d116b0152a04d4fdb08258276d34199 (patch)
treed3331f1ec3b67671d210c0cc0a85d6c709bd4924 /src/fstate.cc
parente374dbf89b0ba9a4f5835ef9ac30eda6df1dce6a (diff)
* Derivation expressions now can specify arguments to be passed to the
  builder.  Note that this unfortunately causes all Fix-computed
  hashes to change.

Diffstat (limited to 'src/fstate.cc')
-rw-r--r--src/fstate.cc33
1 files changed, 27 insertions, 6 deletions
diff --git a/src/fstate.cc b/src/fstate.cc
index 2e2857ffc9f6..47a93901feab 100644
--- a/src/fstate.cc
+++ b/src/fstate.cc
@@ -120,13 +120,19 @@ static bool parseSlice(ATerm t, Slice & slice)
 
 static bool parseDerive(ATerm t, Derive & derive)
 {
-    ATermList outs, ins, bnds;
+    ATermList outs, ins, args, bnds;
     char * builder;
     char * platform;
 
-    if (!ATmatch(t, "Derive([<list>], [<list>], <str>, <str>, [<list>])",
-            &outs, &ins, &builder, &platform, &bnds))
-        return false;
+    if (!ATmatch(t, "Derive([<list>], [<list>], <str>, <str>, [<list>], [<list>])",
+            &outs, &ins, &platform, &builder, &args, &bnds))
+    {
+        /* !!! compatibility -> remove eventually */
+        if (!ATmatch(t, "Derive([<list>], [<list>], <str>, <str>, [<list>])",
+                &outs, &ins, &builder, &platform, &bnds))
+            return false;
+        args = ATempty;
+    }
 
     while (!ATisEmpty(outs)) {
         char * s1, * s2;
@@ -142,6 +148,15 @@ static bool parseDerive(ATerm t, Derive & derive)
     derive.builder = builder;
     derive.platform = platform;
     
+    while (!ATisEmpty(args)) {
+        char * s;
+        ATerm arg = ATgetFirst(args);
+        if (!ATmatch(arg, "<str>", &s))
+            throw badTerm("string expected", arg);
+        derive.args.push_back(s);
+        args = ATgetNext(args);
+    }
+
     while (!ATisEmpty(bnds)) {
         char * s1, * s2;
         ATerm bnd = ATgetFirst(bnds);
@@ -204,6 +219,11 @@ static ATerm unparseDerive(const Derive & derive)
             ATmake("(<str>, <str>)", 
                 i->first.c_str(), ((string) i->second).c_str()));
     
+    ATermList args = ATempty;
+    for (Strings::const_iterator i = derive.args.begin();
+         i != derive.args.end(); i++)
+        args = ATinsert(args, ATmake("<str>", i->c_str()));
+
     ATermList env = ATempty;
     for (StringPairs::const_iterator i = derive.env.begin();
          i != derive.env.end(); i++)
@@ -211,11 +231,12 @@ static ATerm unparseDerive(const Derive & derive)
             ATmake("(<str>, <str>)", 
                 i->first.c_str(), i->second.c_str()));
 
-    return ATmake("Derive(<term>, <term>, <str>, <str>, <term>)",
+    return ATmake("Derive(<term>, <term>, <str>, <str>, <term>, <term>)",
         ATreverse(outs),
         unparseIds(derive.inputs),
-        derive.builder.c_str(),
         derive.platform.c_str(),
+        derive.builder.c_str(),
+        ATreverse(args),
         ATreverse(env));
 }