Commit 71383ddf authored by Alexandru Dura's avatar Alexandru Dura
Browse files

Merge branch 'master' into EX3

parents 5831627a bf39c01f
......@@ -223,6 +223,7 @@ aspect IRGen {
// the same name at different scopes, and we want them to have a unique
// name inside the IR
v = new IRVar(new IRName(d.name() + counter++), d.variableType().genIRTypeRef());
v.setSourceLocation(d.sourceLocation());
F.getLocals().add(v);
locals.put(d, v);
}
......@@ -465,12 +466,19 @@ aspect IRGen {
// copy this to the return value
ctx.addInsn(new IRCopyInsn(new IRVarRef(ctx.getReturnVar()), retVal));
IRCodeBB currentBB = ctx.getCurrentBB();
currentBB.setIRCodeExit(new IRReturn(new IRVarRef(ctx.getReturnVar())));
IRReturn ret = new IRReturn(new IRVarRef(ctx.getReturnVar()));
ret.setSourceLocation(sourceLocation());
currentBB.setIRCodeExit(ret);
// ctx will auto-start a new basic block to hold the translation
// of any (unreachable) statements following the return if needed.
ctx.endBB();
}
syn IRVar VarDecl.genIR() = new IRVar(getIdDecl().genIR(), variableType().genIRTypeRef());
syn IRVar VarDecl.genIR() {
IRVar var = new IRVar(getIdDecl().genIR(), variableType().genIRTypeRef());
var.setSourceLocation(sourceLocation());
return var;
}
syn IRName IdDecl.genIR() = new IRName(getIdentifier());
}
......@@ -31,9 +31,12 @@ aspect SemanticCheck {
Type contributes new SemanticError(sourceLocation(), "Actual type parameters are disallowed for types other than array[T].")
when !isArray() && getNumActual() != 0 to Program.semanticErrors();
Type contributes new SemanticError(sourceLocation(), "array[T] should must have a single type parameter.")
Type contributes new SemanticError(sourceLocation(), "Instances of array[T] take a single type parameter.")
when isArray() && getNumActual() != 1 to Program.semanticErrors();
TypeDecl contributes new SemanticError(sourceLocation(), "User defined type cannot have formal type parameters.")
when !isArray() && getNumTypeFormal() != 0 to Program.semanticErrors();
MemberAccess contributes new SemanticError(sourceLocation(), "Access of unknown field, '" + getIdentifier() + "'. Consider using type annotations.")
when getExpr().type().memberLookup(getIdentifier()) == null to Program.semanticErrors();
}
......@@ -105,6 +105,10 @@ aspect IRPrint {
getIRName().print(out);
out.print(" : ");
getIRTypeRef().print(out);
if (IRProgram.printSourceLocations) {
out.print("\t");
getSourceLocation().print(out);
}
}
public void IRCodeBB.print(PrintStream out) {
......@@ -131,6 +135,11 @@ aspect IRPrint {
public void IRReturn.print(PrintStream out) {
out.print("ret ");
getIRVarRef().print(out);
if (IRProgram.printSourceLocations) {
out.print("\t");
getSourceLocation().print(out);
}
}
public void IRJump.print(PrintStream out) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment