Skip to content

Commit

Permalink
Improved failure detection in CompiledConsole; closes #1099
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulKlint committed Jun 22, 2017
1 parent 7d2c3ef commit 4056564
Showing 1 changed file with 23 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -532,12 +532,16 @@ private IValue evalStatement(String src, ITree stat) throws RascalShellExecution
Variable var = variables.get(name);
if(var != null){
val = executeModule("\nvalue main() { " + src + "}\n", true);
updateVar(name, val);
if(val != null){
updateVar(name, val);
}
return val;
} else {
val = executeModule(makeMain(unparse(get(stat, "statement"))), true);
declareVar(val.getType().toString(), name);
updateVar(name, val);
if(val != null){
declareVar(val.getType().toString(), name);
updateVar(name, val);
}
forceRecompilation = true;
return val;
}
Expand All @@ -547,7 +551,7 @@ private IValue evalStatement(String src, ITree stat) throws RascalShellExecution
String name = getBaseVar(assignable);
Variable var = variables.get(name);
val = executeModule(makeMain(unparse(get(stat, "statement"))), true);
if(var != null){
if(var != null && val != null){
annotateVar(name, annoName, val);
}
return val;
Expand All @@ -556,7 +560,7 @@ private IValue evalStatement(String src, ITree stat) throws RascalShellExecution
String name = getBaseVar(assignable);
Variable var = variables.get(name);
val = executeModule(makeMain(src), true);
if(var == null){
if(var == null && val != null){
declareVar(val.getType().toString(), name);
updateVar(name, val);
}
Expand All @@ -566,19 +570,20 @@ private IValue evalStatement(String src, ITree stat) throws RascalShellExecution
case "tuple": {
ITree elements = get(assignable, "elements");
val = executeModule(makeMain(unparse(get(stat, "statement"))), true);

ITuple tupleVal = (ITuple) val;
IList elemList = TreeAdapter.getListASTArgs(elements);
for(int i = 0; i < elemList.length(); i++){
ITree element = (ITree) elemList.get(i);
String elemName = getBaseVar((ITree)element);
if(elemName != null){
declareVar(val.getType().getFieldType(i).toString(), elemName);
updateVar(elemName, tupleVal.get(i));
forceRecompilation = true;
} else {
return reportError("Assignable is not supported: " + unparse((ITree)element));
}
if(val != null){
ITuple tupleVal = (ITuple) val;
IList elemList = TreeAdapter.getListASTArgs(elements);
for(int i = 0; i < elemList.length(); i++){
ITree element = (ITree) elemList.get(i);
String elemName = getBaseVar((ITree)element);
if(elemName != null){
declareVar(val.getType().getFieldType(i).toString(), elemName);
updateVar(elemName, tupleVal.get(i));
forceRecompilation = true;
} else {
return reportError("Assignable is not supported: " + unparse((ITree)element));
}
}
}
return val;
}
Expand Down

0 comments on commit 4056564

Please sign in to comment.