Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/cwi-swat/rascal.git
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulKlint committed Jun 5, 2015
2 parents cb88fd3 + d1aaa23 commit 06fba64
Show file tree
Hide file tree
Showing 20 changed files with 87 additions and 82 deletions.
3 changes: 1 addition & 2 deletions src/org/rascalmpl/interpreter/StackTraceEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,12 @@ void format(StringBuilder b, boolean withLink) {
b.append("*** somewhere ***");
}
b.append("(");
URI uri = loc.getURI();
if(withLink) {
// b.append("\uE007[");
b.append(loc.toString());
}
else {
b.append(uri.getRawPath());
b.append(loc.getPath());
// if(withLink) {
// b.append("](");
// b.append(uri);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ public FailedTestError(AbstractAST t, Throwable e) {

@Override
public String getMessage() {
URI url = loc.getURI();

return (url.getScheme().equals("file") ? (url.getAuthority() + url.getPath()) : url)
return (loc.getScheme().equals("file") ? (loc.getAuthority() + loc.getPath()) : loc.top())
+ ":" + loc.getBeginLine()
+ "," + loc.getBeginColumn()
+ ": " + super.getMessage()
Expand Down
4 changes: 1 addition & 3 deletions src/org/rascalmpl/interpreter/control_exceptions/Throw.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,7 @@ public Throwable fillInStackTrace() {
@Override
public String getMessage() {
if (loc != null) {
URI url = loc.getURI();

return (url.getScheme().equals("file") ? (url.getAuthority() + url.getPath()) : url)
return (loc.getScheme().equals("file") ? (loc.getAuthority() + loc.getPath()) : loc.top())
+ ":" + loc.getBeginLine()
+ "," + loc.getBeginColumn()
+ ": " + super.getMessage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ else if (name.equals("user")) {
break;

case "top":
return makeResult(tf.sourceLocationType(), vf.sourceLocation(value.getURI()), ctx);
return makeResult(tf.sourceLocationType(), value.top(), ctx);

// now the calculated fields
case "parent": {
Expand Down Expand Up @@ -668,7 +668,7 @@ protected LessThanOrEqualResult lessThanOrEqualSourceLocation(SourceLocationResu
ISourceLocation left = that.getValue();
ISourceLocation right = this.getValue();

int compare = left.getURI().toString().compareTo(right.getURI().toString());
int compare = left.top().toString().compareTo(right.top().toString());
if (compare < 0) {
return new LessThanOrEqualResult(true, false, ctx);
}
Expand Down Expand Up @@ -728,7 +728,7 @@ protected int compareSourceLocationInt(SourceLocationResult that) {
}

// they are not the same
int compare = left.getURI().toString().compareTo(right.getURI().toString());
int compare = left.top().toString().compareTo(right.top().toString());
if (compare != 0) {
return compare;
}
Expand Down
15 changes: 7 additions & 8 deletions src/org/rascalmpl/interpreter/staticErrors/StaticError.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public ISourceLocation getLocation() {
}

public void setLocation(ISourceLocation loc) {
String mod = loc.getURI().getPath().replaceAll("^.*/", "").replaceAll("\\..*$", "");
getStackTrace()[0] = new StackTraceElement(mod, "?", loc.getURI().getPath(), loc.getBeginLine());
String mod = loc.getPath().replaceAll("^.*/", "").replaceAll("\\..*$", "");
getStackTrace()[0] = new StackTraceElement(mod, "?", loc.getPath(), loc.getBeginLine());

this.loc = loc;
}
Expand All @@ -66,20 +66,19 @@ private void addStackTraceElement(ISourceLocation loc) {
StackTraceElement[] stackTrace = new StackTraceElement[oldStackTrace.length+1];
int i = 0;

URI uri = loc.getURI();
String mod;
if(uri.getScheme().equals("rascal"))
mod = uri.getAuthority();
if(loc.getScheme().equals("rascal"))
mod = loc.getAuthority();
else
mod = uri.getPath().replaceAll("^.*/", "").replaceAll("\\..*$", "");
mod = loc.getPath().replaceAll("^.*/", "").replaceAll("\\..*$", "");
if(mod == null)
mod = "<empty>";

if (loc.hasLineColumn()) {
stackTrace[i++] = new StackTraceElement(mod, "?", loc.getURI().getPath(), loc.getBeginLine());
stackTrace[i++] = new StackTraceElement(mod, "?", loc.getPath(), loc.getBeginLine());
}
else {
stackTrace[i++] = new StackTraceElement(mod, "?", loc.getURI().getPath(), 1);
stackTrace[i++] = new StackTraceElement(mod, "?", loc.getPath(), 1);
}

for (StackTraceElement elt : oldStackTrace) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public void registerSourceResolver(String scheme, ICallableValue function) {
}

public ISourceLocation resolveSourceLocation(ISourceLocation loc) {
String scheme = loc.getURI().getScheme();
String scheme = loc.getScheme();
int pos;

ICallableValue resolver = sourceResolvers.get(scheme);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3715,7 +3715,7 @@ public int execute(final Object[] stack, final int sp, final int arity, final Fr
ISourceLocation left = (ISourceLocation) stack[sp - 2];
ISourceLocation right = (ISourceLocation) stack[sp - 1];

int compare = left.getURI().toString().compareTo(right.getURI().toString());
int compare = left.top().toString().compareTo(right.top().toString());
if (compare < 0) {
stack[sp - 2] = Rascal_TRUE;
return sp - 1;
Expand Down Expand Up @@ -4185,7 +4185,7 @@ public int execute(final Object[] stack, final int sp, final int arity, final Fr
ISourceLocation left = (ISourceLocation) stack[sp - 2];
ISourceLocation right = (ISourceLocation) stack[sp - 1];

int compare = left.getURI().toString().compareTo(right.getURI().toString());
int compare = left.top().toString().compareTo(right.top().toString());
if (compare < 0) {
stack[sp - 2] = Rascal_TRUE;
return sp - 1;
Expand Down Expand Up @@ -6910,7 +6910,7 @@ else if (replType.isSourceLocation()) {

case "port":
if (!URIResolverRegistry.getInstance().supportsHost(sloc)) {
throw RascalRuntimeException.noSuchField("The scheme " + sloc.getURI().getScheme() + " does not support the port field, use authority instead.", currentFrame);
throw RascalRuntimeException.noSuchField("The scheme " + sloc.getScheme() + " does not support the port field, use authority instead.", currentFrame);
}
if (sloc.getURI().getHost() != null) {
int port = Integer.parseInt(((IInteger) repl).getStringRepresentation());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,31 +338,36 @@ public IValue visitSet(Type type) {

@Override
public IValue visitSourceLocation(Type type) {
if (maxDepth <= 0) {
return vf.sourceLocation(URIUtil.assumeCorrect("tmp:///"));
}
else {
try {
String path = stRandom.nextDouble() < 0.9 ? RandomUtil.stringAlphaNumeric(stRandom, stRandom.nextInt(5)) : RandomUtil.string(stRandom, stRandom.nextInt(5));
String nested = "";
URI uri = URIUtil.assumeCorrect("tmp:///");

if (stRandom.nextBoolean()) {
RandomValueTypeVisitor visitor = descend();
ISourceLocation loc = (ISourceLocation) visitor.generate(type);
uri = loc.getURI();
nested = uri.getPath();
}

path = path.startsWith("/") ? path : "/" + path;
uri = URIUtil.changePath(uri, nested.length() > 0 && !nested.equals("/") ? nested + path : path);

return vf.sourceLocation(uri);
} catch (URISyntaxException e) {
// generated illegal URI?
return vf.sourceLocation(URIUtil.assumeCorrect("tmp:///"));
}
try {
if (maxDepth <= 0) {
return vf.sourceLocation("tmp","","");
}
else {

String path = stRandom.nextDouble() < 0.9 ? RandomUtil.stringAlphaNumeric(stRandom, stRandom.nextInt(5)) : RandomUtil.string(stRandom, stRandom.nextInt(5));
String nested = "";

if (stRandom.nextBoolean()) {
RandomValueTypeVisitor visitor = descend();
ISourceLocation loc = (ISourceLocation) visitor.generate(type);
nested = loc.getPath();
}

path = path.startsWith("/") ? path : "/" + path;
if (nested.length() > 0 && !nested.equals("/")) {
path = nested + path;
}
return vf.sourceLocation("tmp","",path);
}
} catch (URISyntaxException e) {
// generated illegal URI?
try {
return vf.sourceLocation("tmp","","");
} catch (URISyntaxException e1) {
throw new RuntimeException(e1); // this sloc should never throw.
}
}

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class CharStreamResult extends ResourceResult {

public CharStreamResult(Type type, IValue value, IEvaluatorContext ctx, ISourceLocation fullURI, String displayURI) {
super(type, value, ctx, fullURI, displayURI);
ISourceLocation uri = FileURIResolver.constructFileURI(fullURI.getURI().getPath());
ISourceLocation uri = FileURIResolver.constructFileURI(fullURI.getPath());
this.value = new LazyList(80, new CharStreamFiller(uri, ctx), type.getElementType());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class FileResult extends ResourceResult {
public FileResult(Type type, IValue value, IEvaluatorContext ctx, ISourceLocation fullURI, String displayURI) {
super(type, value, ctx, fullURI, displayURI);
Prelude prelude = new Prelude(ctx.getValueFactory());
ISourceLocation uri = FileURIResolver.constructFileURI(fullURI.getURI().getPath());
ISourceLocation uri = FileURIResolver.constructFileURI(fullURI.getPath());
this.value = prelude.readFile(uri);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class LineStreamResult extends ResourceResult {

public LineStreamResult(Type type, IValue value, IEvaluatorContext ctx, ISourceLocation fullURI, String displayURI) {
super(type, value, ctx, fullURI, displayURI);
String str = fullURI.getURI().getPath();
String str = fullURI.getPath();
String newHost = str.substring(1,str.indexOf("/",1));
String newPath = str.substring(str.indexOf("/",1)+1);
URI uri = URIUtil.assumeCorrect(newHost, "", newPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public ASTConverter(final TypeStore typeStore, boolean collectBindings) {
public void postVisit(ASTNode node) {
setAnnotation("src", getSourceLocation(node));
ISourceLocation decl = resolveBinding(node);
if (!decl.getURI().getScheme().equals("unknown")) {
if (!decl.getScheme().equals("unknown")) {
setAnnotation("decl", decl);
}
setAnnotation("typ", resolveType(node));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ private IConstructor interfaceSymbol(ISourceLocation decl, IList typeParameters)
}

private IConstructor classSymbol(ISourceLocation decl, IList typeParameters) {
if (decl.getURI().getPath().equals("/java/lang/Object")) {
if (decl.getPath().equals("/java/lang/Object")) {
org.eclipse.imp.pdb.facts.type.Type obj = store.lookupConstructor(getTypeSymbol(), "object", tf.voidType());
return values.constructor(obj);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,13 @@ public void setEnvironmentOptions(ISet classPaths, ISet sourcePaths, IEvaluatorC
classPathEntries.clear();
sourcePathEntries.clear();
for (IValue path : classPaths) {
URI uri = ((ISourceLocation) path).getURI();
assert uri.getScheme().equals("file");
classPathEntries.add(uri.getPath());
assert ((ISourceLocation) path).getScheme().equals("file");
classPathEntries.add(((ISourceLocation) path).getPath());
}

for (IValue path : sourcePaths) {
URI uri = ((ISourceLocation) path).getURI();
assert uri.getScheme().equals("file");
sourcePathEntries.add(uri.getPath());
assert ((ISourceLocation) path).getScheme().equals("file");
sourcePathEntries.add(((ISourceLocation) path).getPath());
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/org/rascalmpl/library/lang/jvm/run/RunClassFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public RunClassFile(IValueFactory values) {

private Class<?> getClass(ISourceLocation path, IEvaluatorContext ctx,BinaryClassLoader load){
try {
assert path.getURI().getScheme().equals("file");
assert path.getScheme().equals("file");
URI input = path.getURI();
Class<?> c = load.defineClass(input);
return c;
Expand Down
2 changes: 1 addition & 1 deletion src/org/rascalmpl/library/util/ShellExec.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private synchronized IInteger createProcessInternal(IString processCommand, ILis

File cwd = null;
if (workingDir != null && workingDir.getScheme().equals("file")) {
cwd = new File(workingDir.getURI().getPath());
cwd = new File(workingDir.getPath());
pb.directory(cwd);
}

Expand Down
2 changes: 1 addition & 1 deletion src/org/rascalmpl/library/util/SystemAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public IValue getFileContent(IString g) {
public IValue getRascalFileContent(ISourceLocation g) {
FileReader a = null;
try {
a = new FileReader(g.getURI().getPath());
a = new FileReader(g.getPath());
IList r = readLines(a, "`", "\"", "\"", "\\\\\"", "<", "\\\\<",
">", "\\\\>");
// System.out.println(((IString) r.get(0)).getValue());
Expand Down
14 changes: 6 additions & 8 deletions src/org/rascalmpl/semantics/dynamic/Import.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,16 @@ public Result<IValue> interpret(IEvaluator<Result<IValue>> eval) {
// jdbctable and a standard URI scheme of mysql. If we do not have a separate
// resource scheme, we just use the specified scheme, e.g., sdf would give
// a resource scheme of sdf and a URI scheme of sdf.
URI uri = sl.getURI();
String resourceScheme = uri.getScheme();
String resourceScheme = sl.getScheme();

if (resourceScheme.contains("+")) {
String uriScheme = resourceScheme.substring(resourceScheme.indexOf("+")+1);
resourceScheme = resourceScheme.substring(0,resourceScheme.indexOf("+"));
try {
uri = URIUtil.changeScheme(uri, uriScheme);
sl = URIUtil.changeScheme(sl, uriScheme);
} catch (URISyntaxException e) {
throw RuntimeExceptionFactory.malformedURI(uri.toString().substring(uri.toString().indexOf("+")+1), null, null);
throw RuntimeExceptionFactory.malformedURI(sl.toString().substring(sl.toString().indexOf("+")+1), null, null);
}
sl = ValueFactoryFactory.getValueFactory().sourceLocation(uri);
}

String moduleName = Names.fullName(this.getName());
Expand Down Expand Up @@ -592,19 +590,19 @@ private static ITree parseFragment(IEvaluator<Result<IValue>> eval, ModuleEnviro
}
catch (ParseError e) {
ISourceLocation loc = TreeAdapter.getLocation(tree);
ISourceLocation src = eval.getValueFactory().sourceLocation(eval.getValueFactory().sourceLocation(loc.getURI()), loc.getOffset() + e.getOffset(), loc.getLength(), loc.getBeginLine() + e.getBeginLine() - 1, loc.getEndLine() + e.getEndLine() - 1, loc.getBeginColumn() + e.getBeginColumn(), loc.getBeginColumn() + e.getEndColumn());
ISourceLocation src = eval.getValueFactory().sourceLocation(loc.top(), loc.getOffset() + e.getOffset(), loc.getLength(), loc.getBeginLine() + e.getBeginLine() - 1, loc.getEndLine() + e.getEndLine() - 1, loc.getBeginColumn() + e.getBeginColumn(), loc.getBeginColumn() + e.getEndColumn());
eval.getMonitor().warning("parse error in concrete syntax", src);
return (ITree) tree.asAnnotatable().setAnnotation("parseError", src);
}
catch (StaticError e) {
ISourceLocation loc = TreeAdapter.getLocation(tree);
ISourceLocation src = eval.getValueFactory().sourceLocation(eval.getValueFactory().sourceLocation(loc.getURI()), loc.getOffset(), loc.getLength(), loc.getBeginLine(), loc.getEndLine(), loc.getBeginColumn(), loc.getBeginColumn());
ISourceLocation src = eval.getValueFactory().sourceLocation(loc.top(), loc.getOffset(), loc.getLength(), loc.getBeginLine(), loc.getEndLine(), loc.getBeginColumn(), loc.getBeginColumn());
eval.getMonitor().warning(e.getMessage(), e.getLocation());
return (ITree) tree.asAnnotatable().setAnnotation("can not parse fragment due to " + e.getMessage(), src);
}
catch (UndeclaredNonTerminalException e) {
ISourceLocation loc = TreeAdapter.getLocation(tree);
ISourceLocation src = eval.getValueFactory().sourceLocation(eval.getValueFactory().sourceLocation(loc.getURI()), loc.getOffset(), loc.getLength(), loc.getBeginLine(), loc.getEndLine(), loc.getBeginColumn(), loc.getBeginColumn());
ISourceLocation src = eval.getValueFactory().sourceLocation(loc.top(), loc.getOffset(), loc.getLength(), loc.getBeginLine(), loc.getEndLine(), loc.getBeginColumn(), loc.getBeginColumn());
eval.getMonitor().warning(e.getMessage(), src);
return (ITree) tree.asAnnotatable().setAnnotation("can not parse fragment due to " + e.getMessage(), src);
}
Expand Down
Loading

0 comments on commit 06fba64

Please sign in to comment.