Skip to content

Commit

Permalink
Added missing case for field update on ADTs
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulKlint committed Dec 23, 2013
1 parent ee43f53 commit caf33da
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -490,20 +490,23 @@ MuExp translate (e:(Expression) `<Expression expression> . <Name field>`) {
// Field update
MuExp translate (e:(Expression) `<Expression expression> [ <Name key> = <Expression replacement> ]`) {
tp = getType(expression@\loc);
tp = getType(expression@\loc);
list[str] fieldNames = [];
if(isRelType(tp)){
tp = getSetElementType(tp);
} else if(isListType(tp)){
tp = getListElementType(tp);
} else if(isMapType(tp)){
tp = getMapFieldsAsTuple(tp);
} else if(isADTType(tp)){
println("tp = <tp>");
return muCallPrim("adt_field_update", [ translate(expression), muCon("<key>"), translate(replacement) ]);
}
if(tupleHasFieldNames(tp)){
fieldNames = getTupleFieldNames(tp);
fieldNames = getTupleFieldNames(tp);
}
return muCallPrim("<getOuterType(expression)>_update", [ translate(expression), muCon(indexOf(fieldNames, "<key>")), translate(replacement) ]);
//muCallPrim("<getOuterType(expression)>_field_update", [ translate(expression), muCon("<key>"), translate(replacement) ]);
}
// Field project
Expand All @@ -518,7 +521,7 @@ MuExp translate (e:(Expression) `<Expression expression> \< <{Field ","}+ fields
tp = getMapFieldsAsTuple(tp);
}
if(tupleHasFieldNames(tp)){
fieldNames = getTupleFieldNames(tp);
fieldNames = getTupleFieldNames(tp);
}
fcode = [(f is index) ? muCon(toInt("<f>")) : muCon(indexOf(fieldNames, "<f>")) | f <- fields];
//fcode = [(f is index) ? muCon(toInt("<f>")) : muCon("<f>") | f <- fields];
Expand Down

0 comments on commit caf33da

Please sign in to comment.