Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce Lifetimes #642

Merged
merged 2 commits into from Apr 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 13 additions & 1 deletion modules/wyc/src/wyc/builder/CodeGenerator.java
Expand Up @@ -312,6 +312,8 @@ private void generate(Stmt stmt, EnclosingScope scope) {
generate((Break) stmt, scope);
} else if (stmt instanceof Continue) {
generate((Continue) stmt, scope);
} else if (stmt instanceof NamedBlock) {
generate((NamedBlock) stmt, scope);
} else if (stmt instanceof While) {
generate((While) stmt, scope);
} else if (stmt instanceof DoWhile) {
Expand Down Expand Up @@ -974,6 +976,15 @@ private void checkNoDuplicateLabels(List<Stmt.Case> cases, EnclosingScope scope)
}


/**
* Translate a named block into WyIL bytecodes.
*/
private void generate(Stmt.NamedBlock s, EnclosingScope scope) {
for (Stmt st : s.body) {
generate(st, scope);
}
}

/**
* Translate a while loop into WyIL bytecodes. Consider the following use of
* a while statement:
Expand Down Expand Up @@ -1675,7 +1686,8 @@ private Type.FunctionOrMethod determineLambdaParametersAndOperands(Expr.Lambda e
if(lambdaType instanceof Nominal.Function) {
return Type.Function(rawLambdaType.returns(),rawParamTypes);
} else {
return Type.Method(rawLambdaType.returns(),rawParamTypes);
return Type.Method(rawLambdaType.returns(),rawLambdaType.contextLifetimes(),
rawLambdaType.lifetimeParams(),rawParamTypes);
}
}

Expand Down
860 changes: 700 additions & 160 deletions modules/wyc/src/wyc/builder/FlowTypeChecker.java

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions modules/wyc/src/wyc/io/WhileyFileLexer.java
Expand Up @@ -563,6 +563,8 @@ private void syntaxError(String msg, int index) {
put("export", Token.Kind.Export);
put("method", Token.Kind.Method);
put("package", Token.Kind.Package);
// lifetimes
put("this", Token.Kind.This);
}
};

Expand Down Expand Up @@ -627,6 +629,8 @@ public enum Kind {
Export("export"),
Function("function"),
Method("method"),
// Lifetimes
This("this"),
// Expressions
All("all"),
No("no"),
Expand Down