Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Christoph Reichenbach
EDAP15-exercise-3
Commits
71383ddf
Commit
71383ddf
authored
Dec 04, 2020
by
Alexandru Dura
Browse files
Merge branch 'master' into EX3
parents
5831627a
bf39c01f
Changes
3
Hide whitespace changes
Inline
Side-by-side
compiler/teal0/backend/IRGen.jrag
View file @
71383ddf
...
...
@@ -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());
}
compiler/teal2/frontend/SemanticCheck.jrag
View file @
71383ddf
...
...
@@ -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 hav
e a single type parameter.")
Type contributes new SemanticError(sourceLocation(), "
Instances of array[T] tak
e 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();
}
ir/teal0/ast/IRPrint.jrag
View file @
71383ddf
...
...
@@ -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) {
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment