From caf33da9b68d886108fbccdf3809407417eed27f Mon Sep 17 00:00:00 2001 From: paulklint Date: Mon, 23 Dec 2013 12:08:58 +0100 Subject: [PATCH] Added missing case for field update on ADTs --- .../Compiler/Rascal2muRascal/RascalExpression.rsc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/org/rascalmpl/library/experiments/Compiler/Rascal2muRascal/RascalExpression.rsc b/src/org/rascalmpl/library/experiments/Compiler/Rascal2muRascal/RascalExpression.rsc index cba5128beb5..6835f6175d3 100644 --- a/src/org/rascalmpl/library/experiments/Compiler/Rascal2muRascal/RascalExpression.rsc +++ b/src/org/rascalmpl/library/experiments/Compiler/Rascal2muRascal/RascalExpression.rsc @@ -490,7 +490,8 @@ MuExp translate (e:(Expression) ` . `) { // Field update MuExp translate (e:(Expression) ` [ = ]`) { - tp = getType(expression@\loc); + tp = getType(expression@\loc); + list[str] fieldNames = []; if(isRelType(tp)){ tp = getSetElementType(tp); @@ -498,12 +499,14 @@ MuExp translate (e:(Expression) ` [ = "); + return muCallPrim("adt_field_update", [ translate(expression), muCon(""), translate(replacement) ]); } if(tupleHasFieldNames(tp)){ - fieldNames = getTupleFieldNames(tp); + fieldNames = getTupleFieldNames(tp); } return muCallPrim("_update", [ translate(expression), muCon(indexOf(fieldNames, "")), translate(replacement) ]); - //muCallPrim("_field_update", [ translate(expression), muCon(""), translate(replacement) ]); } // Field project @@ -518,7 +521,7 @@ MuExp translate (e:(Expression) ` \< <{Field ","}+ fields tp = getMapFieldsAsTuple(tp); } if(tupleHasFieldNames(tp)){ - fieldNames = getTupleFieldNames(tp); + fieldNames = getTupleFieldNames(tp); } fcode = [(f is index) ? muCon(toInt("")) : muCon(indexOf(fieldNames, "")) | f <- fields]; //fcode = [(f is index) ? muCon(toInt("")) : muCon("") | f <- fields];