Skip to content

Instantly share code, notes, and snippets.

@ejamesc
Created March 22, 2012 17:06
Show Gist options
  • Select an option

  • Save ejamesc/2159782 to your computer and use it in GitHub Desktop.

Select an option

Save ejamesc/2159782 to your computer and use it in GitHub Desktop.
Assignment
public StoreAndValue eval(Store s, Environment e) {
StoreAndValue s_and_v = rightHandSide.eval(s, e);
int loc = s.newLocation();
// Be careful of this. It might be wrong, though it works now
e.extendDestructive(leftHandSide, loc);
if (s_and_v.value instanceof BoolValue) {
BoolValue res = (BoolValue) s_and_v.value;
s = s.extend(loc, res);
return new StoreAndValue(s, res);
} else if (s_and_v.value instanceof IntValue) {
IntValue res = (IntValue) s_and_v.value;
s = s.extend(loc, res);
return new StoreAndValue(s, res);
} else if (s_and_v.value instanceof FunValue) {
FunValue res = (FunValue) s_and_v.value;
s = s.extend(loc, res);
return new StoreAndValue(s, res);
} else {
return new StoreAndValue(s,new BoolValue(true));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment