Skip to content
Snippets Groups Projects
Commit 727b1065 authored by Viktor Kuncak's avatar Viktor Kuncak
Browse files

expr

parent d6b502c5
No related branches found
No related tags found
No related merge requests found
...@@ -67,12 +67,12 @@ object ExprComp { ...@@ -67,12 +67,12 @@ object ExprComp {
def run0(p : Program) = run(p, EStack()) def run0(p : Program) = run(p, EStack())
// Compiling expressions to programs // Compiling expressions to programs
def compile(e : Expr, acc : Program) : Program = e match { def compile(e : Expr, acc : Program, vs : /* ghost */ ValueStack) : Program = { e match {
case Constant(v) => NProgram(PushVal(v), acc) case Constant(v) => NProgram(PushVal(v), acc)
case Binary(e1,op,e2) => NProgram(ApplyBinOp(op),compile(e2,compile(e1,acc))) case Binary(e1,op,e2) => NProgram(ApplyBinOp(op),compile(e2,compile(e1,acc)))
} } } // ensuring (res => run(res, vs) = NStack(eval(e), vs))
def compile0(e : Expr) : Program = compile(e, EProgram()) def compile0(e : Expr) : Program = compile(e, EProgram(), EStack())
// Correctness statement // Correctness statement
// val anyS : ValueStack = EStack() // not really, but arbitrary // val anyS : ValueStack = EStack() // not really, but arbitrary
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment