Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,41 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "$GENERATED_PARSER$244372483",
"request": "launch",
"mainClass": "org.rascalmpl.test.parser.$GENERATED_PARSER$244372483",
"projectName": "rascal"
},
{
"type": "java",
"name": "$GENERATED_PARSER$279786030",
"request": "launch",
"mainClass": "org.rascalmpl.test.parser.$GENERATED_PARSER$279786030",
"projectName": "rascal"
},
{
"type": "java",
"name": "TopLevelStarListEmpty",
"request": "launch",
"mainClass": "org.rascalmpl.test.parser.TopLevelStarListEmpty",
"projectName": "rascal"
},
{
"type": "java",
"name": "TopLevelStarList",
"request": "launch",
"mainClass": "org.rascalmpl.test.parser.TopLevelStarList",
"projectName": "rascal"
},
{
"type": "java",
"name": "NonTerminalStarListEmpty",
"request": "launch",
"mainClass": "org.rascalmpl.test.parser.NonTerminalStarListEmpty",
"projectName": "rascal"
},
{
"type": "java",
"name": "RascalCheck",
Expand Down
2 changes: 1 addition & 1 deletion src/org/rascalmpl/exceptions/JavaCompilation.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class JavaCompilation extends RuntimeException {
private final long column;

public JavaCompilation(String message, long line, long column, String source, Exception cause) {
super("Java compilation failed due to " + message, cause);
super("Java compilation failed due to " + message + " at " + line + ", " + column, cause);
this.source = source;
this.line = line;
this.column = column;
Expand Down
4 changes: 4 additions & 0 deletions src/org/rascalmpl/exceptions/RuntimeExceptionFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,10 @@ public static Throw jsonParseError(ISourceLocation file, int line, int col, Stri
public static Throw parseError(ISourceLocation loc, AbstractAST ast, StackTrace trace) {
return new Throw(VF.constructor(ParseError, loc), ast != null ? ast.getLocation() : null, trace);
}

public static Throw parseError(ISourceLocation loc, ISourceLocation caller, StackTrace trace) {
return new Throw(VF.constructor(ParseError, loc), caller, trace);
}

// pathNotFound

Expand Down
19 changes: 9 additions & 10 deletions src/org/rascalmpl/exceptions/Throw.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@
* of exception values, not different kind of Java classes.
*/
public final class Throw extends ControlException {
public static final String RASCAL_FILL_IN_LATER = "rascalfillinlater";
private static final long serialVersionUID = -7290501865940548332L;
private final IValue exception;
private volatile ISourceLocation loc;
private volatile StackTrace trace;
private ISourceLocation loc;
private StackTrace trace;

/**
* Make a new Rascal exception.
Expand All @@ -50,26 +51,23 @@ public final class Throw extends ControlException {
public Throw(IValue value, ISourceLocation loc, StackTrace trace) {
super(toString(value, 4096));
this.exception = value;
this.loc = loc;
this.loc = loc != null ? loc : URIUtil.rootLocation(RASCAL_FILL_IN_LATER);
if(trace == null) {
trace = StackTrace.EMPTY_STACK_TRACE;
}
this.trace = trace;
}

/**
* Make a new Rascal exception.
* Make a new Rascal exception, where location and trace
* are to be filled in later by the runtime, automatically.
*
* @param value The Rascal exception value
* @param loc A source location, or null if unavailable
* @param trace A stack trace, or null
*/
public Throw(IValue value) {
super(toString(value, 4096));
this.exception = value;
// TODO: convert top stack frame location to rascal loc
this.loc = URIUtil.rootLocation("TODO");
// TODO: convert JVM trace to Rascal trace..
this.loc = URIUtil.rootLocation(RASCAL_FILL_IN_LATER);
this.trace = StackTrace.EMPTY_STACK_TRACE;
}

Expand Down Expand Up @@ -106,7 +104,7 @@ public StackTrace getTrace() {
* @param trace The new trace, or null for an empty trace
*/
public void setTrace(StackTrace trace) {
if(trace == null) {
if (trace == null) {
trace = StackTrace.EMPTY_STACK_TRACE;
}
this.trace = trace;
Expand All @@ -130,6 +128,7 @@ public ISourceLocation getLocation() {
* @param loc The source location, or null
*/
public void setLocation(ISourceLocation loc) {
assert loc != null;
this.loc = loc;
}

Expand Down
7 changes: 4 additions & 3 deletions src/org/rascalmpl/interpreter/result/JavaMethod.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public Result<IValue> call(Type[] actualStaticTypes, IValue[] actuals, Map<Strin

try {
ctx.pushEnv(getName());

ctx.setCurrentAST(getAst()); // otherwise it becomes the final parameter of the call site
Environment env = ctx.getCurrentEnvt();
Map<Type, Type> renamings = Collections.emptyMap();

Expand Down Expand Up @@ -327,10 +327,11 @@ public IValue invoke(Object[] oActuals) {
trace.addAll(th.getTrace());

ISourceLocation loc = th.getLocation();
if (loc == null || loc.getScheme().equals("TODO")) {
if (loc == null || loc.getScheme().equals(Throw.RASCAL_FILL_IN_LATER)) {
// this happens when Throw is created without a current AST location and a trace.
loc = getAst().getLocation();
}
trace.add(loc, null);
trace.add(loc, name);

th.setLocation(loc);
trace.addAll(eval.getStackTrace());
Expand Down
1 change: 0 additions & 1 deletion src/org/rascalmpl/interpreter/result/RascalFunction.java
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,6 @@ public Result<IValue> call(Type[] actualStaticTypes, IValue[] actuals, Map<Strin
// formals are now bound by side effect of the pattern matcher
try {
bindKeywordArgs(keyArgValues);

result = runBody();
storeMemoizedResult(actuals, keyArgValues, result);
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,10 @@ public static void throwMessage(PrintWriter out, Throw e, StandardTextWriter pre
prettyPrinter.write(e.getException(), lros);
}
}
catch(/*IOLimitReachedException*/ RuntimeException iolrex){
catch (/*IOLimitReachedException*/ RuntimeException iolrex){
// This is fine, ignore.
}
catch(IOException ioex){
catch (IOException ioex){
// This can/should never happen.
}

Expand Down
Loading
Loading