-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
do continue/break encoding in constructors, but do not generate return
- Loading branch information
1 parent
5c2b0d2
commit 36a4608
Showing
5 changed files
with
68 additions
and
36 deletions.
There are no files selected for viewing
3 changes: 2 additions & 1 deletion
3
src/col/vct/col/ast/statement/exceptional/ExceptionalStatementImpl.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
package vct.col.ast.statement.exceptional | ||
|
||
import vct.col.ast.ExceptionalStatement | ||
import vct.col.ast.statement.StatementImpl | ||
|
||
trait ExceptionalStatementImpl[G] { this: ExceptionalStatement[G] => | ||
trait ExceptionalStatementImpl[G] extends StatementImpl[G] { this: ExceptionalStatement[G] => | ||
|
||
} |
15 changes: 12 additions & 3 deletions
15
src/col/vct/col/ast/statement/exceptional/ReturnImpl.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,19 @@ | ||
package vct.col.ast.statement.exceptional | ||
|
||
import vct.col.ast.{Return, Void} | ||
import vct.col.print.{Ctx, Doc, Text, Empty} | ||
import vct.col.ast.{AbstractMethod, Constructor, Return, Void} | ||
import vct.col.print.{Ctx, Doc, Empty, Text} | ||
import vct.col.ast.ops.ReturnOps | ||
import vct.col.check.{CheckContext, CheckError, ReturnOutsideMethod} | ||
|
||
trait ReturnImpl[G] extends ExceptionalStatementImpl[G] with ReturnOps[G] { this: Return[G] => | ||
override def check(context: CheckContext[G]): Seq[CheckError] = | ||
super.check(context) ++ (context.currentApplicable match { | ||
case None => Seq(ReturnOutsideMethod(this)) | ||
case Some(_: Constructor[G]) => Seq(ReturnOutsideMethod(this)) | ||
case Some(_: AbstractMethod[G]) => Nil | ||
case Some(_) => Seq(ReturnOutsideMethod(this)) | ||
}) | ||
|
||
trait ReturnImpl[G] extends ReturnOps[G] { this: Return[G] => | ||
override def layout(implicit ctx: Ctx): Doc = | ||
Text("return") <> (if(result == Void[G]()) Text(";") else Empty <+> result <> ";") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters