diff --git a/executable_semantics/BUILD b/executable_semantics/BUILD index 25f18f17285a..abb8fbeac74d 100644 --- a/executable_semantics/BUILD +++ b/executable_semantics/BUILD @@ -62,8 +62,6 @@ EXAMPLES = [ "tuple_match", "tuple1", "tuple2", - "undef1", - "undef2", "while1", "zero", ] diff --git a/executable_semantics/ast/statement.cpp b/executable_semantics/ast/statement.cpp index b282eebb37ba..ff4d51c3869f 100644 --- a/executable_semantics/ast/statement.cpp +++ b/executable_semantics/ast/statement.cpp @@ -55,7 +55,6 @@ auto MakeWhile(int line_num, Expression* cond, Statement* body) -> Statement* { } auto MakeBreak(int line_num) -> Statement* { - std::cout << "MakeBlock" << std::endl; auto* s = new Statement(); s->line_num = line_num; s->tag = StatementKind::Break; diff --git a/executable_semantics/interpreter/interpreter.cpp b/executable_semantics/interpreter/interpreter.cpp index d3d26e00ef5c..bcb1f82c4b21 100644 --- a/executable_semantics/interpreter/interpreter.cpp +++ b/executable_semantics/interpreter/interpreter.cpp @@ -419,13 +419,6 @@ auto ToValue(Expression* value) -> Value* { // Returns nullopt if the value doesn't match the pattern. auto PatternMatch(Value* p, Value* v, Env env, std::list* vars, int line_num) -> std::optional { - if (tracing_output) { - std::cout << "pattern_match("; - PrintValue(p, std::cout); - std::cout << ", "; - PrintValue(v, std::cout); - std::cout << ")" << std::endl; - } switch (p->tag) { case ValKind::VarPatV: { Address a = AllocateValue(CopyVal(v, line_num)); diff --git a/executable_semantics/main.cpp b/executable_semantics/main.cpp index a0e3e4038c06..555b3c247407 100644 --- a/executable_semantics/main.cpp +++ b/executable_semantics/main.cpp @@ -16,13 +16,13 @@ int main(int argc, char* argv[]) { using llvm::cl::desc; using llvm::cl::opt; - opt quietOption("quiet", desc("Disable tracing")); + opt trace_option("trace", desc("Enable tracing")); opt inputFileName(llvm::cl::Positional, desc(""), llvm::cl::Required); llvm::cl::ParseCommandLineOptions(argc, argv); - if (quietOption) { - Carbon::tracing_output = false; + if (trace_option) { + Carbon::tracing_output = true; } std::variant astOrError = diff --git a/executable_semantics/testdata/block1.golden b/executable_semantics/testdata/block1.golden index 729da55d2915..2db2755da426 100644 --- a/executable_semantics/testdata/block1.golden +++ b/executable_semantics/testdata/block1.golden @@ -1,265 +1 @@ -********** source program ********** -fn main () -> Int { -var Int: x = 0; -{ -var Int: x = 1; - -} - -return x; - -} -********** type checking ********** ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> - -********** type checking complete ********** -fn main () -> Int { -var Int: x = 0; -{ -var Int: x = 1; - -} - -return x; -} -********** starting execution ********** -********** initializing globals ********** ---- step exp () ---> -********** calling main function ********** -{ -stack: top{main()<-1>} -heap: fun
, -env: main: fun
, -} ---- step exp main() ---> -{ -stack: top{main<-1> :: main()<0>} -heap: fun
, -env: main: fun
, -} ---- step exp main ---> -{ -stack: top{fun
<-1> :: main()<0>} -heap: fun
, -env: main: fun
, -} ---- handle value fun
with main()<1>(fun
,) ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: fun
, -env: main: fun
, -} ---- step exp () ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: fun
, -env: main: fun
, -} ---- handle value () with main()<2>(fun
,(),) ---> -pattern_match((), ()) -{ -stack: main{var Int: x = 0; ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step stmt var Int: x = 0; ... ---> -{ -stack: main{var Int: x = 0;<-1> :: { - ... -} - ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step stmt var Int: x = 0; ---> -{ -stack: main{0<-1> :: var Int: x = 0;<0> :: { - ... -} - ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp 0 ---> -{ -stack: main{0<-1> :: var Int: x = 0;<0> :: { - ... -} - ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value 0 with var Int: x = 0;<1>(0,) ---> -{ -stack: main{Int: x<-1> :: var Int: x = 0;<1>(0,) :: { - ... -} - ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp Int: x ---> -{ -stack: main{Int<-1> :: Int: x<0> :: var Int: x = 0;<1>(0,) :: { - ... -} - ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp Int ---> -{ -stack: main{Int<-1> :: Int: x<0> :: var Int: x = 0;<1>(0,) :: { - ... -} - ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value Int with Int: x<1>(Int,) ---> -{ -stack: main{Int: x<-1> :: var Int: x = 0;<1>(0,) :: { - ... -} - ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value Int: x with var Int: x = 0;<2>(0,Int: x,) ---> -pattern_match(Int: x, 0) -{ -stack: main{{ - ... -} - ... <-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- step stmt { - ... -} - ... ---> -{ -stack: main{{ - ... -} -<-1> :: return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- step stmt { - ... -} - ---> -{ -stack: main{var Int: x = 1;<-1> :: { - ... -} -<0> :: return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- step stmt var Int: x = 1; ---> -{ -stack: main{var Int: x = 1;<-1> :: { - ... -} -<0> :: return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- step stmt var Int: x = 1; ---> -{ -stack: main{1<-1> :: var Int: x = 1;<0> :: { - ... -} -<0> :: return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- step exp 1 ---> -{ -stack: main{1<-1> :: var Int: x = 1;<0> :: { - ... -} -<0> :: return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- handle value 1 with var Int: x = 1;<1>(1,) ---> -{ -stack: main{Int: x<-1> :: var Int: x = 1;<1>(1,) :: { - ... -} -<0> :: return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- step exp Int: x ---> -{ -stack: main{Int<-1> :: Int: x<0> :: var Int: x = 1;<1>(1,) :: { - ... -} -<0> :: return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- step exp Int ---> -{ -stack: main{Int<-1> :: Int: x<0> :: var Int: x = 1;<1>(1,) :: { - ... -} -<0> :: return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- handle value Int with Int: x<1>(Int,) ---> -{ -stack: main{Int: x<-1> :: var Int: x = 1;<1>(1,) :: { - ... -} -<0> :: return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- handle value Int: x with var Int: x = 1;<2>(1,Int: x,) ---> -pattern_match(Int: x, 1) -{ -stack: main{{ - ... -} -<0> :: return x;<-1>} :: top{} -heap: fun
, 0, 1, -env: x: 1, x: 0, main: fun
, -} ---- step stmt { - ... -} - ---> -{ -stack: main{return x;<-1>} :: top{} -heap: fun
, 0, !!1, -env: x: 0, main: fun
, -} ---- step stmt return x; ---> -{ -stack: main{x<-1> :: return x;<0>} :: top{} -heap: fun
, 0, !!1, -env: x: 0, main: fun
, -} ---- step exp x ---> -{ -stack: main{0<-1> :: return x;<0>} :: top{} -heap: fun
, 0, !!1, -env: x: 0, main: fun
, -} ---- handle value 0 with return x;<1>(0,) ---> -{ -stack: top{0<-1>} -heap: fun
, !!0, !!1, -env: main: fun
, -} result: 0 diff --git a/executable_semantics/testdata/break1.golden b/executable_semantics/testdata/break1.golden index f6cb9e290eaf..2db2755da426 100644 --- a/executable_semantics/testdata/break1.golden +++ b/executable_semantics/testdata/break1.golden @@ -1,821 +1 @@ -MakeBlock -********** source program ********** -fn main () -> Int { -var Int: x = 2; -while (true) -{ -if ((x == 0)) -break; -else -x = (x - 1); - -} - -return x; - -} -********** type checking ********** ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> - -********** type checking complete ********** -fn main () -> Int { -var Int: x = 2; -while (true) -{ -if ((x == 0)) -break; -else -x = (x - 1); - -} - -return x; -} -********** starting execution ********** -********** initializing globals ********** ---- step exp () ---> -********** calling main function ********** -{ -stack: top{main()<-1>} -heap: fun
, -env: main: fun
, -} ---- step exp main() ---> -{ -stack: top{main<-1> :: main()<0>} -heap: fun
, -env: main: fun
, -} ---- step exp main ---> -{ -stack: top{fun
<-1> :: main()<0>} -heap: fun
, -env: main: fun
, -} ---- handle value fun
with main()<1>(fun
,) ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: fun
, -env: main: fun
, -} ---- step exp () ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: fun
, -env: main: fun
, -} ---- handle value () with main()<2>(fun
,(),) ---> -pattern_match((), ()) -{ -stack: main{var Int: x = 2; ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step stmt var Int: x = 2; ... ---> -{ -stack: main{var Int: x = 2;<-1> :: while (true) - ... ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step stmt var Int: x = 2; ---> -{ -stack: main{2<-1> :: var Int: x = 2;<0> :: while (true) - ... ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp 2 ---> -{ -stack: main{2<-1> :: var Int: x = 2;<0> :: while (true) - ... ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value 2 with var Int: x = 2;<1>(2,) ---> -{ -stack: main{Int: x<-1> :: var Int: x = 2;<1>(2,) :: while (true) - ... ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp Int: x ---> -{ -stack: main{Int<-1> :: Int: x<0> :: var Int: x = 2;<1>(2,) :: while (true) - ... ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp Int ---> -{ -stack: main{Int<-1> :: Int: x<0> :: var Int: x = 2;<1>(2,) :: while (true) - ... ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value Int with Int: x<1>(Int,) ---> -{ -stack: main{Int: x<-1> :: var Int: x = 2;<1>(2,) :: while (true) - ... ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value Int: x with var Int: x = 2;<2>(2,Int: x,) ---> -pattern_match(Int: x, 2) -{ -stack: main{while (true) - ... ... <-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- step stmt while (true) - ... ... ---> -{ -stack: main{while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- step stmt while (true) - ... ---> -{ -stack: main{true<-1> :: while (true) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- step exp true ---> -{ -stack: main{true<-1> :: while (true) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- handle value true with while (true) - ... <1>(true,) ---> -{ -stack: main{{ - ... -} -<-1> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- step stmt { - ... -} - ---> -{ -stack: main{if ((x == 0)) - ... -else - ... <-1> :: { - ... -} -<0> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- step stmt if ((x == 0)) - ... -else - ... ---> -{ -stack: main{if ((x == 0)) - ... -else - ... <-1> :: { - ... -} -<0> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- step stmt if ((x == 0)) - ... -else - ... ---> -{ -stack: main{(x == 0)<-1> :: if ((x == 0)) - ... -else - ... <0> :: { - ... -} -<0> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- step exp (x == 0) ---> -{ -stack: main{x<-1> :: (x == 0)<0> :: if ((x == 0)) - ... -else - ... <0> :: { - ... -} -<0> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- step exp x ---> -{ -stack: main{2<-1> :: (x == 0)<0> :: if ((x == 0)) - ... -else - ... <0> :: { - ... -} -<0> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- handle value 2 with (x == 0)<1>(2,) ---> -{ -stack: main{0<-1> :: (x == 0)<1>(2,) :: if ((x == 0)) - ... -else - ... <0> :: { - ... -} -<0> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- step exp 0 ---> -{ -stack: main{0<-1> :: (x == 0)<1>(2,) :: if ((x == 0)) - ... -else - ... <0> :: { - ... -} -<0> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- handle value 0 with (x == 0)<2>(2,0,) ---> -{ -stack: main{false<-1> :: if ((x == 0)) - ... -else - ... <0> :: { - ... -} -<0> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- handle value false with if ((x == 0)) - ... -else - ... <1>(false,) ---> -{ -stack: main{x = (x - 1);<-1> :: { - ... -} -<0> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- step stmt x = (x - 1); ---> -{ -stack: main{x<-1> :: x = (x - 1);<0> :: { - ... -} -<0> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- step lvalue x ---> -{ -stack: main{ptr<1><-1> :: x = (x - 1);<0> :: { - ... -} -<0> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- handle value ptr<1> with x = (x - 1);<1>(ptr<1>,) ---> -{ -stack: main{(x - 1)<-1> :: x = (x - 1);<1>(ptr<1>,) :: { - ... -} -<0> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- step exp (x - 1) ---> -{ -stack: main{x<-1> :: (x - 1)<0> :: x = (x - 1);<1>(ptr<1>,) :: { - ... -} -<0> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- step exp x ---> -{ -stack: main{2<-1> :: (x - 1)<0> :: x = (x - 1);<1>(ptr<1>,) :: { - ... -} -<0> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- handle value 2 with (x - 1)<1>(2,) ---> -{ -stack: main{1<-1> :: (x - 1)<1>(2,) :: x = (x - 1);<1>(ptr<1>,) :: { - ... -} -<0> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- step exp 1 ---> -{ -stack: main{1<-1> :: (x - 1)<1>(2,) :: x = (x - 1);<1>(ptr<1>,) :: { - ... -} -<0> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- handle value 1 with (x - 1)<2>(2,1,) ---> -{ -stack: main{1<-1> :: x = (x - 1);<1>(ptr<1>,) :: { - ... -} -<0> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- handle value 1 with x = (x - 1);<2>(ptr<1>,1,) ---> -{ -stack: main{{ - ... -} -<0> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- step stmt { - ... -} - ---> -{ -stack: main{while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- step stmt while (true) - ... ---> -{ -stack: main{true<-1> :: while (true) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- step exp true ---> -{ -stack: main{true<-1> :: while (true) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- handle value true with while (true) - ... <1>(true,) ---> -{ -stack: main{{ - ... -} -<-1> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- step stmt { - ... -} - ---> -{ -stack: main{if ((x == 0)) - ... -else - ... <-1> :: { - ... -} -<0> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- step stmt if ((x == 0)) - ... -else - ... ---> -{ -stack: main{if ((x == 0)) - ... -else - ... <-1> :: { - ... -} -<0> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- step stmt if ((x == 0)) - ... -else - ... ---> -{ -stack: main{(x == 0)<-1> :: if ((x == 0)) - ... -else - ... <0> :: { - ... -} -<0> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- step exp (x == 0) ---> -{ -stack: main{x<-1> :: (x == 0)<0> :: if ((x == 0)) - ... -else - ... <0> :: { - ... -} -<0> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- step exp x ---> -{ -stack: main{1<-1> :: (x == 0)<0> :: if ((x == 0)) - ... -else - ... <0> :: { - ... -} -<0> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- handle value 1 with (x == 0)<1>(1,) ---> -{ -stack: main{0<-1> :: (x == 0)<1>(1,) :: if ((x == 0)) - ... -else - ... <0> :: { - ... -} -<0> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- step exp 0 ---> -{ -stack: main{0<-1> :: (x == 0)<1>(1,) :: if ((x == 0)) - ... -else - ... <0> :: { - ... -} -<0> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- handle value 0 with (x == 0)<2>(1,0,) ---> -{ -stack: main{false<-1> :: if ((x == 0)) - ... -else - ... <0> :: { - ... -} -<0> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- handle value false with if ((x == 0)) - ... -else - ... <1>(false,) ---> -{ -stack: main{x = (x - 1);<-1> :: { - ... -} -<0> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- step stmt x = (x - 1); ---> -{ -stack: main{x<-1> :: x = (x - 1);<0> :: { - ... -} -<0> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- step lvalue x ---> -{ -stack: main{ptr<1><-1> :: x = (x - 1);<0> :: { - ... -} -<0> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- handle value ptr<1> with x = (x - 1);<1>(ptr<1>,) ---> -{ -stack: main{(x - 1)<-1> :: x = (x - 1);<1>(ptr<1>,) :: { - ... -} -<0> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- step exp (x - 1) ---> -{ -stack: main{x<-1> :: (x - 1)<0> :: x = (x - 1);<1>(ptr<1>,) :: { - ... -} -<0> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- step exp x ---> -{ -stack: main{1<-1> :: (x - 1)<0> :: x = (x - 1);<1>(ptr<1>,) :: { - ... -} -<0> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- handle value 1 with (x - 1)<1>(1,) ---> -{ -stack: main{1<-1> :: (x - 1)<1>(1,) :: x = (x - 1);<1>(ptr<1>,) :: { - ... -} -<0> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- step exp 1 ---> -{ -stack: main{1<-1> :: (x - 1)<1>(1,) :: x = (x - 1);<1>(ptr<1>,) :: { - ... -} -<0> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- handle value 1 with (x - 1)<2>(1,1,) ---> -{ -stack: main{0<-1> :: x = (x - 1);<1>(ptr<1>,) :: { - ... -} -<0> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- handle value 0 with x = (x - 1);<2>(ptr<1>,0,) ---> -{ -stack: main{{ - ... -} -<0> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- step stmt { - ... -} - ---> -{ -stack: main{while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- step stmt while (true) - ... ---> -{ -stack: main{true<-1> :: while (true) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- step exp true ---> -{ -stack: main{true<-1> :: while (true) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- handle value true with while (true) - ... <1>(true,) ---> -{ -stack: main{{ - ... -} -<-1> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- step stmt { - ... -} - ---> -{ -stack: main{if ((x == 0)) - ... -else - ... <-1> :: { - ... -} -<0> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- step stmt if ((x == 0)) - ... -else - ... ---> -{ -stack: main{if ((x == 0)) - ... -else - ... <-1> :: { - ... -} -<0> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- step stmt if ((x == 0)) - ... -else - ... ---> -{ -stack: main{(x == 0)<-1> :: if ((x == 0)) - ... -else - ... <0> :: { - ... -} -<0> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- step exp (x == 0) ---> -{ -stack: main{x<-1> :: (x == 0)<0> :: if ((x == 0)) - ... -else - ... <0> :: { - ... -} -<0> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- step exp x ---> -{ -stack: main{0<-1> :: (x == 0)<0> :: if ((x == 0)) - ... -else - ... <0> :: { - ... -} -<0> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- handle value 0 with (x == 0)<1>(0,) ---> -{ -stack: main{0<-1> :: (x == 0)<1>(0,) :: if ((x == 0)) - ... -else - ... <0> :: { - ... -} -<0> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- step exp 0 ---> -{ -stack: main{0<-1> :: (x == 0)<1>(0,) :: if ((x == 0)) - ... -else - ... <0> :: { - ... -} -<0> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- handle value 0 with (x == 0)<2>(0,0,) ---> -{ -stack: main{true<-1> :: if ((x == 0)) - ... -else - ... <0> :: { - ... -} -<0> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- handle value true with if ((x == 0)) - ... -else - ... <1>(true,) ---> -{ -stack: main{break;<-1> :: { - ... -} -<0> :: while (true) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- step stmt break; ---> -{ -stack: main{return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- step stmt return x; ---> -{ -stack: main{x<-1> :: return x;<0>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- step exp x ---> -{ -stack: main{0<-1> :: return x;<0>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- handle value 0 with return x;<1>(0,) ---> -{ -stack: top{0<-1>} -heap: fun
, !!0, -env: main: fun
, -} result: 0 diff --git a/executable_semantics/testdata/choice1.golden b/executable_semantics/testdata/choice1.golden index 009c5c8dae95..2db2755da426 100644 --- a/executable_semantics/testdata/choice1.golden +++ b/executable_semantics/testdata/choice1.golden @@ -1,899 +1 @@ -********** source program ********** -choice Ints { -alt None (); -alt One (0 = Int); -alt Two (0 = Int, 1 = Int); -} -fn main () -> Int { -var auto: x = Ints.None(); -var auto: y = Ints.One(0 = 42); -var auto: n = 0; -match (y) { -case Ints.None => -n = (n + 2); -case Ints.One(0 = auto: x) => -n = ((x + 1) - 42); -case Ints.Two(0 = auto: a, 1 = auto: b) => -n = 2; -} -match (x) { -case Ints.One(0 = auto: x) => -n = (x + 2); -case Ints.None() => -n = (n - 1); -case Ints.Two(0 = auto: x, 1 = auto: y) => -n = 5; -} -return n; - -} -choice MoreInts { -alt None (); -alt One (0 = Int); -alt Two (0 = Int, 1 = Int); -} -********** type checking ********** ---- step exp () ---> ---- step exp (0 = Int) ---> ---- step exp Int ---> ---- handle value Int with (0 = Int)<1>(Int,) ---> ---- step exp (0 = Int, 1 = Int) ---> ---- step exp Int ---> ---- handle value Int with (0 = Int, 1 = Int)<1>(Int,) ---> ---- step exp Int ---> ---- handle value Int with (0 = Int, 1 = Int)<2>(Int,Int,) ---> ---- step exp Int ---> ---- step exp () ---> ---- step exp (0 = Int) ---> ---- step exp Int ---> ---- handle value Int with (0 = Int)<1>(Int,) ---> ---- step exp (0 = Int, 1 = Int) ---> ---- step exp Int ---> ---- handle value Int with (0 = Int, 1 = Int)<1>(Int,) ---> ---- step exp Int ---> ---- handle value Int with (0 = Int, 1 = Int)<2>(Int,Int,) ---> ---- step exp Int ---> ---- step exp auto ---> ---- step exp auto ---> ---- step exp auto ---> ---- step exp auto ---> ---- step exp auto ---> ---- step exp auto ---> ---- step exp auto ---> ---- step exp auto ---> ---- step exp auto ---> - -********** type checking complete ********** -choice Ints { -alt None (); -alt One (0 = Int); -alt Two (0 = Int, 1 = Int); -} -fn main () -> Int { -var auto: x = Ints.None(); -var auto: y = Ints.One(0 = 42); -var auto: n = 0; -match (y) { -case Ints.None => -n = (n + 2); -case Ints.One(0 = auto: x) => -n = ((x + 1) - 42); -case Ints.Two(0 = auto: a, 1 = auto: b) => -n = 2; -} -match (x) { -case Ints.One(0 = auto: x) => -n = (x + 2); -case Ints.None() => -n = (n - 1); -case Ints.Two(0 = auto: x, 1 = auto: y) => -n = 5; -} -return n; -} -choice MoreInts { -alt None (); -alt One (0 = Int); -alt Two (0 = Int, 1 = Int); -} -********** starting execution ********** -********** initializing globals ********** ---- step exp () ---> ---- step exp (0 = Int) ---> ---- step exp Int ---> ---- handle value Int with (0 = Int)<1>(Int,) ---> ---- step exp (0 = Int, 1 = Int) ---> ---- step exp Int ---> ---- handle value Int with (0 = Int, 1 = Int)<1>(Int,) ---> ---- step exp Int ---> ---- handle value Int with (0 = Int, 1 = Int)<2>(Int,Int,) ---> ---- step exp () ---> ---- step exp () ---> ---- step exp (0 = Int) ---> ---- step exp Int ---> ---- handle value Int with (0 = Int)<1>(Int,) ---> ---- step exp (0 = Int, 1 = Int) ---> ---- step exp Int ---> ---- handle value Int with (0 = Int, 1 = Int)<1>(Int,) ---> ---- step exp Int ---> ---- handle value Int with (0 = Int, 1 = Int)<2>(Int,Int,) ---> -********** calling main function ********** -{ -stack: top{main()<-1>} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, -env: MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step exp main() ---> -{ -stack: top{main<-1> :: main()<0>} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, -env: MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step exp main ---> -{ -stack: top{fun
<-1> :: main()<0>} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, -env: MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value fun
with main()<1>(fun
,) ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, -env: MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step exp () ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, -env: MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value () with main()<2>(fun
,(),) ---> -pattern_match((), ()) -{ -stack: main{var auto: x = Ints.None(); ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, -env: MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step stmt var auto: x = Ints.None(); ... ---> -{ -stack: main{var auto: x = Ints.None();<-1> :: var auto: y = Ints.One(0 = 42); ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, -env: MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step stmt var auto: x = Ints.None(); ---> -{ -stack: main{Ints.None()<-1> :: var auto: x = Ints.None();<0> :: var auto: y = Ints.One(0 = 42); ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, -env: MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step exp Ints.None() ---> -{ -stack: main{Ints.None<-1> :: Ints.None()<0> :: var auto: x = Ints.None();<0> :: var auto: y = Ints.One(0 = 42); ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, -env: MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step exp Ints.None ---> -{ -stack: main{Ints<-1> :: Ints.None<0> :: Ints.None()<0> :: var auto: x = Ints.None();<0> :: var auto: y = Ints.One(0 = 42); ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, -env: MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step lvalue Ints ---> -{ -stack: main{ptr<3><-1> :: Ints.None<0> :: Ints.None()<0> :: var auto: x = Ints.None();<0> :: var auto: y = Ints.One(0 = 42); ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, -env: MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value ptr<3> with Ints.None<1>(ptr<3>,) ---> -{ -stack: main{Ints.None<-1> :: Ints.None()<0> :: var auto: x = Ints.None();<0> :: var auto: y = Ints.One(0 = 42); ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, -env: MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value Ints.None with Ints.None()<1>(Ints.None,) ---> -{ -stack: main{()<-1> :: Ints.None()<1>(Ints.None,) :: var auto: x = Ints.None();<0> :: var auto: y = Ints.One(0 = 42); ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, -env: MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step exp () ---> -{ -stack: main{()<-1> :: Ints.None()<1>(Ints.None,) :: var auto: x = Ints.None();<0> :: var auto: y = Ints.One(0 = 42); ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, -env: MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value () with Ints.None()<2>(Ints.None,(),) ---> -{ -stack: main{alt Ints.None ()<-1> :: var auto: x = Ints.None();<0> :: var auto: y = Ints.One(0 = 42); ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, -env: MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value alt Ints.None () with var auto: x = Ints.None();<1>(alt Ints.None (),) ---> -{ -stack: main{auto: x<-1> :: var auto: x = Ints.None();<1>(alt Ints.None (),) :: var auto: y = Ints.One(0 = 42); ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, -env: MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step exp auto: x ---> -{ -stack: main{auto<-1> :: auto: x<0> :: var auto: x = Ints.None();<1>(alt Ints.None (),) :: var auto: y = Ints.One(0 = 42); ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, -env: MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step exp auto ---> -{ -stack: main{auto<-1> :: auto: x<0> :: var auto: x = Ints.None();<1>(alt Ints.None (),) :: var auto: y = Ints.One(0 = 42); ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, -env: MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value auto with auto: x<1>(auto,) ---> -{ -stack: main{auto: x<-1> :: var auto: x = Ints.None();<1>(alt Ints.None (),) :: var auto: y = Ints.One(0 = 42); ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, -env: MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value auto: x with var auto: x = Ints.None();<2>(alt Ints.None (),auto: x,) ---> -pattern_match(auto: x, alt Ints.None ()) -{ -stack: main{var auto: y = Ints.One(0 = 42); ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), -env: x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step stmt var auto: y = Ints.One(0 = 42); ... ---> -{ -stack: main{var auto: y = Ints.One(0 = 42);<-1> :: var auto: n = 0; ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), -env: x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step stmt var auto: y = Ints.One(0 = 42); ---> -{ -stack: main{Ints.One(0 = 42)<-1> :: var auto: y = Ints.One(0 = 42);<0> :: var auto: n = 0; ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), -env: x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step exp Ints.One(0 = 42) ---> -{ -stack: main{Ints.One<-1> :: Ints.One(0 = 42)<0> :: var auto: y = Ints.One(0 = 42);<0> :: var auto: n = 0; ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), -env: x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step exp Ints.One ---> -{ -stack: main{Ints<-1> :: Ints.One<0> :: Ints.One(0 = 42)<0> :: var auto: y = Ints.One(0 = 42);<0> :: var auto: n = 0; ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), -env: x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step lvalue Ints ---> -{ -stack: main{ptr<3><-1> :: Ints.One<0> :: Ints.One(0 = 42)<0> :: var auto: y = Ints.One(0 = 42);<0> :: var auto: n = 0; ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), -env: x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value ptr<3> with Ints.One<1>(ptr<3>,) ---> -{ -stack: main{Ints.One<-1> :: Ints.One(0 = 42)<0> :: var auto: y = Ints.One(0 = 42);<0> :: var auto: n = 0; ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, -env: x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value Ints.One with Ints.One(0 = 42)<1>(Ints.One,) ---> -{ -stack: main{(0 = 42)<-1> :: Ints.One(0 = 42)<1>(Ints.One,) :: var auto: y = Ints.One(0 = 42);<0> :: var auto: n = 0; ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, -env: x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step exp (0 = 42) ---> -{ -stack: main{42<-1> :: (0 = 42)<0> :: Ints.One(0 = 42)<1>(Ints.One,) :: var auto: y = Ints.One(0 = 42);<0> :: var auto: n = 0; ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, -env: x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step exp 42 ---> -{ -stack: main{42<-1> :: (0 = 42)<0> :: Ints.One(0 = 42)<1>(Ints.One,) :: var auto: y = Ints.One(0 = 42);<0> :: var auto: n = 0; ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, -env: x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value 42 with (0 = 42)<1>(42,) ---> -{ -stack: main{(0 = 42@12)<-1> :: Ints.One(0 = 42)<1>(Ints.One,) :: var auto: y = Ints.One(0 = 42);<0> :: var auto: n = 0; ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, -env: x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value (0 = 42@12) with Ints.One(0 = 42)<2>(Ints.One,(0 = 42@12),) ---> -{ -stack: main{alt Ints.One (0 = 42@13)<-1> :: var auto: y = Ints.One(0 = 42);<0> :: var auto: n = 0; ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, -env: x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value alt Ints.One (0 = 42@13) with var auto: y = Ints.One(0 = 42);<1>(alt Ints.One (0 = 42@13),) ---> -{ -stack: main{auto: y<-1> :: var auto: y = Ints.One(0 = 42);<1>(alt Ints.One (0 = 42@13),) :: var auto: n = 0; ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, -env: x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step exp auto: y ---> -{ -stack: main{auto<-1> :: auto: y<0> :: var auto: y = Ints.One(0 = 42);<1>(alt Ints.One (0 = 42@13),) :: var auto: n = 0; ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, -env: x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step exp auto ---> -{ -stack: main{auto<-1> :: auto: y<0> :: var auto: y = Ints.One(0 = 42);<1>(alt Ints.One (0 = 42@13),) :: var auto: n = 0; ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, -env: x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value auto with auto: y<1>(auto,) ---> -{ -stack: main{auto: y<-1> :: var auto: y = Ints.One(0 = 42);<1>(alt Ints.One (0 = 42@13),) :: var auto: n = 0; ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, -env: x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value auto: y with var auto: y = Ints.One(0 = 42);<2>(alt Ints.One (0 = 42@13),auto: y,) ---> -pattern_match(auto: y, alt Ints.One (0 = 42@13)) -{ -stack: main{var auto: n = 0; ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), -env: y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step stmt var auto: n = 0; ... ---> -{ -stack: main{var auto: n = 0;<-1> :: match (y) {...} ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), -env: y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step stmt var auto: n = 0; ---> -{ -stack: main{0<-1> :: var auto: n = 0;<0> :: match (y) {...} ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), -env: y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step exp 0 ---> -{ -stack: main{0<-1> :: var auto: n = 0;<0> :: match (y) {...} ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), -env: y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value 0 with var auto: n = 0;<1>(0,) ---> -{ -stack: main{auto: n<-1> :: var auto: n = 0;<1>(0,) :: match (y) {...} ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), -env: y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step exp auto: n ---> -{ -stack: main{auto<-1> :: auto: n<0> :: var auto: n = 0;<1>(0,) :: match (y) {...} ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), -env: y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step exp auto ---> -{ -stack: main{auto<-1> :: auto: n<0> :: var auto: n = 0;<1>(0,) :: match (y) {...} ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), -env: y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value auto with auto: n<1>(auto,) ---> -{ -stack: main{auto: n<-1> :: var auto: n = 0;<1>(0,) :: match (y) {...} ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), -env: y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value auto: n with var auto: n = 0;<2>(0,auto: n,) ---> -pattern_match(auto: n, 0) -{ -stack: main{match (y) {...} ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 0, -env: n: 0, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step stmt match (y) {...} ... ---> -{ -stack: main{match (y) {...}<-1> :: match (x) {...} ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 0, -env: n: 0, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step stmt match (y) {...} ---> -{ -stack: main{y<-1> :: match (y) {...}<0> :: match (x) {...} ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 0, -env: n: 0, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step exp y ---> -{ -stack: main{alt Ints.One (0 = 42@14)<-1> :: match (y) {...}<0> :: match (x) {...} ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 0, -env: n: 0, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value alt Ints.One (0 = 42@14) with match (y) {...}<1>(alt Ints.One (0 = 42@14),) ---> -{ -stack: main{Ints.None<-1> :: match (y) {...}<1>(alt Ints.One (0 = 42@14),) :: match (x) {...} ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 0, -env: n: 0, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step exp Ints.None ---> -{ -stack: main{Ints<-1> :: Ints.None<0> :: match (y) {...}<1>(alt Ints.One (0 = 42@14),) :: match (x) {...} ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 0, -env: n: 0, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step lvalue Ints ---> -{ -stack: main{ptr<3><-1> :: Ints.None<0> :: match (y) {...}<1>(alt Ints.One (0 = 42@14),) :: match (x) {...} ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 0, -env: n: 0, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value ptr<3> with Ints.None<1>(ptr<3>,) ---> -{ -stack: main{Ints.None<-1> :: match (y) {...}<1>(alt Ints.One (0 = 42@14),) :: match (x) {...} ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 0, Ints.None, -env: n: 0, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value Ints.None with match (y) {...}<2>(alt Ints.One (0 = 42@14),Ints.None,) ---> -pattern_match(Ints.None, alt Ints.One (0 = 42@14)) -{ -stack: main{Ints.One(0 = auto: x)<-1> :: match (y) {...}<3>(alt Ints.One (0 = 42@14),Ints.None,) :: match (x) {...} ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 0, Ints.None, -env: n: 0, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step exp Ints.One(0 = auto: x) ---> -{ -stack: main{Ints.One<-1> :: Ints.One(0 = auto: x)<0> :: match (y) {...}<3>(alt Ints.One (0 = 42@14),Ints.None,) :: match (x) {...} ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 0, Ints.None, -env: n: 0, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step exp Ints.One ---> -{ -stack: main{Ints<-1> :: Ints.One<0> :: Ints.One(0 = auto: x)<0> :: match (y) {...}<3>(alt Ints.One (0 = 42@14),Ints.None,) :: match (x) {...} ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 0, Ints.None, -env: n: 0, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step lvalue Ints ---> -{ -stack: main{ptr<3><-1> :: Ints.One<0> :: Ints.One(0 = auto: x)<0> :: match (y) {...}<3>(alt Ints.One (0 = 42@14),Ints.None,) :: match (x) {...} ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 0, Ints.None, -env: n: 0, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value ptr<3> with Ints.One<1>(ptr<3>,) ---> -{ -stack: main{Ints.One<-1> :: Ints.One(0 = auto: x)<0> :: match (y) {...}<3>(alt Ints.One (0 = 42@14),Ints.None,) :: match (x) {...} ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 0, Ints.None, Ints.One, -env: n: 0, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value Ints.One with Ints.One(0 = auto: x)<1>(Ints.One,) ---> -{ -stack: main{(0 = auto: x)<-1> :: Ints.One(0 = auto: x)<1>(Ints.One,) :: match (y) {...}<3>(alt Ints.One (0 = 42@14),Ints.None,) :: match (x) {...} ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 0, Ints.None, Ints.One, -env: n: 0, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step exp (0 = auto: x) ---> -{ -stack: main{auto: x<-1> :: (0 = auto: x)<0> :: Ints.One(0 = auto: x)<1>(Ints.One,) :: match (y) {...}<3>(alt Ints.One (0 = 42@14),Ints.None,) :: match (x) {...} ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 0, Ints.None, Ints.One, -env: n: 0, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step exp auto: x ---> -{ -stack: main{auto<-1> :: auto: x<0> :: (0 = auto: x)<0> :: Ints.One(0 = auto: x)<1>(Ints.One,) :: match (y) {...}<3>(alt Ints.One (0 = 42@14),Ints.None,) :: match (x) {...} ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 0, Ints.None, Ints.One, -env: n: 0, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step exp auto ---> -{ -stack: main{auto<-1> :: auto: x<0> :: (0 = auto: x)<0> :: Ints.One(0 = auto: x)<1>(Ints.One,) :: match (y) {...}<3>(alt Ints.One (0 = 42@14),Ints.None,) :: match (x) {...} ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 0, Ints.None, Ints.One, -env: n: 0, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value auto with auto: x<1>(auto,) ---> -{ -stack: main{auto: x<-1> :: (0 = auto: x)<0> :: Ints.One(0 = auto: x)<1>(Ints.One,) :: match (y) {...}<3>(alt Ints.One (0 = 42@14),Ints.None,) :: match (x) {...} ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 0, Ints.None, Ints.One, -env: n: 0, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value auto: x with (0 = auto: x)<1>(auto: x,) ---> -{ -stack: main{(0 = auto: x@19)<-1> :: Ints.One(0 = auto: x)<1>(Ints.One,) :: match (y) {...}<3>(alt Ints.One (0 = 42@14),Ints.None,) :: match (x) {...} ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 0, Ints.None, Ints.One, auto: x, -env: n: 0, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value (0 = auto: x@19) with Ints.One(0 = auto: x)<2>(Ints.One,(0 = auto: x@19),) ---> -{ -stack: main{alt Ints.One (0 = auto: x@20)<-1> :: match (y) {...}<3>(alt Ints.One (0 = 42@14),Ints.None,) :: match (x) {...} ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 0, Ints.None, Ints.One, auto: x, auto: x, -env: n: 0, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value alt Ints.One (0 = auto: x@20) with match (y) {...}<4>(alt Ints.One (0 = 42@14),Ints.None,alt Ints.One (0 = auto: x@20),) ---> -pattern_match(alt Ints.One (0 = auto: x@20), alt Ints.One (0 = 42@14)) -pattern_match((0 = auto: x@20), (0 = 42@14)) -pattern_match(auto: x, 42) -{ -stack: main{n = ((x + 1) - 42);<-1> :: { - ... -} -<0> :: match (x) {...} ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 0, Ints.None, Ints.One, auto: x, auto: x, 42, -env: x: 42, n: 0, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step stmt n = ((x + 1) - 42); ---> -{ -stack: main{n<-1> :: n = ((x + 1) - 42);<0> :: { - ... -} -<0> :: match (x) {...} ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 0, Ints.None, Ints.One, auto: x, auto: x, 42, -env: x: 42, n: 0, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step lvalue n ---> -{ -stack: main{ptr<16><-1> :: n = ((x + 1) - 42);<0> :: { - ... -} -<0> :: match (x) {...} ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 0, Ints.None, Ints.One, auto: x, auto: x, 42, -env: x: 42, n: 0, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value ptr<16> with n = ((x + 1) - 42);<1>(ptr<16>,) ---> -{ -stack: main{((x + 1) - 42)<-1> :: n = ((x + 1) - 42);<1>(ptr<16>,) :: { - ... -} -<0> :: match (x) {...} ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 0, Ints.None, Ints.One, auto: x, auto: x, 42, -env: x: 42, n: 0, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step exp ((x + 1) - 42) ---> -{ -stack: main{(x + 1)<-1> :: ((x + 1) - 42)<0> :: n = ((x + 1) - 42);<1>(ptr<16>,) :: { - ... -} -<0> :: match (x) {...} ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 0, Ints.None, Ints.One, auto: x, auto: x, 42, -env: x: 42, n: 0, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step exp (x + 1) ---> -{ -stack: main{x<-1> :: (x + 1)<0> :: ((x + 1) - 42)<0> :: n = ((x + 1) - 42);<1>(ptr<16>,) :: { - ... -} -<0> :: match (x) {...} ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 0, Ints.None, Ints.One, auto: x, auto: x, 42, -env: x: 42, n: 0, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step exp x ---> -{ -stack: main{42<-1> :: (x + 1)<0> :: ((x + 1) - 42)<0> :: n = ((x + 1) - 42);<1>(ptr<16>,) :: { - ... -} -<0> :: match (x) {...} ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 0, Ints.None, Ints.One, auto: x, auto: x, 42, -env: x: 42, n: 0, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value 42 with (x + 1)<1>(42,) ---> -{ -stack: main{1<-1> :: (x + 1)<1>(42,) :: ((x + 1) - 42)<0> :: n = ((x + 1) - 42);<1>(ptr<16>,) :: { - ... -} -<0> :: match (x) {...} ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 0, Ints.None, Ints.One, auto: x, auto: x, 42, -env: x: 42, n: 0, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step exp 1 ---> -{ -stack: main{1<-1> :: (x + 1)<1>(42,) :: ((x + 1) - 42)<0> :: n = ((x + 1) - 42);<1>(ptr<16>,) :: { - ... -} -<0> :: match (x) {...} ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 0, Ints.None, Ints.One, auto: x, auto: x, 42, -env: x: 42, n: 0, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value 1 with (x + 1)<2>(42,1,) ---> -{ -stack: main{43<-1> :: ((x + 1) - 42)<0> :: n = ((x + 1) - 42);<1>(ptr<16>,) :: { - ... -} -<0> :: match (x) {...} ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 0, Ints.None, Ints.One, auto: x, auto: x, 42, -env: x: 42, n: 0, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value 43 with ((x + 1) - 42)<1>(43,) ---> -{ -stack: main{42<-1> :: ((x + 1) - 42)<1>(43,) :: n = ((x + 1) - 42);<1>(ptr<16>,) :: { - ... -} -<0> :: match (x) {...} ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 0, Ints.None, Ints.One, auto: x, auto: x, 42, -env: x: 42, n: 0, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step exp 42 ---> -{ -stack: main{42<-1> :: ((x + 1) - 42)<1>(43,) :: n = ((x + 1) - 42);<1>(ptr<16>,) :: { - ... -} -<0> :: match (x) {...} ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 0, Ints.None, Ints.One, auto: x, auto: x, 42, -env: x: 42, n: 0, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value 42 with ((x + 1) - 42)<2>(43,42,) ---> -{ -stack: main{1<-1> :: n = ((x + 1) - 42);<1>(ptr<16>,) :: { - ... -} -<0> :: match (x) {...} ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 0, Ints.None, Ints.One, auto: x, auto: x, 42, -env: x: 42, n: 0, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value 1 with n = ((x + 1) - 42);<2>(ptr<16>,1,) ---> -{ -stack: main{{ - ... -} -<0> :: match (x) {...} ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 1, Ints.None, Ints.One, auto: x, auto: x, 42, -env: x: 42, n: 1, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step stmt { - ... -} - ---> -{ -stack: main{match (x) {...} ... <-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 1, Ints.None, Ints.One, auto: x, auto: x, !!42, -env: n: 1, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step stmt match (x) {...} ... ---> -{ -stack: main{match (x) {...}<-1> :: return n;<-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 1, Ints.None, Ints.One, auto: x, auto: x, !!42, -env: n: 1, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step stmt match (x) {...} ---> -{ -stack: main{x<-1> :: match (x) {...}<0> :: return n;<-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 1, Ints.None, Ints.One, auto: x, auto: x, !!42, -env: n: 1, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step exp x ---> -{ -stack: main{alt Ints.None ()<-1> :: match (x) {...}<0> :: return n;<-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 1, Ints.None, Ints.One, auto: x, auto: x, !!42, -env: n: 1, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value alt Ints.None () with match (x) {...}<1>(alt Ints.None (),) ---> -{ -stack: main{Ints.One(0 = auto: x)<-1> :: match (x) {...}<1>(alt Ints.None (),) :: return n;<-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 1, Ints.None, Ints.One, auto: x, auto: x, !!42, -env: n: 1, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step exp Ints.One(0 = auto: x) ---> -{ -stack: main{Ints.One<-1> :: Ints.One(0 = auto: x)<0> :: match (x) {...}<1>(alt Ints.None (),) :: return n;<-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 1, Ints.None, Ints.One, auto: x, auto: x, !!42, -env: n: 1, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step exp Ints.One ---> -{ -stack: main{Ints<-1> :: Ints.One<0> :: Ints.One(0 = auto: x)<0> :: match (x) {...}<1>(alt Ints.None (),) :: return n;<-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 1, Ints.None, Ints.One, auto: x, auto: x, !!42, -env: n: 1, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step lvalue Ints ---> -{ -stack: main{ptr<3><-1> :: Ints.One<0> :: Ints.One(0 = auto: x)<0> :: match (x) {...}<1>(alt Ints.None (),) :: return n;<-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 1, Ints.None, Ints.One, auto: x, auto: x, !!42, -env: n: 1, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value ptr<3> with Ints.One<1>(ptr<3>,) ---> -{ -stack: main{Ints.One<-1> :: Ints.One(0 = auto: x)<0> :: match (x) {...}<1>(alt Ints.None (),) :: return n;<-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 1, Ints.None, Ints.One, auto: x, auto: x, !!42, Ints.One, -env: n: 1, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value Ints.One with Ints.One(0 = auto: x)<1>(Ints.One,) ---> -{ -stack: main{(0 = auto: x)<-1> :: Ints.One(0 = auto: x)<1>(Ints.One,) :: match (x) {...}<1>(alt Ints.None (),) :: return n;<-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 1, Ints.None, Ints.One, auto: x, auto: x, !!42, Ints.One, -env: n: 1, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step exp (0 = auto: x) ---> -{ -stack: main{auto: x<-1> :: (0 = auto: x)<0> :: Ints.One(0 = auto: x)<1>(Ints.One,) :: match (x) {...}<1>(alt Ints.None (),) :: return n;<-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 1, Ints.None, Ints.One, auto: x, auto: x, !!42, Ints.One, -env: n: 1, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step exp auto: x ---> -{ -stack: main{auto<-1> :: auto: x<0> :: (0 = auto: x)<0> :: Ints.One(0 = auto: x)<1>(Ints.One,) :: match (x) {...}<1>(alt Ints.None (),) :: return n;<-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 1, Ints.None, Ints.One, auto: x, auto: x, !!42, Ints.One, -env: n: 1, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step exp auto ---> -{ -stack: main{auto<-1> :: auto: x<0> :: (0 = auto: x)<0> :: Ints.One(0 = auto: x)<1>(Ints.One,) :: match (x) {...}<1>(alt Ints.None (),) :: return n;<-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 1, Ints.None, Ints.One, auto: x, auto: x, !!42, Ints.One, -env: n: 1, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value auto with auto: x<1>(auto,) ---> -{ -stack: main{auto: x<-1> :: (0 = auto: x)<0> :: Ints.One(0 = auto: x)<1>(Ints.One,) :: match (x) {...}<1>(alt Ints.None (),) :: return n;<-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 1, Ints.None, Ints.One, auto: x, auto: x, !!42, Ints.One, -env: n: 1, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value auto: x with (0 = auto: x)<1>(auto: x,) ---> -{ -stack: main{(0 = auto: x@23)<-1> :: Ints.One(0 = auto: x)<1>(Ints.One,) :: match (x) {...}<1>(alt Ints.None (),) :: return n;<-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 1, Ints.None, Ints.One, auto: x, auto: x, !!42, Ints.One, auto: x, -env: n: 1, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value (0 = auto: x@23) with Ints.One(0 = auto: x)<2>(Ints.One,(0 = auto: x@23),) ---> -{ -stack: main{alt Ints.One (0 = auto: x@24)<-1> :: match (x) {...}<1>(alt Ints.None (),) :: return n;<-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 1, Ints.None, Ints.One, auto: x, auto: x, !!42, Ints.One, auto: x, auto: x, -env: n: 1, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value alt Ints.One (0 = auto: x@24) with match (x) {...}<2>(alt Ints.None (),alt Ints.One (0 = auto: x@24),) ---> -pattern_match(alt Ints.One (0 = auto: x@24), alt Ints.None ()) -{ -stack: main{Ints.None()<-1> :: match (x) {...}<3>(alt Ints.None (),alt Ints.One (0 = auto: x@24),) :: return n;<-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 1, Ints.None, Ints.One, auto: x, auto: x, !!42, Ints.One, auto: x, auto: x, -env: n: 1, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step exp Ints.None() ---> -{ -stack: main{Ints.None<-1> :: Ints.None()<0> :: match (x) {...}<3>(alt Ints.None (),alt Ints.One (0 = auto: x@24),) :: return n;<-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 1, Ints.None, Ints.One, auto: x, auto: x, !!42, Ints.One, auto: x, auto: x, -env: n: 1, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step exp Ints.None ---> -{ -stack: main{Ints<-1> :: Ints.None<0> :: Ints.None()<0> :: match (x) {...}<3>(alt Ints.None (),alt Ints.One (0 = auto: x@24),) :: return n;<-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 1, Ints.None, Ints.One, auto: x, auto: x, !!42, Ints.One, auto: x, auto: x, -env: n: 1, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step lvalue Ints ---> -{ -stack: main{ptr<3><-1> :: Ints.None<0> :: Ints.None()<0> :: match (x) {...}<3>(alt Ints.None (),alt Ints.One (0 = auto: x@24),) :: return n;<-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 1, Ints.None, Ints.One, auto: x, auto: x, !!42, Ints.One, auto: x, auto: x, -env: n: 1, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value ptr<3> with Ints.None<1>(ptr<3>,) ---> -{ -stack: main{Ints.None<-1> :: Ints.None()<0> :: match (x) {...}<3>(alt Ints.None (),alt Ints.One (0 = auto: x@24),) :: return n;<-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 1, Ints.None, Ints.One, auto: x, auto: x, !!42, Ints.One, auto: x, auto: x, Ints.None, -env: n: 1, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value Ints.None with Ints.None()<1>(Ints.None,) ---> -{ -stack: main{()<-1> :: Ints.None()<1>(Ints.None,) :: match (x) {...}<3>(alt Ints.None (),alt Ints.One (0 = auto: x@24),) :: return n;<-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 1, Ints.None, Ints.One, auto: x, auto: x, !!42, Ints.One, auto: x, auto: x, Ints.None, -env: n: 1, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step exp () ---> -{ -stack: main{()<-1> :: Ints.None()<1>(Ints.None,) :: match (x) {...}<3>(alt Ints.None (),alt Ints.One (0 = auto: x@24),) :: return n;<-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 1, Ints.None, Ints.One, auto: x, auto: x, !!42, Ints.One, auto: x, auto: x, Ints.None, -env: n: 1, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value () with Ints.None()<2>(Ints.None,(),) ---> -{ -stack: main{alt Ints.None ()<-1> :: match (x) {...}<3>(alt Ints.None (),alt Ints.One (0 = auto: x@24),) :: return n;<-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 1, Ints.None, Ints.One, auto: x, auto: x, !!42, Ints.One, auto: x, auto: x, Ints.None, -env: n: 1, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value alt Ints.None () with match (x) {...}<4>(alt Ints.None (),alt Ints.One (0 = auto: x@24),alt Ints.None (),) ---> -pattern_match(alt Ints.None (), alt Ints.None ()) -pattern_match((), ()) -{ -stack: main{n = (n - 1);<-1> :: { - ... -} -<0> :: return n;<-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 1, Ints.None, Ints.One, auto: x, auto: x, !!42, Ints.One, auto: x, auto: x, Ints.None, -env: n: 1, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step stmt n = (n - 1); ---> -{ -stack: main{n<-1> :: n = (n - 1);<0> :: { - ... -} -<0> :: return n;<-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 1, Ints.None, Ints.One, auto: x, auto: x, !!42, Ints.One, auto: x, auto: x, Ints.None, -env: n: 1, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step lvalue n ---> -{ -stack: main{ptr<16><-1> :: n = (n - 1);<0> :: { - ... -} -<0> :: return n;<-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 1, Ints.None, Ints.One, auto: x, auto: x, !!42, Ints.One, auto: x, auto: x, Ints.None, -env: n: 1, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value ptr<16> with n = (n - 1);<1>(ptr<16>,) ---> -{ -stack: main{(n - 1)<-1> :: n = (n - 1);<1>(ptr<16>,) :: { - ... -} -<0> :: return n;<-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 1, Ints.None, Ints.One, auto: x, auto: x, !!42, Ints.One, auto: x, auto: x, Ints.None, -env: n: 1, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step exp (n - 1) ---> -{ -stack: main{n<-1> :: (n - 1)<0> :: n = (n - 1);<1>(ptr<16>,) :: { - ... -} -<0> :: return n;<-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 1, Ints.None, Ints.One, auto: x, auto: x, !!42, Ints.One, auto: x, auto: x, Ints.None, -env: n: 1, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step exp n ---> -{ -stack: main{1<-1> :: (n - 1)<0> :: n = (n - 1);<1>(ptr<16>,) :: { - ... -} -<0> :: return n;<-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 1, Ints.None, Ints.One, auto: x, auto: x, !!42, Ints.One, auto: x, auto: x, Ints.None, -env: n: 1, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value 1 with (n - 1)<1>(1,) ---> -{ -stack: main{1<-1> :: (n - 1)<1>(1,) :: n = (n - 1);<1>(ptr<16>,) :: { - ... -} -<0> :: return n;<-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 1, Ints.None, Ints.One, auto: x, auto: x, !!42, Ints.One, auto: x, auto: x, Ints.None, -env: n: 1, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step exp 1 ---> -{ -stack: main{1<-1> :: (n - 1)<1>(1,) :: n = (n - 1);<1>(ptr<16>,) :: { - ... -} -<0> :: return n;<-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 1, Ints.None, Ints.One, auto: x, auto: x, !!42, Ints.One, auto: x, auto: x, Ints.None, -env: n: 1, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value 1 with (n - 1)<2>(1,1,) ---> -{ -stack: main{0<-1> :: n = (n - 1);<1>(ptr<16>,) :: { - ... -} -<0> :: return n;<-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 1, Ints.None, Ints.One, auto: x, auto: x, !!42, Ints.One, auto: x, auto: x, Ints.None, -env: n: 1, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value 0 with n = (n - 1);<2>(ptr<16>,0,) ---> -{ -stack: main{{ - ... -} -<0> :: return n;<-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 0, Ints.None, Ints.One, auto: x, auto: x, !!42, Ints.One, auto: x, auto: x, Ints.None, -env: n: 0, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step stmt { - ... -} - ---> -{ -stack: main{return n;<-1>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 0, Ints.None, Ints.One, auto: x, auto: x, !!42, Ints.One, auto: x, auto: x, Ints.None, -env: n: 0, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step stmt return n; ---> -{ -stack: main{n<-1> :: return n;<0>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 0, Ints.None, Ints.One, auto: x, auto: x, !!42, Ints.One, auto: x, auto: x, Ints.None, -env: n: 0, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- step exp n ---> -{ -stack: main{0<-1> :: return n;<0>} :: top{} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, alt Ints.None (), Ints.One, 42, 42, 42, alt Ints.One (0 = 42@14), 0, Ints.None, Ints.One, auto: x, auto: x, !!42, Ints.One, auto: x, auto: x, Ints.None, -env: n: 0, y: alt Ints.One (0 = 42@14), x: alt Ints.None (), MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} ---- handle value 0 with return n;<1>(0,) ---> -{ -stack: top{0<-1>} -heap: Int, Int, Int, choice Ints, fun
, Int, Int, Int, choice MoreInts, Ints.None, !!alt Ints.None !!(), Ints.One, 42, 42, !!42, !!alt Ints.One !!(0 = !!42@14), !!0, Ints.None, Ints.One, auto: x, auto: x, !!42, Ints.One, auto: x, auto: x, Ints.None, -env: MoreInts: choice MoreInts, main: fun
, Ints: choice Ints, -} result: 0 diff --git a/executable_semantics/testdata/continue1.golden b/executable_semantics/testdata/continue1.golden index d63b002d8630..2db2755da426 100644 --- a/executable_semantics/testdata/continue1.golden +++ b/executable_semantics/testdata/continue1.golden @@ -1,616 +1 @@ -********** source program ********** -fn main () -> Int { -var auto: x = 2; -while ((! (x == 0))) -{ -x = (x - 1); -continue; -x = (x + 1); - -} - -return x; - -} -********** type checking ********** ---- step exp Int ---> ---- step exp Int ---> ---- step exp auto ---> - -********** type checking complete ********** -fn main () -> Int { -var auto: x = 2; -while ((! (x == 0))) -{ -x = (x - 1); -continue; -x = (x + 1); - -} - -return x; -} -********** starting execution ********** -********** initializing globals ********** ---- step exp () ---> -********** calling main function ********** -{ -stack: top{main()<-1>} -heap: fun
, -env: main: fun
, -} ---- step exp main() ---> -{ -stack: top{main<-1> :: main()<0>} -heap: fun
, -env: main: fun
, -} ---- step exp main ---> -{ -stack: top{fun
<-1> :: main()<0>} -heap: fun
, -env: main: fun
, -} ---- handle value fun
with main()<1>(fun
,) ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: fun
, -env: main: fun
, -} ---- step exp () ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: fun
, -env: main: fun
, -} ---- handle value () with main()<2>(fun
,(),) ---> -pattern_match((), ()) -{ -stack: main{var auto: x = 2; ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step stmt var auto: x = 2; ... ---> -{ -stack: main{var auto: x = 2;<-1> :: while ((! (x == 0))) - ... ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step stmt var auto: x = 2; ---> -{ -stack: main{2<-1> :: var auto: x = 2;<0> :: while ((! (x == 0))) - ... ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp 2 ---> -{ -stack: main{2<-1> :: var auto: x = 2;<0> :: while ((! (x == 0))) - ... ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value 2 with var auto: x = 2;<1>(2,) ---> -{ -stack: main{auto: x<-1> :: var auto: x = 2;<1>(2,) :: while ((! (x == 0))) - ... ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp auto: x ---> -{ -stack: main{auto<-1> :: auto: x<0> :: var auto: x = 2;<1>(2,) :: while ((! (x == 0))) - ... ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp auto ---> -{ -stack: main{auto<-1> :: auto: x<0> :: var auto: x = 2;<1>(2,) :: while ((! (x == 0))) - ... ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value auto with auto: x<1>(auto,) ---> -{ -stack: main{auto: x<-1> :: var auto: x = 2;<1>(2,) :: while ((! (x == 0))) - ... ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value auto: x with var auto: x = 2;<2>(2,auto: x,) ---> -pattern_match(auto: x, 2) -{ -stack: main{while ((! (x == 0))) - ... ... <-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- step stmt while ((! (x == 0))) - ... ... ---> -{ -stack: main{while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- step stmt while ((! (x == 0))) - ... ---> -{ -stack: main{(! (x == 0))<-1> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- step exp (! (x == 0)) ---> -{ -stack: main{(x == 0)<-1> :: (! (x == 0))<0> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- step exp (x == 0) ---> -{ -stack: main{x<-1> :: (x == 0)<0> :: (! (x == 0))<0> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- step exp x ---> -{ -stack: main{2<-1> :: (x == 0)<0> :: (! (x == 0))<0> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- handle value 2 with (x == 0)<1>(2,) ---> -{ -stack: main{0<-1> :: (x == 0)<1>(2,) :: (! (x == 0))<0> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- step exp 0 ---> -{ -stack: main{0<-1> :: (x == 0)<1>(2,) :: (! (x == 0))<0> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- handle value 0 with (x == 0)<2>(2,0,) ---> -{ -stack: main{false<-1> :: (! (x == 0))<0> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- handle value false with (! (x == 0))<1>(false,) ---> -{ -stack: main{true<-1> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- handle value true with while ((! (x == 0))) - ... <1>(true,) ---> -{ -stack: main{{ - ... -} -<-1> :: while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- step stmt { - ... -} - ---> -{ -stack: main{x = (x - 1); ... <-1> :: { - ... -} -<0> :: while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- step stmt x = (x - 1); ... ---> -{ -stack: main{x = (x - 1);<-1> :: continue; ... <-1> :: { - ... -} -<0> :: while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- step stmt x = (x - 1); ---> -{ -stack: main{x<-1> :: x = (x - 1);<0> :: continue; ... <-1> :: { - ... -} -<0> :: while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- step lvalue x ---> -{ -stack: main{ptr<1><-1> :: x = (x - 1);<0> :: continue; ... <-1> :: { - ... -} -<0> :: while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- handle value ptr<1> with x = (x - 1);<1>(ptr<1>,) ---> -{ -stack: main{(x - 1)<-1> :: x = (x - 1);<1>(ptr<1>,) :: continue; ... <-1> :: { - ... -} -<0> :: while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- step exp (x - 1) ---> -{ -stack: main{x<-1> :: (x - 1)<0> :: x = (x - 1);<1>(ptr<1>,) :: continue; ... <-1> :: { - ... -} -<0> :: while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- step exp x ---> -{ -stack: main{2<-1> :: (x - 1)<0> :: x = (x - 1);<1>(ptr<1>,) :: continue; ... <-1> :: { - ... -} -<0> :: while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- handle value 2 with (x - 1)<1>(2,) ---> -{ -stack: main{1<-1> :: (x - 1)<1>(2,) :: x = (x - 1);<1>(ptr<1>,) :: continue; ... <-1> :: { - ... -} -<0> :: while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- step exp 1 ---> -{ -stack: main{1<-1> :: (x - 1)<1>(2,) :: x = (x - 1);<1>(ptr<1>,) :: continue; ... <-1> :: { - ... -} -<0> :: while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- handle value 1 with (x - 1)<2>(2,1,) ---> -{ -stack: main{1<-1> :: x = (x - 1);<1>(ptr<1>,) :: continue; ... <-1> :: { - ... -} -<0> :: while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- handle value 1 with x = (x - 1);<2>(ptr<1>,1,) ---> -{ -stack: main{continue; ... <-1> :: { - ... -} -<0> :: while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- step stmt continue; ... ---> -{ -stack: main{continue;<-1> :: x = (x + 1);<-1> :: { - ... -} -<0> :: while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- step stmt continue; ---> -{ -stack: main{while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- step stmt while ((! (x == 0))) - ... ---> -{ -stack: main{(! (x == 0))<-1> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- step exp (! (x == 0)) ---> -{ -stack: main{(x == 0)<-1> :: (! (x == 0))<0> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- step exp (x == 0) ---> -{ -stack: main{x<-1> :: (x == 0)<0> :: (! (x == 0))<0> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- step exp x ---> -{ -stack: main{1<-1> :: (x == 0)<0> :: (! (x == 0))<0> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- handle value 1 with (x == 0)<1>(1,) ---> -{ -stack: main{0<-1> :: (x == 0)<1>(1,) :: (! (x == 0))<0> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- step exp 0 ---> -{ -stack: main{0<-1> :: (x == 0)<1>(1,) :: (! (x == 0))<0> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- handle value 0 with (x == 0)<2>(1,0,) ---> -{ -stack: main{false<-1> :: (! (x == 0))<0> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- handle value false with (! (x == 0))<1>(false,) ---> -{ -stack: main{true<-1> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- handle value true with while ((! (x == 0))) - ... <1>(true,) ---> -{ -stack: main{{ - ... -} -<-1> :: while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- step stmt { - ... -} - ---> -{ -stack: main{x = (x - 1); ... <-1> :: { - ... -} -<0> :: while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- step stmt x = (x - 1); ... ---> -{ -stack: main{x = (x - 1);<-1> :: continue; ... <-1> :: { - ... -} -<0> :: while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- step stmt x = (x - 1); ---> -{ -stack: main{x<-1> :: x = (x - 1);<0> :: continue; ... <-1> :: { - ... -} -<0> :: while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- step lvalue x ---> -{ -stack: main{ptr<1><-1> :: x = (x - 1);<0> :: continue; ... <-1> :: { - ... -} -<0> :: while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- handle value ptr<1> with x = (x - 1);<1>(ptr<1>,) ---> -{ -stack: main{(x - 1)<-1> :: x = (x - 1);<1>(ptr<1>,) :: continue; ... <-1> :: { - ... -} -<0> :: while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- step exp (x - 1) ---> -{ -stack: main{x<-1> :: (x - 1)<0> :: x = (x - 1);<1>(ptr<1>,) :: continue; ... <-1> :: { - ... -} -<0> :: while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- step exp x ---> -{ -stack: main{1<-1> :: (x - 1)<0> :: x = (x - 1);<1>(ptr<1>,) :: continue; ... <-1> :: { - ... -} -<0> :: while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- handle value 1 with (x - 1)<1>(1,) ---> -{ -stack: main{1<-1> :: (x - 1)<1>(1,) :: x = (x - 1);<1>(ptr<1>,) :: continue; ... <-1> :: { - ... -} -<0> :: while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- step exp 1 ---> -{ -stack: main{1<-1> :: (x - 1)<1>(1,) :: x = (x - 1);<1>(ptr<1>,) :: continue; ... <-1> :: { - ... -} -<0> :: while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- handle value 1 with (x - 1)<2>(1,1,) ---> -{ -stack: main{0<-1> :: x = (x - 1);<1>(ptr<1>,) :: continue; ... <-1> :: { - ... -} -<0> :: while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- handle value 0 with x = (x - 1);<2>(ptr<1>,0,) ---> -{ -stack: main{continue; ... <-1> :: { - ... -} -<0> :: while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- step stmt continue; ... ---> -{ -stack: main{continue;<-1> :: x = (x + 1);<-1> :: { - ... -} -<0> :: while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- step stmt continue; ---> -{ -stack: main{while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- step stmt while ((! (x == 0))) - ... ---> -{ -stack: main{(! (x == 0))<-1> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- step exp (! (x == 0)) ---> -{ -stack: main{(x == 0)<-1> :: (! (x == 0))<0> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- step exp (x == 0) ---> -{ -stack: main{x<-1> :: (x == 0)<0> :: (! (x == 0))<0> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- step exp x ---> -{ -stack: main{0<-1> :: (x == 0)<0> :: (! (x == 0))<0> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- handle value 0 with (x == 0)<1>(0,) ---> -{ -stack: main{0<-1> :: (x == 0)<1>(0,) :: (! (x == 0))<0> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- step exp 0 ---> -{ -stack: main{0<-1> :: (x == 0)<1>(0,) :: (! (x == 0))<0> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- handle value 0 with (x == 0)<2>(0,0,) ---> -{ -stack: main{true<-1> :: (! (x == 0))<0> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- handle value true with (! (x == 0))<1>(true,) ---> -{ -stack: main{false<-1> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- handle value false with while ((! (x == 0))) - ... <1>(false,) ---> -{ -stack: main{return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- step stmt return x; ---> -{ -stack: main{x<-1> :: return x;<0>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- step exp x ---> -{ -stack: main{0<-1> :: return x;<0>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- handle value 0 with return x;<1>(0,) ---> -{ -stack: top{0<-1>} -heap: fun
, !!0, -env: main: fun
, -} result: 0 diff --git a/executable_semantics/testdata/fun1.golden b/executable_semantics/testdata/fun1.golden index 77b895e21ce0..2db2755da426 100644 --- a/executable_semantics/testdata/fun1.golden +++ b/executable_semantics/testdata/fun1.golden @@ -1,168 +1 @@ -********** source program ********** -fn f (0 = Int: x) -> Int { -return (x - 1); - -} -fn main () -> Int { -return f(0 = 1); - -} -********** type checking ********** ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> - -********** type checking complete ********** -fn f (0 = Int: x) -> Int { -return (x - 1); -} -fn main () -> Int { -return f(0 = 1); -} -********** starting execution ********** -********** initializing globals ********** ---- step exp (0 = Int: x) ---> ---- step exp Int: x ---> ---- step exp Int ---> ---- handle value Int with Int: x<1>(Int,) ---> ---- handle value Int: x with (0 = Int: x)<1>(Int: x,) ---> ---- step exp () ---> -********** calling main function ********** -{ -stack: top{main()<-1>} -heap: Int: x, fun, fun
, -env: main: fun
, f: fun, -} ---- step exp main() ---> -{ -stack: top{main<-1> :: main()<0>} -heap: Int: x, fun, fun
, -env: main: fun
, f: fun, -} ---- step exp main ---> -{ -stack: top{fun
<-1> :: main()<0>} -heap: Int: x, fun, fun
, -env: main: fun
, f: fun, -} ---- handle value fun
with main()<1>(fun
,) ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: Int: x, fun, fun
, -env: main: fun
, f: fun, -} ---- step exp () ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: Int: x, fun, fun
, -env: main: fun
, f: fun, -} ---- handle value () with main()<2>(fun
,(),) ---> -pattern_match((), ()) -{ -stack: main{return f(0 = 1);<-1>} :: top{} -heap: Int: x, fun, fun
, -env: main: fun
, f: fun, -} ---- step stmt return f(0 = 1); ---> -{ -stack: main{f(0 = 1)<-1> :: return f(0 = 1);<0>} :: top{} -heap: Int: x, fun, fun
, -env: main: fun
, f: fun, -} ---- step exp f(0 = 1) ---> -{ -stack: main{f<-1> :: f(0 = 1)<0> :: return f(0 = 1);<0>} :: top{} -heap: Int: x, fun, fun
, -env: main: fun
, f: fun, -} ---- step exp f ---> -{ -stack: main{fun<-1> :: f(0 = 1)<0> :: return f(0 = 1);<0>} :: top{} -heap: Int: x, fun, fun
, -env: main: fun
, f: fun, -} ---- handle value fun with f(0 = 1)<1>(fun,) ---> -{ -stack: main{(0 = 1)<-1> :: f(0 = 1)<1>(fun,) :: return f(0 = 1);<0>} :: top{} -heap: Int: x, fun, fun
, -env: main: fun
, f: fun, -} ---- step exp (0 = 1) ---> -{ -stack: main{1<-1> :: (0 = 1)<0> :: f(0 = 1)<1>(fun,) :: return f(0 = 1);<0>} :: top{} -heap: Int: x, fun, fun
, -env: main: fun
, f: fun, -} ---- step exp 1 ---> -{ -stack: main{1<-1> :: (0 = 1)<0> :: f(0 = 1)<1>(fun,) :: return f(0 = 1);<0>} :: top{} -heap: Int: x, fun, fun
, -env: main: fun
, f: fun, -} ---- handle value 1 with (0 = 1)<1>(1,) ---> -{ -stack: main{(0 = 1@3)<-1> :: f(0 = 1)<1>(fun,) :: return f(0 = 1);<0>} :: top{} -heap: Int: x, fun, fun
, 1, -env: main: fun
, f: fun, -} ---- handle value (0 = 1@3) with f(0 = 1)<2>(fun,(0 = 1@3),) ---> -pattern_match((0 = Int: x@0), (0 = 1@3)) -pattern_match(Int: x, 1) -{ -stack: f{return (x - 1);<-1>} :: main{return f(0 = 1);<0>} :: top{} -heap: Int: x, fun, fun
, 1, 1, -env: x: 1, main: fun
, f: fun, -} ---- step stmt return (x - 1); ---> -{ -stack: f{(x - 1)<-1> :: return (x - 1);<0>} :: main{return f(0 = 1);<0>} :: top{} -heap: Int: x, fun, fun
, 1, 1, -env: x: 1, main: fun
, f: fun, -} ---- step exp (x - 1) ---> -{ -stack: f{x<-1> :: (x - 1)<0> :: return (x - 1);<0>} :: main{return f(0 = 1);<0>} :: top{} -heap: Int: x, fun, fun
, 1, 1, -env: x: 1, main: fun
, f: fun, -} ---- step exp x ---> -{ -stack: f{1<-1> :: (x - 1)<0> :: return (x - 1);<0>} :: main{return f(0 = 1);<0>} :: top{} -heap: Int: x, fun, fun
, 1, 1, -env: x: 1, main: fun
, f: fun, -} ---- handle value 1 with (x - 1)<1>(1,) ---> -{ -stack: f{1<-1> :: (x - 1)<1>(1,) :: return (x - 1);<0>} :: main{return f(0 = 1);<0>} :: top{} -heap: Int: x, fun, fun
, 1, 1, -env: x: 1, main: fun
, f: fun, -} ---- step exp 1 ---> -{ -stack: f{1<-1> :: (x - 1)<1>(1,) :: return (x - 1);<0>} :: main{return f(0 = 1);<0>} :: top{} -heap: Int: x, fun, fun
, 1, 1, -env: x: 1, main: fun
, f: fun, -} ---- handle value 1 with (x - 1)<2>(1,1,) ---> -{ -stack: f{0<-1> :: return (x - 1);<0>} :: main{return f(0 = 1);<0>} :: top{} -heap: Int: x, fun, fun
, 1, 1, -env: x: 1, main: fun
, f: fun, -} ---- handle value 0 with return (x - 1);<1>(0,) ---> -{ -stack: main{0<-1> :: return f(0 = 1);<0>} :: top{} -heap: Int: x, fun, fun
, 1, !!1, -env: main: fun
, f: fun, -} ---- handle value 0 with return f(0 = 1);<1>(0,) ---> -{ -stack: top{0<-1>} -heap: Int: x, fun, fun
, 1, !!1, -env: main: fun
, f: fun, -} result: 0 diff --git a/executable_semantics/testdata/fun2.golden b/executable_semantics/testdata/fun2.golden index 421e6ce5f9c2..2db2755da426 100644 --- a/executable_semantics/testdata/fun2.golden +++ b/executable_semantics/testdata/fun2.golden @@ -1,312 +1 @@ -********** source program ********** -fn f (0 = Int: x) -> Int { -return 0; - -} -fn main () -> Int { -var Int: a = 0; -var Int: b = 1; -f(0 = a); -b = a; -return b; - -} -********** type checking ********** ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> - -********** type checking complete ********** -fn f (0 = Int: x) -> Int { -return 0; -} -fn main () -> Int { -var Int: a = 0; -var Int: b = 1; -f(0 = a); -b = a; -return b; -} -********** starting execution ********** -********** initializing globals ********** ---- step exp (0 = Int: x) ---> ---- step exp Int: x ---> ---- step exp Int ---> ---- handle value Int with Int: x<1>(Int,) ---> ---- handle value Int: x with (0 = Int: x)<1>(Int: x,) ---> ---- step exp () ---> -********** calling main function ********** -{ -stack: top{main()<-1>} -heap: Int: x, fun, fun
, -env: main: fun
, f: fun, -} ---- step exp main() ---> -{ -stack: top{main<-1> :: main()<0>} -heap: Int: x, fun, fun
, -env: main: fun
, f: fun, -} ---- step exp main ---> -{ -stack: top{fun
<-1> :: main()<0>} -heap: Int: x, fun, fun
, -env: main: fun
, f: fun, -} ---- handle value fun
with main()<1>(fun
,) ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: Int: x, fun, fun
, -env: main: fun
, f: fun, -} ---- step exp () ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: Int: x, fun, fun
, -env: main: fun
, f: fun, -} ---- handle value () with main()<2>(fun
,(),) ---> -pattern_match((), ()) -{ -stack: main{var Int: a = 0; ... <-1>} :: top{} -heap: Int: x, fun, fun
, -env: main: fun
, f: fun, -} ---- step stmt var Int: a = 0; ... ---> -{ -stack: main{var Int: a = 0;<-1> :: var Int: b = 1; ... <-1>} :: top{} -heap: Int: x, fun, fun
, -env: main: fun
, f: fun, -} ---- step stmt var Int: a = 0; ---> -{ -stack: main{0<-1> :: var Int: a = 0;<0> :: var Int: b = 1; ... <-1>} :: top{} -heap: Int: x, fun, fun
, -env: main: fun
, f: fun, -} ---- step exp 0 ---> -{ -stack: main{0<-1> :: var Int: a = 0;<0> :: var Int: b = 1; ... <-1>} :: top{} -heap: Int: x, fun, fun
, -env: main: fun
, f: fun, -} ---- handle value 0 with var Int: a = 0;<1>(0,) ---> -{ -stack: main{Int: a<-1> :: var Int: a = 0;<1>(0,) :: var Int: b = 1; ... <-1>} :: top{} -heap: Int: x, fun, fun
, -env: main: fun
, f: fun, -} ---- step exp Int: a ---> -{ -stack: main{Int<-1> :: Int: a<0> :: var Int: a = 0;<1>(0,) :: var Int: b = 1; ... <-1>} :: top{} -heap: Int: x, fun, fun
, -env: main: fun
, f: fun, -} ---- step exp Int ---> -{ -stack: main{Int<-1> :: Int: a<0> :: var Int: a = 0;<1>(0,) :: var Int: b = 1; ... <-1>} :: top{} -heap: Int: x, fun, fun
, -env: main: fun
, f: fun, -} ---- handle value Int with Int: a<1>(Int,) ---> -{ -stack: main{Int: a<-1> :: var Int: a = 0;<1>(0,) :: var Int: b = 1; ... <-1>} :: top{} -heap: Int: x, fun, fun
, -env: main: fun
, f: fun, -} ---- handle value Int: a with var Int: a = 0;<2>(0,Int: a,) ---> -pattern_match(Int: a, 0) -{ -stack: main{var Int: b = 1; ... <-1>} :: top{} -heap: Int: x, fun, fun
, 0, -env: a: 0, main: fun
, f: fun, -} ---- step stmt var Int: b = 1; ... ---> -{ -stack: main{var Int: b = 1;<-1> :: f(0 = a); ... <-1>} :: top{} -heap: Int: x, fun, fun
, 0, -env: a: 0, main: fun
, f: fun, -} ---- step stmt var Int: b = 1; ---> -{ -stack: main{1<-1> :: var Int: b = 1;<0> :: f(0 = a); ... <-1>} :: top{} -heap: Int: x, fun, fun
, 0, -env: a: 0, main: fun
, f: fun, -} ---- step exp 1 ---> -{ -stack: main{1<-1> :: var Int: b = 1;<0> :: f(0 = a); ... <-1>} :: top{} -heap: Int: x, fun, fun
, 0, -env: a: 0, main: fun
, f: fun, -} ---- handle value 1 with var Int: b = 1;<1>(1,) ---> -{ -stack: main{Int: b<-1> :: var Int: b = 1;<1>(1,) :: f(0 = a); ... <-1>} :: top{} -heap: Int: x, fun, fun
, 0, -env: a: 0, main: fun
, f: fun, -} ---- step exp Int: b ---> -{ -stack: main{Int<-1> :: Int: b<0> :: var Int: b = 1;<1>(1,) :: f(0 = a); ... <-1>} :: top{} -heap: Int: x, fun, fun
, 0, -env: a: 0, main: fun
, f: fun, -} ---- step exp Int ---> -{ -stack: main{Int<-1> :: Int: b<0> :: var Int: b = 1;<1>(1,) :: f(0 = a); ... <-1>} :: top{} -heap: Int: x, fun, fun
, 0, -env: a: 0, main: fun
, f: fun, -} ---- handle value Int with Int: b<1>(Int,) ---> -{ -stack: main{Int: b<-1> :: var Int: b = 1;<1>(1,) :: f(0 = a); ... <-1>} :: top{} -heap: Int: x, fun, fun
, 0, -env: a: 0, main: fun
, f: fun, -} ---- handle value Int: b with var Int: b = 1;<2>(1,Int: b,) ---> -pattern_match(Int: b, 1) -{ -stack: main{f(0 = a); ... <-1>} :: top{} -heap: Int: x, fun, fun
, 0, 1, -env: b: 1, a: 0, main: fun
, f: fun, -} ---- step stmt f(0 = a); ... ---> -{ -stack: main{f(0 = a);<-1> :: b = a; ... <-1>} :: top{} -heap: Int: x, fun, fun
, 0, 1, -env: b: 1, a: 0, main: fun
, f: fun, -} ---- step stmt f(0 = a); ---> -{ -stack: main{f(0 = a)<-1> :: f(0 = a);<-1> :: b = a; ... <-1>} :: top{} -heap: Int: x, fun, fun
, 0, 1, -env: b: 1, a: 0, main: fun
, f: fun, -} ---- step exp f(0 = a) ---> -{ -stack: main{f<-1> :: f(0 = a)<0> :: f(0 = a);<-1> :: b = a; ... <-1>} :: top{} -heap: Int: x, fun, fun
, 0, 1, -env: b: 1, a: 0, main: fun
, f: fun, -} ---- step exp f ---> -{ -stack: main{fun<-1> :: f(0 = a)<0> :: f(0 = a);<-1> :: b = a; ... <-1>} :: top{} -heap: Int: x, fun, fun
, 0, 1, -env: b: 1, a: 0, main: fun
, f: fun, -} ---- handle value fun with f(0 = a)<1>(fun,) ---> -{ -stack: main{(0 = a)<-1> :: f(0 = a)<1>(fun,) :: f(0 = a);<-1> :: b = a; ... <-1>} :: top{} -heap: Int: x, fun, fun
, 0, 1, -env: b: 1, a: 0, main: fun
, f: fun, -} ---- step exp (0 = a) ---> -{ -stack: main{a<-1> :: (0 = a)<0> :: f(0 = a)<1>(fun,) :: f(0 = a);<-1> :: b = a; ... <-1>} :: top{} -heap: Int: x, fun, fun
, 0, 1, -env: b: 1, a: 0, main: fun
, f: fun, -} ---- step exp a ---> -{ -stack: main{0<-1> :: (0 = a)<0> :: f(0 = a)<1>(fun,) :: f(0 = a);<-1> :: b = a; ... <-1>} :: top{} -heap: Int: x, fun, fun
, 0, 1, -env: b: 1, a: 0, main: fun
, f: fun, -} ---- handle value 0 with (0 = a)<1>(0,) ---> -{ -stack: main{(0 = 0@5)<-1> :: f(0 = a)<1>(fun,) :: f(0 = a);<-1> :: b = a; ... <-1>} :: top{} -heap: Int: x, fun, fun
, 0, 1, 0, -env: b: 1, a: 0, main: fun
, f: fun, -} ---- handle value (0 = 0@5) with f(0 = a)<2>(fun,(0 = 0@5),) ---> -pattern_match((0 = Int: x@0), (0 = 0@5)) -pattern_match(Int: x, 0) -{ -stack: f{return 0;<-1>} :: main{f(0 = a);<-1> :: b = a; ... <-1>} :: top{} -heap: Int: x, fun, fun
, 0, 1, 0, 0, -env: x: 0, main: fun
, f: fun, -} ---- step stmt return 0; ---> -{ -stack: f{0<-1> :: return 0;<0>} :: main{f(0 = a);<-1> :: b = a; ... <-1>} :: top{} -heap: Int: x, fun, fun
, 0, 1, 0, 0, -env: x: 0, main: fun
, f: fun, -} ---- step exp 0 ---> -{ -stack: f{0<-1> :: return 0;<0>} :: main{f(0 = a);<-1> :: b = a; ... <-1>} :: top{} -heap: Int: x, fun, fun
, 0, 1, 0, 0, -env: x: 0, main: fun
, f: fun, -} ---- handle value 0 with return 0;<1>(0,) ---> -{ -stack: main{0<-1> :: f(0 = a);<-1> :: b = a; ... <-1>} :: top{} -heap: Int: x, fun, fun
, 0, 1, 0, !!0, -env: b: 1, a: 0, main: fun
, f: fun, -} ---- handle value 0 with f(0 = a);<0>(0,) ---> -{ -stack: main{b = a; ... <-1>} :: top{} -heap: Int: x, fun, fun
, 0, 1, 0, !!0, -env: b: 1, a: 0, main: fun
, f: fun, -} ---- step stmt b = a; ... ---> -{ -stack: main{b = a;<-1> :: return b;<-1>} :: top{} -heap: Int: x, fun, fun
, 0, 1, 0, !!0, -env: b: 1, a: 0, main: fun
, f: fun, -} ---- step stmt b = a; ---> -{ -stack: main{b<-1> :: b = a;<0> :: return b;<-1>} :: top{} -heap: Int: x, fun, fun
, 0, 1, 0, !!0, -env: b: 1, a: 0, main: fun
, f: fun, -} ---- step lvalue b ---> -{ -stack: main{ptr<4><-1> :: b = a;<0> :: return b;<-1>} :: top{} -heap: Int: x, fun, fun
, 0, 1, 0, !!0, -env: b: 1, a: 0, main: fun
, f: fun, -} ---- handle value ptr<4> with b = a;<1>(ptr<4>,) ---> -{ -stack: main{a<-1> :: b = a;<1>(ptr<4>,) :: return b;<-1>} :: top{} -heap: Int: x, fun, fun
, 0, 1, 0, !!0, -env: b: 1, a: 0, main: fun
, f: fun, -} ---- step exp a ---> -{ -stack: main{0<-1> :: b = a;<1>(ptr<4>,) :: return b;<-1>} :: top{} -heap: Int: x, fun, fun
, 0, 1, 0, !!0, -env: b: 1, a: 0, main: fun
, f: fun, -} ---- handle value 0 with b = a;<2>(ptr<4>,0,) ---> -{ -stack: main{return b;<-1>} :: top{} -heap: Int: x, fun, fun
, 0, 0, 0, !!0, -env: b: 0, a: 0, main: fun
, f: fun, -} ---- step stmt return b; ---> -{ -stack: main{b<-1> :: return b;<0>} :: top{} -heap: Int: x, fun, fun
, 0, 0, 0, !!0, -env: b: 0, a: 0, main: fun
, f: fun, -} ---- step exp b ---> -{ -stack: main{0<-1> :: return b;<0>} :: top{} -heap: Int: x, fun, fun
, 0, 0, 0, !!0, -env: b: 0, a: 0, main: fun
, f: fun, -} ---- handle value 0 with return b;<1>(0,) ---> -{ -stack: top{0<-1>} -heap: Int: x, fun, fun
, !!0, !!0, !!0, !!0, -env: main: fun
, f: fun, -} result: 0 diff --git a/executable_semantics/testdata/fun3.golden b/executable_semantics/testdata/fun3.golden index 579c024f6b34..2db2755da426 100644 --- a/executable_semantics/testdata/fun3.golden +++ b/executable_semantics/testdata/fun3.golden @@ -1,211 +1 @@ -********** source program ********** -fn f (0 = Int: x, 1 = Int: y) -> Int { -return (x + y); - -} -fn main () -> Int { -return (f(0 = 2, 1 = 3) - 5); - -} -********** type checking ********** ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> - -********** type checking complete ********** -fn f (0 = Int: x, 1 = Int: y) -> Int { -return (x + y); -} -fn main () -> Int { -return (f(0 = 2, 1 = 3) - 5); -} -********** starting execution ********** -********** initializing globals ********** ---- step exp (0 = Int: x, 1 = Int: y) ---> ---- step exp Int: x ---> ---- step exp Int ---> ---- handle value Int with Int: x<1>(Int,) ---> ---- handle value Int: x with (0 = Int: x, 1 = Int: y)<1>(Int: x,) ---> ---- step exp Int: y ---> ---- step exp Int ---> ---- handle value Int with Int: y<1>(Int,) ---> ---- handle value Int: y with (0 = Int: x, 1 = Int: y)<2>(Int: x,Int: y,) ---> ---- step exp () ---> -********** calling main function ********** -{ -stack: top{main()<-1>} -heap: Int: x, Int: y, fun, fun
, -env: main: fun
, f: fun, -} ---- step exp main() ---> -{ -stack: top{main<-1> :: main()<0>} -heap: Int: x, Int: y, fun, fun
, -env: main: fun
, f: fun, -} ---- step exp main ---> -{ -stack: top{fun
<-1> :: main()<0>} -heap: Int: x, Int: y, fun, fun
, -env: main: fun
, f: fun, -} ---- handle value fun
with main()<1>(fun
,) ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: Int: x, Int: y, fun, fun
, -env: main: fun
, f: fun, -} ---- step exp () ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: Int: x, Int: y, fun, fun
, -env: main: fun
, f: fun, -} ---- handle value () with main()<2>(fun
,(),) ---> -pattern_match((), ()) -{ -stack: main{return (f(0 = 2, 1 = 3) - 5);<-1>} :: top{} -heap: Int: x, Int: y, fun, fun
, -env: main: fun
, f: fun, -} ---- step stmt return (f(0 = 2, 1 = 3) - 5); ---> -{ -stack: main{(f(0 = 2, 1 = 3) - 5)<-1> :: return (f(0 = 2, 1 = 3) - 5);<0>} :: top{} -heap: Int: x, Int: y, fun, fun
, -env: main: fun
, f: fun, -} ---- step exp (f(0 = 2, 1 = 3) - 5) ---> -{ -stack: main{f(0 = 2, 1 = 3)<-1> :: (f(0 = 2, 1 = 3) - 5)<0> :: return (f(0 = 2, 1 = 3) - 5);<0>} :: top{} -heap: Int: x, Int: y, fun, fun
, -env: main: fun
, f: fun, -} ---- step exp f(0 = 2, 1 = 3) ---> -{ -stack: main{f<-1> :: f(0 = 2, 1 = 3)<0> :: (f(0 = 2, 1 = 3) - 5)<0> :: return (f(0 = 2, 1 = 3) - 5);<0>} :: top{} -heap: Int: x, Int: y, fun, fun
, -env: main: fun
, f: fun, -} ---- step exp f ---> -{ -stack: main{fun<-1> :: f(0 = 2, 1 = 3)<0> :: (f(0 = 2, 1 = 3) - 5)<0> :: return (f(0 = 2, 1 = 3) - 5);<0>} :: top{} -heap: Int: x, Int: y, fun, fun
, -env: main: fun
, f: fun, -} ---- handle value fun with f(0 = 2, 1 = 3)<1>(fun,) ---> -{ -stack: main{(0 = 2, 1 = 3)<-1> :: f(0 = 2, 1 = 3)<1>(fun,) :: (f(0 = 2, 1 = 3) - 5)<0> :: return (f(0 = 2, 1 = 3) - 5);<0>} :: top{} -heap: Int: x, Int: y, fun, fun
, -env: main: fun
, f: fun, -} ---- step exp (0 = 2, 1 = 3) ---> -{ -stack: main{2<-1> :: (0 = 2, 1 = 3)<0> :: f(0 = 2, 1 = 3)<1>(fun,) :: (f(0 = 2, 1 = 3) - 5)<0> :: return (f(0 = 2, 1 = 3) - 5);<0>} :: top{} -heap: Int: x, Int: y, fun, fun
, -env: main: fun
, f: fun, -} ---- step exp 2 ---> -{ -stack: main{2<-1> :: (0 = 2, 1 = 3)<0> :: f(0 = 2, 1 = 3)<1>(fun,) :: (f(0 = 2, 1 = 3) - 5)<0> :: return (f(0 = 2, 1 = 3) - 5);<0>} :: top{} -heap: Int: x, Int: y, fun, fun
, -env: main: fun
, f: fun, -} ---- handle value 2 with (0 = 2, 1 = 3)<1>(2,) ---> -{ -stack: main{3<-1> :: (0 = 2, 1 = 3)<1>(2,) :: f(0 = 2, 1 = 3)<1>(fun,) :: (f(0 = 2, 1 = 3) - 5)<0> :: return (f(0 = 2, 1 = 3) - 5);<0>} :: top{} -heap: Int: x, Int: y, fun, fun
, -env: main: fun
, f: fun, -} ---- step exp 3 ---> -{ -stack: main{3<-1> :: (0 = 2, 1 = 3)<1>(2,) :: f(0 = 2, 1 = 3)<1>(fun,) :: (f(0 = 2, 1 = 3) - 5)<0> :: return (f(0 = 2, 1 = 3) - 5);<0>} :: top{} -heap: Int: x, Int: y, fun, fun
, -env: main: fun
, f: fun, -} ---- handle value 3 with (0 = 2, 1 = 3)<2>(2,3,) ---> -{ -stack: main{(0 = 2@4, 1 = 3@5)<-1> :: f(0 = 2, 1 = 3)<1>(fun,) :: (f(0 = 2, 1 = 3) - 5)<0> :: return (f(0 = 2, 1 = 3) - 5);<0>} :: top{} -heap: Int: x, Int: y, fun, fun
, 2, 3, -env: main: fun
, f: fun, -} ---- handle value (0 = 2@4, 1 = 3@5) with f(0 = 2, 1 = 3)<2>(fun,(0 = 2@4, 1 = 3@5),) ---> -pattern_match((0 = Int: x@0, 1 = Int: y@1), (0 = 2@4, 1 = 3@5)) -pattern_match(Int: x, 2) -pattern_match(Int: y, 3) -{ -stack: f{return (x + y);<-1>} :: main{(f(0 = 2, 1 = 3) - 5)<0> :: return (f(0 = 2, 1 = 3) - 5);<0>} :: top{} -heap: Int: x, Int: y, fun, fun
, 2, 3, 2, 3, -env: y: 3, x: 2, main: fun
, f: fun, -} ---- step stmt return (x + y); ---> -{ -stack: f{(x + y)<-1> :: return (x + y);<0>} :: main{(f(0 = 2, 1 = 3) - 5)<0> :: return (f(0 = 2, 1 = 3) - 5);<0>} :: top{} -heap: Int: x, Int: y, fun, fun
, 2, 3, 2, 3, -env: y: 3, x: 2, main: fun
, f: fun, -} ---- step exp (x + y) ---> -{ -stack: f{x<-1> :: (x + y)<0> :: return (x + y);<0>} :: main{(f(0 = 2, 1 = 3) - 5)<0> :: return (f(0 = 2, 1 = 3) - 5);<0>} :: top{} -heap: Int: x, Int: y, fun, fun
, 2, 3, 2, 3, -env: y: 3, x: 2, main: fun
, f: fun, -} ---- step exp x ---> -{ -stack: f{2<-1> :: (x + y)<0> :: return (x + y);<0>} :: main{(f(0 = 2, 1 = 3) - 5)<0> :: return (f(0 = 2, 1 = 3) - 5);<0>} :: top{} -heap: Int: x, Int: y, fun, fun
, 2, 3, 2, 3, -env: y: 3, x: 2, main: fun
, f: fun, -} ---- handle value 2 with (x + y)<1>(2,) ---> -{ -stack: f{y<-1> :: (x + y)<1>(2,) :: return (x + y);<0>} :: main{(f(0 = 2, 1 = 3) - 5)<0> :: return (f(0 = 2, 1 = 3) - 5);<0>} :: top{} -heap: Int: x, Int: y, fun, fun
, 2, 3, 2, 3, -env: y: 3, x: 2, main: fun
, f: fun, -} ---- step exp y ---> -{ -stack: f{3<-1> :: (x + y)<1>(2,) :: return (x + y);<0>} :: main{(f(0 = 2, 1 = 3) - 5)<0> :: return (f(0 = 2, 1 = 3) - 5);<0>} :: top{} -heap: Int: x, Int: y, fun, fun
, 2, 3, 2, 3, -env: y: 3, x: 2, main: fun
, f: fun, -} ---- handle value 3 with (x + y)<2>(2,3,) ---> -{ -stack: f{5<-1> :: return (x + y);<0>} :: main{(f(0 = 2, 1 = 3) - 5)<0> :: return (f(0 = 2, 1 = 3) - 5);<0>} :: top{} -heap: Int: x, Int: y, fun, fun
, 2, 3, 2, 3, -env: y: 3, x: 2, main: fun
, f: fun, -} ---- handle value 5 with return (x + y);<1>(5,) ---> -{ -stack: main{5<-1> :: (f(0 = 2, 1 = 3) - 5)<0> :: return (f(0 = 2, 1 = 3) - 5);<0>} :: top{} -heap: Int: x, Int: y, fun, fun
, 2, 3, !!2, !!3, -env: main: fun
, f: fun, -} ---- handle value 5 with (f(0 = 2, 1 = 3) - 5)<1>(5,) ---> -{ -stack: main{5<-1> :: (f(0 = 2, 1 = 3) - 5)<1>(5,) :: return (f(0 = 2, 1 = 3) - 5);<0>} :: top{} -heap: Int: x, Int: y, fun, fun
, 2, 3, !!2, !!3, -env: main: fun
, f: fun, -} ---- step exp 5 ---> -{ -stack: main{5<-1> :: (f(0 = 2, 1 = 3) - 5)<1>(5,) :: return (f(0 = 2, 1 = 3) - 5);<0>} :: top{} -heap: Int: x, Int: y, fun, fun
, 2, 3, !!2, !!3, -env: main: fun
, f: fun, -} ---- handle value 5 with (f(0 = 2, 1 = 3) - 5)<2>(5,5,) ---> -{ -stack: main{0<-1> :: return (f(0 = 2, 1 = 3) - 5);<0>} :: top{} -heap: Int: x, Int: y, fun, fun
, 2, 3, !!2, !!3, -env: main: fun
, f: fun, -} ---- handle value 0 with return (f(0 = 2, 1 = 3) - 5);<1>(0,) ---> -{ -stack: top{0<-1>} -heap: Int: x, Int: y, fun, fun
, 2, 3, !!2, !!3, -env: main: fun
, f: fun, -} result: 0 diff --git a/executable_semantics/testdata/fun4.golden b/executable_semantics/testdata/fun4.golden index 78b0823dc6be..2db2755da426 100644 --- a/executable_semantics/testdata/fun4.golden +++ b/executable_semantics/testdata/fun4.golden @@ -1,148 +1 @@ -********** source program ********** -fn f () -> (); -fn main () -> Int { -f(); -return 0; - -} -********** type checking ********** ---- step exp () ---> ---- step exp Int ---> ---- step exp () ---> ---- step exp Int ---> - -********** type checking complete ********** -fn f () -> () { -return (); -} -fn main () -> Int { -f(); -return 0; -} -********** starting execution ********** -********** initializing globals ********** ---- step exp () ---> ---- step exp () ---> -********** calling main function ********** -{ -stack: top{main()<-1>} -heap: fun, fun
, -env: main: fun
, f: fun, -} ---- step exp main() ---> -{ -stack: top{main<-1> :: main()<0>} -heap: fun, fun
, -env: main: fun
, f: fun, -} ---- step exp main ---> -{ -stack: top{fun
<-1> :: main()<0>} -heap: fun, fun
, -env: main: fun
, f: fun, -} ---- handle value fun
with main()<1>(fun
,) ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: fun, fun
, -env: main: fun
, f: fun, -} ---- step exp () ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: fun, fun
, -env: main: fun
, f: fun, -} ---- handle value () with main()<2>(fun
,(),) ---> -pattern_match((), ()) -{ -stack: main{f(); ... <-1>} :: top{} -heap: fun, fun
, -env: main: fun
, f: fun, -} ---- step stmt f(); ... ---> -{ -stack: main{f();<-1> :: return 0;<-1>} :: top{} -heap: fun, fun
, -env: main: fun
, f: fun, -} ---- step stmt f(); ---> -{ -stack: main{f()<-1> :: f();<-1> :: return 0;<-1>} :: top{} -heap: fun, fun
, -env: main: fun
, f: fun, -} ---- step exp f() ---> -{ -stack: main{f<-1> :: f()<0> :: f();<-1> :: return 0;<-1>} :: top{} -heap: fun, fun
, -env: main: fun
, f: fun, -} ---- step exp f ---> -{ -stack: main{fun<-1> :: f()<0> :: f();<-1> :: return 0;<-1>} :: top{} -heap: fun, fun
, -env: main: fun
, f: fun, -} ---- handle value fun with f()<1>(fun,) ---> -{ -stack: main{()<-1> :: f()<1>(fun,) :: f();<-1> :: return 0;<-1>} :: top{} -heap: fun, fun
, -env: main: fun
, f: fun, -} ---- step exp () ---> -{ -stack: main{()<-1> :: f()<1>(fun,) :: f();<-1> :: return 0;<-1>} :: top{} -heap: fun, fun
, -env: main: fun
, f: fun, -} ---- handle value () with f()<2>(fun,(),) ---> -pattern_match((), ()) -{ -stack: f{return ();<-1>} :: main{f();<-1> :: return 0;<-1>} :: top{} -heap: fun, fun
, -env: main: fun
, f: fun, -} ---- step stmt return (); ---> -{ -stack: f{()<-1> :: return ();<0>} :: main{f();<-1> :: return 0;<-1>} :: top{} -heap: fun, fun
, -env: main: fun
, f: fun, -} ---- step exp () ---> -{ -stack: f{()<-1> :: return ();<0>} :: main{f();<-1> :: return 0;<-1>} :: top{} -heap: fun, fun
, -env: main: fun
, f: fun, -} ---- handle value () with return ();<1>((),) ---> -{ -stack: main{()<-1> :: f();<-1> :: return 0;<-1>} :: top{} -heap: fun, fun
, -env: main: fun
, f: fun, -} ---- handle value () with f();<0>((),) ---> -{ -stack: main{return 0;<-1>} :: top{} -heap: fun, fun
, -env: main: fun
, f: fun, -} ---- step stmt return 0; ---> -{ -stack: main{0<-1> :: return 0;<0>} :: top{} -heap: fun, fun
, -env: main: fun
, f: fun, -} ---- step exp 0 ---> -{ -stack: main{0<-1> :: return 0;<0>} :: top{} -heap: fun, fun
, -env: main: fun
, f: fun, -} ---- handle value 0 with return 0;<1>(0,) ---> -{ -stack: top{0<-1>} -heap: fun, fun
, -env: main: fun
, f: fun, -} result: 0 diff --git a/executable_semantics/testdata/fun5.golden b/executable_semantics/testdata/fun5.golden index 1fb83d77c0e8..2db2755da426 100644 --- a/executable_semantics/testdata/fun5.golden +++ b/executable_semantics/testdata/fun5.golden @@ -1,214 +1 @@ -********** source program ********** -fn add (0 = Int: x, 1 = Int: y) -> auto { -return (x + y); -} -fn main () -> Int { -return (add(0 = 1, 1 = 2) - 3); - -} -********** type checking ********** ---- step exp Int ---> ---- step exp Int ---> ---- step exp auto ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp auto ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp auto ---> ---- step exp Int ---> - -********** type checking complete ********** -fn add (0 = Int: x, 1 = Int: y) -> Int { -return (x + y); -} -fn main () -> Int { -return (add(0 = 1, 1 = 2) - 3); -} -********** starting execution ********** -********** initializing globals ********** ---- step exp (0 = Int: x, 1 = Int: y) ---> ---- step exp Int: x ---> ---- step exp Int ---> ---- handle value Int with Int: x<1>(Int,) ---> ---- handle value Int: x with (0 = Int: x, 1 = Int: y)<1>(Int: x,) ---> ---- step exp Int: y ---> ---- step exp Int ---> ---- handle value Int with Int: y<1>(Int,) ---> ---- handle value Int: y with (0 = Int: x, 1 = Int: y)<2>(Int: x,Int: y,) ---> ---- step exp () ---> -********** calling main function ********** -{ -stack: top{main()<-1>} -heap: Int: x, Int: y, fun, fun
, -env: main: fun
, add: fun, -} ---- step exp main() ---> -{ -stack: top{main<-1> :: main()<0>} -heap: Int: x, Int: y, fun, fun
, -env: main: fun
, add: fun, -} ---- step exp main ---> -{ -stack: top{fun
<-1> :: main()<0>} -heap: Int: x, Int: y, fun, fun
, -env: main: fun
, add: fun, -} ---- handle value fun
with main()<1>(fun
,) ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: Int: x, Int: y, fun, fun
, -env: main: fun
, add: fun, -} ---- step exp () ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: Int: x, Int: y, fun, fun
, -env: main: fun
, add: fun, -} ---- handle value () with main()<2>(fun
,(),) ---> -pattern_match((), ()) -{ -stack: main{return (add(0 = 1, 1 = 2) - 3);<-1>} :: top{} -heap: Int: x, Int: y, fun, fun
, -env: main: fun
, add: fun, -} ---- step stmt return (add(0 = 1, 1 = 2) - 3); ---> -{ -stack: main{(add(0 = 1, 1 = 2) - 3)<-1> :: return (add(0 = 1, 1 = 2) - 3);<0>} :: top{} -heap: Int: x, Int: y, fun, fun
, -env: main: fun
, add: fun, -} ---- step exp (add(0 = 1, 1 = 2) - 3) ---> -{ -stack: main{add(0 = 1, 1 = 2)<-1> :: (add(0 = 1, 1 = 2) - 3)<0> :: return (add(0 = 1, 1 = 2) - 3);<0>} :: top{} -heap: Int: x, Int: y, fun, fun
, -env: main: fun
, add: fun, -} ---- step exp add(0 = 1, 1 = 2) ---> -{ -stack: main{add<-1> :: add(0 = 1, 1 = 2)<0> :: (add(0 = 1, 1 = 2) - 3)<0> :: return (add(0 = 1, 1 = 2) - 3);<0>} :: top{} -heap: Int: x, Int: y, fun, fun
, -env: main: fun
, add: fun, -} ---- step exp add ---> -{ -stack: main{fun<-1> :: add(0 = 1, 1 = 2)<0> :: (add(0 = 1, 1 = 2) - 3)<0> :: return (add(0 = 1, 1 = 2) - 3);<0>} :: top{} -heap: Int: x, Int: y, fun, fun
, -env: main: fun
, add: fun, -} ---- handle value fun with add(0 = 1, 1 = 2)<1>(fun,) ---> -{ -stack: main{(0 = 1, 1 = 2)<-1> :: add(0 = 1, 1 = 2)<1>(fun,) :: (add(0 = 1, 1 = 2) - 3)<0> :: return (add(0 = 1, 1 = 2) - 3);<0>} :: top{} -heap: Int: x, Int: y, fun, fun
, -env: main: fun
, add: fun, -} ---- step exp (0 = 1, 1 = 2) ---> -{ -stack: main{1<-1> :: (0 = 1, 1 = 2)<0> :: add(0 = 1, 1 = 2)<1>(fun,) :: (add(0 = 1, 1 = 2) - 3)<0> :: return (add(0 = 1, 1 = 2) - 3);<0>} :: top{} -heap: Int: x, Int: y, fun, fun
, -env: main: fun
, add: fun, -} ---- step exp 1 ---> -{ -stack: main{1<-1> :: (0 = 1, 1 = 2)<0> :: add(0 = 1, 1 = 2)<1>(fun,) :: (add(0 = 1, 1 = 2) - 3)<0> :: return (add(0 = 1, 1 = 2) - 3);<0>} :: top{} -heap: Int: x, Int: y, fun, fun
, -env: main: fun
, add: fun, -} ---- handle value 1 with (0 = 1, 1 = 2)<1>(1,) ---> -{ -stack: main{2<-1> :: (0 = 1, 1 = 2)<1>(1,) :: add(0 = 1, 1 = 2)<1>(fun,) :: (add(0 = 1, 1 = 2) - 3)<0> :: return (add(0 = 1, 1 = 2) - 3);<0>} :: top{} -heap: Int: x, Int: y, fun, fun
, -env: main: fun
, add: fun, -} ---- step exp 2 ---> -{ -stack: main{2<-1> :: (0 = 1, 1 = 2)<1>(1,) :: add(0 = 1, 1 = 2)<1>(fun,) :: (add(0 = 1, 1 = 2) - 3)<0> :: return (add(0 = 1, 1 = 2) - 3);<0>} :: top{} -heap: Int: x, Int: y, fun, fun
, -env: main: fun
, add: fun, -} ---- handle value 2 with (0 = 1, 1 = 2)<2>(1,2,) ---> -{ -stack: main{(0 = 1@4, 1 = 2@5)<-1> :: add(0 = 1, 1 = 2)<1>(fun,) :: (add(0 = 1, 1 = 2) - 3)<0> :: return (add(0 = 1, 1 = 2) - 3);<0>} :: top{} -heap: Int: x, Int: y, fun, fun
, 1, 2, -env: main: fun
, add: fun, -} ---- handle value (0 = 1@4, 1 = 2@5) with add(0 = 1, 1 = 2)<2>(fun,(0 = 1@4, 1 = 2@5),) ---> -pattern_match((0 = Int: x@0, 1 = Int: y@1), (0 = 1@4, 1 = 2@5)) -pattern_match(Int: x, 1) -pattern_match(Int: y, 2) -{ -stack: add{return (x + y);<-1>} :: main{(add(0 = 1, 1 = 2) - 3)<0> :: return (add(0 = 1, 1 = 2) - 3);<0>} :: top{} -heap: Int: x, Int: y, fun, fun
, 1, 2, 1, 2, -env: y: 2, x: 1, main: fun
, add: fun, -} ---- step stmt return (x + y); ---> -{ -stack: add{(x + y)<-1> :: return (x + y);<0>} :: main{(add(0 = 1, 1 = 2) - 3)<0> :: return (add(0 = 1, 1 = 2) - 3);<0>} :: top{} -heap: Int: x, Int: y, fun, fun
, 1, 2, 1, 2, -env: y: 2, x: 1, main: fun
, add: fun, -} ---- step exp (x + y) ---> -{ -stack: add{x<-1> :: (x + y)<0> :: return (x + y);<0>} :: main{(add(0 = 1, 1 = 2) - 3)<0> :: return (add(0 = 1, 1 = 2) - 3);<0>} :: top{} -heap: Int: x, Int: y, fun, fun
, 1, 2, 1, 2, -env: y: 2, x: 1, main: fun
, add: fun, -} ---- step exp x ---> -{ -stack: add{1<-1> :: (x + y)<0> :: return (x + y);<0>} :: main{(add(0 = 1, 1 = 2) - 3)<0> :: return (add(0 = 1, 1 = 2) - 3);<0>} :: top{} -heap: Int: x, Int: y, fun, fun
, 1, 2, 1, 2, -env: y: 2, x: 1, main: fun
, add: fun, -} ---- handle value 1 with (x + y)<1>(1,) ---> -{ -stack: add{y<-1> :: (x + y)<1>(1,) :: return (x + y);<0>} :: main{(add(0 = 1, 1 = 2) - 3)<0> :: return (add(0 = 1, 1 = 2) - 3);<0>} :: top{} -heap: Int: x, Int: y, fun, fun
, 1, 2, 1, 2, -env: y: 2, x: 1, main: fun
, add: fun, -} ---- step exp y ---> -{ -stack: add{2<-1> :: (x + y)<1>(1,) :: return (x + y);<0>} :: main{(add(0 = 1, 1 = 2) - 3)<0> :: return (add(0 = 1, 1 = 2) - 3);<0>} :: top{} -heap: Int: x, Int: y, fun, fun
, 1, 2, 1, 2, -env: y: 2, x: 1, main: fun
, add: fun, -} ---- handle value 2 with (x + y)<2>(1,2,) ---> -{ -stack: add{3<-1> :: return (x + y);<0>} :: main{(add(0 = 1, 1 = 2) - 3)<0> :: return (add(0 = 1, 1 = 2) - 3);<0>} :: top{} -heap: Int: x, Int: y, fun, fun
, 1, 2, 1, 2, -env: y: 2, x: 1, main: fun
, add: fun, -} ---- handle value 3 with return (x + y);<1>(3,) ---> -{ -stack: main{3<-1> :: (add(0 = 1, 1 = 2) - 3)<0> :: return (add(0 = 1, 1 = 2) - 3);<0>} :: top{} -heap: Int: x, Int: y, fun, fun
, 1, 2, !!1, !!2, -env: main: fun
, add: fun, -} ---- handle value 3 with (add(0 = 1, 1 = 2) - 3)<1>(3,) ---> -{ -stack: main{3<-1> :: (add(0 = 1, 1 = 2) - 3)<1>(3,) :: return (add(0 = 1, 1 = 2) - 3);<0>} :: top{} -heap: Int: x, Int: y, fun, fun
, 1, 2, !!1, !!2, -env: main: fun
, add: fun, -} ---- step exp 3 ---> -{ -stack: main{3<-1> :: (add(0 = 1, 1 = 2) - 3)<1>(3,) :: return (add(0 = 1, 1 = 2) - 3);<0>} :: top{} -heap: Int: x, Int: y, fun, fun
, 1, 2, !!1, !!2, -env: main: fun
, add: fun, -} ---- handle value 3 with (add(0 = 1, 1 = 2) - 3)<2>(3,3,) ---> -{ -stack: main{0<-1> :: return (add(0 = 1, 1 = 2) - 3);<0>} :: top{} -heap: Int: x, Int: y, fun, fun
, 1, 2, !!1, !!2, -env: main: fun
, add: fun, -} ---- handle value 0 with return (add(0 = 1, 1 = 2) - 3);<1>(0,) ---> -{ -stack: top{0<-1>} -heap: Int: x, Int: y, fun, fun
, 1, 2, !!1, !!2, -env: main: fun
, add: fun, -} result: 0 diff --git a/executable_semantics/testdata/fun6_fail_type.golden b/executable_semantics/testdata/fun6_fail_type.golden index 62f598f1b87f..6812bf092fbd 100644 --- a/executable_semantics/testdata/fun6_fail_type.golden +++ b/executable_semantics/testdata/fun6_fail_type.golden @@ -1,27 +1,3 @@ -********** source program ********** -fn f (0 = Int: x, 1 = Int: y) -> Int { -return (x + y); - -} -fn main () -> Int { -var (0 = Int, 1 = Int): xy = (0 = 1, 1 = 2); -return f(0 = xy); - -} -********** type checking ********** ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp (0 = Int, 1 = Int) ---> ---- step exp Int ---> ---- handle value Int with (0 = Int, 1 = Int)<1>(Int,) ---> ---- step exp Int ---> ---- handle value Int with (0 = Int, 1 = Int)<2>(Int,Int,) ---> 10: type error in call expected: Tuple(0 = Int, 1 = Int) actual: Tuple(0 = Tuple(0 = Int, 1 = Int)) diff --git a/executable_semantics/testdata/fun_recur.golden b/executable_semantics/testdata/fun_recur.golden index d305571cd5fa..2db2755da426 100644 --- a/executable_semantics/testdata/fun_recur.golden +++ b/executable_semantics/testdata/fun_recur.golden @@ -1,517 +1 @@ -********** source program ********** -fn f (0 = Int: x) -> Int { -if ((x == 0)) -return x; -else -return f(0 = (x - 1)); - -} -fn main () -> Int { -return f(0 = 2); - -} -********** type checking ********** ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> - -********** type checking complete ********** -fn f (0 = Int: x) -> Int { -if ((x == 0)) -return x; -else -return f(0 = (x - 1)); -} -fn main () -> Int { -return f(0 = 2); -} -********** starting execution ********** -********** initializing globals ********** ---- step exp (0 = Int: x) ---> ---- step exp Int: x ---> ---- step exp Int ---> ---- handle value Int with Int: x<1>(Int,) ---> ---- handle value Int: x with (0 = Int: x)<1>(Int: x,) ---> ---- step exp () ---> -********** calling main function ********** -{ -stack: top{main()<-1>} -heap: Int: x, fun, fun
, -env: main: fun
, f: fun, -} ---- step exp main() ---> -{ -stack: top{main<-1> :: main()<0>} -heap: Int: x, fun, fun
, -env: main: fun
, f: fun, -} ---- step exp main ---> -{ -stack: top{fun
<-1> :: main()<0>} -heap: Int: x, fun, fun
, -env: main: fun
, f: fun, -} ---- handle value fun
with main()<1>(fun
,) ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: Int: x, fun, fun
, -env: main: fun
, f: fun, -} ---- step exp () ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: Int: x, fun, fun
, -env: main: fun
, f: fun, -} ---- handle value () with main()<2>(fun
,(),) ---> -pattern_match((), ()) -{ -stack: main{return f(0 = 2);<-1>} :: top{} -heap: Int: x, fun, fun
, -env: main: fun
, f: fun, -} ---- step stmt return f(0 = 2); ---> -{ -stack: main{f(0 = 2)<-1> :: return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, -env: main: fun
, f: fun, -} ---- step exp f(0 = 2) ---> -{ -stack: main{f<-1> :: f(0 = 2)<0> :: return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, -env: main: fun
, f: fun, -} ---- step exp f ---> -{ -stack: main{fun<-1> :: f(0 = 2)<0> :: return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, -env: main: fun
, f: fun, -} ---- handle value fun with f(0 = 2)<1>(fun,) ---> -{ -stack: main{(0 = 2)<-1> :: f(0 = 2)<1>(fun,) :: return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, -env: main: fun
, f: fun, -} ---- step exp (0 = 2) ---> -{ -stack: main{2<-1> :: (0 = 2)<0> :: f(0 = 2)<1>(fun,) :: return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, -env: main: fun
, f: fun, -} ---- step exp 2 ---> -{ -stack: main{2<-1> :: (0 = 2)<0> :: f(0 = 2)<1>(fun,) :: return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, -env: main: fun
, f: fun, -} ---- handle value 2 with (0 = 2)<1>(2,) ---> -{ -stack: main{(0 = 2@3)<-1> :: f(0 = 2)<1>(fun,) :: return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, -env: main: fun
, f: fun, -} ---- handle value (0 = 2@3) with f(0 = 2)<2>(fun,(0 = 2@3),) ---> -pattern_match((0 = Int: x@0), (0 = 2@3)) -pattern_match(Int: x, 2) -{ -stack: f{if ((x == 0)) - ... -else - ... <-1>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, -env: x: 2, main: fun
, f: fun, -} ---- step stmt if ((x == 0)) - ... -else - ... ---> -{ -stack: f{(x == 0)<-1> :: if ((x == 0)) - ... -else - ... <0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, -env: x: 2, main: fun
, f: fun, -} ---- step exp (x == 0) ---> -{ -stack: f{x<-1> :: (x == 0)<0> :: if ((x == 0)) - ... -else - ... <0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, -env: x: 2, main: fun
, f: fun, -} ---- step exp x ---> -{ -stack: f{2<-1> :: (x == 0)<0> :: if ((x == 0)) - ... -else - ... <0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, -env: x: 2, main: fun
, f: fun, -} ---- handle value 2 with (x == 0)<1>(2,) ---> -{ -stack: f{0<-1> :: (x == 0)<1>(2,) :: if ((x == 0)) - ... -else - ... <0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, -env: x: 2, main: fun
, f: fun, -} ---- step exp 0 ---> -{ -stack: f{0<-1> :: (x == 0)<1>(2,) :: if ((x == 0)) - ... -else - ... <0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, -env: x: 2, main: fun
, f: fun, -} ---- handle value 0 with (x == 0)<2>(2,0,) ---> -{ -stack: f{false<-1> :: if ((x == 0)) - ... -else - ... <0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, -env: x: 2, main: fun
, f: fun, -} ---- handle value false with if ((x == 0)) - ... -else - ... <1>(false,) ---> -{ -stack: f{return f(0 = (x - 1));<-1>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, -env: x: 2, main: fun
, f: fun, -} ---- step stmt return f(0 = (x - 1)); ---> -{ -stack: f{f(0 = (x - 1))<-1> :: return f(0 = (x - 1));<0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, -env: x: 2, main: fun
, f: fun, -} ---- step exp f(0 = (x - 1)) ---> -{ -stack: f{f<-1> :: f(0 = (x - 1))<0> :: return f(0 = (x - 1));<0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, -env: x: 2, main: fun
, f: fun, -} ---- step exp f ---> -{ -stack: f{fun<-1> :: f(0 = (x - 1))<0> :: return f(0 = (x - 1));<0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, -env: x: 2, main: fun
, f: fun, -} ---- handle value fun with f(0 = (x - 1))<1>(fun,) ---> -{ -stack: f{(0 = (x - 1))<-1> :: f(0 = (x - 1))<1>(fun,) :: return f(0 = (x - 1));<0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, -env: x: 2, main: fun
, f: fun, -} ---- step exp (0 = (x - 1)) ---> -{ -stack: f{(x - 1)<-1> :: (0 = (x - 1))<0> :: f(0 = (x - 1))<1>(fun,) :: return f(0 = (x - 1));<0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, -env: x: 2, main: fun
, f: fun, -} ---- step exp (x - 1) ---> -{ -stack: f{x<-1> :: (x - 1)<0> :: (0 = (x - 1))<0> :: f(0 = (x - 1))<1>(fun,) :: return f(0 = (x - 1));<0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, -env: x: 2, main: fun
, f: fun, -} ---- step exp x ---> -{ -stack: f{2<-1> :: (x - 1)<0> :: (0 = (x - 1))<0> :: f(0 = (x - 1))<1>(fun,) :: return f(0 = (x - 1));<0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, -env: x: 2, main: fun
, f: fun, -} ---- handle value 2 with (x - 1)<1>(2,) ---> -{ -stack: f{1<-1> :: (x - 1)<1>(2,) :: (0 = (x - 1))<0> :: f(0 = (x - 1))<1>(fun,) :: return f(0 = (x - 1));<0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, -env: x: 2, main: fun
, f: fun, -} ---- step exp 1 ---> -{ -stack: f{1<-1> :: (x - 1)<1>(2,) :: (0 = (x - 1))<0> :: f(0 = (x - 1))<1>(fun,) :: return f(0 = (x - 1));<0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, -env: x: 2, main: fun
, f: fun, -} ---- handle value 1 with (x - 1)<2>(2,1,) ---> -{ -stack: f{1<-1> :: (0 = (x - 1))<0> :: f(0 = (x - 1))<1>(fun,) :: return f(0 = (x - 1));<0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, -env: x: 2, main: fun
, f: fun, -} ---- handle value 1 with (0 = (x - 1))<1>(1,) ---> -{ -stack: f{(0 = 1@5)<-1> :: f(0 = (x - 1))<1>(fun,) :: return f(0 = (x - 1));<0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, 1, -env: x: 2, main: fun
, f: fun, -} ---- handle value (0 = 1@5) with f(0 = (x - 1))<2>(fun,(0 = 1@5),) ---> -pattern_match((0 = Int: x@0), (0 = 1@5)) -pattern_match(Int: x, 1) -{ -stack: f{if ((x == 0)) - ... -else - ... <-1>} :: f{return f(0 = (x - 1));<0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, 1, 1, -env: x: 1, main: fun
, f: fun, -} ---- step stmt if ((x == 0)) - ... -else - ... ---> -{ -stack: f{(x == 0)<-1> :: if ((x == 0)) - ... -else - ... <0>} :: f{return f(0 = (x - 1));<0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, 1, 1, -env: x: 1, main: fun
, f: fun, -} ---- step exp (x == 0) ---> -{ -stack: f{x<-1> :: (x == 0)<0> :: if ((x == 0)) - ... -else - ... <0>} :: f{return f(0 = (x - 1));<0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, 1, 1, -env: x: 1, main: fun
, f: fun, -} ---- step exp x ---> -{ -stack: f{1<-1> :: (x == 0)<0> :: if ((x == 0)) - ... -else - ... <0>} :: f{return f(0 = (x - 1));<0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, 1, 1, -env: x: 1, main: fun
, f: fun, -} ---- handle value 1 with (x == 0)<1>(1,) ---> -{ -stack: f{0<-1> :: (x == 0)<1>(1,) :: if ((x == 0)) - ... -else - ... <0>} :: f{return f(0 = (x - 1));<0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, 1, 1, -env: x: 1, main: fun
, f: fun, -} ---- step exp 0 ---> -{ -stack: f{0<-1> :: (x == 0)<1>(1,) :: if ((x == 0)) - ... -else - ... <0>} :: f{return f(0 = (x - 1));<0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, 1, 1, -env: x: 1, main: fun
, f: fun, -} ---- handle value 0 with (x == 0)<2>(1,0,) ---> -{ -stack: f{false<-1> :: if ((x == 0)) - ... -else - ... <0>} :: f{return f(0 = (x - 1));<0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, 1, 1, -env: x: 1, main: fun
, f: fun, -} ---- handle value false with if ((x == 0)) - ... -else - ... <1>(false,) ---> -{ -stack: f{return f(0 = (x - 1));<-1>} :: f{return f(0 = (x - 1));<0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, 1, 1, -env: x: 1, main: fun
, f: fun, -} ---- step stmt return f(0 = (x - 1)); ---> -{ -stack: f{f(0 = (x - 1))<-1> :: return f(0 = (x - 1));<0>} :: f{return f(0 = (x - 1));<0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, 1, 1, -env: x: 1, main: fun
, f: fun, -} ---- step exp f(0 = (x - 1)) ---> -{ -stack: f{f<-1> :: f(0 = (x - 1))<0> :: return f(0 = (x - 1));<0>} :: f{return f(0 = (x - 1));<0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, 1, 1, -env: x: 1, main: fun
, f: fun, -} ---- step exp f ---> -{ -stack: f{fun<-1> :: f(0 = (x - 1))<0> :: return f(0 = (x - 1));<0>} :: f{return f(0 = (x - 1));<0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, 1, 1, -env: x: 1, main: fun
, f: fun, -} ---- handle value fun with f(0 = (x - 1))<1>(fun,) ---> -{ -stack: f{(0 = (x - 1))<-1> :: f(0 = (x - 1))<1>(fun,) :: return f(0 = (x - 1));<0>} :: f{return f(0 = (x - 1));<0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, 1, 1, -env: x: 1, main: fun
, f: fun, -} ---- step exp (0 = (x - 1)) ---> -{ -stack: f{(x - 1)<-1> :: (0 = (x - 1))<0> :: f(0 = (x - 1))<1>(fun,) :: return f(0 = (x - 1));<0>} :: f{return f(0 = (x - 1));<0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, 1, 1, -env: x: 1, main: fun
, f: fun, -} ---- step exp (x - 1) ---> -{ -stack: f{x<-1> :: (x - 1)<0> :: (0 = (x - 1))<0> :: f(0 = (x - 1))<1>(fun,) :: return f(0 = (x - 1));<0>} :: f{return f(0 = (x - 1));<0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, 1, 1, -env: x: 1, main: fun
, f: fun, -} ---- step exp x ---> -{ -stack: f{1<-1> :: (x - 1)<0> :: (0 = (x - 1))<0> :: f(0 = (x - 1))<1>(fun,) :: return f(0 = (x - 1));<0>} :: f{return f(0 = (x - 1));<0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, 1, 1, -env: x: 1, main: fun
, f: fun, -} ---- handle value 1 with (x - 1)<1>(1,) ---> -{ -stack: f{1<-1> :: (x - 1)<1>(1,) :: (0 = (x - 1))<0> :: f(0 = (x - 1))<1>(fun,) :: return f(0 = (x - 1));<0>} :: f{return f(0 = (x - 1));<0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, 1, 1, -env: x: 1, main: fun
, f: fun, -} ---- step exp 1 ---> -{ -stack: f{1<-1> :: (x - 1)<1>(1,) :: (0 = (x - 1))<0> :: f(0 = (x - 1))<1>(fun,) :: return f(0 = (x - 1));<0>} :: f{return f(0 = (x - 1));<0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, 1, 1, -env: x: 1, main: fun
, f: fun, -} ---- handle value 1 with (x - 1)<2>(1,1,) ---> -{ -stack: f{0<-1> :: (0 = (x - 1))<0> :: f(0 = (x - 1))<1>(fun,) :: return f(0 = (x - 1));<0>} :: f{return f(0 = (x - 1));<0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, 1, 1, -env: x: 1, main: fun
, f: fun, -} ---- handle value 0 with (0 = (x - 1))<1>(0,) ---> -{ -stack: f{(0 = 0@7)<-1> :: f(0 = (x - 1))<1>(fun,) :: return f(0 = (x - 1));<0>} :: f{return f(0 = (x - 1));<0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, 1, 1, 0, -env: x: 1, main: fun
, f: fun, -} ---- handle value (0 = 0@7) with f(0 = (x - 1))<2>(fun,(0 = 0@7),) ---> -pattern_match((0 = Int: x@0), (0 = 0@7)) -pattern_match(Int: x, 0) -{ -stack: f{if ((x == 0)) - ... -else - ... <-1>} :: f{return f(0 = (x - 1));<0>} :: f{return f(0 = (x - 1));<0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, 1, 1, 0, 0, -env: x: 0, main: fun
, f: fun, -} ---- step stmt if ((x == 0)) - ... -else - ... ---> -{ -stack: f{(x == 0)<-1> :: if ((x == 0)) - ... -else - ... <0>} :: f{return f(0 = (x - 1));<0>} :: f{return f(0 = (x - 1));<0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, 1, 1, 0, 0, -env: x: 0, main: fun
, f: fun, -} ---- step exp (x == 0) ---> -{ -stack: f{x<-1> :: (x == 0)<0> :: if ((x == 0)) - ... -else - ... <0>} :: f{return f(0 = (x - 1));<0>} :: f{return f(0 = (x - 1));<0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, 1, 1, 0, 0, -env: x: 0, main: fun
, f: fun, -} ---- step exp x ---> -{ -stack: f{0<-1> :: (x == 0)<0> :: if ((x == 0)) - ... -else - ... <0>} :: f{return f(0 = (x - 1));<0>} :: f{return f(0 = (x - 1));<0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, 1, 1, 0, 0, -env: x: 0, main: fun
, f: fun, -} ---- handle value 0 with (x == 0)<1>(0,) ---> -{ -stack: f{0<-1> :: (x == 0)<1>(0,) :: if ((x == 0)) - ... -else - ... <0>} :: f{return f(0 = (x - 1));<0>} :: f{return f(0 = (x - 1));<0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, 1, 1, 0, 0, -env: x: 0, main: fun
, f: fun, -} ---- step exp 0 ---> -{ -stack: f{0<-1> :: (x == 0)<1>(0,) :: if ((x == 0)) - ... -else - ... <0>} :: f{return f(0 = (x - 1));<0>} :: f{return f(0 = (x - 1));<0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, 1, 1, 0, 0, -env: x: 0, main: fun
, f: fun, -} ---- handle value 0 with (x == 0)<2>(0,0,) ---> -{ -stack: f{true<-1> :: if ((x == 0)) - ... -else - ... <0>} :: f{return f(0 = (x - 1));<0>} :: f{return f(0 = (x - 1));<0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, 1, 1, 0, 0, -env: x: 0, main: fun
, f: fun, -} ---- handle value true with if ((x == 0)) - ... -else - ... <1>(true,) ---> -{ -stack: f{return x;<-1>} :: f{return f(0 = (x - 1));<0>} :: f{return f(0 = (x - 1));<0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, 1, 1, 0, 0, -env: x: 0, main: fun
, f: fun, -} ---- step stmt return x; ---> -{ -stack: f{x<-1> :: return x;<0>} :: f{return f(0 = (x - 1));<0>} :: f{return f(0 = (x - 1));<0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, 1, 1, 0, 0, -env: x: 0, main: fun
, f: fun, -} ---- step exp x ---> -{ -stack: f{0<-1> :: return x;<0>} :: f{return f(0 = (x - 1));<0>} :: f{return f(0 = (x - 1));<0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, 1, 1, 0, 0, -env: x: 0, main: fun
, f: fun, -} ---- handle value 0 with return x;<1>(0,) ---> -{ -stack: f{0<-1> :: return f(0 = (x - 1));<0>} :: f{return f(0 = (x - 1));<0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, 1, 1, 0, !!0, -env: x: 1, main: fun
, f: fun, -} ---- handle value 0 with return f(0 = (x - 1));<1>(0,) ---> -{ -stack: f{0<-1> :: return f(0 = (x - 1));<0>} :: main{return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, 2, 1, !!1, 0, !!0, -env: x: 2, main: fun
, f: fun, -} ---- handle value 0 with return f(0 = (x - 1));<1>(0,) ---> -{ -stack: main{0<-1> :: return f(0 = 2);<0>} :: top{} -heap: Int: x, fun, fun
, 2, !!2, 1, !!1, 0, !!0, -env: main: fun
, f: fun, -} ---- handle value 0 with return f(0 = 2);<1>(0,) ---> -{ -stack: top{0<-1>} -heap: Int: x, fun, fun
, 2, !!2, 1, !!1, 0, !!0, -env: main: fun
, f: fun, -} result: 0 diff --git a/executable_semantics/testdata/funptr1.golden b/executable_semantics/testdata/funptr1.golden index c5bf12ded2c2..2db2755da426 100644 --- a/executable_semantics/testdata/funptr1.golden +++ b/executable_semantics/testdata/funptr1.golden @@ -1,274 +1 @@ -********** source program ********** -fn add1 (0 = Int: x) -> Int { -return (x + 1); - -} -fn main () -> Int { -var fn (0 = Int) -> Int: f = add1; -return f(0 = (- 1)); - -} -********** type checking ********** ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp fn (0 = Int) -> Int ---> ---- step exp (0 = Int) ---> ---- step exp Int ---> ---- handle value Int with (0 = Int)<1>(Int,) ---> ---- handle value (0 = Int@0) with fn (0 = Int) -> Int<1>((0 = Int@0),) ---> ---- step exp Int ---> ---- handle value Int with fn (0 = Int) -> Int<2>((0 = Int@0),Int,) ---> - -********** type checking complete ********** -fn add1 (0 = Int: x) -> Int { -return (x + 1); -} -fn main () -> Int { -var fn (0 = Int) -> Int: f = add1; -return f(0 = (- 1)); -} -********** starting execution ********** -********** initializing globals ********** ---- step exp (0 = Int: x) ---> ---- step exp Int: x ---> ---- step exp Int ---> ---- handle value Int with Int: x<1>(Int,) ---> ---- handle value Int: x with (0 = Int: x)<1>(Int: x,) ---> ---- step exp () ---> -********** calling main function ********** -{ -stack: top{main()<-1>} -heap: Int: x, fun, fun
, -env: main: fun
, add1: fun, -} ---- step exp main() ---> -{ -stack: top{main<-1> :: main()<0>} -heap: Int: x, fun, fun
, -env: main: fun
, add1: fun, -} ---- step exp main ---> -{ -stack: top{fun
<-1> :: main()<0>} -heap: Int: x, fun, fun
, -env: main: fun
, add1: fun, -} ---- handle value fun
with main()<1>(fun
,) ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: Int: x, fun, fun
, -env: main: fun
, add1: fun, -} ---- step exp () ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: Int: x, fun, fun
, -env: main: fun
, add1: fun, -} ---- handle value () with main()<2>(fun
,(),) ---> -pattern_match((), ()) -{ -stack: main{var fn (0 = Int) -> Int: f = add1; ... <-1>} :: top{} -heap: Int: x, fun, fun
, -env: main: fun
, add1: fun, -} ---- step stmt var fn (0 = Int) -> Int: f = add1; ... ---> -{ -stack: main{var fn (0 = Int) -> Int: f = add1;<-1> :: return f(0 = (- 1));<-1>} :: top{} -heap: Int: x, fun, fun
, -env: main: fun
, add1: fun, -} ---- step stmt var fn (0 = Int) -> Int: f = add1; ---> -{ -stack: main{add1<-1> :: var fn (0 = Int) -> Int: f = add1;<0> :: return f(0 = (- 1));<-1>} :: top{} -heap: Int: x, fun, fun
, -env: main: fun
, add1: fun, -} ---- step exp add1 ---> -{ -stack: main{fun<-1> :: var fn (0 = Int) -> Int: f = add1;<0> :: return f(0 = (- 1));<-1>} :: top{} -heap: Int: x, fun, fun
, -env: main: fun
, add1: fun, -} ---- handle value fun with var fn (0 = Int) -> Int: f = add1;<1>(fun,) ---> -{ -stack: main{fn (0 = Int) -> Int: f<-1> :: var fn (0 = Int) -> Int: f = add1;<1>(fun,) :: return f(0 = (- 1));<-1>} :: top{} -heap: Int: x, fun, fun
, -env: main: fun
, add1: fun, -} ---- step exp fn (0 = Int) -> Int: f ---> -{ -stack: main{fn (0 = Int) -> Int<-1> :: fn (0 = Int) -> Int: f<0> :: var fn (0 = Int) -> Int: f = add1;<1>(fun,) :: return f(0 = (- 1));<-1>} :: top{} -heap: Int: x, fun, fun
, -env: main: fun
, add1: fun, -} ---- step exp fn (0 = Int) -> Int ---> -{ -stack: main{(0 = Int)<-1> :: fn (0 = Int) -> Int<0> :: fn (0 = Int) -> Int: f<0> :: var fn (0 = Int) -> Int: f = add1;<1>(fun,) :: return f(0 = (- 1));<-1>} :: top{} -heap: Int: x, fun, fun
, -env: main: fun
, add1: fun, -} ---- step exp (0 = Int) ---> -{ -stack: main{Int<-1> :: (0 = Int)<0> :: fn (0 = Int) -> Int<0> :: fn (0 = Int) -> Int: f<0> :: var fn (0 = Int) -> Int: f = add1;<1>(fun,) :: return f(0 = (- 1));<-1>} :: top{} -heap: Int: x, fun, fun
, -env: main: fun
, add1: fun, -} ---- step exp Int ---> -{ -stack: main{Int<-1> :: (0 = Int)<0> :: fn (0 = Int) -> Int<0> :: fn (0 = Int) -> Int: f<0> :: var fn (0 = Int) -> Int: f = add1;<1>(fun,) :: return f(0 = (- 1));<-1>} :: top{} -heap: Int: x, fun, fun
, -env: main: fun
, add1: fun, -} ---- handle value Int with (0 = Int)<1>(Int,) ---> -{ -stack: main{(0 = Int@3)<-1> :: fn (0 = Int) -> Int<0> :: fn (0 = Int) -> Int: f<0> :: var fn (0 = Int) -> Int: f = add1;<1>(fun,) :: return f(0 = (- 1));<-1>} :: top{} -heap: Int: x, fun, fun
, Int, -env: main: fun
, add1: fun, -} ---- handle value (0 = Int@3) with fn (0 = Int) -> Int<1>((0 = Int@3),) ---> -{ -stack: main{Int<-1> :: fn (0 = Int) -> Int<1>((0 = Int@3),) :: fn (0 = Int) -> Int: f<0> :: var fn (0 = Int) -> Int: f = add1;<1>(fun,) :: return f(0 = (- 1));<-1>} :: top{} -heap: Int: x, fun, fun
, Int, -env: main: fun
, add1: fun, -} ---- step exp Int ---> -{ -stack: main{Int<-1> :: fn (0 = Int) -> Int<1>((0 = Int@3),) :: fn (0 = Int) -> Int: f<0> :: var fn (0 = Int) -> Int: f = add1;<1>(fun,) :: return f(0 = (- 1));<-1>} :: top{} -heap: Int: x, fun, fun
, Int, -env: main: fun
, add1: fun, -} ---- handle value Int with fn (0 = Int) -> Int<2>((0 = Int@3),Int,) ---> -{ -stack: main{fn (0 = Int@3) -> Int<-1> :: fn (0 = Int) -> Int: f<0> :: var fn (0 = Int) -> Int: f = add1;<1>(fun,) :: return f(0 = (- 1));<-1>} :: top{} -heap: Int: x, fun, fun
, Int, -env: main: fun
, add1: fun, -} ---- handle value fn (0 = Int@3) -> Int with fn (0 = Int) -> Int: f<1>(fn (0 = Int@3) -> Int,) ---> -{ -stack: main{fn (0 = Int@3) -> Int: f<-1> :: var fn (0 = Int) -> Int: f = add1;<1>(fun,) :: return f(0 = (- 1));<-1>} :: top{} -heap: Int: x, fun, fun
, Int, -env: main: fun
, add1: fun, -} ---- handle value fn (0 = Int@3) -> Int: f with var fn (0 = Int) -> Int: f = add1;<2>(fun,fn (0 = Int@3) -> Int: f,) ---> -pattern_match(fn (0 = Int@3) -> Int: f, fun) -{ -stack: main{return f(0 = (- 1));<-1>} :: top{} -heap: Int: x, fun, fun
, Int, fun, -env: f: fun, main: fun
, add1: fun, -} ---- step stmt return f(0 = (- 1)); ---> -{ -stack: main{f(0 = (- 1))<-1> :: return f(0 = (- 1));<0>} :: top{} -heap: Int: x, fun, fun
, Int, fun, -env: f: fun, main: fun
, add1: fun, -} ---- step exp f(0 = (- 1)) ---> -{ -stack: main{f<-1> :: f(0 = (- 1))<0> :: return f(0 = (- 1));<0>} :: top{} -heap: Int: x, fun, fun
, Int, fun, -env: f: fun, main: fun
, add1: fun, -} ---- step exp f ---> -{ -stack: main{fun<-1> :: f(0 = (- 1))<0> :: return f(0 = (- 1));<0>} :: top{} -heap: Int: x, fun, fun
, Int, fun, -env: f: fun, main: fun
, add1: fun, -} ---- handle value fun with f(0 = (- 1))<1>(fun,) ---> -{ -stack: main{(0 = (- 1))<-1> :: f(0 = (- 1))<1>(fun,) :: return f(0 = (- 1));<0>} :: top{} -heap: Int: x, fun, fun
, Int, fun, -env: f: fun, main: fun
, add1: fun, -} ---- step exp (0 = (- 1)) ---> -{ -stack: main{(- 1)<-1> :: (0 = (- 1))<0> :: f(0 = (- 1))<1>(fun,) :: return f(0 = (- 1));<0>} :: top{} -heap: Int: x, fun, fun
, Int, fun, -env: f: fun, main: fun
, add1: fun, -} ---- step exp (- 1) ---> -{ -stack: main{1<-1> :: (- 1)<0> :: (0 = (- 1))<0> :: f(0 = (- 1))<1>(fun,) :: return f(0 = (- 1));<0>} :: top{} -heap: Int: x, fun, fun
, Int, fun, -env: f: fun, main: fun
, add1: fun, -} ---- step exp 1 ---> -{ -stack: main{1<-1> :: (- 1)<0> :: (0 = (- 1))<0> :: f(0 = (- 1))<1>(fun,) :: return f(0 = (- 1));<0>} :: top{} -heap: Int: x, fun, fun
, Int, fun, -env: f: fun, main: fun
, add1: fun, -} ---- handle value 1 with (- 1)<1>(1,) ---> -{ -stack: main{-1<-1> :: (0 = (- 1))<0> :: f(0 = (- 1))<1>(fun,) :: return f(0 = (- 1));<0>} :: top{} -heap: Int: x, fun, fun
, Int, fun, -env: f: fun, main: fun
, add1: fun, -} ---- handle value -1 with (0 = (- 1))<1>(-1,) ---> -{ -stack: main{(0 = -1@5)<-1> :: f(0 = (- 1))<1>(fun,) :: return f(0 = (- 1));<0>} :: top{} -heap: Int: x, fun, fun
, Int, fun, -1, -env: f: fun, main: fun
, add1: fun, -} ---- handle value (0 = -1@5) with f(0 = (- 1))<2>(fun,(0 = -1@5),) ---> -pattern_match((0 = Int: x@0), (0 = -1@5)) -pattern_match(Int: x, -1) -{ -stack: add1{return (x + 1);<-1>} :: main{return f(0 = (- 1));<0>} :: top{} -heap: Int: x, fun, fun
, Int, fun, -1, -1, -env: x: -1, main: fun
, add1: fun, -} ---- step stmt return (x + 1); ---> -{ -stack: add1{(x + 1)<-1> :: return (x + 1);<0>} :: main{return f(0 = (- 1));<0>} :: top{} -heap: Int: x, fun, fun
, Int, fun, -1, -1, -env: x: -1, main: fun
, add1: fun, -} ---- step exp (x + 1) ---> -{ -stack: add1{x<-1> :: (x + 1)<0> :: return (x + 1);<0>} :: main{return f(0 = (- 1));<0>} :: top{} -heap: Int: x, fun, fun
, Int, fun, -1, -1, -env: x: -1, main: fun
, add1: fun, -} ---- step exp x ---> -{ -stack: add1{-1<-1> :: (x + 1)<0> :: return (x + 1);<0>} :: main{return f(0 = (- 1));<0>} :: top{} -heap: Int: x, fun, fun
, Int, fun, -1, -1, -env: x: -1, main: fun
, add1: fun, -} ---- handle value -1 with (x + 1)<1>(-1,) ---> -{ -stack: add1{1<-1> :: (x + 1)<1>(-1,) :: return (x + 1);<0>} :: main{return f(0 = (- 1));<0>} :: top{} -heap: Int: x, fun, fun
, Int, fun, -1, -1, -env: x: -1, main: fun
, add1: fun, -} ---- step exp 1 ---> -{ -stack: add1{1<-1> :: (x + 1)<1>(-1,) :: return (x + 1);<0>} :: main{return f(0 = (- 1));<0>} :: top{} -heap: Int: x, fun, fun
, Int, fun, -1, -1, -env: x: -1, main: fun
, add1: fun, -} ---- handle value 1 with (x + 1)<2>(-1,1,) ---> -{ -stack: add1{0<-1> :: return (x + 1);<0>} :: main{return f(0 = (- 1));<0>} :: top{} -heap: Int: x, fun, fun
, Int, fun, -1, -1, -env: x: -1, main: fun
, add1: fun, -} ---- handle value 0 with return (x + 1);<1>(0,) ---> -{ -stack: main{0<-1> :: return f(0 = (- 1));<0>} :: top{} -heap: Int: x, fun, fun
, Int, fun, -1, !!-1, -env: f: fun, main: fun
, add1: fun, -} ---- handle value 0 with return f(0 = (- 1));<1>(0,) ---> -{ -stack: top{0<-1>} -heap: Int: x, fun, fun
, Int, !!fun, -1, !!-1, -env: main: fun
, add1: fun, -} result: 0 diff --git a/executable_semantics/testdata/global_variable1.golden b/executable_semantics/testdata/global_variable1.golden index e77175c84da3..2db2755da426 100644 --- a/executable_semantics/testdata/global_variable1.golden +++ b/executable_semantics/testdata/global_variable1.golden @@ -1,77 +1 @@ -********** source program ********** -var Int : zero = 0 -fn main () -> Int { -return zero; - -} -********** type checking ********** ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> - -********** type checking complete ********** -var Int : zero = 0 -fn main () -> Int { -return zero; -} -********** starting execution ********** -********** initializing globals ********** ---- step exp 0 ---> ---- step exp () ---> -********** calling main function ********** -{ -stack: top{main()<-1>} -heap: 0, fun
, -env: main: fun
, zero: 0, -} ---- step exp main() ---> -{ -stack: top{main<-1> :: main()<0>} -heap: 0, fun
, -env: main: fun
, zero: 0, -} ---- step exp main ---> -{ -stack: top{fun
<-1> :: main()<0>} -heap: 0, fun
, -env: main: fun
, zero: 0, -} ---- handle value fun
with main()<1>(fun
,) ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: 0, fun
, -env: main: fun
, zero: 0, -} ---- step exp () ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: 0, fun
, -env: main: fun
, zero: 0, -} ---- handle value () with main()<2>(fun
,(),) ---> -pattern_match((), ()) -{ -stack: main{return zero;<-1>} :: top{} -heap: 0, fun
, -env: main: fun
, zero: 0, -} ---- step stmt return zero; ---> -{ -stack: main{zero<-1> :: return zero;<0>} :: top{} -heap: 0, fun
, -env: main: fun
, zero: 0, -} ---- step exp zero ---> -{ -stack: main{0<-1> :: return zero;<0>} :: top{} -heap: 0, fun
, -env: main: fun
, zero: 0, -} ---- handle value 0 with return zero;<1>(0,) ---> -{ -stack: top{0<-1>} -heap: 0, fun
, -env: main: fun
, zero: 0, -} result: 0 diff --git a/executable_semantics/testdata/global_variable2.golden b/executable_semantics/testdata/global_variable2.golden index c6fc1b852d4d..2db2755da426 100644 --- a/executable_semantics/testdata/global_variable2.golden +++ b/executable_semantics/testdata/global_variable2.golden @@ -1,193 +1 @@ -********** source program ********** -var Int : flag = 1 -fn flipFlag () -> () { -flag = 0; - -} -fn main () -> Int { -flipFlag(); -return flag; - -} -********** type checking ********** ---- step exp Int ---> ---- step exp () ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp () ---> ---- step exp Int ---> - -********** type checking complete ********** -var Int : flag = 1 -fn flipFlag () -> () { -flag = 0; -return (); -} -fn main () -> Int { -flipFlag(); -return flag; -} -********** starting execution ********** -********** initializing globals ********** ---- step exp 1 ---> ---- step exp () ---> ---- step exp () ---> -********** calling main function ********** -{ -stack: top{main()<-1>} -heap: 1, fun, fun
, -env: main: fun
, flipFlag: fun, flag: 1, -} ---- step exp main() ---> -{ -stack: top{main<-1> :: main()<0>} -heap: 1, fun, fun
, -env: main: fun
, flipFlag: fun, flag: 1, -} ---- step exp main ---> -{ -stack: top{fun
<-1> :: main()<0>} -heap: 1, fun, fun
, -env: main: fun
, flipFlag: fun, flag: 1, -} ---- handle value fun
with main()<1>(fun
,) ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: 1, fun, fun
, -env: main: fun
, flipFlag: fun, flag: 1, -} ---- step exp () ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: 1, fun, fun
, -env: main: fun
, flipFlag: fun, flag: 1, -} ---- handle value () with main()<2>(fun
,(),) ---> -pattern_match((), ()) -{ -stack: main{flipFlag(); ... <-1>} :: top{} -heap: 1, fun, fun
, -env: main: fun
, flipFlag: fun, flag: 1, -} ---- step stmt flipFlag(); ... ---> -{ -stack: main{flipFlag();<-1> :: return flag;<-1>} :: top{} -heap: 1, fun, fun
, -env: main: fun
, flipFlag: fun, flag: 1, -} ---- step stmt flipFlag(); ---> -{ -stack: main{flipFlag()<-1> :: flipFlag();<-1> :: return flag;<-1>} :: top{} -heap: 1, fun, fun
, -env: main: fun
, flipFlag: fun, flag: 1, -} ---- step exp flipFlag() ---> -{ -stack: main{flipFlag<-1> :: flipFlag()<0> :: flipFlag();<-1> :: return flag;<-1>} :: top{} -heap: 1, fun, fun
, -env: main: fun
, flipFlag: fun, flag: 1, -} ---- step exp flipFlag ---> -{ -stack: main{fun<-1> :: flipFlag()<0> :: flipFlag();<-1> :: return flag;<-1>} :: top{} -heap: 1, fun, fun
, -env: main: fun
, flipFlag: fun, flag: 1, -} ---- handle value fun with flipFlag()<1>(fun,) ---> -{ -stack: main{()<-1> :: flipFlag()<1>(fun,) :: flipFlag();<-1> :: return flag;<-1>} :: top{} -heap: 1, fun, fun
, -env: main: fun
, flipFlag: fun, flag: 1, -} ---- step exp () ---> -{ -stack: main{()<-1> :: flipFlag()<1>(fun,) :: flipFlag();<-1> :: return flag;<-1>} :: top{} -heap: 1, fun, fun
, -env: main: fun
, flipFlag: fun, flag: 1, -} ---- handle value () with flipFlag()<2>(fun,(),) ---> -pattern_match((), ()) -{ -stack: flipFlag{flag = 0; ... <-1>} :: main{flipFlag();<-1> :: return flag;<-1>} :: top{} -heap: 1, fun, fun
, -env: main: fun
, flipFlag: fun, flag: 1, -} ---- step stmt flag = 0; ... ---> -{ -stack: flipFlag{flag = 0;<-1> :: return ();<-1>} :: main{flipFlag();<-1> :: return flag;<-1>} :: top{} -heap: 1, fun, fun
, -env: main: fun
, flipFlag: fun, flag: 1, -} ---- step stmt flag = 0; ---> -{ -stack: flipFlag{flag<-1> :: flag = 0;<0> :: return ();<-1>} :: main{flipFlag();<-1> :: return flag;<-1>} :: top{} -heap: 1, fun, fun
, -env: main: fun
, flipFlag: fun, flag: 1, -} ---- step lvalue flag ---> -{ -stack: flipFlag{ptr<0><-1> :: flag = 0;<0> :: return ();<-1>} :: main{flipFlag();<-1> :: return flag;<-1>} :: top{} -heap: 1, fun, fun
, -env: main: fun
, flipFlag: fun, flag: 1, -} ---- handle value ptr<0> with flag = 0;<1>(ptr<0>,) ---> -{ -stack: flipFlag{0<-1> :: flag = 0;<1>(ptr<0>,) :: return ();<-1>} :: main{flipFlag();<-1> :: return flag;<-1>} :: top{} -heap: 1, fun, fun
, -env: main: fun
, flipFlag: fun, flag: 1, -} ---- step exp 0 ---> -{ -stack: flipFlag{0<-1> :: flag = 0;<1>(ptr<0>,) :: return ();<-1>} :: main{flipFlag();<-1> :: return flag;<-1>} :: top{} -heap: 1, fun, fun
, -env: main: fun
, flipFlag: fun, flag: 1, -} ---- handle value 0 with flag = 0;<2>(ptr<0>,0,) ---> -{ -stack: flipFlag{return ();<-1>} :: main{flipFlag();<-1> :: return flag;<-1>} :: top{} -heap: 0, fun, fun
, -env: main: fun
, flipFlag: fun, flag: 0, -} ---- step stmt return (); ---> -{ -stack: flipFlag{()<-1> :: return ();<0>} :: main{flipFlag();<-1> :: return flag;<-1>} :: top{} -heap: 0, fun, fun
, -env: main: fun
, flipFlag: fun, flag: 0, -} ---- step exp () ---> -{ -stack: flipFlag{()<-1> :: return ();<0>} :: main{flipFlag();<-1> :: return flag;<-1>} :: top{} -heap: 0, fun, fun
, -env: main: fun
, flipFlag: fun, flag: 0, -} ---- handle value () with return ();<1>((),) ---> -{ -stack: main{()<-1> :: flipFlag();<-1> :: return flag;<-1>} :: top{} -heap: 0, fun, fun
, -env: main: fun
, flipFlag: fun, flag: 0, -} ---- handle value () with flipFlag();<0>((),) ---> -{ -stack: main{return flag;<-1>} :: top{} -heap: 0, fun, fun
, -env: main: fun
, flipFlag: fun, flag: 0, -} ---- step stmt return flag; ---> -{ -stack: main{flag<-1> :: return flag;<0>} :: top{} -heap: 0, fun, fun
, -env: main: fun
, flipFlag: fun, flag: 0, -} ---- step exp flag ---> -{ -stack: main{0<-1> :: return flag;<0>} :: top{} -heap: 0, fun, fun
, -env: main: fun
, flipFlag: fun, flag: 0, -} ---- handle value 0 with return flag;<1>(0,) ---> -{ -stack: top{0<-1>} -heap: 0, fun, fun
, -env: main: fun
, flipFlag: fun, flag: 0, -} result: 0 diff --git a/executable_semantics/testdata/global_variable3.golden b/executable_semantics/testdata/global_variable3.golden index 0ed7876bd96d..ad7d101f148b 100644 --- a/executable_semantics/testdata/global_variable3.golden +++ b/executable_semantics/testdata/global_variable3.golden @@ -1,13 +1,3 @@ -********** source program ********** -var Int : flag = true -fn main () -> Int { -return 0; - -} -********** type checking ********** ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> 7: type error in initializer of variable expected: Int actual: Bool diff --git a/executable_semantics/testdata/global_variable4.golden b/executable_semantics/testdata/global_variable4.golden index ddb21b120b88..2db2755da426 100644 --- a/executable_semantics/testdata/global_variable4.golden +++ b/executable_semantics/testdata/global_variable4.golden @@ -1,115 +1 @@ -********** source program ********** -var Int : zero = 1 -fn main () -> Int { -zero = 0; -return zero; - -} -********** type checking ********** ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> - -********** type checking complete ********** -var Int : zero = 1 -fn main () -> Int { -zero = 0; -return zero; -} -********** starting execution ********** -********** initializing globals ********** ---- step exp 1 ---> ---- step exp () ---> -********** calling main function ********** -{ -stack: top{main()<-1>} -heap: 1, fun
, -env: main: fun
, zero: 1, -} ---- step exp main() ---> -{ -stack: top{main<-1> :: main()<0>} -heap: 1, fun
, -env: main: fun
, zero: 1, -} ---- step exp main ---> -{ -stack: top{fun
<-1> :: main()<0>} -heap: 1, fun
, -env: main: fun
, zero: 1, -} ---- handle value fun
with main()<1>(fun
,) ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: 1, fun
, -env: main: fun
, zero: 1, -} ---- step exp () ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: 1, fun
, -env: main: fun
, zero: 1, -} ---- handle value () with main()<2>(fun
,(),) ---> -pattern_match((), ()) -{ -stack: main{zero = 0; ... <-1>} :: top{} -heap: 1, fun
, -env: main: fun
, zero: 1, -} ---- step stmt zero = 0; ... ---> -{ -stack: main{zero = 0;<-1> :: return zero;<-1>} :: top{} -heap: 1, fun
, -env: main: fun
, zero: 1, -} ---- step stmt zero = 0; ---> -{ -stack: main{zero<-1> :: zero = 0;<0> :: return zero;<-1>} :: top{} -heap: 1, fun
, -env: main: fun
, zero: 1, -} ---- step lvalue zero ---> -{ -stack: main{ptr<0><-1> :: zero = 0;<0> :: return zero;<-1>} :: top{} -heap: 1, fun
, -env: main: fun
, zero: 1, -} ---- handle value ptr<0> with zero = 0;<1>(ptr<0>,) ---> -{ -stack: main{0<-1> :: zero = 0;<1>(ptr<0>,) :: return zero;<-1>} :: top{} -heap: 1, fun
, -env: main: fun
, zero: 1, -} ---- step exp 0 ---> -{ -stack: main{0<-1> :: zero = 0;<1>(ptr<0>,) :: return zero;<-1>} :: top{} -heap: 1, fun
, -env: main: fun
, zero: 1, -} ---- handle value 0 with zero = 0;<2>(ptr<0>,0,) ---> -{ -stack: main{return zero;<-1>} :: top{} -heap: 0, fun
, -env: main: fun
, zero: 0, -} ---- step stmt return zero; ---> -{ -stack: main{zero<-1> :: return zero;<0>} :: top{} -heap: 0, fun
, -env: main: fun
, zero: 0, -} ---- step exp zero ---> -{ -stack: main{0<-1> :: return zero;<0>} :: top{} -heap: 0, fun
, -env: main: fun
, zero: 0, -} ---- handle value 0 with return zero;<1>(0,) ---> -{ -stack: top{0<-1>} -heap: 0, fun
, -env: main: fun
, zero: 0, -} result: 0 diff --git a/executable_semantics/testdata/global_variable5.golden b/executable_semantics/testdata/global_variable5.golden index 51ba8a2193ab..e90cb516a289 100644 --- a/executable_semantics/testdata/global_variable5.golden +++ b/executable_semantics/testdata/global_variable5.golden @@ -1,21 +1,3 @@ -********** source program ********** -var Int : x = 1 -fn identity (0 = Int: x) -> () { -return x; - -} -fn main () -> Int { -return identity(0 = 0); - -} -********** type checking ********** ---- step exp Int ---> ---- step exp Int ---> ---- step exp () ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp () ---> 10: type error in return expected: Tuple() actual: Int diff --git a/executable_semantics/testdata/global_variable6.golden b/executable_semantics/testdata/global_variable6.golden index a637eb1b4d38..2db2755da426 100644 --- a/executable_semantics/testdata/global_variable6.golden +++ b/executable_semantics/testdata/global_variable6.golden @@ -1,82 +1 @@ -********** source program ********** -var Int : x = 0 -var Int : y = x -fn main () -> Int { -return y; - -} -********** type checking ********** ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> - -********** type checking complete ********** -var Int : x = 0 -var Int : y = x -fn main () -> Int { -return y; -} -********** starting execution ********** -********** initializing globals ********** ---- step exp 0 ---> ---- step exp x ---> ---- step exp () ---> -********** calling main function ********** -{ -stack: top{main()<-1>} -heap: 0, 0, fun
, -env: main: fun
, y: 0, x: 0, -} ---- step exp main() ---> -{ -stack: top{main<-1> :: main()<0>} -heap: 0, 0, fun
, -env: main: fun
, y: 0, x: 0, -} ---- step exp main ---> -{ -stack: top{fun
<-1> :: main()<0>} -heap: 0, 0, fun
, -env: main: fun
, y: 0, x: 0, -} ---- handle value fun
with main()<1>(fun
,) ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: 0, 0, fun
, -env: main: fun
, y: 0, x: 0, -} ---- step exp () ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: 0, 0, fun
, -env: main: fun
, y: 0, x: 0, -} ---- handle value () with main()<2>(fun
,(),) ---> -pattern_match((), ()) -{ -stack: main{return y;<-1>} :: top{} -heap: 0, 0, fun
, -env: main: fun
, y: 0, x: 0, -} ---- step stmt return y; ---> -{ -stack: main{y<-1> :: return y;<0>} :: top{} -heap: 0, 0, fun
, -env: main: fun
, y: 0, x: 0, -} ---- step exp y ---> -{ -stack: main{0<-1> :: return y;<0>} :: top{} -heap: 0, 0, fun
, -env: main: fun
, y: 0, x: 0, -} ---- handle value 0 with return y;<1>(0,) ---> -{ -stack: top{0<-1>} -heap: 0, 0, fun
, -env: main: fun
, y: 0, x: 0, -} result: 0 diff --git a/executable_semantics/testdata/global_variable7.golden b/executable_semantics/testdata/global_variable7.golden index 74666387b11b..2db2755da426 100644 --- a/executable_semantics/testdata/global_variable7.golden +++ b/executable_semantics/testdata/global_variable7.golden @@ -1,95 +1 @@ -********** source program ********** -fn f () -> Int { -return 0; - -} -var Int : y = f() -fn main () -> Int { -return y; - -} -********** type checking ********** ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> - -********** type checking complete ********** -fn f () -> Int { -return 0; -} -var Int : y = f() -fn main () -> Int { -return y; -} -********** starting execution ********** -********** initializing globals ********** ---- step exp () ---> ---- step exp f() ---> ---- step exp f ---> ---- handle value fun with f()<1>(fun,) ---> ---- step exp () ---> ---- handle value () with f()<2>(fun,(),) ---> -pattern_match((), ()) ---- step stmt return 0; ---> ---- step exp 0 ---> ---- handle value 0 with return 0;<1>(0,) ---> ---- step exp () ---> -********** calling main function ********** -{ -stack: top{main()<-1>} -heap: fun, 0, fun
, -env: main: fun
, y: 0, f: fun, -} ---- step exp main() ---> -{ -stack: top{main<-1> :: main()<0>} -heap: fun, 0, fun
, -env: main: fun
, y: 0, f: fun, -} ---- step exp main ---> -{ -stack: top{fun
<-1> :: main()<0>} -heap: fun, 0, fun
, -env: main: fun
, y: 0, f: fun, -} ---- handle value fun
with main()<1>(fun
,) ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: fun, 0, fun
, -env: main: fun
, y: 0, f: fun, -} ---- step exp () ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: fun, 0, fun
, -env: main: fun
, y: 0, f: fun, -} ---- handle value () with main()<2>(fun
,(),) ---> -pattern_match((), ()) -{ -stack: main{return y;<-1>} :: top{} -heap: fun, 0, fun
, -env: main: fun
, y: 0, f: fun, -} ---- step stmt return y; ---> -{ -stack: main{y<-1> :: return y;<0>} :: top{} -heap: fun, 0, fun
, -env: main: fun
, y: 0, f: fun, -} ---- step exp y ---> -{ -stack: main{0<-1> :: return y;<0>} :: top{} -heap: fun, 0, fun
, -env: main: fun
, y: 0, f: fun, -} ---- handle value 0 with return y;<1>(0,) ---> -{ -stack: top{0<-1>} -heap: fun, 0, fun
, -env: main: fun
, y: 0, f: fun, -} result: 0 diff --git a/executable_semantics/testdata/global_variable8.golden b/executable_semantics/testdata/global_variable8.golden index 4cfe0efe1027..f7b1ace2d97a 100644 --- a/executable_semantics/testdata/global_variable8.golden +++ b/executable_semantics/testdata/global_variable8.golden @@ -1,26 +1,2 @@ -********** source program ********** -var Int : x = y -var Int : y = 0 -fn main () -> Int { -return x; - -} -********** type checking ********** ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> - -********** type checking complete ********** -var Int : x = y -var Int : y = 0 -fn main () -> Int { -return x; -} -********** starting execution ********** -********** initializing globals ********** ---- step exp y ---> 8: could not find `y` EXIT CODE: 255 diff --git a/executable_semantics/testdata/if1.golden b/executable_semantics/testdata/if1.golden index 334dfcc2c7fe..2db2755da426 100644 --- a/executable_semantics/testdata/if1.golden +++ b/executable_semantics/testdata/if1.golden @@ -1,161 +1 @@ -********** source program ********** -fn main () -> Int { -if ((1 == 1)) -return 0; -else - -return 1; - -} -********** type checking ********** ---- step exp Int ---> ---- step exp Int ---> - -********** type checking complete ********** -fn main () -> Int { -if ((1 == 1)) -return 0; -else - -return 1; -} -********** starting execution ********** -********** initializing globals ********** ---- step exp () ---> -********** calling main function ********** -{ -stack: top{main()<-1>} -heap: fun
, -env: main: fun
, -} ---- step exp main() ---> -{ -stack: top{main<-1> :: main()<0>} -heap: fun
, -env: main: fun
, -} ---- step exp main ---> -{ -stack: top{fun
<-1> :: main()<0>} -heap: fun
, -env: main: fun
, -} ---- handle value fun
with main()<1>(fun
,) ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: fun
, -env: main: fun
, -} ---- step exp () ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: fun
, -env: main: fun
, -} ---- handle value () with main()<2>(fun
,(),) ---> -pattern_match((), ()) -{ -stack: main{if ((1 == 1)) - ... -else - ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step stmt if ((1 == 1)) - ... -else - ... ---> -{ -stack: main{if ((1 == 1)) - ... -else -<-1> :: return 1;<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step stmt if ((1 == 1)) - ... -else - ---> -{ -stack: main{(1 == 1)<-1> :: if ((1 == 1)) - ... -else -<0> :: return 1;<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp (1 == 1) ---> -{ -stack: main{1<-1> :: (1 == 1)<0> :: if ((1 == 1)) - ... -else -<0> :: return 1;<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp 1 ---> -{ -stack: main{1<-1> :: (1 == 1)<0> :: if ((1 == 1)) - ... -else -<0> :: return 1;<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value 1 with (1 == 1)<1>(1,) ---> -{ -stack: main{1<-1> :: (1 == 1)<1>(1,) :: if ((1 == 1)) - ... -else -<0> :: return 1;<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp 1 ---> -{ -stack: main{1<-1> :: (1 == 1)<1>(1,) :: if ((1 == 1)) - ... -else -<0> :: return 1;<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value 1 with (1 == 1)<2>(1,1,) ---> -{ -stack: main{true<-1> :: if ((1 == 1)) - ... -else -<0> :: return 1;<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value true with if ((1 == 1)) - ... -else -<1>(true,) ---> -{ -stack: main{return 0;<-1> :: return 1;<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step stmt return 0; ---> -{ -stack: main{0<-1> :: return 0;<0> :: return 1;<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp 0 ---> -{ -stack: main{0<-1> :: return 0;<0> :: return 1;<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value 0 with return 0;<1>(0,) ---> -{ -stack: top{0<-1>} -heap: fun
, -env: main: fun
, -} result: 0 diff --git a/executable_semantics/testdata/if2.golden b/executable_semantics/testdata/if2.golden index 301eed79accb..2db2755da426 100644 --- a/executable_semantics/testdata/if2.golden +++ b/executable_semantics/testdata/if2.golden @@ -1,161 +1 @@ -********** source program ********** -fn main () -> Int { -if ((0 == 1)) -return 1; -else - -return 0; - -} -********** type checking ********** ---- step exp Int ---> ---- step exp Int ---> - -********** type checking complete ********** -fn main () -> Int { -if ((0 == 1)) -return 1; -else - -return 0; -} -********** starting execution ********** -********** initializing globals ********** ---- step exp () ---> -********** calling main function ********** -{ -stack: top{main()<-1>} -heap: fun
, -env: main: fun
, -} ---- step exp main() ---> -{ -stack: top{main<-1> :: main()<0>} -heap: fun
, -env: main: fun
, -} ---- step exp main ---> -{ -stack: top{fun
<-1> :: main()<0>} -heap: fun
, -env: main: fun
, -} ---- handle value fun
with main()<1>(fun
,) ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: fun
, -env: main: fun
, -} ---- step exp () ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: fun
, -env: main: fun
, -} ---- handle value () with main()<2>(fun
,(),) ---> -pattern_match((), ()) -{ -stack: main{if ((0 == 1)) - ... -else - ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step stmt if ((0 == 1)) - ... -else - ... ---> -{ -stack: main{if ((0 == 1)) - ... -else -<-1> :: return 0;<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step stmt if ((0 == 1)) - ... -else - ---> -{ -stack: main{(0 == 1)<-1> :: if ((0 == 1)) - ... -else -<0> :: return 0;<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp (0 == 1) ---> -{ -stack: main{0<-1> :: (0 == 1)<0> :: if ((0 == 1)) - ... -else -<0> :: return 0;<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp 0 ---> -{ -stack: main{0<-1> :: (0 == 1)<0> :: if ((0 == 1)) - ... -else -<0> :: return 0;<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value 0 with (0 == 1)<1>(0,) ---> -{ -stack: main{1<-1> :: (0 == 1)<1>(0,) :: if ((0 == 1)) - ... -else -<0> :: return 0;<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp 1 ---> -{ -stack: main{1<-1> :: (0 == 1)<1>(0,) :: if ((0 == 1)) - ... -else -<0> :: return 0;<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value 1 with (0 == 1)<2>(0,1,) ---> -{ -stack: main{false<-1> :: if ((0 == 1)) - ... -else -<0> :: return 0;<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value false with if ((0 == 1)) - ... -else -<1>(false,) ---> -{ -stack: main{return 0;<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step stmt return 0; ---> -{ -stack: main{0<-1> :: return 0;<0>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp 0 ---> -{ -stack: main{0<-1> :: return 0;<0>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value 0 with return 0;<1>(0,) ---> -{ -stack: top{0<-1>} -heap: fun
, -env: main: fun
, -} result: 0 diff --git a/executable_semantics/testdata/if3.golden b/executable_semantics/testdata/if3.golden index 3a6d6e68be7b..2db2755da426 100644 --- a/executable_semantics/testdata/if3.golden +++ b/executable_semantics/testdata/if3.golden @@ -1,236 +1 @@ -********** source program ********** -fn main () -> Int { -if ((0 == 0)) -if ((0 == 1)) -return 1; -else -return 0; -else - -return 1; - -} -********** type checking ********** ---- step exp Int ---> ---- step exp Int ---> - -********** type checking complete ********** -fn main () -> Int { -if ((0 == 0)) -if ((0 == 1)) -return 1; -else -return 0; -else - -return 1; -} -********** starting execution ********** -********** initializing globals ********** ---- step exp () ---> -********** calling main function ********** -{ -stack: top{main()<-1>} -heap: fun
, -env: main: fun
, -} ---- step exp main() ---> -{ -stack: top{main<-1> :: main()<0>} -heap: fun
, -env: main: fun
, -} ---- step exp main ---> -{ -stack: top{fun
<-1> :: main()<0>} -heap: fun
, -env: main: fun
, -} ---- handle value fun
with main()<1>(fun
,) ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: fun
, -env: main: fun
, -} ---- step exp () ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: fun
, -env: main: fun
, -} ---- handle value () with main()<2>(fun
,(),) ---> -pattern_match((), ()) -{ -stack: main{if ((0 == 0)) - ... -else - ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step stmt if ((0 == 0)) - ... -else - ... ---> -{ -stack: main{if ((0 == 0)) - ... -else -<-1> :: return 1;<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step stmt if ((0 == 0)) - ... -else - ---> -{ -stack: main{(0 == 0)<-1> :: if ((0 == 0)) - ... -else -<0> :: return 1;<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp (0 == 0) ---> -{ -stack: main{0<-1> :: (0 == 0)<0> :: if ((0 == 0)) - ... -else -<0> :: return 1;<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp 0 ---> -{ -stack: main{0<-1> :: (0 == 0)<0> :: if ((0 == 0)) - ... -else -<0> :: return 1;<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value 0 with (0 == 0)<1>(0,) ---> -{ -stack: main{0<-1> :: (0 == 0)<1>(0,) :: if ((0 == 0)) - ... -else -<0> :: return 1;<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp 0 ---> -{ -stack: main{0<-1> :: (0 == 0)<1>(0,) :: if ((0 == 0)) - ... -else -<0> :: return 1;<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value 0 with (0 == 0)<2>(0,0,) ---> -{ -stack: main{true<-1> :: if ((0 == 0)) - ... -else -<0> :: return 1;<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value true with if ((0 == 0)) - ... -else -<1>(true,) ---> -{ -stack: main{if ((0 == 1)) - ... -else - ... <-1> :: return 1;<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step stmt if ((0 == 1)) - ... -else - ... ---> -{ -stack: main{(0 == 1)<-1> :: if ((0 == 1)) - ... -else - ... <0> :: return 1;<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp (0 == 1) ---> -{ -stack: main{0<-1> :: (0 == 1)<0> :: if ((0 == 1)) - ... -else - ... <0> :: return 1;<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp 0 ---> -{ -stack: main{0<-1> :: (0 == 1)<0> :: if ((0 == 1)) - ... -else - ... <0> :: return 1;<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value 0 with (0 == 1)<1>(0,) ---> -{ -stack: main{1<-1> :: (0 == 1)<1>(0,) :: if ((0 == 1)) - ... -else - ... <0> :: return 1;<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp 1 ---> -{ -stack: main{1<-1> :: (0 == 1)<1>(0,) :: if ((0 == 1)) - ... -else - ... <0> :: return 1;<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value 1 with (0 == 1)<2>(0,1,) ---> -{ -stack: main{false<-1> :: if ((0 == 1)) - ... -else - ... <0> :: return 1;<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value false with if ((0 == 1)) - ... -else - ... <1>(false,) ---> -{ -stack: main{return 0;<-1> :: return 1;<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step stmt return 0; ---> -{ -stack: main{0<-1> :: return 0;<0> :: return 1;<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp 0 ---> -{ -stack: main{0<-1> :: return 0;<0> :: return 1;<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value 0 with return 0;<1>(0,) ---> -{ -stack: top{0<-1>} -heap: fun
, -env: main: fun
, -} result: 0 diff --git a/executable_semantics/testdata/match_int.golden b/executable_semantics/testdata/match_int.golden index c0e330959c2f..2db2755da426 100644 --- a/executable_semantics/testdata/match_int.golden +++ b/executable_semantics/testdata/match_int.golden @@ -1,175 +1 @@ -********** source program ********** -fn main () -> Int { -var auto: t = 5; -match (t) { -case 5 => -return 0; -case auto: _ => -return 1; -} - -} -********** type checking ********** ---- step exp Int ---> ---- step exp Int ---> ---- step exp auto ---> ---- step exp auto ---> - -********** type checking complete ********** -fn main () -> Int { -var auto: t = 5; -match (t) { -case 5 => -return 0; -case auto: _ => -return 1; -} -} -********** starting execution ********** -********** initializing globals ********** ---- step exp () ---> -********** calling main function ********** -{ -stack: top{main()<-1>} -heap: fun
, -env: main: fun
, -} ---- step exp main() ---> -{ -stack: top{main<-1> :: main()<0>} -heap: fun
, -env: main: fun
, -} ---- step exp main ---> -{ -stack: top{fun
<-1> :: main()<0>} -heap: fun
, -env: main: fun
, -} ---- handle value fun
with main()<1>(fun
,) ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: fun
, -env: main: fun
, -} ---- step exp () ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: fun
, -env: main: fun
, -} ---- handle value () with main()<2>(fun
,(),) ---> -pattern_match((), ()) -{ -stack: main{var auto: t = 5; ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step stmt var auto: t = 5; ... ---> -{ -stack: main{var auto: t = 5;<-1> :: match (t) {...}<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step stmt var auto: t = 5; ---> -{ -stack: main{5<-1> :: var auto: t = 5;<0> :: match (t) {...}<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp 5 ---> -{ -stack: main{5<-1> :: var auto: t = 5;<0> :: match (t) {...}<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value 5 with var auto: t = 5;<1>(5,) ---> -{ -stack: main{auto: t<-1> :: var auto: t = 5;<1>(5,) :: match (t) {...}<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp auto: t ---> -{ -stack: main{auto<-1> :: auto: t<0> :: var auto: t = 5;<1>(5,) :: match (t) {...}<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp auto ---> -{ -stack: main{auto<-1> :: auto: t<0> :: var auto: t = 5;<1>(5,) :: match (t) {...}<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value auto with auto: t<1>(auto,) ---> -{ -stack: main{auto: t<-1> :: var auto: t = 5;<1>(5,) :: match (t) {...}<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value auto: t with var auto: t = 5;<2>(5,auto: t,) ---> -pattern_match(auto: t, 5) -{ -stack: main{match (t) {...}<-1>} :: top{} -heap: fun
, 5, -env: t: 5, main: fun
, -} ---- step stmt match (t) {...} ---> -{ -stack: main{t<-1> :: match (t) {...}<0>} :: top{} -heap: fun
, 5, -env: t: 5, main: fun
, -} ---- step exp t ---> -{ -stack: main{5<-1> :: match (t) {...}<0>} :: top{} -heap: fun
, 5, -env: t: 5, main: fun
, -} ---- handle value 5 with match (t) {...}<1>(5,) ---> -{ -stack: main{5<-1> :: match (t) {...}<1>(5,)} :: top{} -heap: fun
, 5, -env: t: 5, main: fun
, -} ---- step exp 5 ---> -{ -stack: main{5<-1> :: match (t) {...}<1>(5,)} :: top{} -heap: fun
, 5, -env: t: 5, main: fun
, -} ---- handle value 5 with match (t) {...}<2>(5,5,) ---> -pattern_match(5, 5) -{ -stack: main{return 0;<-1> :: { - ... -} -<0>} :: top{} -heap: fun
, 5, -env: t: 5, main: fun
, -} ---- step stmt return 0; ---> -{ -stack: main{0<-1> :: return 0;<0> :: { - ... -} -<0>} :: top{} -heap: fun
, 5, -env: t: 5, main: fun
, -} ---- step exp 0 ---> -{ -stack: main{0<-1> :: return 0;<0> :: { - ... -} -<0>} :: top{} -heap: fun
, 5, -env: t: 5, main: fun
, -} ---- handle value 0 with return 0;<1>(0,) ---> -{ -stack: top{0<-1>} -heap: fun
, !!5, -env: main: fun
, -} result: 0 diff --git a/executable_semantics/testdata/match_int_default.golden b/executable_semantics/testdata/match_int_default.golden index f37685493c5d..2db2755da426 100644 --- a/executable_semantics/testdata/match_int_default.golden +++ b/executable_semantics/testdata/match_int_default.golden @@ -1,217 +1 @@ -********** source program ********** -fn main () -> Int { -var auto: t = 5; -match (t) { -case 3 => -return (- 1); -case 4 => -return (- 1); -case auto: _ => -return 0; -} - -} -********** type checking ********** ---- step exp Int ---> ---- step exp Int ---> ---- step exp auto ---> ---- step exp auto ---> - -********** type checking complete ********** -fn main () -> Int { -var auto: t = 5; -match (t) { -case 3 => -return (- 1); -case 4 => -return (- 1); -case auto: _ => -return 0; -} -} -********** starting execution ********** -********** initializing globals ********** ---- step exp () ---> -********** calling main function ********** -{ -stack: top{main()<-1>} -heap: fun
, -env: main: fun
, -} ---- step exp main() ---> -{ -stack: top{main<-1> :: main()<0>} -heap: fun
, -env: main: fun
, -} ---- step exp main ---> -{ -stack: top{fun
<-1> :: main()<0>} -heap: fun
, -env: main: fun
, -} ---- handle value fun
with main()<1>(fun
,) ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: fun
, -env: main: fun
, -} ---- step exp () ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: fun
, -env: main: fun
, -} ---- handle value () with main()<2>(fun
,(),) ---> -pattern_match((), ()) -{ -stack: main{var auto: t = 5; ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step stmt var auto: t = 5; ... ---> -{ -stack: main{var auto: t = 5;<-1> :: match (t) {...}<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step stmt var auto: t = 5; ---> -{ -stack: main{5<-1> :: var auto: t = 5;<0> :: match (t) {...}<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp 5 ---> -{ -stack: main{5<-1> :: var auto: t = 5;<0> :: match (t) {...}<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value 5 with var auto: t = 5;<1>(5,) ---> -{ -stack: main{auto: t<-1> :: var auto: t = 5;<1>(5,) :: match (t) {...}<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp auto: t ---> -{ -stack: main{auto<-1> :: auto: t<0> :: var auto: t = 5;<1>(5,) :: match (t) {...}<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp auto ---> -{ -stack: main{auto<-1> :: auto: t<0> :: var auto: t = 5;<1>(5,) :: match (t) {...}<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value auto with auto: t<1>(auto,) ---> -{ -stack: main{auto: t<-1> :: var auto: t = 5;<1>(5,) :: match (t) {...}<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value auto: t with var auto: t = 5;<2>(5,auto: t,) ---> -pattern_match(auto: t, 5) -{ -stack: main{match (t) {...}<-1>} :: top{} -heap: fun
, 5, -env: t: 5, main: fun
, -} ---- step stmt match (t) {...} ---> -{ -stack: main{t<-1> :: match (t) {...}<0>} :: top{} -heap: fun
, 5, -env: t: 5, main: fun
, -} ---- step exp t ---> -{ -stack: main{5<-1> :: match (t) {...}<0>} :: top{} -heap: fun
, 5, -env: t: 5, main: fun
, -} ---- handle value 5 with match (t) {...}<1>(5,) ---> -{ -stack: main{3<-1> :: match (t) {...}<1>(5,)} :: top{} -heap: fun
, 5, -env: t: 5, main: fun
, -} ---- step exp 3 ---> -{ -stack: main{3<-1> :: match (t) {...}<1>(5,)} :: top{} -heap: fun
, 5, -env: t: 5, main: fun
, -} ---- handle value 3 with match (t) {...}<2>(5,3,) ---> -pattern_match(3, 5) -{ -stack: main{4<-1> :: match (t) {...}<3>(5,3,)} :: top{} -heap: fun
, 5, -env: t: 5, main: fun
, -} ---- step exp 4 ---> -{ -stack: main{4<-1> :: match (t) {...}<3>(5,3,)} :: top{} -heap: fun
, 5, -env: t: 5, main: fun
, -} ---- handle value 4 with match (t) {...}<4>(5,3,4,) ---> -pattern_match(4, 5) -{ -stack: main{auto: _<-1> :: match (t) {...}<5>(5,3,4,)} :: top{} -heap: fun
, 5, -env: t: 5, main: fun
, -} ---- step exp auto: _ ---> -{ -stack: main{auto<-1> :: auto: _<0> :: match (t) {...}<5>(5,3,4,)} :: top{} -heap: fun
, 5, -env: t: 5, main: fun
, -} ---- step exp auto ---> -{ -stack: main{auto<-1> :: auto: _<0> :: match (t) {...}<5>(5,3,4,)} :: top{} -heap: fun
, 5, -env: t: 5, main: fun
, -} ---- handle value auto with auto: _<1>(auto,) ---> -{ -stack: main{auto: _<-1> :: match (t) {...}<5>(5,3,4,)} :: top{} -heap: fun
, 5, -env: t: 5, main: fun
, -} ---- handle value auto: _ with match (t) {...}<6>(5,3,4,auto: _,) ---> -pattern_match(auto: _, 5) -{ -stack: main{return 0;<-1> :: { - ... -} -<0>} :: top{} -heap: fun
, 5, 5, -env: _: 5, t: 5, main: fun
, -} ---- step stmt return 0; ---> -{ -stack: main{0<-1> :: return 0;<0> :: { - ... -} -<0>} :: top{} -heap: fun
, 5, 5, -env: _: 5, t: 5, main: fun
, -} ---- step exp 0 ---> -{ -stack: main{0<-1> :: return 0;<0> :: { - ... -} -<0>} :: top{} -heap: fun
, 5, 5, -env: _: 5, t: 5, main: fun
, -} ---- handle value 0 with return 0;<1>(0,) ---> -{ -stack: top{0<-1>} -heap: fun
, !!5, !!5, -env: main: fun
, -} result: 0 diff --git a/executable_semantics/testdata/match_type.golden b/executable_semantics/testdata/match_type.golden index 4bd82581859b..2db2755da426 100644 --- a/executable_semantics/testdata/match_type.golden +++ b/executable_semantics/testdata/match_type.golden @@ -1,653 +1 @@ -********** source program ********** -fn main () -> Int { -var auto: t = fn (0 = Int, 1 = Int) -> (); -var Int: x = 0; -match (t) { -case fn (0 = Int, 1 = Int) -> (): z => -x = (x + 1); -} -match (t) { -case fn (0 = Type: a, 1 = Type: b) -> () => -x = (x - 1); -} -return x; - -} -********** type checking ********** ---- step exp Int ---> ---- step exp Int ---> ---- step exp (0 = Int, 1 = Int) ---> ---- step exp Int ---> ---- handle value Int with (0 = Int, 1 = Int)<1>(Int,) ---> ---- step exp Int ---> ---- handle value Int with (0 = Int, 1 = Int)<2>(Int,Int,) ---> ---- step exp () ---> ---- step exp auto ---> ---- step exp Int ---> ---- step exp fn (0 = Int, 1 = Int) -> () ---> ---- step exp (0 = Int, 1 = Int) ---> ---- step exp Int ---> ---- handle value Int with (0 = Int, 1 = Int)<1>(Int,) ---> ---- step exp Int ---> ---- handle value Int with (0 = Int, 1 = Int)<2>(Int,Int,) ---> ---- handle value (0 = Int@2, 1 = Int@3) with fn (0 = Int, 1 = Int) -> ()<1>((0 = Int@2, 1 = Int@3),) ---> ---- step exp () ---> ---- handle value () with fn (0 = Int, 1 = Int) -> ()<2>((0 = Int@2, 1 = Int@3),(),) ---> ---- step exp Type ---> ---- step exp Type ---> - -********** type checking complete ********** -fn main () -> Int { -var auto: t = fn (0 = Int, 1 = Int) -> (); -var Int: x = 0; -match (t) { -case fn (0 = Int, 1 = Int) -> (): z => -x = (x + 1); -} -match (t) { -case fn (0 = Type: a, 1 = Type: b) -> () => -x = (x - 1); -} -return x; -} -********** starting execution ********** -********** initializing globals ********** ---- step exp () ---> -********** calling main function ********** -{ -stack: top{main()<-1>} -heap: fun
, -env: main: fun
, -} ---- step exp main() ---> -{ -stack: top{main<-1> :: main()<0>} -heap: fun
, -env: main: fun
, -} ---- step exp main ---> -{ -stack: top{fun
<-1> :: main()<0>} -heap: fun
, -env: main: fun
, -} ---- handle value fun
with main()<1>(fun
,) ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: fun
, -env: main: fun
, -} ---- step exp () ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: fun
, -env: main: fun
, -} ---- handle value () with main()<2>(fun
,(),) ---> -pattern_match((), ()) -{ -stack: main{var auto: t = fn (0 = Int, 1 = Int) -> (); ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step stmt var auto: t = fn (0 = Int, 1 = Int) -> (); ... ---> -{ -stack: main{var auto: t = fn (0 = Int, 1 = Int) -> ();<-1> :: var Int: x = 0; ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step stmt var auto: t = fn (0 = Int, 1 = Int) -> (); ---> -{ -stack: main{fn (0 = Int, 1 = Int) -> ()<-1> :: var auto: t = fn (0 = Int, 1 = Int) -> ();<0> :: var Int: x = 0; ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp fn (0 = Int, 1 = Int) -> () ---> -{ -stack: main{(0 = Int, 1 = Int)<-1> :: fn (0 = Int, 1 = Int) -> ()<0> :: var auto: t = fn (0 = Int, 1 = Int) -> ();<0> :: var Int: x = 0; ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp (0 = Int, 1 = Int) ---> -{ -stack: main{Int<-1> :: (0 = Int, 1 = Int)<0> :: fn (0 = Int, 1 = Int) -> ()<0> :: var auto: t = fn (0 = Int, 1 = Int) -> ();<0> :: var Int: x = 0; ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp Int ---> -{ -stack: main{Int<-1> :: (0 = Int, 1 = Int)<0> :: fn (0 = Int, 1 = Int) -> ()<0> :: var auto: t = fn (0 = Int, 1 = Int) -> ();<0> :: var Int: x = 0; ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value Int with (0 = Int, 1 = Int)<1>(Int,) ---> -{ -stack: main{Int<-1> :: (0 = Int, 1 = Int)<1>(Int,) :: fn (0 = Int, 1 = Int) -> ()<0> :: var auto: t = fn (0 = Int, 1 = Int) -> ();<0> :: var Int: x = 0; ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp Int ---> -{ -stack: main{Int<-1> :: (0 = Int, 1 = Int)<1>(Int,) :: fn (0 = Int, 1 = Int) -> ()<0> :: var auto: t = fn (0 = Int, 1 = Int) -> ();<0> :: var Int: x = 0; ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value Int with (0 = Int, 1 = Int)<2>(Int,Int,) ---> -{ -stack: main{(0 = Int@1, 1 = Int@2)<-1> :: fn (0 = Int, 1 = Int) -> ()<0> :: var auto: t = fn (0 = Int, 1 = Int) -> ();<0> :: var Int: x = 0; ... <-1>} :: top{} -heap: fun
, Int, Int, -env: main: fun
, -} ---- handle value (0 = Int@1, 1 = Int@2) with fn (0 = Int, 1 = Int) -> ()<1>((0 = Int@1, 1 = Int@2),) ---> -{ -stack: main{()<-1> :: fn (0 = Int, 1 = Int) -> ()<1>((0 = Int@1, 1 = Int@2),) :: var auto: t = fn (0 = Int, 1 = Int) -> ();<0> :: var Int: x = 0; ... <-1>} :: top{} -heap: fun
, Int, Int, -env: main: fun
, -} ---- step exp () ---> -{ -stack: main{()<-1> :: fn (0 = Int, 1 = Int) -> ()<1>((0 = Int@1, 1 = Int@2),) :: var auto: t = fn (0 = Int, 1 = Int) -> ();<0> :: var Int: x = 0; ... <-1>} :: top{} -heap: fun
, Int, Int, -env: main: fun
, -} ---- handle value () with fn (0 = Int, 1 = Int) -> ()<2>((0 = Int@1, 1 = Int@2),(),) ---> -{ -stack: main{fn (0 = Int@1, 1 = Int@2) -> ()<-1> :: var auto: t = fn (0 = Int, 1 = Int) -> ();<0> :: var Int: x = 0; ... <-1>} :: top{} -heap: fun
, Int, Int, -env: main: fun
, -} ---- handle value fn (0 = Int@1, 1 = Int@2) -> () with var auto: t = fn (0 = Int, 1 = Int) -> ();<1>(fn (0 = Int@1, 1 = Int@2) -> (),) ---> -{ -stack: main{auto: t<-1> :: var auto: t = fn (0 = Int, 1 = Int) -> ();<1>(fn (0 = Int@1, 1 = Int@2) -> (),) :: var Int: x = 0; ... <-1>} :: top{} -heap: fun
, Int, Int, -env: main: fun
, -} ---- step exp auto: t ---> -{ -stack: main{auto<-1> :: auto: t<0> :: var auto: t = fn (0 = Int, 1 = Int) -> ();<1>(fn (0 = Int@1, 1 = Int@2) -> (),) :: var Int: x = 0; ... <-1>} :: top{} -heap: fun
, Int, Int, -env: main: fun
, -} ---- step exp auto ---> -{ -stack: main{auto<-1> :: auto: t<0> :: var auto: t = fn (0 = Int, 1 = Int) -> ();<1>(fn (0 = Int@1, 1 = Int@2) -> (),) :: var Int: x = 0; ... <-1>} :: top{} -heap: fun
, Int, Int, -env: main: fun
, -} ---- handle value auto with auto: t<1>(auto,) ---> -{ -stack: main{auto: t<-1> :: var auto: t = fn (0 = Int, 1 = Int) -> ();<1>(fn (0 = Int@1, 1 = Int@2) -> (),) :: var Int: x = 0; ... <-1>} :: top{} -heap: fun
, Int, Int, -env: main: fun
, -} ---- handle value auto: t with var auto: t = fn (0 = Int, 1 = Int) -> ();<2>(fn (0 = Int@1, 1 = Int@2) -> (),auto: t,) ---> -pattern_match(auto: t, fn (0 = Int@1, 1 = Int@2) -> ()) -{ -stack: main{var Int: x = 0; ... <-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), -env: t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- step stmt var Int: x = 0; ... ---> -{ -stack: main{var Int: x = 0;<-1> :: match (t) {...} ... <-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), -env: t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- step stmt var Int: x = 0; ---> -{ -stack: main{0<-1> :: var Int: x = 0;<0> :: match (t) {...} ... <-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), -env: t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- step exp 0 ---> -{ -stack: main{0<-1> :: var Int: x = 0;<0> :: match (t) {...} ... <-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), -env: t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- handle value 0 with var Int: x = 0;<1>(0,) ---> -{ -stack: main{Int: x<-1> :: var Int: x = 0;<1>(0,) :: match (t) {...} ... <-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), -env: t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- step exp Int: x ---> -{ -stack: main{Int<-1> :: Int: x<0> :: var Int: x = 0;<1>(0,) :: match (t) {...} ... <-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), -env: t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- step exp Int ---> -{ -stack: main{Int<-1> :: Int: x<0> :: var Int: x = 0;<1>(0,) :: match (t) {...} ... <-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), -env: t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- handle value Int with Int: x<1>(Int,) ---> -{ -stack: main{Int: x<-1> :: var Int: x = 0;<1>(0,) :: match (t) {...} ... <-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), -env: t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- handle value Int: x with var Int: x = 0;<2>(0,Int: x,) ---> -pattern_match(Int: x, 0) -{ -stack: main{match (t) {...} ... <-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 0, -env: x: 0, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- step stmt match (t) {...} ... ---> -{ -stack: main{match (t) {...}<-1> :: match (t) {...} ... <-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 0, -env: x: 0, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- step stmt match (t) {...} ---> -{ -stack: main{t<-1> :: match (t) {...}<0> :: match (t) {...} ... <-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 0, -env: x: 0, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- step exp t ---> -{ -stack: main{fn (0 = Int@3, 1 = Int@4) -> ()<-1> :: match (t) {...}<0> :: match (t) {...} ... <-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 0, -env: x: 0, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- handle value fn (0 = Int@3, 1 = Int@4) -> () with match (t) {...}<1>(fn (0 = Int@3, 1 = Int@4) -> (),) ---> -{ -stack: main{fn (0 = Int, 1 = Int) -> (): z<-1> :: match (t) {...}<1>(fn (0 = Int@3, 1 = Int@4) -> (),) :: match (t) {...} ... <-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 0, -env: x: 0, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- step exp fn (0 = Int, 1 = Int) -> (): z ---> -{ -stack: main{fn (0 = Int, 1 = Int) -> ()<-1> :: fn (0 = Int, 1 = Int) -> (): z<0> :: match (t) {...}<1>(fn (0 = Int@3, 1 = Int@4) -> (),) :: match (t) {...} ... <-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 0, -env: x: 0, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- step exp fn (0 = Int, 1 = Int) -> () ---> -{ -stack: main{(0 = Int, 1 = Int)<-1> :: fn (0 = Int, 1 = Int) -> ()<0> :: fn (0 = Int, 1 = Int) -> (): z<0> :: match (t) {...}<1>(fn (0 = Int@3, 1 = Int@4) -> (),) :: match (t) {...} ... <-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 0, -env: x: 0, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- step exp (0 = Int, 1 = Int) ---> -{ -stack: main{Int<-1> :: (0 = Int, 1 = Int)<0> :: fn (0 = Int, 1 = Int) -> ()<0> :: fn (0 = Int, 1 = Int) -> (): z<0> :: match (t) {...}<1>(fn (0 = Int@3, 1 = Int@4) -> (),) :: match (t) {...} ... <-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 0, -env: x: 0, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- step exp Int ---> -{ -stack: main{Int<-1> :: (0 = Int, 1 = Int)<0> :: fn (0 = Int, 1 = Int) -> ()<0> :: fn (0 = Int, 1 = Int) -> (): z<0> :: match (t) {...}<1>(fn (0 = Int@3, 1 = Int@4) -> (),) :: match (t) {...} ... <-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 0, -env: x: 0, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- handle value Int with (0 = Int, 1 = Int)<1>(Int,) ---> -{ -stack: main{Int<-1> :: (0 = Int, 1 = Int)<1>(Int,) :: fn (0 = Int, 1 = Int) -> ()<0> :: fn (0 = Int, 1 = Int) -> (): z<0> :: match (t) {...}<1>(fn (0 = Int@3, 1 = Int@4) -> (),) :: match (t) {...} ... <-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 0, -env: x: 0, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- step exp Int ---> -{ -stack: main{Int<-1> :: (0 = Int, 1 = Int)<1>(Int,) :: fn (0 = Int, 1 = Int) -> ()<0> :: fn (0 = Int, 1 = Int) -> (): z<0> :: match (t) {...}<1>(fn (0 = Int@3, 1 = Int@4) -> (),) :: match (t) {...} ... <-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 0, -env: x: 0, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- handle value Int with (0 = Int, 1 = Int)<2>(Int,Int,) ---> -{ -stack: main{(0 = Int@7, 1 = Int@8)<-1> :: fn (0 = Int, 1 = Int) -> ()<0> :: fn (0 = Int, 1 = Int) -> (): z<0> :: match (t) {...}<1>(fn (0 = Int@3, 1 = Int@4) -> (),) :: match (t) {...} ... <-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 0, Int, Int, -env: x: 0, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- handle value (0 = Int@7, 1 = Int@8) with fn (0 = Int, 1 = Int) -> ()<1>((0 = Int@7, 1 = Int@8),) ---> -{ -stack: main{()<-1> :: fn (0 = Int, 1 = Int) -> ()<1>((0 = Int@7, 1 = Int@8),) :: fn (0 = Int, 1 = Int) -> (): z<0> :: match (t) {...}<1>(fn (0 = Int@3, 1 = Int@4) -> (),) :: match (t) {...} ... <-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 0, Int, Int, -env: x: 0, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- step exp () ---> -{ -stack: main{()<-1> :: fn (0 = Int, 1 = Int) -> ()<1>((0 = Int@7, 1 = Int@8),) :: fn (0 = Int, 1 = Int) -> (): z<0> :: match (t) {...}<1>(fn (0 = Int@3, 1 = Int@4) -> (),) :: match (t) {...} ... <-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 0, Int, Int, -env: x: 0, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- handle value () with fn (0 = Int, 1 = Int) -> ()<2>((0 = Int@7, 1 = Int@8),(),) ---> -{ -stack: main{fn (0 = Int@7, 1 = Int@8) -> ()<-1> :: fn (0 = Int, 1 = Int) -> (): z<0> :: match (t) {...}<1>(fn (0 = Int@3, 1 = Int@4) -> (),) :: match (t) {...} ... <-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 0, Int, Int, -env: x: 0, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- handle value fn (0 = Int@7, 1 = Int@8) -> () with fn (0 = Int, 1 = Int) -> (): z<1>(fn (0 = Int@7, 1 = Int@8) -> (),) ---> -{ -stack: main{fn (0 = Int@7, 1 = Int@8) -> (): z<-1> :: match (t) {...}<1>(fn (0 = Int@3, 1 = Int@4) -> (),) :: match (t) {...} ... <-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 0, Int, Int, -env: x: 0, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- handle value fn (0 = Int@7, 1 = Int@8) -> (): z with match (t) {...}<2>(fn (0 = Int@3, 1 = Int@4) -> (),fn (0 = Int@7, 1 = Int@8) -> (): z,) ---> -pattern_match(fn (0 = Int@7, 1 = Int@8) -> (): z, fn (0 = Int@3, 1 = Int@4) -> ()) -{ -stack: main{x = (x + 1);<-1> :: { - ... -} -<0> :: match (t) {...} ... <-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 0, Int, Int, Int, Int, fn (0 = Int@9, 1 = Int@10) -> (), -env: z: fn (0 = Int@9, 1 = Int@10) -> (), x: 0, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- step stmt x = (x + 1); ---> -{ -stack: main{x<-1> :: x = (x + 1);<0> :: { - ... -} -<0> :: match (t) {...} ... <-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 0, Int, Int, Int, Int, fn (0 = Int@9, 1 = Int@10) -> (), -env: z: fn (0 = Int@9, 1 = Int@10) -> (), x: 0, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- step lvalue x ---> -{ -stack: main{ptr<6><-1> :: x = (x + 1);<0> :: { - ... -} -<0> :: match (t) {...} ... <-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 0, Int, Int, Int, Int, fn (0 = Int@9, 1 = Int@10) -> (), -env: z: fn (0 = Int@9, 1 = Int@10) -> (), x: 0, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- handle value ptr<6> with x = (x + 1);<1>(ptr<6>,) ---> -{ -stack: main{(x + 1)<-1> :: x = (x + 1);<1>(ptr<6>,) :: { - ... -} -<0> :: match (t) {...} ... <-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 0, Int, Int, Int, Int, fn (0 = Int@9, 1 = Int@10) -> (), -env: z: fn (0 = Int@9, 1 = Int@10) -> (), x: 0, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- step exp (x + 1) ---> -{ -stack: main{x<-1> :: (x + 1)<0> :: x = (x + 1);<1>(ptr<6>,) :: { - ... -} -<0> :: match (t) {...} ... <-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 0, Int, Int, Int, Int, fn (0 = Int@9, 1 = Int@10) -> (), -env: z: fn (0 = Int@9, 1 = Int@10) -> (), x: 0, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- step exp x ---> -{ -stack: main{0<-1> :: (x + 1)<0> :: x = (x + 1);<1>(ptr<6>,) :: { - ... -} -<0> :: match (t) {...} ... <-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 0, Int, Int, Int, Int, fn (0 = Int@9, 1 = Int@10) -> (), -env: z: fn (0 = Int@9, 1 = Int@10) -> (), x: 0, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- handle value 0 with (x + 1)<1>(0,) ---> -{ -stack: main{1<-1> :: (x + 1)<1>(0,) :: x = (x + 1);<1>(ptr<6>,) :: { - ... -} -<0> :: match (t) {...} ... <-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 0, Int, Int, Int, Int, fn (0 = Int@9, 1 = Int@10) -> (), -env: z: fn (0 = Int@9, 1 = Int@10) -> (), x: 0, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- step exp 1 ---> -{ -stack: main{1<-1> :: (x + 1)<1>(0,) :: x = (x + 1);<1>(ptr<6>,) :: { - ... -} -<0> :: match (t) {...} ... <-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 0, Int, Int, Int, Int, fn (0 = Int@9, 1 = Int@10) -> (), -env: z: fn (0 = Int@9, 1 = Int@10) -> (), x: 0, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- handle value 1 with (x + 1)<2>(0,1,) ---> -{ -stack: main{1<-1> :: x = (x + 1);<1>(ptr<6>,) :: { - ... -} -<0> :: match (t) {...} ... <-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 0, Int, Int, Int, Int, fn (0 = Int@9, 1 = Int@10) -> (), -env: z: fn (0 = Int@9, 1 = Int@10) -> (), x: 0, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- handle value 1 with x = (x + 1);<2>(ptr<6>,1,) ---> -{ -stack: main{{ - ... -} -<0> :: match (t) {...} ... <-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 1, Int, Int, Int, Int, fn (0 = Int@9, 1 = Int@10) -> (), -env: z: fn (0 = Int@9, 1 = Int@10) -> (), x: 1, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- step stmt { - ... -} - ---> -{ -stack: main{match (t) {...} ... <-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 1, Int, Int, Int, Int, !!fn (0 = Int@9, 1 = Int@10) -> (), -env: x: 1, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- step stmt match (t) {...} ... ---> -{ -stack: main{match (t) {...}<-1> :: return x;<-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 1, Int, Int, Int, Int, !!fn (0 = Int@9, 1 = Int@10) -> (), -env: x: 1, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- step stmt match (t) {...} ---> -{ -stack: main{t<-1> :: match (t) {...}<0> :: return x;<-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 1, Int, Int, Int, Int, !!fn (0 = Int@9, 1 = Int@10) -> (), -env: x: 1, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- step exp t ---> -{ -stack: main{fn (0 = Int@3, 1 = Int@4) -> ()<-1> :: match (t) {...}<0> :: return x;<-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 1, Int, Int, Int, Int, !!fn (0 = Int@9, 1 = Int@10) -> (), -env: x: 1, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- handle value fn (0 = Int@3, 1 = Int@4) -> () with match (t) {...}<1>(fn (0 = Int@3, 1 = Int@4) -> (),) ---> -{ -stack: main{fn (0 = Type: a, 1 = Type: b) -> ()<-1> :: match (t) {...}<1>(fn (0 = Int@3, 1 = Int@4) -> (),) :: return x;<-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 1, Int, Int, Int, Int, !!fn (0 = Int@9, 1 = Int@10) -> (), -env: x: 1, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- step exp fn (0 = Type: a, 1 = Type: b) -> () ---> -{ -stack: main{(0 = Type: a, 1 = Type: b)<-1> :: fn (0 = Type: a, 1 = Type: b) -> ()<0> :: match (t) {...}<1>(fn (0 = Int@3, 1 = Int@4) -> (),) :: return x;<-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 1, Int, Int, Int, Int, !!fn (0 = Int@9, 1 = Int@10) -> (), -env: x: 1, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- step exp (0 = Type: a, 1 = Type: b) ---> -{ -stack: main{Type: a<-1> :: (0 = Type: a, 1 = Type: b)<0> :: fn (0 = Type: a, 1 = Type: b) -> ()<0> :: match (t) {...}<1>(fn (0 = Int@3, 1 = Int@4) -> (),) :: return x;<-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 1, Int, Int, Int, Int, !!fn (0 = Int@9, 1 = Int@10) -> (), -env: x: 1, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- step exp Type: a ---> -{ -stack: main{Type<-1> :: Type: a<0> :: (0 = Type: a, 1 = Type: b)<0> :: fn (0 = Type: a, 1 = Type: b) -> ()<0> :: match (t) {...}<1>(fn (0 = Int@3, 1 = Int@4) -> (),) :: return x;<-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 1, Int, Int, Int, Int, !!fn (0 = Int@9, 1 = Int@10) -> (), -env: x: 1, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- step exp Type ---> -{ -stack: main{Type<-1> :: Type: a<0> :: (0 = Type: a, 1 = Type: b)<0> :: fn (0 = Type: a, 1 = Type: b) -> ()<0> :: match (t) {...}<1>(fn (0 = Int@3, 1 = Int@4) -> (),) :: return x;<-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 1, Int, Int, Int, Int, !!fn (0 = Int@9, 1 = Int@10) -> (), -env: x: 1, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- handle value Type with Type: a<1>(Type,) ---> -{ -stack: main{Type: a<-1> :: (0 = Type: a, 1 = Type: b)<0> :: fn (0 = Type: a, 1 = Type: b) -> ()<0> :: match (t) {...}<1>(fn (0 = Int@3, 1 = Int@4) -> (),) :: return x;<-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 1, Int, Int, Int, Int, !!fn (0 = Int@9, 1 = Int@10) -> (), -env: x: 1, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- handle value Type: a with (0 = Type: a, 1 = Type: b)<1>(Type: a,) ---> -{ -stack: main{Type: b<-1> :: (0 = Type: a, 1 = Type: b)<1>(Type: a,) :: fn (0 = Type: a, 1 = Type: b) -> ()<0> :: match (t) {...}<1>(fn (0 = Int@3, 1 = Int@4) -> (),) :: return x;<-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 1, Int, Int, Int, Int, !!fn (0 = Int@9, 1 = Int@10) -> (), -env: x: 1, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- step exp Type: b ---> -{ -stack: main{Type<-1> :: Type: b<0> :: (0 = Type: a, 1 = Type: b)<1>(Type: a,) :: fn (0 = Type: a, 1 = Type: b) -> ()<0> :: match (t) {...}<1>(fn (0 = Int@3, 1 = Int@4) -> (),) :: return x;<-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 1, Int, Int, Int, Int, !!fn (0 = Int@9, 1 = Int@10) -> (), -env: x: 1, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- step exp Type ---> -{ -stack: main{Type<-1> :: Type: b<0> :: (0 = Type: a, 1 = Type: b)<1>(Type: a,) :: fn (0 = Type: a, 1 = Type: b) -> ()<0> :: match (t) {...}<1>(fn (0 = Int@3, 1 = Int@4) -> (),) :: return x;<-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 1, Int, Int, Int, Int, !!fn (0 = Int@9, 1 = Int@10) -> (), -env: x: 1, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- handle value Type with Type: b<1>(Type,) ---> -{ -stack: main{Type: b<-1> :: (0 = Type: a, 1 = Type: b)<1>(Type: a,) :: fn (0 = Type: a, 1 = Type: b) -> ()<0> :: match (t) {...}<1>(fn (0 = Int@3, 1 = Int@4) -> (),) :: return x;<-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 1, Int, Int, Int, Int, !!fn (0 = Int@9, 1 = Int@10) -> (), -env: x: 1, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- handle value Type: b with (0 = Type: a, 1 = Type: b)<2>(Type: a,Type: b,) ---> -{ -stack: main{(0 = Type: a@12, 1 = Type: b@13)<-1> :: fn (0 = Type: a, 1 = Type: b) -> ()<0> :: match (t) {...}<1>(fn (0 = Int@3, 1 = Int@4) -> (),) :: return x;<-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 1, Int, Int, Int, Int, !!fn (0 = Int@9, 1 = Int@10) -> (), Type: a, Type: b, -env: x: 1, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- handle value (0 = Type: a@12, 1 = Type: b@13) with fn (0 = Type: a, 1 = Type: b) -> ()<1>((0 = Type: a@12, 1 = Type: b@13),) ---> -{ -stack: main{()<-1> :: fn (0 = Type: a, 1 = Type: b) -> ()<1>((0 = Type: a@12, 1 = Type: b@13),) :: match (t) {...}<1>(fn (0 = Int@3, 1 = Int@4) -> (),) :: return x;<-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 1, Int, Int, Int, Int, !!fn (0 = Int@9, 1 = Int@10) -> (), Type: a, Type: b, -env: x: 1, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- step exp () ---> -{ -stack: main{()<-1> :: fn (0 = Type: a, 1 = Type: b) -> ()<1>((0 = Type: a@12, 1 = Type: b@13),) :: match (t) {...}<1>(fn (0 = Int@3, 1 = Int@4) -> (),) :: return x;<-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 1, Int, Int, Int, Int, !!fn (0 = Int@9, 1 = Int@10) -> (), Type: a, Type: b, -env: x: 1, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- handle value () with fn (0 = Type: a, 1 = Type: b) -> ()<2>((0 = Type: a@12, 1 = Type: b@13),(),) ---> -{ -stack: main{fn (0 = Type: a@12, 1 = Type: b@13) -> ()<-1> :: match (t) {...}<1>(fn (0 = Int@3, 1 = Int@4) -> (),) :: return x;<-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 1, Int, Int, Int, Int, !!fn (0 = Int@9, 1 = Int@10) -> (), Type: a, Type: b, -env: x: 1, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- handle value fn (0 = Type: a@12, 1 = Type: b@13) -> () with match (t) {...}<2>(fn (0 = Int@3, 1 = Int@4) -> (),fn (0 = Type: a@12, 1 = Type: b@13) -> (),) ---> -pattern_match(fn (0 = Type: a@12, 1 = Type: b@13) -> (), fn (0 = Int@3, 1 = Int@4) -> ()) -pattern_match((0 = Type: a@12, 1 = Type: b@13), (0 = Int@3, 1 = Int@4)) -pattern_match(Type: a, Int) -pattern_match(Type: b, Int) -pattern_match((), ()) -{ -stack: main{x = (x - 1);<-1> :: { - ... -} -<0> :: return x;<-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 1, Int, Int, Int, Int, !!fn (0 = Int@9, 1 = Int@10) -> (), Type: a, Type: b, Int, Int, -env: b: Int, a: Int, x: 1, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- step stmt x = (x - 1); ---> -{ -stack: main{x<-1> :: x = (x - 1);<0> :: { - ... -} -<0> :: return x;<-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 1, Int, Int, Int, Int, !!fn (0 = Int@9, 1 = Int@10) -> (), Type: a, Type: b, Int, Int, -env: b: Int, a: Int, x: 1, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- step lvalue x ---> -{ -stack: main{ptr<6><-1> :: x = (x - 1);<0> :: { - ... -} -<0> :: return x;<-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 1, Int, Int, Int, Int, !!fn (0 = Int@9, 1 = Int@10) -> (), Type: a, Type: b, Int, Int, -env: b: Int, a: Int, x: 1, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- handle value ptr<6> with x = (x - 1);<1>(ptr<6>,) ---> -{ -stack: main{(x - 1)<-1> :: x = (x - 1);<1>(ptr<6>,) :: { - ... -} -<0> :: return x;<-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 1, Int, Int, Int, Int, !!fn (0 = Int@9, 1 = Int@10) -> (), Type: a, Type: b, Int, Int, -env: b: Int, a: Int, x: 1, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- step exp (x - 1) ---> -{ -stack: main{x<-1> :: (x - 1)<0> :: x = (x - 1);<1>(ptr<6>,) :: { - ... -} -<0> :: return x;<-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 1, Int, Int, Int, Int, !!fn (0 = Int@9, 1 = Int@10) -> (), Type: a, Type: b, Int, Int, -env: b: Int, a: Int, x: 1, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- step exp x ---> -{ -stack: main{1<-1> :: (x - 1)<0> :: x = (x - 1);<1>(ptr<6>,) :: { - ... -} -<0> :: return x;<-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 1, Int, Int, Int, Int, !!fn (0 = Int@9, 1 = Int@10) -> (), Type: a, Type: b, Int, Int, -env: b: Int, a: Int, x: 1, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- handle value 1 with (x - 1)<1>(1,) ---> -{ -stack: main{1<-1> :: (x - 1)<1>(1,) :: x = (x - 1);<1>(ptr<6>,) :: { - ... -} -<0> :: return x;<-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 1, Int, Int, Int, Int, !!fn (0 = Int@9, 1 = Int@10) -> (), Type: a, Type: b, Int, Int, -env: b: Int, a: Int, x: 1, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- step exp 1 ---> -{ -stack: main{1<-1> :: (x - 1)<1>(1,) :: x = (x - 1);<1>(ptr<6>,) :: { - ... -} -<0> :: return x;<-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 1, Int, Int, Int, Int, !!fn (0 = Int@9, 1 = Int@10) -> (), Type: a, Type: b, Int, Int, -env: b: Int, a: Int, x: 1, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- handle value 1 with (x - 1)<2>(1,1,) ---> -{ -stack: main{0<-1> :: x = (x - 1);<1>(ptr<6>,) :: { - ... -} -<0> :: return x;<-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 1, Int, Int, Int, Int, !!fn (0 = Int@9, 1 = Int@10) -> (), Type: a, Type: b, Int, Int, -env: b: Int, a: Int, x: 1, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- handle value 0 with x = (x - 1);<2>(ptr<6>,0,) ---> -{ -stack: main{{ - ... -} -<0> :: return x;<-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 0, Int, Int, Int, Int, !!fn (0 = Int@9, 1 = Int@10) -> (), Type: a, Type: b, Int, Int, -env: b: Int, a: Int, x: 0, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- step stmt { - ... -} - ---> -{ -stack: main{return x;<-1>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 0, Int, Int, Int, Int, !!fn (0 = Int@9, 1 = Int@10) -> (), Type: a, Type: b, !!Int, !!Int, -env: x: 0, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- step stmt return x; ---> -{ -stack: main{x<-1> :: return x;<0>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 0, Int, Int, Int, Int, !!fn (0 = Int@9, 1 = Int@10) -> (), Type: a, Type: b, !!Int, !!Int, -env: x: 0, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- step exp x ---> -{ -stack: main{0<-1> :: return x;<0>} :: top{} -heap: fun
, Int, Int, Int, Int, fn (0 = Int@3, 1 = Int@4) -> (), 0, Int, Int, Int, Int, !!fn (0 = Int@9, 1 = Int@10) -> (), Type: a, Type: b, !!Int, !!Int, -env: x: 0, t: fn (0 = Int@3, 1 = Int@4) -> (), main: fun
, -} ---- handle value 0 with return x;<1>(0,) ---> -{ -stack: top{0<-1>} -heap: fun
, Int, Int, Int, Int, !!fn (0 = Int@3, 1 = Int@4) -> (), !!0, Int, Int, Int, Int, !!fn (0 = Int@9, 1 = Int@10) -> (), Type: a, Type: b, !!Int, !!Int, -env: main: fun
, -} result: 0 diff --git a/executable_semantics/testdata/next.golden b/executable_semantics/testdata/next.golden index 441bc36a6587..2db2755da426 100644 --- a/executable_semantics/testdata/next.golden +++ b/executable_semantics/testdata/next.golden @@ -1,124 +1 @@ -********** source program ********** -fn main () -> Int { -var Int: x = 0; -return x; - -} -********** type checking ********** ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> - -********** type checking complete ********** -fn main () -> Int { -var Int: x = 0; -return x; -} -********** starting execution ********** -********** initializing globals ********** ---- step exp () ---> -********** calling main function ********** -{ -stack: top{main()<-1>} -heap: fun
, -env: main: fun
, -} ---- step exp main() ---> -{ -stack: top{main<-1> :: main()<0>} -heap: fun
, -env: main: fun
, -} ---- step exp main ---> -{ -stack: top{fun
<-1> :: main()<0>} -heap: fun
, -env: main: fun
, -} ---- handle value fun
with main()<1>(fun
,) ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: fun
, -env: main: fun
, -} ---- step exp () ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: fun
, -env: main: fun
, -} ---- handle value () with main()<2>(fun
,(),) ---> -pattern_match((), ()) -{ -stack: main{var Int: x = 0; ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step stmt var Int: x = 0; ... ---> -{ -stack: main{var Int: x = 0;<-1> :: return x;<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step stmt var Int: x = 0; ---> -{ -stack: main{0<-1> :: var Int: x = 0;<0> :: return x;<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp 0 ---> -{ -stack: main{0<-1> :: var Int: x = 0;<0> :: return x;<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value 0 with var Int: x = 0;<1>(0,) ---> -{ -stack: main{Int: x<-1> :: var Int: x = 0;<1>(0,) :: return x;<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp Int: x ---> -{ -stack: main{Int<-1> :: Int: x<0> :: var Int: x = 0;<1>(0,) :: return x;<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp Int ---> -{ -stack: main{Int<-1> :: Int: x<0> :: var Int: x = 0;<1>(0,) :: return x;<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value Int with Int: x<1>(Int,) ---> -{ -stack: main{Int: x<-1> :: var Int: x = 0;<1>(0,) :: return x;<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value Int: x with var Int: x = 0;<2>(0,Int: x,) ---> -pattern_match(Int: x, 0) -{ -stack: main{return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- step stmt return x; ---> -{ -stack: main{x<-1> :: return x;<0>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- step exp x ---> -{ -stack: main{0<-1> :: return x;<0>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- handle value 0 with return x;<1>(0,) ---> -{ -stack: top{0<-1>} -heap: fun
, !!0, -env: main: fun
, -} result: 0 diff --git a/executable_semantics/testdata/pattern_init.golden b/executable_semantics/testdata/pattern_init.golden index 527a42bfdc75..2db2755da426 100644 --- a/executable_semantics/testdata/pattern_init.golden +++ b/executable_semantics/testdata/pattern_init.golden @@ -1,235 +1 @@ -********** source program ********** -fn main () -> Int { -var (0 = auto: x, 1 = auto: y) = (0 = 2, 1 = 3); -return ((y - x) - 1); - -} -********** type checking ********** ---- step exp Int ---> ---- step exp Int ---> ---- step exp auto ---> ---- step exp auto ---> - -********** type checking complete ********** -fn main () -> Int { -var (0 = auto: x, 1 = auto: y) = (0 = 2, 1 = 3); -return ((y - x) - 1); -} -********** starting execution ********** -********** initializing globals ********** ---- step exp () ---> -********** calling main function ********** -{ -stack: top{main()<-1>} -heap: fun
, -env: main: fun
, -} ---- step exp main() ---> -{ -stack: top{main<-1> :: main()<0>} -heap: fun
, -env: main: fun
, -} ---- step exp main ---> -{ -stack: top{fun
<-1> :: main()<0>} -heap: fun
, -env: main: fun
, -} ---- handle value fun
with main()<1>(fun
,) ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: fun
, -env: main: fun
, -} ---- step exp () ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: fun
, -env: main: fun
, -} ---- handle value () with main()<2>(fun
,(),) ---> -pattern_match((), ()) -{ -stack: main{var (0 = auto: x, 1 = auto: y) = (0 = 2, 1 = 3); ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step stmt var (0 = auto: x, 1 = auto: y) = (0 = 2, 1 = 3); ... ---> -{ -stack: main{var (0 = auto: x, 1 = auto: y) = (0 = 2, 1 = 3);<-1> :: return ((y - x) - 1);<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step stmt var (0 = auto: x, 1 = auto: y) = (0 = 2, 1 = 3); ---> -{ -stack: main{(0 = 2, 1 = 3)<-1> :: var (0 = auto: x, 1 = auto: y) = (0 = 2, 1 = 3);<0> :: return ((y - x) - 1);<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp (0 = 2, 1 = 3) ---> -{ -stack: main{2<-1> :: (0 = 2, 1 = 3)<0> :: var (0 = auto: x, 1 = auto: y) = (0 = 2, 1 = 3);<0> :: return ((y - x) - 1);<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp 2 ---> -{ -stack: main{2<-1> :: (0 = 2, 1 = 3)<0> :: var (0 = auto: x, 1 = auto: y) = (0 = 2, 1 = 3);<0> :: return ((y - x) - 1);<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value 2 with (0 = 2, 1 = 3)<1>(2,) ---> -{ -stack: main{3<-1> :: (0 = 2, 1 = 3)<1>(2,) :: var (0 = auto: x, 1 = auto: y) = (0 = 2, 1 = 3);<0> :: return ((y - x) - 1);<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp 3 ---> -{ -stack: main{3<-1> :: (0 = 2, 1 = 3)<1>(2,) :: var (0 = auto: x, 1 = auto: y) = (0 = 2, 1 = 3);<0> :: return ((y - x) - 1);<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value 3 with (0 = 2, 1 = 3)<2>(2,3,) ---> -{ -stack: main{(0 = 2@1, 1 = 3@2)<-1> :: var (0 = auto: x, 1 = auto: y) = (0 = 2, 1 = 3);<0> :: return ((y - x) - 1);<-1>} :: top{} -heap: fun
, 2, 3, -env: main: fun
, -} ---- handle value (0 = 2@1, 1 = 3@2) with var (0 = auto: x, 1 = auto: y) = (0 = 2, 1 = 3);<1>((0 = 2@1, 1 = 3@2),) ---> -{ -stack: main{(0 = auto: x, 1 = auto: y)<-1> :: var (0 = auto: x, 1 = auto: y) = (0 = 2, 1 = 3);<1>((0 = 2@1, 1 = 3@2),) :: return ((y - x) - 1);<-1>} :: top{} -heap: fun
, 2, 3, -env: main: fun
, -} ---- step exp (0 = auto: x, 1 = auto: y) ---> -{ -stack: main{auto: x<-1> :: (0 = auto: x, 1 = auto: y)<0> :: var (0 = auto: x, 1 = auto: y) = (0 = 2, 1 = 3);<1>((0 = 2@1, 1 = 3@2),) :: return ((y - x) - 1);<-1>} :: top{} -heap: fun
, 2, 3, -env: main: fun
, -} ---- step exp auto: x ---> -{ -stack: main{auto<-1> :: auto: x<0> :: (0 = auto: x, 1 = auto: y)<0> :: var (0 = auto: x, 1 = auto: y) = (0 = 2, 1 = 3);<1>((0 = 2@1, 1 = 3@2),) :: return ((y - x) - 1);<-1>} :: top{} -heap: fun
, 2, 3, -env: main: fun
, -} ---- step exp auto ---> -{ -stack: main{auto<-1> :: auto: x<0> :: (0 = auto: x, 1 = auto: y)<0> :: var (0 = auto: x, 1 = auto: y) = (0 = 2, 1 = 3);<1>((0 = 2@1, 1 = 3@2),) :: return ((y - x) - 1);<-1>} :: top{} -heap: fun
, 2, 3, -env: main: fun
, -} ---- handle value auto with auto: x<1>(auto,) ---> -{ -stack: main{auto: x<-1> :: (0 = auto: x, 1 = auto: y)<0> :: var (0 = auto: x, 1 = auto: y) = (0 = 2, 1 = 3);<1>((0 = 2@1, 1 = 3@2),) :: return ((y - x) - 1);<-1>} :: top{} -heap: fun
, 2, 3, -env: main: fun
, -} ---- handle value auto: x with (0 = auto: x, 1 = auto: y)<1>(auto: x,) ---> -{ -stack: main{auto: y<-1> :: (0 = auto: x, 1 = auto: y)<1>(auto: x,) :: var (0 = auto: x, 1 = auto: y) = (0 = 2, 1 = 3);<1>((0 = 2@1, 1 = 3@2),) :: return ((y - x) - 1);<-1>} :: top{} -heap: fun
, 2, 3, -env: main: fun
, -} ---- step exp auto: y ---> -{ -stack: main{auto<-1> :: auto: y<0> :: (0 = auto: x, 1 = auto: y)<1>(auto: x,) :: var (0 = auto: x, 1 = auto: y) = (0 = 2, 1 = 3);<1>((0 = 2@1, 1 = 3@2),) :: return ((y - x) - 1);<-1>} :: top{} -heap: fun
, 2, 3, -env: main: fun
, -} ---- step exp auto ---> -{ -stack: main{auto<-1> :: auto: y<0> :: (0 = auto: x, 1 = auto: y)<1>(auto: x,) :: var (0 = auto: x, 1 = auto: y) = (0 = 2, 1 = 3);<1>((0 = 2@1, 1 = 3@2),) :: return ((y - x) - 1);<-1>} :: top{} -heap: fun
, 2, 3, -env: main: fun
, -} ---- handle value auto with auto: y<1>(auto,) ---> -{ -stack: main{auto: y<-1> :: (0 = auto: x, 1 = auto: y)<1>(auto: x,) :: var (0 = auto: x, 1 = auto: y) = (0 = 2, 1 = 3);<1>((0 = 2@1, 1 = 3@2),) :: return ((y - x) - 1);<-1>} :: top{} -heap: fun
, 2, 3, -env: main: fun
, -} ---- handle value auto: y with (0 = auto: x, 1 = auto: y)<2>(auto: x,auto: y,) ---> -{ -stack: main{(0 = auto: x@3, 1 = auto: y@4)<-1> :: var (0 = auto: x, 1 = auto: y) = (0 = 2, 1 = 3);<1>((0 = 2@1, 1 = 3@2),) :: return ((y - x) - 1);<-1>} :: top{} -heap: fun
, 2, 3, auto: x, auto: y, -env: main: fun
, -} ---- handle value (0 = auto: x@3, 1 = auto: y@4) with var (0 = auto: x, 1 = auto: y) = (0 = 2, 1 = 3);<2>((0 = 2@1, 1 = 3@2),(0 = auto: x@3, 1 = auto: y@4),) ---> -pattern_match((0 = auto: x@3, 1 = auto: y@4), (0 = 2@1, 1 = 3@2)) -pattern_match(auto: x, 2) -pattern_match(auto: y, 3) -{ -stack: main{return ((y - x) - 1);<-1>} :: top{} -heap: fun
, 2, 3, auto: x, auto: y, 2, 3, -env: y: 3, x: 2, main: fun
, -} ---- step stmt return ((y - x) - 1); ---> -{ -stack: main{((y - x) - 1)<-1> :: return ((y - x) - 1);<0>} :: top{} -heap: fun
, 2, 3, auto: x, auto: y, 2, 3, -env: y: 3, x: 2, main: fun
, -} ---- step exp ((y - x) - 1) ---> -{ -stack: main{(y - x)<-1> :: ((y - x) - 1)<0> :: return ((y - x) - 1);<0>} :: top{} -heap: fun
, 2, 3, auto: x, auto: y, 2, 3, -env: y: 3, x: 2, main: fun
, -} ---- step exp (y - x) ---> -{ -stack: main{y<-1> :: (y - x)<0> :: ((y - x) - 1)<0> :: return ((y - x) - 1);<0>} :: top{} -heap: fun
, 2, 3, auto: x, auto: y, 2, 3, -env: y: 3, x: 2, main: fun
, -} ---- step exp y ---> -{ -stack: main{3<-1> :: (y - x)<0> :: ((y - x) - 1)<0> :: return ((y - x) - 1);<0>} :: top{} -heap: fun
, 2, 3, auto: x, auto: y, 2, 3, -env: y: 3, x: 2, main: fun
, -} ---- handle value 3 with (y - x)<1>(3,) ---> -{ -stack: main{x<-1> :: (y - x)<1>(3,) :: ((y - x) - 1)<0> :: return ((y - x) - 1);<0>} :: top{} -heap: fun
, 2, 3, auto: x, auto: y, 2, 3, -env: y: 3, x: 2, main: fun
, -} ---- step exp x ---> -{ -stack: main{2<-1> :: (y - x)<1>(3,) :: ((y - x) - 1)<0> :: return ((y - x) - 1);<0>} :: top{} -heap: fun
, 2, 3, auto: x, auto: y, 2, 3, -env: y: 3, x: 2, main: fun
, -} ---- handle value 2 with (y - x)<2>(3,2,) ---> -{ -stack: main{1<-1> :: ((y - x) - 1)<0> :: return ((y - x) - 1);<0>} :: top{} -heap: fun
, 2, 3, auto: x, auto: y, 2, 3, -env: y: 3, x: 2, main: fun
, -} ---- handle value 1 with ((y - x) - 1)<1>(1,) ---> -{ -stack: main{1<-1> :: ((y - x) - 1)<1>(1,) :: return ((y - x) - 1);<0>} :: top{} -heap: fun
, 2, 3, auto: x, auto: y, 2, 3, -env: y: 3, x: 2, main: fun
, -} ---- step exp 1 ---> -{ -stack: main{1<-1> :: ((y - x) - 1)<1>(1,) :: return ((y - x) - 1);<0>} :: top{} -heap: fun
, 2, 3, auto: x, auto: y, 2, 3, -env: y: 3, x: 2, main: fun
, -} ---- handle value 1 with ((y - x) - 1)<2>(1,1,) ---> -{ -stack: main{0<-1> :: return ((y - x) - 1);<0>} :: top{} -heap: fun
, 2, 3, auto: x, auto: y, 2, 3, -env: y: 3, x: 2, main: fun
, -} ---- handle value 0 with return ((y - x) - 1);<1>(0,) ---> -{ -stack: top{0<-1>} -heap: fun
, 2, 3, auto: x, auto: y, !!2, !!3, -env: main: fun
, -} result: 0 diff --git a/executable_semantics/testdata/pattern_variable_fail.6c b/executable_semantics/testdata/pattern_variable_fail.6c index 6abbf7b5838e..938380adc9d7 100644 --- a/executable_semantics/testdata/pattern_variable_fail.6c +++ b/executable_semantics/testdata/pattern_variable_fail.6c @@ -3,6 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception fn main() -> Int { - Int : x; // error + // error + Int : x; return 1; } diff --git a/executable_semantics/testdata/pattern_variable_fail.golden b/executable_semantics/testdata/pattern_variable_fail.golden index 8f34dfa13179..b3b6c70aa57e 100644 --- a/executable_semantics/testdata/pattern_variable_fail.golden +++ b/executable_semantics/testdata/pattern_variable_fail.golden @@ -1,11 +1,2 @@ -********** source program ********** -fn main () -> Int { -Int: x; -return 1; - -} -********** type checking ********** ---- step exp Int ---> ---- step exp Int ---> -6: compilation error, pattern variables are only allowed in pattern context +7: compilation error, pattern variables are only allowed in pattern context EXIT CODE: 255 diff --git a/executable_semantics/testdata/record1.golden b/executable_semantics/testdata/record1.golden index d1997a9ab5bb..2db2755da426 100644 --- a/executable_semantics/testdata/record1.golden +++ b/executable_semantics/testdata/record1.golden @@ -1,298 +1 @@ -********** source program ********** -fn main () -> Int { -var (x = Int, y = Int): t2 = (y = 5, x = 2); -t2.y = 3; -return ((t2.y - t2.x) - 1); - -} -********** type checking ********** ---- step exp Int ---> ---- step exp Int ---> ---- step exp (x = Int, y = Int) ---> ---- step exp Int ---> ---- handle value Int with (x = Int, y = Int)<1>(Int,) ---> ---- step exp Int ---> ---- handle value Int with (x = Int, y = Int)<2>(Int,Int,) ---> - -********** type checking complete ********** -fn main () -> Int { -var (x = Int, y = Int): t2 = (y = 5, x = 2); -t2.y = 3; -return ((t2.y - t2.x) - 1); -} -********** starting execution ********** -********** initializing globals ********** ---- step exp () ---> -********** calling main function ********** -{ -stack: top{main()<-1>} -heap: fun
, -env: main: fun
, -} ---- step exp main() ---> -{ -stack: top{main<-1> :: main()<0>} -heap: fun
, -env: main: fun
, -} ---- step exp main ---> -{ -stack: top{fun
<-1> :: main()<0>} -heap: fun
, -env: main: fun
, -} ---- handle value fun
with main()<1>(fun
,) ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: fun
, -env: main: fun
, -} ---- step exp () ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: fun
, -env: main: fun
, -} ---- handle value () with main()<2>(fun
,(),) ---> -pattern_match((), ()) -{ -stack: main{var (x = Int, y = Int): t2 = (y = 5, x = 2); ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step stmt var (x = Int, y = Int): t2 = (y = 5, x = 2); ... ---> -{ -stack: main{var (x = Int, y = Int): t2 = (y = 5, x = 2);<-1> :: t2.y = 3; ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step stmt var (x = Int, y = Int): t2 = (y = 5, x = 2); ---> -{ -stack: main{(y = 5, x = 2)<-1> :: var (x = Int, y = Int): t2 = (y = 5, x = 2);<0> :: t2.y = 3; ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp (y = 5, x = 2) ---> -{ -stack: main{5<-1> :: (y = 5, x = 2)<0> :: var (x = Int, y = Int): t2 = (y = 5, x = 2);<0> :: t2.y = 3; ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp 5 ---> -{ -stack: main{5<-1> :: (y = 5, x = 2)<0> :: var (x = Int, y = Int): t2 = (y = 5, x = 2);<0> :: t2.y = 3; ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value 5 with (y = 5, x = 2)<1>(5,) ---> -{ -stack: main{2<-1> :: (y = 5, x = 2)<1>(5,) :: var (x = Int, y = Int): t2 = (y = 5, x = 2);<0> :: t2.y = 3; ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp 2 ---> -{ -stack: main{2<-1> :: (y = 5, x = 2)<1>(5,) :: var (x = Int, y = Int): t2 = (y = 5, x = 2);<0> :: t2.y = 3; ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value 2 with (y = 5, x = 2)<2>(5,2,) ---> -{ -stack: main{(y = 5@1, x = 2@2)<-1> :: var (x = Int, y = Int): t2 = (y = 5, x = 2);<0> :: t2.y = 3; ... <-1>} :: top{} -heap: fun
, 5, 2, -env: main: fun
, -} ---- handle value (y = 5@1, x = 2@2) with var (x = Int, y = Int): t2 = (y = 5, x = 2);<1>((y = 5@1, x = 2@2),) ---> -{ -stack: main{(x = Int, y = Int): t2<-1> :: var (x = Int, y = Int): t2 = (y = 5, x = 2);<1>((y = 5@1, x = 2@2),) :: t2.y = 3; ... <-1>} :: top{} -heap: fun
, 5, 2, -env: main: fun
, -} ---- step exp (x = Int, y = Int): t2 ---> -{ -stack: main{(x = Int, y = Int)<-1> :: (x = Int, y = Int): t2<0> :: var (x = Int, y = Int): t2 = (y = 5, x = 2);<1>((y = 5@1, x = 2@2),) :: t2.y = 3; ... <-1>} :: top{} -heap: fun
, 5, 2, -env: main: fun
, -} ---- step exp (x = Int, y = Int) ---> -{ -stack: main{Int<-1> :: (x = Int, y = Int)<0> :: (x = Int, y = Int): t2<0> :: var (x = Int, y = Int): t2 = (y = 5, x = 2);<1>((y = 5@1, x = 2@2),) :: t2.y = 3; ... <-1>} :: top{} -heap: fun
, 5, 2, -env: main: fun
, -} ---- step exp Int ---> -{ -stack: main{Int<-1> :: (x = Int, y = Int)<0> :: (x = Int, y = Int): t2<0> :: var (x = Int, y = Int): t2 = (y = 5, x = 2);<1>((y = 5@1, x = 2@2),) :: t2.y = 3; ... <-1>} :: top{} -heap: fun
, 5, 2, -env: main: fun
, -} ---- handle value Int with (x = Int, y = Int)<1>(Int,) ---> -{ -stack: main{Int<-1> :: (x = Int, y = Int)<1>(Int,) :: (x = Int, y = Int): t2<0> :: var (x = Int, y = Int): t2 = (y = 5, x = 2);<1>((y = 5@1, x = 2@2),) :: t2.y = 3; ... <-1>} :: top{} -heap: fun
, 5, 2, -env: main: fun
, -} ---- step exp Int ---> -{ -stack: main{Int<-1> :: (x = Int, y = Int)<1>(Int,) :: (x = Int, y = Int): t2<0> :: var (x = Int, y = Int): t2 = (y = 5, x = 2);<1>((y = 5@1, x = 2@2),) :: t2.y = 3; ... <-1>} :: top{} -heap: fun
, 5, 2, -env: main: fun
, -} ---- handle value Int with (x = Int, y = Int)<2>(Int,Int,) ---> -{ -stack: main{(x = Int@3, y = Int@4)<-1> :: (x = Int, y = Int): t2<0> :: var (x = Int, y = Int): t2 = (y = 5, x = 2);<1>((y = 5@1, x = 2@2),) :: t2.y = 3; ... <-1>} :: top{} -heap: fun
, 5, 2, Int, Int, -env: main: fun
, -} ---- handle value (x = Int@3, y = Int@4) with (x = Int, y = Int): t2<1>((x = Int@3, y = Int@4),) ---> -{ -stack: main{(x = Int@3, y = Int@4): t2<-1> :: var (x = Int, y = Int): t2 = (y = 5, x = 2);<1>((y = 5@1, x = 2@2),) :: t2.y = 3; ... <-1>} :: top{} -heap: fun
, 5, 2, Int, Int, -env: main: fun
, -} ---- handle value (x = Int@3, y = Int@4): t2 with var (x = Int, y = Int): t2 = (y = 5, x = 2);<2>((y = 5@1, x = 2@2),(x = Int@3, y = Int@4): t2,) ---> -pattern_match((x = Int@3, y = Int@4): t2, (y = 5@1, x = 2@2)) -{ -stack: main{t2.y = 3; ... <-1>} :: top{} -heap: fun
, 5, 2, Int, Int, 5, 2, (y = 5@5, x = 2@6), -env: t2: (y = 5@5, x = 2@6), main: fun
, -} ---- step stmt t2.y = 3; ... ---> -{ -stack: main{t2.y = 3;<-1> :: return ((t2.y - t2.x) - 1);<-1>} :: top{} -heap: fun
, 5, 2, Int, Int, 5, 2, (y = 5@5, x = 2@6), -env: t2: (y = 5@5, x = 2@6), main: fun
, -} ---- step stmt t2.y = 3; ---> -{ -stack: main{t2.y<-1> :: t2.y = 3;<0> :: return ((t2.y - t2.x) - 1);<-1>} :: top{} -heap: fun
, 5, 2, Int, Int, 5, 2, (y = 5@5, x = 2@6), -env: t2: (y = 5@5, x = 2@6), main: fun
, -} ---- step lvalue t2.y ---> -{ -stack: main{t2<-1> :: t2.y<0> :: t2.y = 3;<0> :: return ((t2.y - t2.x) - 1);<-1>} :: top{} -heap: fun
, 5, 2, Int, Int, 5, 2, (y = 5@5, x = 2@6), -env: t2: (y = 5@5, x = 2@6), main: fun
, -} ---- step lvalue t2 ---> -{ -stack: main{ptr<7><-1> :: t2.y<0> :: t2.y = 3;<0> :: return ((t2.y - t2.x) - 1);<-1>} :: top{} -heap: fun
, 5, 2, Int, Int, 5, 2, (y = 5@5, x = 2@6), -env: t2: (y = 5@5, x = 2@6), main: fun
, -} ---- handle value ptr<7> with t2.y<1>(ptr<7>,) ---> -{ -stack: main{ptr<5><-1> :: t2.y = 3;<0> :: return ((t2.y - t2.x) - 1);<-1>} :: top{} -heap: fun
, 5, 2, Int, Int, 5, 2, (y = 5@5, x = 2@6), -env: t2: (y = 5@5, x = 2@6), main: fun
, -} ---- handle value ptr<5> with t2.y = 3;<1>(ptr<5>,) ---> -{ -stack: main{3<-1> :: t2.y = 3;<1>(ptr<5>,) :: return ((t2.y - t2.x) - 1);<-1>} :: top{} -heap: fun
, 5, 2, Int, Int, 5, 2, (y = 5@5, x = 2@6), -env: t2: (y = 5@5, x = 2@6), main: fun
, -} ---- step exp 3 ---> -{ -stack: main{3<-1> :: t2.y = 3;<1>(ptr<5>,) :: return ((t2.y - t2.x) - 1);<-1>} :: top{} -heap: fun
, 5, 2, Int, Int, 5, 2, (y = 5@5, x = 2@6), -env: t2: (y = 5@5, x = 2@6), main: fun
, -} ---- handle value 3 with t2.y = 3;<2>(ptr<5>,3,) ---> -{ -stack: main{return ((t2.y - t2.x) - 1);<-1>} :: top{} -heap: fun
, 5, 2, Int, Int, 3, 2, (y = 3@5, x = 2@6), -env: t2: (y = 3@5, x = 2@6), main: fun
, -} ---- step stmt return ((t2.y - t2.x) - 1); ---> -{ -stack: main{((t2.y - t2.x) - 1)<-1> :: return ((t2.y - t2.x) - 1);<0>} :: top{} -heap: fun
, 5, 2, Int, Int, 3, 2, (y = 3@5, x = 2@6), -env: t2: (y = 3@5, x = 2@6), main: fun
, -} ---- step exp ((t2.y - t2.x) - 1) ---> -{ -stack: main{(t2.y - t2.x)<-1> :: ((t2.y - t2.x) - 1)<0> :: return ((t2.y - t2.x) - 1);<0>} :: top{} -heap: fun
, 5, 2, Int, Int, 3, 2, (y = 3@5, x = 2@6), -env: t2: (y = 3@5, x = 2@6), main: fun
, -} ---- step exp (t2.y - t2.x) ---> -{ -stack: main{t2.y<-1> :: (t2.y - t2.x)<0> :: ((t2.y - t2.x) - 1)<0> :: return ((t2.y - t2.x) - 1);<0>} :: top{} -heap: fun
, 5, 2, Int, Int, 3, 2, (y = 3@5, x = 2@6), -env: t2: (y = 3@5, x = 2@6), main: fun
, -} ---- step exp t2.y ---> -{ -stack: main{t2<-1> :: t2.y<0> :: (t2.y - t2.x)<0> :: ((t2.y - t2.x) - 1)<0> :: return ((t2.y - t2.x) - 1);<0>} :: top{} -heap: fun
, 5, 2, Int, Int, 3, 2, (y = 3@5, x = 2@6), -env: t2: (y = 3@5, x = 2@6), main: fun
, -} ---- step lvalue t2 ---> -{ -stack: main{ptr<7><-1> :: t2.y<0> :: (t2.y - t2.x)<0> :: ((t2.y - t2.x) - 1)<0> :: return ((t2.y - t2.x) - 1);<0>} :: top{} -heap: fun
, 5, 2, Int, Int, 3, 2, (y = 3@5, x = 2@6), -env: t2: (y = 3@5, x = 2@6), main: fun
, -} ---- handle value ptr<7> with t2.y<1>(ptr<7>,) ---> -{ -stack: main{3<-1> :: (t2.y - t2.x)<0> :: ((t2.y - t2.x) - 1)<0> :: return ((t2.y - t2.x) - 1);<0>} :: top{} -heap: fun
, 5, 2, Int, Int, 3, 2, (y = 3@5, x = 2@6), -env: t2: (y = 3@5, x = 2@6), main: fun
, -} ---- handle value 3 with (t2.y - t2.x)<1>(3,) ---> -{ -stack: main{t2.x<-1> :: (t2.y - t2.x)<1>(3,) :: ((t2.y - t2.x) - 1)<0> :: return ((t2.y - t2.x) - 1);<0>} :: top{} -heap: fun
, 5, 2, Int, Int, 3, 2, (y = 3@5, x = 2@6), -env: t2: (y = 3@5, x = 2@6), main: fun
, -} ---- step exp t2.x ---> -{ -stack: main{t2<-1> :: t2.x<0> :: (t2.y - t2.x)<1>(3,) :: ((t2.y - t2.x) - 1)<0> :: return ((t2.y - t2.x) - 1);<0>} :: top{} -heap: fun
, 5, 2, Int, Int, 3, 2, (y = 3@5, x = 2@6), -env: t2: (y = 3@5, x = 2@6), main: fun
, -} ---- step lvalue t2 ---> -{ -stack: main{ptr<7><-1> :: t2.x<0> :: (t2.y - t2.x)<1>(3,) :: ((t2.y - t2.x) - 1)<0> :: return ((t2.y - t2.x) - 1);<0>} :: top{} -heap: fun
, 5, 2, Int, Int, 3, 2, (y = 3@5, x = 2@6), -env: t2: (y = 3@5, x = 2@6), main: fun
, -} ---- handle value ptr<7> with t2.x<1>(ptr<7>,) ---> -{ -stack: main{2<-1> :: (t2.y - t2.x)<1>(3,) :: ((t2.y - t2.x) - 1)<0> :: return ((t2.y - t2.x) - 1);<0>} :: top{} -heap: fun
, 5, 2, Int, Int, 3, 2, (y = 3@5, x = 2@6), -env: t2: (y = 3@5, x = 2@6), main: fun
, -} ---- handle value 2 with (t2.y - t2.x)<2>(3,2,) ---> -{ -stack: main{1<-1> :: ((t2.y - t2.x) - 1)<0> :: return ((t2.y - t2.x) - 1);<0>} :: top{} -heap: fun
, 5, 2, Int, Int, 3, 2, (y = 3@5, x = 2@6), -env: t2: (y = 3@5, x = 2@6), main: fun
, -} ---- handle value 1 with ((t2.y - t2.x) - 1)<1>(1,) ---> -{ -stack: main{1<-1> :: ((t2.y - t2.x) - 1)<1>(1,) :: return ((t2.y - t2.x) - 1);<0>} :: top{} -heap: fun
, 5, 2, Int, Int, 3, 2, (y = 3@5, x = 2@6), -env: t2: (y = 3@5, x = 2@6), main: fun
, -} ---- step exp 1 ---> -{ -stack: main{1<-1> :: ((t2.y - t2.x) - 1)<1>(1,) :: return ((t2.y - t2.x) - 1);<0>} :: top{} -heap: fun
, 5, 2, Int, Int, 3, 2, (y = 3@5, x = 2@6), -env: t2: (y = 3@5, x = 2@6), main: fun
, -} ---- handle value 1 with ((t2.y - t2.x) - 1)<2>(1,1,) ---> -{ -stack: main{0<-1> :: return ((t2.y - t2.x) - 1);<0>} :: top{} -heap: fun
, 5, 2, Int, Int, 3, 2, (y = 3@5, x = 2@6), -env: t2: (y = 3@5, x = 2@6), main: fun
, -} ---- handle value 0 with return ((t2.y - t2.x) - 1);<1>(0,) ---> -{ -stack: top{0<-1>} -heap: fun
, 5, 2, Int, Int, !!3, !!2, !!(y = !!3@5, x = !!2@6), -env: main: fun
, -} result: 0 diff --git a/executable_semantics/testdata/struct1.golden b/executable_semantics/testdata/struct1.golden index 28ae32f7f6ce..2db2755da426 100644 --- a/executable_semantics/testdata/struct1.golden +++ b/executable_semantics/testdata/struct1.golden @@ -1,256 +1 @@ -********** source program ********** -struct Point { -var x : Int; -var y : Int; -} -fn main () -> Int { -var auto: p = Point(x = 1, y = 2); -return ((p.y - p.x) - 1); - -} -********** type checking ********** ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp auto ---> - -********** type checking complete ********** -struct Point { -var x : Int; -var y : Int; -} -fn main () -> Int { -var auto: p = Point(x = 1, y = 2); -return ((p.y - p.x) - 1); -} -********** starting execution ********** -********** initializing globals ********** ---- step exp Int ---> ---- step exp Int ---> ---- step exp () ---> -********** calling main function ********** -{ -stack: top{main()<-1>} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- step exp main() ---> -{ -stack: top{main<-1> :: main()<0>} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- step exp main ---> -{ -stack: top{fun
<-1> :: main()<0>} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- handle value fun
with main()<1>(fun
,) ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- step exp () ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- handle value () with main()<2>(fun
,(),) ---> -pattern_match((), ()) -{ -stack: main{var auto: p = Point(x = 1, y = 2); ... <-1>} :: top{} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- step stmt var auto: p = Point(x = 1, y = 2); ... ---> -{ -stack: main{var auto: p = Point(x = 1, y = 2);<-1> :: return ((p.y - p.x) - 1);<-1>} :: top{} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- step stmt var auto: p = Point(x = 1, y = 2); ---> -{ -stack: main{Point(x = 1, y = 2)<-1> :: var auto: p = Point(x = 1, y = 2);<0> :: return ((p.y - p.x) - 1);<-1>} :: top{} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- step exp Point(x = 1, y = 2) ---> -{ -stack: main{Point<-1> :: Point(x = 1, y = 2)<0> :: var auto: p = Point(x = 1, y = 2);<0> :: return ((p.y - p.x) - 1);<-1>} :: top{} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- step exp Point ---> -{ -stack: main{struct Point<-1> :: Point(x = 1, y = 2)<0> :: var auto: p = Point(x = 1, y = 2);<0> :: return ((p.y - p.x) - 1);<-1>} :: top{} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- handle value struct Point with Point(x = 1, y = 2)<1>(struct Point,) ---> -{ -stack: main{(x = 1, y = 2)<-1> :: Point(x = 1, y = 2)<1>(struct Point,) :: var auto: p = Point(x = 1, y = 2);<0> :: return ((p.y - p.x) - 1);<-1>} :: top{} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- step exp (x = 1, y = 2) ---> -{ -stack: main{1<-1> :: (x = 1, y = 2)<0> :: Point(x = 1, y = 2)<1>(struct Point,) :: var auto: p = Point(x = 1, y = 2);<0> :: return ((p.y - p.x) - 1);<-1>} :: top{} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- step exp 1 ---> -{ -stack: main{1<-1> :: (x = 1, y = 2)<0> :: Point(x = 1, y = 2)<1>(struct Point,) :: var auto: p = Point(x = 1, y = 2);<0> :: return ((p.y - p.x) - 1);<-1>} :: top{} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- handle value 1 with (x = 1, y = 2)<1>(1,) ---> -{ -stack: main{2<-1> :: (x = 1, y = 2)<1>(1,) :: Point(x = 1, y = 2)<1>(struct Point,) :: var auto: p = Point(x = 1, y = 2);<0> :: return ((p.y - p.x) - 1);<-1>} :: top{} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- step exp 2 ---> -{ -stack: main{2<-1> :: (x = 1, y = 2)<1>(1,) :: Point(x = 1, y = 2)<1>(struct Point,) :: var auto: p = Point(x = 1, y = 2);<0> :: return ((p.y - p.x) - 1);<-1>} :: top{} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- handle value 2 with (x = 1, y = 2)<2>(1,2,) ---> -{ -stack: main{(x = 1@2, y = 2@3)<-1> :: Point(x = 1, y = 2)<1>(struct Point,) :: var auto: p = Point(x = 1, y = 2);<0> :: return ((p.y - p.x) - 1);<-1>} :: top{} -heap: struct Point, fun
, 1, 2, -env: main: fun
, Point: struct Point, -} ---- handle value (x = 1@2, y = 2@3) with Point(x = 1, y = 2)<2>(struct Point,(x = 1@2, y = 2@3),) ---> -{ -stack: main{Point(x = 1@4, y = 2@5)<-1> :: var auto: p = Point(x = 1, y = 2);<0> :: return ((p.y - p.x) - 1);<-1>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, -env: main: fun
, Point: struct Point, -} ---- handle value Point(x = 1@4, y = 2@5) with var auto: p = Point(x = 1, y = 2);<1>(Point(x = 1@4, y = 2@5),) ---> -{ -stack: main{auto: p<-1> :: var auto: p = Point(x = 1, y = 2);<1>(Point(x = 1@4, y = 2@5),) :: return ((p.y - p.x) - 1);<-1>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, -env: main: fun
, Point: struct Point, -} ---- step exp auto: p ---> -{ -stack: main{auto<-1> :: auto: p<0> :: var auto: p = Point(x = 1, y = 2);<1>(Point(x = 1@4, y = 2@5),) :: return ((p.y - p.x) - 1);<-1>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, -env: main: fun
, Point: struct Point, -} ---- step exp auto ---> -{ -stack: main{auto<-1> :: auto: p<0> :: var auto: p = Point(x = 1, y = 2);<1>(Point(x = 1@4, y = 2@5),) :: return ((p.y - p.x) - 1);<-1>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, -env: main: fun
, Point: struct Point, -} ---- handle value auto with auto: p<1>(auto,) ---> -{ -stack: main{auto: p<-1> :: var auto: p = Point(x = 1, y = 2);<1>(Point(x = 1@4, y = 2@5),) :: return ((p.y - p.x) - 1);<-1>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, -env: main: fun
, Point: struct Point, -} ---- handle value auto: p with var auto: p = Point(x = 1, y = 2);<2>(Point(x = 1@4, y = 2@5),auto: p,) ---> -pattern_match(auto: p, Point(x = 1@4, y = 2@5)) -{ -stack: main{return ((p.y - p.x) - 1);<-1>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), -env: p: Point(x = 1@6, y = 2@7), main: fun
, Point: struct Point, -} ---- step stmt return ((p.y - p.x) - 1); ---> -{ -stack: main{((p.y - p.x) - 1)<-1> :: return ((p.y - p.x) - 1);<0>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), -env: p: Point(x = 1@6, y = 2@7), main: fun
, Point: struct Point, -} ---- step exp ((p.y - p.x) - 1) ---> -{ -stack: main{(p.y - p.x)<-1> :: ((p.y - p.x) - 1)<0> :: return ((p.y - p.x) - 1);<0>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), -env: p: Point(x = 1@6, y = 2@7), main: fun
, Point: struct Point, -} ---- step exp (p.y - p.x) ---> -{ -stack: main{p.y<-1> :: (p.y - p.x)<0> :: ((p.y - p.x) - 1)<0> :: return ((p.y - p.x) - 1);<0>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), -env: p: Point(x = 1@6, y = 2@7), main: fun
, Point: struct Point, -} ---- step exp p.y ---> -{ -stack: main{p<-1> :: p.y<0> :: (p.y - p.x)<0> :: ((p.y - p.x) - 1)<0> :: return ((p.y - p.x) - 1);<0>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), -env: p: Point(x = 1@6, y = 2@7), main: fun
, Point: struct Point, -} ---- step lvalue p ---> -{ -stack: main{ptr<8><-1> :: p.y<0> :: (p.y - p.x)<0> :: ((p.y - p.x) - 1)<0> :: return ((p.y - p.x) - 1);<0>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), -env: p: Point(x = 1@6, y = 2@7), main: fun
, Point: struct Point, -} ---- handle value ptr<8> with p.y<1>(ptr<8>,) ---> -{ -stack: main{2<-1> :: (p.y - p.x)<0> :: ((p.y - p.x) - 1)<0> :: return ((p.y - p.x) - 1);<0>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), -env: p: Point(x = 1@6, y = 2@7), main: fun
, Point: struct Point, -} ---- handle value 2 with (p.y - p.x)<1>(2,) ---> -{ -stack: main{p.x<-1> :: (p.y - p.x)<1>(2,) :: ((p.y - p.x) - 1)<0> :: return ((p.y - p.x) - 1);<0>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), -env: p: Point(x = 1@6, y = 2@7), main: fun
, Point: struct Point, -} ---- step exp p.x ---> -{ -stack: main{p<-1> :: p.x<0> :: (p.y - p.x)<1>(2,) :: ((p.y - p.x) - 1)<0> :: return ((p.y - p.x) - 1);<0>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), -env: p: Point(x = 1@6, y = 2@7), main: fun
, Point: struct Point, -} ---- step lvalue p ---> -{ -stack: main{ptr<8><-1> :: p.x<0> :: (p.y - p.x)<1>(2,) :: ((p.y - p.x) - 1)<0> :: return ((p.y - p.x) - 1);<0>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), -env: p: Point(x = 1@6, y = 2@7), main: fun
, Point: struct Point, -} ---- handle value ptr<8> with p.x<1>(ptr<8>,) ---> -{ -stack: main{1<-1> :: (p.y - p.x)<1>(2,) :: ((p.y - p.x) - 1)<0> :: return ((p.y - p.x) - 1);<0>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), -env: p: Point(x = 1@6, y = 2@7), main: fun
, Point: struct Point, -} ---- handle value 1 with (p.y - p.x)<2>(2,1,) ---> -{ -stack: main{1<-1> :: ((p.y - p.x) - 1)<0> :: return ((p.y - p.x) - 1);<0>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), -env: p: Point(x = 1@6, y = 2@7), main: fun
, Point: struct Point, -} ---- handle value 1 with ((p.y - p.x) - 1)<1>(1,) ---> -{ -stack: main{1<-1> :: ((p.y - p.x) - 1)<1>(1,) :: return ((p.y - p.x) - 1);<0>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), -env: p: Point(x = 1@6, y = 2@7), main: fun
, Point: struct Point, -} ---- step exp 1 ---> -{ -stack: main{1<-1> :: ((p.y - p.x) - 1)<1>(1,) :: return ((p.y - p.x) - 1);<0>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), -env: p: Point(x = 1@6, y = 2@7), main: fun
, Point: struct Point, -} ---- handle value 1 with ((p.y - p.x) - 1)<2>(1,1,) ---> -{ -stack: main{0<-1> :: return ((p.y - p.x) - 1);<0>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), -env: p: Point(x = 1@6, y = 2@7), main: fun
, Point: struct Point, -} ---- handle value 0 with return ((p.y - p.x) - 1);<1>(0,) ---> -{ -stack: top{0<-1>} -heap: struct Point, fun
, 1, 2, 1, 2, !!1, !!2, !!Point!!(x = !!1@6, y = !!2@7), -env: main: fun
, Point: struct Point, -} result: 0 diff --git a/executable_semantics/testdata/struct2.golden b/executable_semantics/testdata/struct2.golden index c8c5abbab451..2db2755da426 100644 --- a/executable_semantics/testdata/struct2.golden +++ b/executable_semantics/testdata/struct2.golden @@ -1,322 +1 @@ -********** source program ********** -struct Point { -var x : Int; -var y : Int; -} -fn main () -> Int { -var auto: p1 = Point(x = 1, y = 2); -var auto: p2 = p1; -p2.x = 3; -return (p1.x - 1); - -} -********** type checking ********** ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp auto ---> ---- step exp auto ---> - -********** type checking complete ********** -struct Point { -var x : Int; -var y : Int; -} -fn main () -> Int { -var auto: p1 = Point(x = 1, y = 2); -var auto: p2 = p1; -p2.x = 3; -return (p1.x - 1); -} -********** starting execution ********** -********** initializing globals ********** ---- step exp Int ---> ---- step exp Int ---> ---- step exp () ---> -********** calling main function ********** -{ -stack: top{main()<-1>} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- step exp main() ---> -{ -stack: top{main<-1> :: main()<0>} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- step exp main ---> -{ -stack: top{fun
<-1> :: main()<0>} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- handle value fun
with main()<1>(fun
,) ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- step exp () ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- handle value () with main()<2>(fun
,(),) ---> -pattern_match((), ()) -{ -stack: main{var auto: p1 = Point(x = 1, y = 2); ... <-1>} :: top{} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- step stmt var auto: p1 = Point(x = 1, y = 2); ... ---> -{ -stack: main{var auto: p1 = Point(x = 1, y = 2);<-1> :: var auto: p2 = p1; ... <-1>} :: top{} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- step stmt var auto: p1 = Point(x = 1, y = 2); ---> -{ -stack: main{Point(x = 1, y = 2)<-1> :: var auto: p1 = Point(x = 1, y = 2);<0> :: var auto: p2 = p1; ... <-1>} :: top{} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- step exp Point(x = 1, y = 2) ---> -{ -stack: main{Point<-1> :: Point(x = 1, y = 2)<0> :: var auto: p1 = Point(x = 1, y = 2);<0> :: var auto: p2 = p1; ... <-1>} :: top{} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- step exp Point ---> -{ -stack: main{struct Point<-1> :: Point(x = 1, y = 2)<0> :: var auto: p1 = Point(x = 1, y = 2);<0> :: var auto: p2 = p1; ... <-1>} :: top{} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- handle value struct Point with Point(x = 1, y = 2)<1>(struct Point,) ---> -{ -stack: main{(x = 1, y = 2)<-1> :: Point(x = 1, y = 2)<1>(struct Point,) :: var auto: p1 = Point(x = 1, y = 2);<0> :: var auto: p2 = p1; ... <-1>} :: top{} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- step exp (x = 1, y = 2) ---> -{ -stack: main{1<-1> :: (x = 1, y = 2)<0> :: Point(x = 1, y = 2)<1>(struct Point,) :: var auto: p1 = Point(x = 1, y = 2);<0> :: var auto: p2 = p1; ... <-1>} :: top{} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- step exp 1 ---> -{ -stack: main{1<-1> :: (x = 1, y = 2)<0> :: Point(x = 1, y = 2)<1>(struct Point,) :: var auto: p1 = Point(x = 1, y = 2);<0> :: var auto: p2 = p1; ... <-1>} :: top{} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- handle value 1 with (x = 1, y = 2)<1>(1,) ---> -{ -stack: main{2<-1> :: (x = 1, y = 2)<1>(1,) :: Point(x = 1, y = 2)<1>(struct Point,) :: var auto: p1 = Point(x = 1, y = 2);<0> :: var auto: p2 = p1; ... <-1>} :: top{} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- step exp 2 ---> -{ -stack: main{2<-1> :: (x = 1, y = 2)<1>(1,) :: Point(x = 1, y = 2)<1>(struct Point,) :: var auto: p1 = Point(x = 1, y = 2);<0> :: var auto: p2 = p1; ... <-1>} :: top{} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- handle value 2 with (x = 1, y = 2)<2>(1,2,) ---> -{ -stack: main{(x = 1@2, y = 2@3)<-1> :: Point(x = 1, y = 2)<1>(struct Point,) :: var auto: p1 = Point(x = 1, y = 2);<0> :: var auto: p2 = p1; ... <-1>} :: top{} -heap: struct Point, fun
, 1, 2, -env: main: fun
, Point: struct Point, -} ---- handle value (x = 1@2, y = 2@3) with Point(x = 1, y = 2)<2>(struct Point,(x = 1@2, y = 2@3),) ---> -{ -stack: main{Point(x = 1@4, y = 2@5)<-1> :: var auto: p1 = Point(x = 1, y = 2);<0> :: var auto: p2 = p1; ... <-1>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, -env: main: fun
, Point: struct Point, -} ---- handle value Point(x = 1@4, y = 2@5) with var auto: p1 = Point(x = 1, y = 2);<1>(Point(x = 1@4, y = 2@5),) ---> -{ -stack: main{auto: p1<-1> :: var auto: p1 = Point(x = 1, y = 2);<1>(Point(x = 1@4, y = 2@5),) :: var auto: p2 = p1; ... <-1>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, -env: main: fun
, Point: struct Point, -} ---- step exp auto: p1 ---> -{ -stack: main{auto<-1> :: auto: p1<0> :: var auto: p1 = Point(x = 1, y = 2);<1>(Point(x = 1@4, y = 2@5),) :: var auto: p2 = p1; ... <-1>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, -env: main: fun
, Point: struct Point, -} ---- step exp auto ---> -{ -stack: main{auto<-1> :: auto: p1<0> :: var auto: p1 = Point(x = 1, y = 2);<1>(Point(x = 1@4, y = 2@5),) :: var auto: p2 = p1; ... <-1>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, -env: main: fun
, Point: struct Point, -} ---- handle value auto with auto: p1<1>(auto,) ---> -{ -stack: main{auto: p1<-1> :: var auto: p1 = Point(x = 1, y = 2);<1>(Point(x = 1@4, y = 2@5),) :: var auto: p2 = p1; ... <-1>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, -env: main: fun
, Point: struct Point, -} ---- handle value auto: p1 with var auto: p1 = Point(x = 1, y = 2);<2>(Point(x = 1@4, y = 2@5),auto: p1,) ---> -pattern_match(auto: p1, Point(x = 1@4, y = 2@5)) -{ -stack: main{var auto: p2 = p1; ... <-1>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), -env: p1: Point(x = 1@6, y = 2@7), main: fun
, Point: struct Point, -} ---- step stmt var auto: p2 = p1; ... ---> -{ -stack: main{var auto: p2 = p1;<-1> :: p2.x = 3; ... <-1>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), -env: p1: Point(x = 1@6, y = 2@7), main: fun
, Point: struct Point, -} ---- step stmt var auto: p2 = p1; ---> -{ -stack: main{p1<-1> :: var auto: p2 = p1;<0> :: p2.x = 3; ... <-1>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), -env: p1: Point(x = 1@6, y = 2@7), main: fun
, Point: struct Point, -} ---- step exp p1 ---> -{ -stack: main{Point(x = 1@6, y = 2@7)<-1> :: var auto: p2 = p1;<0> :: p2.x = 3; ... <-1>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), -env: p1: Point(x = 1@6, y = 2@7), main: fun
, Point: struct Point, -} ---- handle value Point(x = 1@6, y = 2@7) with var auto: p2 = p1;<1>(Point(x = 1@6, y = 2@7),) ---> -{ -stack: main{auto: p2<-1> :: var auto: p2 = p1;<1>(Point(x = 1@6, y = 2@7),) :: p2.x = 3; ... <-1>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), -env: p1: Point(x = 1@6, y = 2@7), main: fun
, Point: struct Point, -} ---- step exp auto: p2 ---> -{ -stack: main{auto<-1> :: auto: p2<0> :: var auto: p2 = p1;<1>(Point(x = 1@6, y = 2@7),) :: p2.x = 3; ... <-1>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), -env: p1: Point(x = 1@6, y = 2@7), main: fun
, Point: struct Point, -} ---- step exp auto ---> -{ -stack: main{auto<-1> :: auto: p2<0> :: var auto: p2 = p1;<1>(Point(x = 1@6, y = 2@7),) :: p2.x = 3; ... <-1>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), -env: p1: Point(x = 1@6, y = 2@7), main: fun
, Point: struct Point, -} ---- handle value auto with auto: p2<1>(auto,) ---> -{ -stack: main{auto: p2<-1> :: var auto: p2 = p1;<1>(Point(x = 1@6, y = 2@7),) :: p2.x = 3; ... <-1>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), -env: p1: Point(x = 1@6, y = 2@7), main: fun
, Point: struct Point, -} ---- handle value auto: p2 with var auto: p2 = p1;<2>(Point(x = 1@6, y = 2@7),auto: p2,) ---> -pattern_match(auto: p2, Point(x = 1@6, y = 2@7)) -{ -stack: main{p2.x = 3; ... <-1>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), 1, 2, Point(x = 1@9, y = 2@10), -env: p2: Point(x = 1@9, y = 2@10), p1: Point(x = 1@6, y = 2@7), main: fun
, Point: struct Point, -} ---- step stmt p2.x = 3; ... ---> -{ -stack: main{p2.x = 3;<-1> :: return (p1.x - 1);<-1>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), 1, 2, Point(x = 1@9, y = 2@10), -env: p2: Point(x = 1@9, y = 2@10), p1: Point(x = 1@6, y = 2@7), main: fun
, Point: struct Point, -} ---- step stmt p2.x = 3; ---> -{ -stack: main{p2.x<-1> :: p2.x = 3;<0> :: return (p1.x - 1);<-1>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), 1, 2, Point(x = 1@9, y = 2@10), -env: p2: Point(x = 1@9, y = 2@10), p1: Point(x = 1@6, y = 2@7), main: fun
, Point: struct Point, -} ---- step lvalue p2.x ---> -{ -stack: main{p2<-1> :: p2.x<0> :: p2.x = 3;<0> :: return (p1.x - 1);<-1>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), 1, 2, Point(x = 1@9, y = 2@10), -env: p2: Point(x = 1@9, y = 2@10), p1: Point(x = 1@6, y = 2@7), main: fun
, Point: struct Point, -} ---- step lvalue p2 ---> -{ -stack: main{ptr<11><-1> :: p2.x<0> :: p2.x = 3;<0> :: return (p1.x - 1);<-1>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), 1, 2, Point(x = 1@9, y = 2@10), -env: p2: Point(x = 1@9, y = 2@10), p1: Point(x = 1@6, y = 2@7), main: fun
, Point: struct Point, -} ---- handle value ptr<11> with p2.x<1>(ptr<11>,) ---> -{ -stack: main{ptr<9><-1> :: p2.x = 3;<0> :: return (p1.x - 1);<-1>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), 1, 2, Point(x = 1@9, y = 2@10), -env: p2: Point(x = 1@9, y = 2@10), p1: Point(x = 1@6, y = 2@7), main: fun
, Point: struct Point, -} ---- handle value ptr<9> with p2.x = 3;<1>(ptr<9>,) ---> -{ -stack: main{3<-1> :: p2.x = 3;<1>(ptr<9>,) :: return (p1.x - 1);<-1>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), 1, 2, Point(x = 1@9, y = 2@10), -env: p2: Point(x = 1@9, y = 2@10), p1: Point(x = 1@6, y = 2@7), main: fun
, Point: struct Point, -} ---- step exp 3 ---> -{ -stack: main{3<-1> :: p2.x = 3;<1>(ptr<9>,) :: return (p1.x - 1);<-1>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), 1, 2, Point(x = 1@9, y = 2@10), -env: p2: Point(x = 1@9, y = 2@10), p1: Point(x = 1@6, y = 2@7), main: fun
, Point: struct Point, -} ---- handle value 3 with p2.x = 3;<2>(ptr<9>,3,) ---> -{ -stack: main{return (p1.x - 1);<-1>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), 3, 2, Point(x = 3@9, y = 2@10), -env: p2: Point(x = 3@9, y = 2@10), p1: Point(x = 1@6, y = 2@7), main: fun
, Point: struct Point, -} ---- step stmt return (p1.x - 1); ---> -{ -stack: main{(p1.x - 1)<-1> :: return (p1.x - 1);<0>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), 3, 2, Point(x = 3@9, y = 2@10), -env: p2: Point(x = 3@9, y = 2@10), p1: Point(x = 1@6, y = 2@7), main: fun
, Point: struct Point, -} ---- step exp (p1.x - 1) ---> -{ -stack: main{p1.x<-1> :: (p1.x - 1)<0> :: return (p1.x - 1);<0>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), 3, 2, Point(x = 3@9, y = 2@10), -env: p2: Point(x = 3@9, y = 2@10), p1: Point(x = 1@6, y = 2@7), main: fun
, Point: struct Point, -} ---- step exp p1.x ---> -{ -stack: main{p1<-1> :: p1.x<0> :: (p1.x - 1)<0> :: return (p1.x - 1);<0>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), 3, 2, Point(x = 3@9, y = 2@10), -env: p2: Point(x = 3@9, y = 2@10), p1: Point(x = 1@6, y = 2@7), main: fun
, Point: struct Point, -} ---- step lvalue p1 ---> -{ -stack: main{ptr<8><-1> :: p1.x<0> :: (p1.x - 1)<0> :: return (p1.x - 1);<0>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), 3, 2, Point(x = 3@9, y = 2@10), -env: p2: Point(x = 3@9, y = 2@10), p1: Point(x = 1@6, y = 2@7), main: fun
, Point: struct Point, -} ---- handle value ptr<8> with p1.x<1>(ptr<8>,) ---> -{ -stack: main{1<-1> :: (p1.x - 1)<0> :: return (p1.x - 1);<0>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), 3, 2, Point(x = 3@9, y = 2@10), -env: p2: Point(x = 3@9, y = 2@10), p1: Point(x = 1@6, y = 2@7), main: fun
, Point: struct Point, -} ---- handle value 1 with (p1.x - 1)<1>(1,) ---> -{ -stack: main{1<-1> :: (p1.x - 1)<1>(1,) :: return (p1.x - 1);<0>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), 3, 2, Point(x = 3@9, y = 2@10), -env: p2: Point(x = 3@9, y = 2@10), p1: Point(x = 1@6, y = 2@7), main: fun
, Point: struct Point, -} ---- step exp 1 ---> -{ -stack: main{1<-1> :: (p1.x - 1)<1>(1,) :: return (p1.x - 1);<0>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), 3, 2, Point(x = 3@9, y = 2@10), -env: p2: Point(x = 3@9, y = 2@10), p1: Point(x = 1@6, y = 2@7), main: fun
, Point: struct Point, -} ---- handle value 1 with (p1.x - 1)<2>(1,1,) ---> -{ -stack: main{0<-1> :: return (p1.x - 1);<0>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, 1, 2, Point(x = 1@6, y = 2@7), 3, 2, Point(x = 3@9, y = 2@10), -env: p2: Point(x = 3@9, y = 2@10), p1: Point(x = 1@6, y = 2@7), main: fun
, Point: struct Point, -} ---- handle value 0 with return (p1.x - 1);<1>(0,) ---> -{ -stack: top{0<-1>} -heap: struct Point, fun
, 1, 2, 1, 2, !!1, !!2, !!Point!!(x = !!1@6, y = !!2@7), !!3, !!2, !!Point!!(x = !!3@9, y = !!2@10), -env: main: fun
, Point: struct Point, -} result: 0 diff --git a/executable_semantics/testdata/struct3.golden b/executable_semantics/testdata/struct3.golden index 4db864374f31..2db2755da426 100644 --- a/executable_semantics/testdata/struct3.golden +++ b/executable_semantics/testdata/struct3.golden @@ -1,186 +1 @@ -********** source program ********** -struct Point { -var x : Int; -var y : Int; -} -fn main () -> Int { -return (Point(x = 1, y = 2).x - 1); - -} -********** type checking ********** ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> - -********** type checking complete ********** -struct Point { -var x : Int; -var y : Int; -} -fn main () -> Int { -return (Point(x = 1, y = 2).x - 1); -} -********** starting execution ********** -********** initializing globals ********** ---- step exp Int ---> ---- step exp Int ---> ---- step exp () ---> -********** calling main function ********** -{ -stack: top{main()<-1>} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- step exp main() ---> -{ -stack: top{main<-1> :: main()<0>} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- step exp main ---> -{ -stack: top{fun
<-1> :: main()<0>} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- handle value fun
with main()<1>(fun
,) ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- step exp () ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- handle value () with main()<2>(fun
,(),) ---> -pattern_match((), ()) -{ -stack: main{return (Point(x = 1, y = 2).x - 1);<-1>} :: top{} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- step stmt return (Point(x = 1, y = 2).x - 1); ---> -{ -stack: main{(Point(x = 1, y = 2).x - 1)<-1> :: return (Point(x = 1, y = 2).x - 1);<0>} :: top{} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- step exp (Point(x = 1, y = 2).x - 1) ---> -{ -stack: main{Point(x = 1, y = 2).x<-1> :: (Point(x = 1, y = 2).x - 1)<0> :: return (Point(x = 1, y = 2).x - 1);<0>} :: top{} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- step exp Point(x = 1, y = 2).x ---> -{ -stack: main{Point(x = 1, y = 2)<-1> :: Point(x = 1, y = 2).x<0> :: (Point(x = 1, y = 2).x - 1)<0> :: return (Point(x = 1, y = 2).x - 1);<0>} :: top{} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- step lvalue Point(x = 1, y = 2) ---> -{ -stack: main{Point(x = 1, y = 2)<-1> :: exp=>lval<-1> :: Point(x = 1, y = 2).x<0> :: (Point(x = 1, y = 2).x - 1)<0> :: return (Point(x = 1, y = 2).x - 1);<0>} :: top{} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- step exp Point(x = 1, y = 2) ---> -{ -stack: main{Point<-1> :: Point(x = 1, y = 2)<0> :: exp=>lval<-1> :: Point(x = 1, y = 2).x<0> :: (Point(x = 1, y = 2).x - 1)<0> :: return (Point(x = 1, y = 2).x - 1);<0>} :: top{} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- step exp Point ---> -{ -stack: main{struct Point<-1> :: Point(x = 1, y = 2)<0> :: exp=>lval<-1> :: Point(x = 1, y = 2).x<0> :: (Point(x = 1, y = 2).x - 1)<0> :: return (Point(x = 1, y = 2).x - 1);<0>} :: top{} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- handle value struct Point with Point(x = 1, y = 2)<1>(struct Point,) ---> -{ -stack: main{(x = 1, y = 2)<-1> :: Point(x = 1, y = 2)<1>(struct Point,) :: exp=>lval<-1> :: Point(x = 1, y = 2).x<0> :: (Point(x = 1, y = 2).x - 1)<0> :: return (Point(x = 1, y = 2).x - 1);<0>} :: top{} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- step exp (x = 1, y = 2) ---> -{ -stack: main{1<-1> :: (x = 1, y = 2)<0> :: Point(x = 1, y = 2)<1>(struct Point,) :: exp=>lval<-1> :: Point(x = 1, y = 2).x<0> :: (Point(x = 1, y = 2).x - 1)<0> :: return (Point(x = 1, y = 2).x - 1);<0>} :: top{} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- step exp 1 ---> -{ -stack: main{1<-1> :: (x = 1, y = 2)<0> :: Point(x = 1, y = 2)<1>(struct Point,) :: exp=>lval<-1> :: Point(x = 1, y = 2).x<0> :: (Point(x = 1, y = 2).x - 1)<0> :: return (Point(x = 1, y = 2).x - 1);<0>} :: top{} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- handle value 1 with (x = 1, y = 2)<1>(1,) ---> -{ -stack: main{2<-1> :: (x = 1, y = 2)<1>(1,) :: Point(x = 1, y = 2)<1>(struct Point,) :: exp=>lval<-1> :: Point(x = 1, y = 2).x<0> :: (Point(x = 1, y = 2).x - 1)<0> :: return (Point(x = 1, y = 2).x - 1);<0>} :: top{} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- step exp 2 ---> -{ -stack: main{2<-1> :: (x = 1, y = 2)<1>(1,) :: Point(x = 1, y = 2)<1>(struct Point,) :: exp=>lval<-1> :: Point(x = 1, y = 2).x<0> :: (Point(x = 1, y = 2).x - 1)<0> :: return (Point(x = 1, y = 2).x - 1);<0>} :: top{} -heap: struct Point, fun
, -env: main: fun
, Point: struct Point, -} ---- handle value 2 with (x = 1, y = 2)<2>(1,2,) ---> -{ -stack: main{(x = 1@2, y = 2@3)<-1> :: Point(x = 1, y = 2)<1>(struct Point,) :: exp=>lval<-1> :: Point(x = 1, y = 2).x<0> :: (Point(x = 1, y = 2).x - 1)<0> :: return (Point(x = 1, y = 2).x - 1);<0>} :: top{} -heap: struct Point, fun
, 1, 2, -env: main: fun
, Point: struct Point, -} ---- handle value (x = 1@2, y = 2@3) with Point(x = 1, y = 2)<2>(struct Point,(x = 1@2, y = 2@3),) ---> -{ -stack: main{Point(x = 1@4, y = 2@5)<-1> :: exp=>lval<-1> :: Point(x = 1, y = 2).x<0> :: (Point(x = 1, y = 2).x - 1)<0> :: return (Point(x = 1, y = 2).x - 1);<0>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, -env: main: fun
, Point: struct Point, -} ---- handle value Point(x = 1@4, y = 2@5) with exp=>lval<0>(Point(x = 1@4, y = 2@5),) ---> -{ -stack: main{ptr<6><-1> :: Point(x = 1, y = 2).x<0> :: (Point(x = 1, y = 2).x - 1)<0> :: delete_tmp(6)<-1> :: return (Point(x = 1, y = 2).x - 1);<0>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, Point(x = 1@4, y = 2@5), -env: main: fun
, Point: struct Point, -} ---- handle value ptr<6> with Point(x = 1, y = 2).x<1>(ptr<6>,) ---> -{ -stack: main{1<-1> :: (Point(x = 1, y = 2).x - 1)<0> :: delete_tmp(6)<-1> :: return (Point(x = 1, y = 2).x - 1);<0>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, Point(x = 1@4, y = 2@5), -env: main: fun
, Point: struct Point, -} ---- handle value 1 with (Point(x = 1, y = 2).x - 1)<1>(1,) ---> -{ -stack: main{1<-1> :: (Point(x = 1, y = 2).x - 1)<1>(1,) :: delete_tmp(6)<-1> :: return (Point(x = 1, y = 2).x - 1);<0>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, Point(x = 1@4, y = 2@5), -env: main: fun
, Point: struct Point, -} ---- step exp 1 ---> -{ -stack: main{1<-1> :: (Point(x = 1, y = 2).x - 1)<1>(1,) :: delete_tmp(6)<-1> :: return (Point(x = 1, y = 2).x - 1);<0>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, Point(x = 1@4, y = 2@5), -env: main: fun
, Point: struct Point, -} ---- handle value 1 with (Point(x = 1, y = 2).x - 1)<2>(1,1,) ---> -{ -stack: main{0<-1> :: delete_tmp(6)<-1> :: return (Point(x = 1, y = 2).x - 1);<0>} :: top{} -heap: struct Point, fun
, 1, 2, 1, 2, Point(x = 1@4, y = 2@5), -env: main: fun
, Point: struct Point, -} ---- handle value 0 with delete_tmp(6)<0>(0,) ---> -{ -stack: main{0<-1> :: return (Point(x = 1, y = 2).x - 1);<0>} :: top{} -heap: struct Point, fun
, 1, 2, !!1, !!2, !!Point!!(x = !!1@4, y = !!2@5), -env: main: fun
, Point: struct Point, -} ---- handle value 0 with return (Point(x = 1, y = 2).x - 1);<1>(0,) ---> -{ -stack: top{0<-1>} -heap: struct Point, fun
, 1, 2, !!1, !!2, !!Point!!(x = !!1@4, y = !!2@5), -env: main: fun
, Point: struct Point, -} result: 0 diff --git a/executable_semantics/testdata/tuple1.golden b/executable_semantics/testdata/tuple1.golden index 12f4fca79183..2db2755da426 100644 --- a/executable_semantics/testdata/tuple1.golden +++ b/executable_semantics/testdata/tuple1.golden @@ -1,389 +1 @@ -********** source program ********** -fn main () -> Int { -var Int: x = 1; -var (0 = Int, 1 = Int): t2 = (0 = 5, 1 = 2); -t2[0] = 3; -return ((t2[0] - t2[1]) - x); - -} -********** type checking ********** ---- step exp Int ---> ---- step exp Int ---> ---- step exp Int ---> ---- step exp (0 = Int, 1 = Int) ---> ---- step exp Int ---> ---- handle value Int with (0 = Int, 1 = Int)<1>(Int,) ---> ---- step exp Int ---> ---- handle value Int with (0 = Int, 1 = Int)<2>(Int,Int,) ---> ---- step exp 0 ---> ---- step exp 0 ---> ---- step exp 1 ---> - -********** type checking complete ********** -fn main () -> Int { -var Int: x = 1; -var (0 = Int, 1 = Int): t2 = (0 = 5, 1 = 2); -t2[0] = 3; -return ((t2[0] - t2[1]) - x); -} -********** starting execution ********** -********** initializing globals ********** ---- step exp () ---> -********** calling main function ********** -{ -stack: top{main()<-1>} -heap: fun
, -env: main: fun
, -} ---- step exp main() ---> -{ -stack: top{main<-1> :: main()<0>} -heap: fun
, -env: main: fun
, -} ---- step exp main ---> -{ -stack: top{fun
<-1> :: main()<0>} -heap: fun
, -env: main: fun
, -} ---- handle value fun
with main()<1>(fun
,) ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: fun
, -env: main: fun
, -} ---- step exp () ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: fun
, -env: main: fun
, -} ---- handle value () with main()<2>(fun
,(),) ---> -pattern_match((), ()) -{ -stack: main{var Int: x = 1; ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step stmt var Int: x = 1; ... ---> -{ -stack: main{var Int: x = 1;<-1> :: var (0 = Int, 1 = Int): t2 = (0 = 5, 1 = 2); ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step stmt var Int: x = 1; ---> -{ -stack: main{1<-1> :: var Int: x = 1;<0> :: var (0 = Int, 1 = Int): t2 = (0 = 5, 1 = 2); ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp 1 ---> -{ -stack: main{1<-1> :: var Int: x = 1;<0> :: var (0 = Int, 1 = Int): t2 = (0 = 5, 1 = 2); ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value 1 with var Int: x = 1;<1>(1,) ---> -{ -stack: main{Int: x<-1> :: var Int: x = 1;<1>(1,) :: var (0 = Int, 1 = Int): t2 = (0 = 5, 1 = 2); ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp Int: x ---> -{ -stack: main{Int<-1> :: Int: x<0> :: var Int: x = 1;<1>(1,) :: var (0 = Int, 1 = Int): t2 = (0 = 5, 1 = 2); ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp Int ---> -{ -stack: main{Int<-1> :: Int: x<0> :: var Int: x = 1;<1>(1,) :: var (0 = Int, 1 = Int): t2 = (0 = 5, 1 = 2); ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value Int with Int: x<1>(Int,) ---> -{ -stack: main{Int: x<-1> :: var Int: x = 1;<1>(1,) :: var (0 = Int, 1 = Int): t2 = (0 = 5, 1 = 2); ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value Int: x with var Int: x = 1;<2>(1,Int: x,) ---> -pattern_match(Int: x, 1) -{ -stack: main{var (0 = Int, 1 = Int): t2 = (0 = 5, 1 = 2); ... <-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- step stmt var (0 = Int, 1 = Int): t2 = (0 = 5, 1 = 2); ... ---> -{ -stack: main{var (0 = Int, 1 = Int): t2 = (0 = 5, 1 = 2);<-1> :: t2[0] = 3; ... <-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- step stmt var (0 = Int, 1 = Int): t2 = (0 = 5, 1 = 2); ---> -{ -stack: main{(0 = 5, 1 = 2)<-1> :: var (0 = Int, 1 = Int): t2 = (0 = 5, 1 = 2);<0> :: t2[0] = 3; ... <-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- step exp (0 = 5, 1 = 2) ---> -{ -stack: main{5<-1> :: (0 = 5, 1 = 2)<0> :: var (0 = Int, 1 = Int): t2 = (0 = 5, 1 = 2);<0> :: t2[0] = 3; ... <-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- step exp 5 ---> -{ -stack: main{5<-1> :: (0 = 5, 1 = 2)<0> :: var (0 = Int, 1 = Int): t2 = (0 = 5, 1 = 2);<0> :: t2[0] = 3; ... <-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- handle value 5 with (0 = 5, 1 = 2)<1>(5,) ---> -{ -stack: main{2<-1> :: (0 = 5, 1 = 2)<1>(5,) :: var (0 = Int, 1 = Int): t2 = (0 = 5, 1 = 2);<0> :: t2[0] = 3; ... <-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- step exp 2 ---> -{ -stack: main{2<-1> :: (0 = 5, 1 = 2)<1>(5,) :: var (0 = Int, 1 = Int): t2 = (0 = 5, 1 = 2);<0> :: t2[0] = 3; ... <-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- handle value 2 with (0 = 5, 1 = 2)<2>(5,2,) ---> -{ -stack: main{(0 = 5@2, 1 = 2@3)<-1> :: var (0 = Int, 1 = Int): t2 = (0 = 5, 1 = 2);<0> :: t2[0] = 3; ... <-1>} :: top{} -heap: fun
, 1, 5, 2, -env: x: 1, main: fun
, -} ---- handle value (0 = 5@2, 1 = 2@3) with var (0 = Int, 1 = Int): t2 = (0 = 5, 1 = 2);<1>((0 = 5@2, 1 = 2@3),) ---> -{ -stack: main{(0 = Int, 1 = Int): t2<-1> :: var (0 = Int, 1 = Int): t2 = (0 = 5, 1 = 2);<1>((0 = 5@2, 1 = 2@3),) :: t2[0] = 3; ... <-1>} :: top{} -heap: fun
, 1, 5, 2, -env: x: 1, main: fun
, -} ---- step exp (0 = Int, 1 = Int): t2 ---> -{ -stack: main{(0 = Int, 1 = Int)<-1> :: (0 = Int, 1 = Int): t2<0> :: var (0 = Int, 1 = Int): t2 = (0 = 5, 1 = 2);<1>((0 = 5@2, 1 = 2@3),) :: t2[0] = 3; ... <-1>} :: top{} -heap: fun
, 1, 5, 2, -env: x: 1, main: fun
, -} ---- step exp (0 = Int, 1 = Int) ---> -{ -stack: main{Int<-1> :: (0 = Int, 1 = Int)<0> :: (0 = Int, 1 = Int): t2<0> :: var (0 = Int, 1 = Int): t2 = (0 = 5, 1 = 2);<1>((0 = 5@2, 1 = 2@3),) :: t2[0] = 3; ... <-1>} :: top{} -heap: fun
, 1, 5, 2, -env: x: 1, main: fun
, -} ---- step exp Int ---> -{ -stack: main{Int<-1> :: (0 = Int, 1 = Int)<0> :: (0 = Int, 1 = Int): t2<0> :: var (0 = Int, 1 = Int): t2 = (0 = 5, 1 = 2);<1>((0 = 5@2, 1 = 2@3),) :: t2[0] = 3; ... <-1>} :: top{} -heap: fun
, 1, 5, 2, -env: x: 1, main: fun
, -} ---- handle value Int with (0 = Int, 1 = Int)<1>(Int,) ---> -{ -stack: main{Int<-1> :: (0 = Int, 1 = Int)<1>(Int,) :: (0 = Int, 1 = Int): t2<0> :: var (0 = Int, 1 = Int): t2 = (0 = 5, 1 = 2);<1>((0 = 5@2, 1 = 2@3),) :: t2[0] = 3; ... <-1>} :: top{} -heap: fun
, 1, 5, 2, -env: x: 1, main: fun
, -} ---- step exp Int ---> -{ -stack: main{Int<-1> :: (0 = Int, 1 = Int)<1>(Int,) :: (0 = Int, 1 = Int): t2<0> :: var (0 = Int, 1 = Int): t2 = (0 = 5, 1 = 2);<1>((0 = 5@2, 1 = 2@3),) :: t2[0] = 3; ... <-1>} :: top{} -heap: fun
, 1, 5, 2, -env: x: 1, main: fun
, -} ---- handle value Int with (0 = Int, 1 = Int)<2>(Int,Int,) ---> -{ -stack: main{(0 = Int@4, 1 = Int@5)<-1> :: (0 = Int, 1 = Int): t2<0> :: var (0 = Int, 1 = Int): t2 = (0 = 5, 1 = 2);<1>((0 = 5@2, 1 = 2@3),) :: t2[0] = 3; ... <-1>} :: top{} -heap: fun
, 1, 5, 2, Int, Int, -env: x: 1, main: fun
, -} ---- handle value (0 = Int@4, 1 = Int@5) with (0 = Int, 1 = Int): t2<1>((0 = Int@4, 1 = Int@5),) ---> -{ -stack: main{(0 = Int@4, 1 = Int@5): t2<-1> :: var (0 = Int, 1 = Int): t2 = (0 = 5, 1 = 2);<1>((0 = 5@2, 1 = 2@3),) :: t2[0] = 3; ... <-1>} :: top{} -heap: fun
, 1, 5, 2, Int, Int, -env: x: 1, main: fun
, -} ---- handle value (0 = Int@4, 1 = Int@5): t2 with var (0 = Int, 1 = Int): t2 = (0 = 5, 1 = 2);<2>((0 = 5@2, 1 = 2@3),(0 = Int@4, 1 = Int@5): t2,) ---> -pattern_match((0 = Int@4, 1 = Int@5): t2, (0 = 5@2, 1 = 2@3)) -{ -stack: main{t2[0] = 3; ... <-1>} :: top{} -heap: fun
, 1, 5, 2, Int, Int, 5, 2, (0 = 5@6, 1 = 2@7), -env: t2: (0 = 5@6, 1 = 2@7), x: 1, main: fun
, -} ---- step stmt t2[0] = 3; ... ---> -{ -stack: main{t2[0] = 3;<-1> :: return ((t2[0] - t2[1]) - x);<-1>} :: top{} -heap: fun
, 1, 5, 2, Int, Int, 5, 2, (0 = 5@6, 1 = 2@7), -env: t2: (0 = 5@6, 1 = 2@7), x: 1, main: fun
, -} ---- step stmt t2[0] = 3; ---> -{ -stack: main{t2[0]<-1> :: t2[0] = 3;<0> :: return ((t2[0] - t2[1]) - x);<-1>} :: top{} -heap: fun
, 1, 5, 2, Int, Int, 5, 2, (0 = 5@6, 1 = 2@7), -env: t2: (0 = 5@6, 1 = 2@7), x: 1, main: fun
, -} ---- step lvalue t2[0] ---> -{ -stack: main{t2<-1> :: t2[0]<0> :: t2[0] = 3;<0> :: return ((t2[0] - t2[1]) - x);<-1>} :: top{} -heap: fun
, 1, 5, 2, Int, Int, 5, 2, (0 = 5@6, 1 = 2@7), -env: t2: (0 = 5@6, 1 = 2@7), x: 1, main: fun
, -} ---- step exp t2 ---> -{ -stack: main{(0 = 5@6, 1 = 2@7)<-1> :: t2[0]<0> :: t2[0] = 3;<0> :: return ((t2[0] - t2[1]) - x);<-1>} :: top{} -heap: fun
, 1, 5, 2, Int, Int, 5, 2, (0 = 5@6, 1 = 2@7), -env: t2: (0 = 5@6, 1 = 2@7), x: 1, main: fun
, -} ---- handle value (0 = 5@6, 1 = 2@7) with t2[0]<1>((0 = 5@6, 1 = 2@7),) ---> -{ -stack: main{0<-1> :: t2[0]<1>((0 = 5@6, 1 = 2@7),) :: t2[0] = 3;<0> :: return ((t2[0] - t2[1]) - x);<-1>} :: top{} -heap: fun
, 1, 5, 2, Int, Int, 5, 2, (0 = 5@6, 1 = 2@7), -env: t2: (0 = 5@6, 1 = 2@7), x: 1, main: fun
, -} ---- step exp 0 ---> -{ -stack: main{0<-1> :: t2[0]<1>((0 = 5@6, 1 = 2@7),) :: t2[0] = 3;<0> :: return ((t2[0] - t2[1]) - x);<-1>} :: top{} -heap: fun
, 1, 5, 2, Int, Int, 5, 2, (0 = 5@6, 1 = 2@7), -env: t2: (0 = 5@6, 1 = 2@7), x: 1, main: fun
, -} ---- handle value 0 with t2[0]<2>((0 = 5@6, 1 = 2@7),0,) ---> -{ -stack: main{ptr<6><-1> :: t2[0] = 3;<0> :: return ((t2[0] - t2[1]) - x);<-1>} :: top{} -heap: fun
, 1, 5, 2, Int, Int, 5, 2, (0 = 5@6, 1 = 2@7), -env: t2: (0 = 5@6, 1 = 2@7), x: 1, main: fun
, -} ---- handle value ptr<6> with t2[0] = 3;<1>(ptr<6>,) ---> -{ -stack: main{3<-1> :: t2[0] = 3;<1>(ptr<6>,) :: return ((t2[0] - t2[1]) - x);<-1>} :: top{} -heap: fun
, 1, 5, 2, Int, Int, 5, 2, (0 = 5@6, 1 = 2@7), -env: t2: (0 = 5@6, 1 = 2@7), x: 1, main: fun
, -} ---- step exp 3 ---> -{ -stack: main{3<-1> :: t2[0] = 3;<1>(ptr<6>,) :: return ((t2[0] - t2[1]) - x);<-1>} :: top{} -heap: fun
, 1, 5, 2, Int, Int, 5, 2, (0 = 5@6, 1 = 2@7), -env: t2: (0 = 5@6, 1 = 2@7), x: 1, main: fun
, -} ---- handle value 3 with t2[0] = 3;<2>(ptr<6>,3,) ---> -{ -stack: main{return ((t2[0] - t2[1]) - x);<-1>} :: top{} -heap: fun
, 1, 5, 2, Int, Int, 3, 2, (0 = 3@6, 1 = 2@7), -env: t2: (0 = 3@6, 1 = 2@7), x: 1, main: fun
, -} ---- step stmt return ((t2[0] - t2[1]) - x); ---> -{ -stack: main{((t2[0] - t2[1]) - x)<-1> :: return ((t2[0] - t2[1]) - x);<0>} :: top{} -heap: fun
, 1, 5, 2, Int, Int, 3, 2, (0 = 3@6, 1 = 2@7), -env: t2: (0 = 3@6, 1 = 2@7), x: 1, main: fun
, -} ---- step exp ((t2[0] - t2[1]) - x) ---> -{ -stack: main{(t2[0] - t2[1])<-1> :: ((t2[0] - t2[1]) - x)<0> :: return ((t2[0] - t2[1]) - x);<0>} :: top{} -heap: fun
, 1, 5, 2, Int, Int, 3, 2, (0 = 3@6, 1 = 2@7), -env: t2: (0 = 3@6, 1 = 2@7), x: 1, main: fun
, -} ---- step exp (t2[0] - t2[1]) ---> -{ -stack: main{t2[0]<-1> :: (t2[0] - t2[1])<0> :: ((t2[0] - t2[1]) - x)<0> :: return ((t2[0] - t2[1]) - x);<0>} :: top{} -heap: fun
, 1, 5, 2, Int, Int, 3, 2, (0 = 3@6, 1 = 2@7), -env: t2: (0 = 3@6, 1 = 2@7), x: 1, main: fun
, -} ---- step exp t2[0] ---> -{ -stack: main{t2<-1> :: t2[0]<0> :: (t2[0] - t2[1])<0> :: ((t2[0] - t2[1]) - x)<0> :: return ((t2[0] - t2[1]) - x);<0>} :: top{} -heap: fun
, 1, 5, 2, Int, Int, 3, 2, (0 = 3@6, 1 = 2@7), -env: t2: (0 = 3@6, 1 = 2@7), x: 1, main: fun
, -} ---- step exp t2 ---> -{ -stack: main{(0 = 3@6, 1 = 2@7)<-1> :: t2[0]<0> :: (t2[0] - t2[1])<0> :: ((t2[0] - t2[1]) - x)<0> :: return ((t2[0] - t2[1]) - x);<0>} :: top{} -heap: fun
, 1, 5, 2, Int, Int, 3, 2, (0 = 3@6, 1 = 2@7), -env: t2: (0 = 3@6, 1 = 2@7), x: 1, main: fun
, -} ---- handle value (0 = 3@6, 1 = 2@7) with t2[0]<1>((0 = 3@6, 1 = 2@7),) ---> -{ -stack: main{0<-1> :: t2[0]<1>((0 = 3@6, 1 = 2@7),) :: (t2[0] - t2[1])<0> :: ((t2[0] - t2[1]) - x)<0> :: return ((t2[0] - t2[1]) - x);<0>} :: top{} -heap: fun
, 1, 5, 2, Int, Int, 3, 2, (0 = 3@6, 1 = 2@7), -env: t2: (0 = 3@6, 1 = 2@7), x: 1, main: fun
, -} ---- step exp 0 ---> -{ -stack: main{0<-1> :: t2[0]<1>((0 = 3@6, 1 = 2@7),) :: (t2[0] - t2[1])<0> :: ((t2[0] - t2[1]) - x)<0> :: return ((t2[0] - t2[1]) - x);<0>} :: top{} -heap: fun
, 1, 5, 2, Int, Int, 3, 2, (0 = 3@6, 1 = 2@7), -env: t2: (0 = 3@6, 1 = 2@7), x: 1, main: fun
, -} ---- handle value 0 with t2[0]<2>((0 = 3@6, 1 = 2@7),0,) ---> -{ -stack: main{3<-1> :: (t2[0] - t2[1])<0> :: ((t2[0] - t2[1]) - x)<0> :: return ((t2[0] - t2[1]) - x);<0>} :: top{} -heap: fun
, 1, 5, 2, Int, Int, 3, 2, (0 = 3@6, 1 = 2@7), -env: t2: (0 = 3@6, 1 = 2@7), x: 1, main: fun
, -} ---- handle value 3 with (t2[0] - t2[1])<1>(3,) ---> -{ -stack: main{t2[1]<-1> :: (t2[0] - t2[1])<1>(3,) :: ((t2[0] - t2[1]) - x)<0> :: return ((t2[0] - t2[1]) - x);<0>} :: top{} -heap: fun
, 1, 5, 2, Int, Int, 3, 2, (0 = 3@6, 1 = 2@7), -env: t2: (0 = 3@6, 1 = 2@7), x: 1, main: fun
, -} ---- step exp t2[1] ---> -{ -stack: main{t2<-1> :: t2[1]<0> :: (t2[0] - t2[1])<1>(3,) :: ((t2[0] - t2[1]) - x)<0> :: return ((t2[0] - t2[1]) - x);<0>} :: top{} -heap: fun
, 1, 5, 2, Int, Int, 3, 2, (0 = 3@6, 1 = 2@7), -env: t2: (0 = 3@6, 1 = 2@7), x: 1, main: fun
, -} ---- step exp t2 ---> -{ -stack: main{(0 = 3@6, 1 = 2@7)<-1> :: t2[1]<0> :: (t2[0] - t2[1])<1>(3,) :: ((t2[0] - t2[1]) - x)<0> :: return ((t2[0] - t2[1]) - x);<0>} :: top{} -heap: fun
, 1, 5, 2, Int, Int, 3, 2, (0 = 3@6, 1 = 2@7), -env: t2: (0 = 3@6, 1 = 2@7), x: 1, main: fun
, -} ---- handle value (0 = 3@6, 1 = 2@7) with t2[1]<1>((0 = 3@6, 1 = 2@7),) ---> -{ -stack: main{1<-1> :: t2[1]<1>((0 = 3@6, 1 = 2@7),) :: (t2[0] - t2[1])<1>(3,) :: ((t2[0] - t2[1]) - x)<0> :: return ((t2[0] - t2[1]) - x);<0>} :: top{} -heap: fun
, 1, 5, 2, Int, Int, 3, 2, (0 = 3@6, 1 = 2@7), -env: t2: (0 = 3@6, 1 = 2@7), x: 1, main: fun
, -} ---- step exp 1 ---> -{ -stack: main{1<-1> :: t2[1]<1>((0 = 3@6, 1 = 2@7),) :: (t2[0] - t2[1])<1>(3,) :: ((t2[0] - t2[1]) - x)<0> :: return ((t2[0] - t2[1]) - x);<0>} :: top{} -heap: fun
, 1, 5, 2, Int, Int, 3, 2, (0 = 3@6, 1 = 2@7), -env: t2: (0 = 3@6, 1 = 2@7), x: 1, main: fun
, -} ---- handle value 1 with t2[1]<2>((0 = 3@6, 1 = 2@7),1,) ---> -{ -stack: main{2<-1> :: (t2[0] - t2[1])<1>(3,) :: ((t2[0] - t2[1]) - x)<0> :: return ((t2[0] - t2[1]) - x);<0>} :: top{} -heap: fun
, 1, 5, 2, Int, Int, 3, 2, (0 = 3@6, 1 = 2@7), -env: t2: (0 = 3@6, 1 = 2@7), x: 1, main: fun
, -} ---- handle value 2 with (t2[0] - t2[1])<2>(3,2,) ---> -{ -stack: main{1<-1> :: ((t2[0] - t2[1]) - x)<0> :: return ((t2[0] - t2[1]) - x);<0>} :: top{} -heap: fun
, 1, 5, 2, Int, Int, 3, 2, (0 = 3@6, 1 = 2@7), -env: t2: (0 = 3@6, 1 = 2@7), x: 1, main: fun
, -} ---- handle value 1 with ((t2[0] - t2[1]) - x)<1>(1,) ---> -{ -stack: main{x<-1> :: ((t2[0] - t2[1]) - x)<1>(1,) :: return ((t2[0] - t2[1]) - x);<0>} :: top{} -heap: fun
, 1, 5, 2, Int, Int, 3, 2, (0 = 3@6, 1 = 2@7), -env: t2: (0 = 3@6, 1 = 2@7), x: 1, main: fun
, -} ---- step exp x ---> -{ -stack: main{1<-1> :: ((t2[0] - t2[1]) - x)<1>(1,) :: return ((t2[0] - t2[1]) - x);<0>} :: top{} -heap: fun
, 1, 5, 2, Int, Int, 3, 2, (0 = 3@6, 1 = 2@7), -env: t2: (0 = 3@6, 1 = 2@7), x: 1, main: fun
, -} ---- handle value 1 with ((t2[0] - t2[1]) - x)<2>(1,1,) ---> -{ -stack: main{0<-1> :: return ((t2[0] - t2[1]) - x);<0>} :: top{} -heap: fun
, 1, 5, 2, Int, Int, 3, 2, (0 = 3@6, 1 = 2@7), -env: t2: (0 = 3@6, 1 = 2@7), x: 1, main: fun
, -} ---- handle value 0 with return ((t2[0] - t2[1]) - x);<1>(0,) ---> -{ -stack: top{0<-1>} -heap: fun
, !!1, 5, 2, Int, Int, !!3, !!2, !!(0 = !!3@6, 1 = !!2@7), -env: main: fun
, -} result: 0 diff --git a/executable_semantics/testdata/tuple2.golden b/executable_semantics/testdata/tuple2.golden index d16e910b368a..2db2755da426 100644 --- a/executable_semantics/testdata/tuple2.golden +++ b/executable_semantics/testdata/tuple2.golden @@ -1,199 +1 @@ -********** source program ********** -fn main () -> Int { -var (0 = Int): t = (0 = 5); -return (t[0] - 5); - -} -********** type checking ********** ---- step exp Int ---> ---- step exp Int ---> ---- step exp (0 = Int) ---> ---- step exp Int ---> ---- handle value Int with (0 = Int)<1>(Int,) ---> ---- step exp 0 ---> - -********** type checking complete ********** -fn main () -> Int { -var (0 = Int): t = (0 = 5); -return (t[0] - 5); -} -********** starting execution ********** -********** initializing globals ********** ---- step exp () ---> -********** calling main function ********** -{ -stack: top{main()<-1>} -heap: fun
, -env: main: fun
, -} ---- step exp main() ---> -{ -stack: top{main<-1> :: main()<0>} -heap: fun
, -env: main: fun
, -} ---- step exp main ---> -{ -stack: top{fun
<-1> :: main()<0>} -heap: fun
, -env: main: fun
, -} ---- handle value fun
with main()<1>(fun
,) ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: fun
, -env: main: fun
, -} ---- step exp () ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: fun
, -env: main: fun
, -} ---- handle value () with main()<2>(fun
,(),) ---> -pattern_match((), ()) -{ -stack: main{var (0 = Int): t = (0 = 5); ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step stmt var (0 = Int): t = (0 = 5); ... ---> -{ -stack: main{var (0 = Int): t = (0 = 5);<-1> :: return (t[0] - 5);<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step stmt var (0 = Int): t = (0 = 5); ---> -{ -stack: main{(0 = 5)<-1> :: var (0 = Int): t = (0 = 5);<0> :: return (t[0] - 5);<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp (0 = 5) ---> -{ -stack: main{5<-1> :: (0 = 5)<0> :: var (0 = Int): t = (0 = 5);<0> :: return (t[0] - 5);<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp 5 ---> -{ -stack: main{5<-1> :: (0 = 5)<0> :: var (0 = Int): t = (0 = 5);<0> :: return (t[0] - 5);<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value 5 with (0 = 5)<1>(5,) ---> -{ -stack: main{(0 = 5@1)<-1> :: var (0 = Int): t = (0 = 5);<0> :: return (t[0] - 5);<-1>} :: top{} -heap: fun
, 5, -env: main: fun
, -} ---- handle value (0 = 5@1) with var (0 = Int): t = (0 = 5);<1>((0 = 5@1),) ---> -{ -stack: main{(0 = Int): t<-1> :: var (0 = Int): t = (0 = 5);<1>((0 = 5@1),) :: return (t[0] - 5);<-1>} :: top{} -heap: fun
, 5, -env: main: fun
, -} ---- step exp (0 = Int): t ---> -{ -stack: main{(0 = Int)<-1> :: (0 = Int): t<0> :: var (0 = Int): t = (0 = 5);<1>((0 = 5@1),) :: return (t[0] - 5);<-1>} :: top{} -heap: fun
, 5, -env: main: fun
, -} ---- step exp (0 = Int) ---> -{ -stack: main{Int<-1> :: (0 = Int)<0> :: (0 = Int): t<0> :: var (0 = Int): t = (0 = 5);<1>((0 = 5@1),) :: return (t[0] - 5);<-1>} :: top{} -heap: fun
, 5, -env: main: fun
, -} ---- step exp Int ---> -{ -stack: main{Int<-1> :: (0 = Int)<0> :: (0 = Int): t<0> :: var (0 = Int): t = (0 = 5);<1>((0 = 5@1),) :: return (t[0] - 5);<-1>} :: top{} -heap: fun
, 5, -env: main: fun
, -} ---- handle value Int with (0 = Int)<1>(Int,) ---> -{ -stack: main{(0 = Int@2)<-1> :: (0 = Int): t<0> :: var (0 = Int): t = (0 = 5);<1>((0 = 5@1),) :: return (t[0] - 5);<-1>} :: top{} -heap: fun
, 5, Int, -env: main: fun
, -} ---- handle value (0 = Int@2) with (0 = Int): t<1>((0 = Int@2),) ---> -{ -stack: main{(0 = Int@2): t<-1> :: var (0 = Int): t = (0 = 5);<1>((0 = 5@1),) :: return (t[0] - 5);<-1>} :: top{} -heap: fun
, 5, Int, -env: main: fun
, -} ---- handle value (0 = Int@2): t with var (0 = Int): t = (0 = 5);<2>((0 = 5@1),(0 = Int@2): t,) ---> -pattern_match((0 = Int@2): t, (0 = 5@1)) -{ -stack: main{return (t[0] - 5);<-1>} :: top{} -heap: fun
, 5, Int, 5, (0 = 5@3), -env: t: (0 = 5@3), main: fun
, -} ---- step stmt return (t[0] - 5); ---> -{ -stack: main{(t[0] - 5)<-1> :: return (t[0] - 5);<0>} :: top{} -heap: fun
, 5, Int, 5, (0 = 5@3), -env: t: (0 = 5@3), main: fun
, -} ---- step exp (t[0] - 5) ---> -{ -stack: main{t[0]<-1> :: (t[0] - 5)<0> :: return (t[0] - 5);<0>} :: top{} -heap: fun
, 5, Int, 5, (0 = 5@3), -env: t: (0 = 5@3), main: fun
, -} ---- step exp t[0] ---> -{ -stack: main{t<-1> :: t[0]<0> :: (t[0] - 5)<0> :: return (t[0] - 5);<0>} :: top{} -heap: fun
, 5, Int, 5, (0 = 5@3), -env: t: (0 = 5@3), main: fun
, -} ---- step exp t ---> -{ -stack: main{(0 = 5@3)<-1> :: t[0]<0> :: (t[0] - 5)<0> :: return (t[0] - 5);<0>} :: top{} -heap: fun
, 5, Int, 5, (0 = 5@3), -env: t: (0 = 5@3), main: fun
, -} ---- handle value (0 = 5@3) with t[0]<1>((0 = 5@3),) ---> -{ -stack: main{0<-1> :: t[0]<1>((0 = 5@3),) :: (t[0] - 5)<0> :: return (t[0] - 5);<0>} :: top{} -heap: fun
, 5, Int, 5, (0 = 5@3), -env: t: (0 = 5@3), main: fun
, -} ---- step exp 0 ---> -{ -stack: main{0<-1> :: t[0]<1>((0 = 5@3),) :: (t[0] - 5)<0> :: return (t[0] - 5);<0>} :: top{} -heap: fun
, 5, Int, 5, (0 = 5@3), -env: t: (0 = 5@3), main: fun
, -} ---- handle value 0 with t[0]<2>((0 = 5@3),0,) ---> -{ -stack: main{5<-1> :: (t[0] - 5)<0> :: return (t[0] - 5);<0>} :: top{} -heap: fun
, 5, Int, 5, (0 = 5@3), -env: t: (0 = 5@3), main: fun
, -} ---- handle value 5 with (t[0] - 5)<1>(5,) ---> -{ -stack: main{5<-1> :: (t[0] - 5)<1>(5,) :: return (t[0] - 5);<0>} :: top{} -heap: fun
, 5, Int, 5, (0 = 5@3), -env: t: (0 = 5@3), main: fun
, -} ---- step exp 5 ---> -{ -stack: main{5<-1> :: (t[0] - 5)<1>(5,) :: return (t[0] - 5);<0>} :: top{} -heap: fun
, 5, Int, 5, (0 = 5@3), -env: t: (0 = 5@3), main: fun
, -} ---- handle value 5 with (t[0] - 5)<2>(5,5,) ---> -{ -stack: main{0<-1> :: return (t[0] - 5);<0>} :: top{} -heap: fun
, 5, Int, 5, (0 = 5@3), -env: t: (0 = 5@3), main: fun
, -} ---- handle value 0 with return (t[0] - 5);<1>(0,) ---> -{ -stack: top{0<-1>} -heap: fun
, 5, Int, !!5, !!(0 = !!5@3), -env: main: fun
, -} result: 0 diff --git a/executable_semantics/testdata/tuple_assign.golden b/executable_semantics/testdata/tuple_assign.golden index ac471eac4ff2..2db2755da426 100644 --- a/executable_semantics/testdata/tuple_assign.golden +++ b/executable_semantics/testdata/tuple_assign.golden @@ -1,298 +1 @@ -********** source program ********** -fn main () -> Int { -var auto: x = 0; -var auto: y = 1; -(0 = x, 1 = y) = (0 = 5, 1 = (- 5)); -return (x + y); - -} -********** type checking ********** ---- step exp Int ---> ---- step exp Int ---> ---- step exp auto ---> ---- step exp auto ---> - -********** type checking complete ********** -fn main () -> Int { -var auto: x = 0; -var auto: y = 1; -(0 = x, 1 = y) = (0 = 5, 1 = (- 5)); -return (x + y); -} -********** starting execution ********** -********** initializing globals ********** ---- step exp () ---> -********** calling main function ********** -{ -stack: top{main()<-1>} -heap: fun
, -env: main: fun
, -} ---- step exp main() ---> -{ -stack: top{main<-1> :: main()<0>} -heap: fun
, -env: main: fun
, -} ---- step exp main ---> -{ -stack: top{fun
<-1> :: main()<0>} -heap: fun
, -env: main: fun
, -} ---- handle value fun
with main()<1>(fun
,) ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: fun
, -env: main: fun
, -} ---- step exp () ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: fun
, -env: main: fun
, -} ---- handle value () with main()<2>(fun
,(),) ---> -pattern_match((), ()) -{ -stack: main{var auto: x = 0; ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step stmt var auto: x = 0; ... ---> -{ -stack: main{var auto: x = 0;<-1> :: var auto: y = 1; ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step stmt var auto: x = 0; ---> -{ -stack: main{0<-1> :: var auto: x = 0;<0> :: var auto: y = 1; ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp 0 ---> -{ -stack: main{0<-1> :: var auto: x = 0;<0> :: var auto: y = 1; ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value 0 with var auto: x = 0;<1>(0,) ---> -{ -stack: main{auto: x<-1> :: var auto: x = 0;<1>(0,) :: var auto: y = 1; ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp auto: x ---> -{ -stack: main{auto<-1> :: auto: x<0> :: var auto: x = 0;<1>(0,) :: var auto: y = 1; ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp auto ---> -{ -stack: main{auto<-1> :: auto: x<0> :: var auto: x = 0;<1>(0,) :: var auto: y = 1; ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value auto with auto: x<1>(auto,) ---> -{ -stack: main{auto: x<-1> :: var auto: x = 0;<1>(0,) :: var auto: y = 1; ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value auto: x with var auto: x = 0;<2>(0,auto: x,) ---> -pattern_match(auto: x, 0) -{ -stack: main{var auto: y = 1; ... <-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- step stmt var auto: y = 1; ... ---> -{ -stack: main{var auto: y = 1;<-1> :: (0 = x, 1 = y) = (0 = 5, 1 = (- 5)); ... <-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- step stmt var auto: y = 1; ---> -{ -stack: main{1<-1> :: var auto: y = 1;<0> :: (0 = x, 1 = y) = (0 = 5, 1 = (- 5)); ... <-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- step exp 1 ---> -{ -stack: main{1<-1> :: var auto: y = 1;<0> :: (0 = x, 1 = y) = (0 = 5, 1 = (- 5)); ... <-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- handle value 1 with var auto: y = 1;<1>(1,) ---> -{ -stack: main{auto: y<-1> :: var auto: y = 1;<1>(1,) :: (0 = x, 1 = y) = (0 = 5, 1 = (- 5)); ... <-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- step exp auto: y ---> -{ -stack: main{auto<-1> :: auto: y<0> :: var auto: y = 1;<1>(1,) :: (0 = x, 1 = y) = (0 = 5, 1 = (- 5)); ... <-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- step exp auto ---> -{ -stack: main{auto<-1> :: auto: y<0> :: var auto: y = 1;<1>(1,) :: (0 = x, 1 = y) = (0 = 5, 1 = (- 5)); ... <-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- handle value auto with auto: y<1>(auto,) ---> -{ -stack: main{auto: y<-1> :: var auto: y = 1;<1>(1,) :: (0 = x, 1 = y) = (0 = 5, 1 = (- 5)); ... <-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- handle value auto: y with var auto: y = 1;<2>(1,auto: y,) ---> -pattern_match(auto: y, 1) -{ -stack: main{(0 = x, 1 = y) = (0 = 5, 1 = (- 5)); ... <-1>} :: top{} -heap: fun
, 0, 1, -env: y: 1, x: 0, main: fun
, -} ---- step stmt (0 = x, 1 = y) = (0 = 5, 1 = (- 5)); ... ---> -{ -stack: main{(0 = x, 1 = y) = (0 = 5, 1 = (- 5));<-1> :: return (x + y);<-1>} :: top{} -heap: fun
, 0, 1, -env: y: 1, x: 0, main: fun
, -} ---- step stmt (0 = x, 1 = y) = (0 = 5, 1 = (- 5)); ---> -{ -stack: main{(0 = x, 1 = y)<-1> :: (0 = x, 1 = y) = (0 = 5, 1 = (- 5));<0> :: return (x + y);<-1>} :: top{} -heap: fun
, 0, 1, -env: y: 1, x: 0, main: fun
, -} ---- step lvalue (0 = x, 1 = y) ---> -{ -stack: main{x<-1> :: (0 = x, 1 = y)<0> :: (0 = x, 1 = y) = (0 = 5, 1 = (- 5));<0> :: return (x + y);<-1>} :: top{} -heap: fun
, 0, 1, -env: y: 1, x: 0, main: fun
, -} ---- step lvalue x ---> -{ -stack: main{ptr<1><-1> :: (0 = x, 1 = y)<0> :: (0 = x, 1 = y) = (0 = 5, 1 = (- 5));<0> :: return (x + y);<-1>} :: top{} -heap: fun
, 0, 1, -env: y: 1, x: 0, main: fun
, -} ---- handle value ptr<1> with (0 = x, 1 = y)<1>(ptr<1>,) ---> -{ -stack: main{y<-1> :: (0 = x, 1 = y)<1>(ptr<1>,) :: (0 = x, 1 = y) = (0 = 5, 1 = (- 5));<0> :: return (x + y);<-1>} :: top{} -heap: fun
, 0, 1, -env: y: 1, x: 0, main: fun
, -} ---- step lvalue y ---> -{ -stack: main{ptr<2><-1> :: (0 = x, 1 = y)<1>(ptr<1>,) :: (0 = x, 1 = y) = (0 = 5, 1 = (- 5));<0> :: return (x + y);<-1>} :: top{} -heap: fun
, 0, 1, -env: y: 1, x: 0, main: fun
, -} ---- handle value ptr<2> with (0 = x, 1 = y)<2>(ptr<1>,ptr<2>,) ---> -{ -stack: main{(0 = ptr<1>@3, 1 = ptr<2>@4)<-1> :: (0 = x, 1 = y) = (0 = 5, 1 = (- 5));<0> :: return (x + y);<-1>} :: top{} -heap: fun
, 0, 1, ptr<1>, ptr<2>, -env: y: 1, x: 0, main: fun
, -} ---- handle value (0 = ptr<1>@3, 1 = ptr<2>@4) with (0 = x, 1 = y) = (0 = 5, 1 = (- 5));<1>((0 = ptr<1>@3, 1 = ptr<2>@4),) ---> -{ -stack: main{(0 = 5, 1 = (- 5))<-1> :: (0 = x, 1 = y) = (0 = 5, 1 = (- 5));<1>((0 = ptr<1>@3, 1 = ptr<2>@4),) :: return (x + y);<-1>} :: top{} -heap: fun
, 0, 1, ptr<1>, ptr<2>, -env: y: 1, x: 0, main: fun
, -} ---- step exp (0 = 5, 1 = (- 5)) ---> -{ -stack: main{5<-1> :: (0 = 5, 1 = (- 5))<0> :: (0 = x, 1 = y) = (0 = 5, 1 = (- 5));<1>((0 = ptr<1>@3, 1 = ptr<2>@4),) :: return (x + y);<-1>} :: top{} -heap: fun
, 0, 1, ptr<1>, ptr<2>, -env: y: 1, x: 0, main: fun
, -} ---- step exp 5 ---> -{ -stack: main{5<-1> :: (0 = 5, 1 = (- 5))<0> :: (0 = x, 1 = y) = (0 = 5, 1 = (- 5));<1>((0 = ptr<1>@3, 1 = ptr<2>@4),) :: return (x + y);<-1>} :: top{} -heap: fun
, 0, 1, ptr<1>, ptr<2>, -env: y: 1, x: 0, main: fun
, -} ---- handle value 5 with (0 = 5, 1 = (- 5))<1>(5,) ---> -{ -stack: main{(- 5)<-1> :: (0 = 5, 1 = (- 5))<1>(5,) :: (0 = x, 1 = y) = (0 = 5, 1 = (- 5));<1>((0 = ptr<1>@3, 1 = ptr<2>@4),) :: return (x + y);<-1>} :: top{} -heap: fun
, 0, 1, ptr<1>, ptr<2>, -env: y: 1, x: 0, main: fun
, -} ---- step exp (- 5) ---> -{ -stack: main{5<-1> :: (- 5)<0> :: (0 = 5, 1 = (- 5))<1>(5,) :: (0 = x, 1 = y) = (0 = 5, 1 = (- 5));<1>((0 = ptr<1>@3, 1 = ptr<2>@4),) :: return (x + y);<-1>} :: top{} -heap: fun
, 0, 1, ptr<1>, ptr<2>, -env: y: 1, x: 0, main: fun
, -} ---- step exp 5 ---> -{ -stack: main{5<-1> :: (- 5)<0> :: (0 = 5, 1 = (- 5))<1>(5,) :: (0 = x, 1 = y) = (0 = 5, 1 = (- 5));<1>((0 = ptr<1>@3, 1 = ptr<2>@4),) :: return (x + y);<-1>} :: top{} -heap: fun
, 0, 1, ptr<1>, ptr<2>, -env: y: 1, x: 0, main: fun
, -} ---- handle value 5 with (- 5)<1>(5,) ---> -{ -stack: main{-5<-1> :: (0 = 5, 1 = (- 5))<1>(5,) :: (0 = x, 1 = y) = (0 = 5, 1 = (- 5));<1>((0 = ptr<1>@3, 1 = ptr<2>@4),) :: return (x + y);<-1>} :: top{} -heap: fun
, 0, 1, ptr<1>, ptr<2>, -env: y: 1, x: 0, main: fun
, -} ---- handle value -5 with (0 = 5, 1 = (- 5))<2>(5,-5,) ---> -{ -stack: main{(0 = 5@5, 1 = -5@6)<-1> :: (0 = x, 1 = y) = (0 = 5, 1 = (- 5));<1>((0 = ptr<1>@3, 1 = ptr<2>@4),) :: return (x + y);<-1>} :: top{} -heap: fun
, 0, 1, ptr<1>, ptr<2>, 5, -5, -env: y: 1, x: 0, main: fun
, -} ---- handle value (0 = 5@5, 1 = -5@6) with (0 = x, 1 = y) = (0 = 5, 1 = (- 5));<2>((0 = ptr<1>@3, 1 = ptr<2>@4),(0 = 5@5, 1 = -5@6),) ---> -{ -stack: main{return (x + y);<-1>} :: top{} -heap: fun
, 5, -5, ptr<1>, ptr<2>, 5, -5, -env: y: -5, x: 5, main: fun
, -} ---- step stmt return (x + y); ---> -{ -stack: main{(x + y)<-1> :: return (x + y);<0>} :: top{} -heap: fun
, 5, -5, ptr<1>, ptr<2>, 5, -5, -env: y: -5, x: 5, main: fun
, -} ---- step exp (x + y) ---> -{ -stack: main{x<-1> :: (x + y)<0> :: return (x + y);<0>} :: top{} -heap: fun
, 5, -5, ptr<1>, ptr<2>, 5, -5, -env: y: -5, x: 5, main: fun
, -} ---- step exp x ---> -{ -stack: main{5<-1> :: (x + y)<0> :: return (x + y);<0>} :: top{} -heap: fun
, 5, -5, ptr<1>, ptr<2>, 5, -5, -env: y: -5, x: 5, main: fun
, -} ---- handle value 5 with (x + y)<1>(5,) ---> -{ -stack: main{y<-1> :: (x + y)<1>(5,) :: return (x + y);<0>} :: top{} -heap: fun
, 5, -5, ptr<1>, ptr<2>, 5, -5, -env: y: -5, x: 5, main: fun
, -} ---- step exp y ---> -{ -stack: main{-5<-1> :: (x + y)<1>(5,) :: return (x + y);<0>} :: top{} -heap: fun
, 5, -5, ptr<1>, ptr<2>, 5, -5, -env: y: -5, x: 5, main: fun
, -} ---- handle value -5 with (x + y)<2>(5,-5,) ---> -{ -stack: main{0<-1> :: return (x + y);<0>} :: top{} -heap: fun
, 5, -5, ptr<1>, ptr<2>, 5, -5, -env: y: -5, x: 5, main: fun
, -} ---- handle value 0 with return (x + y);<1>(0,) ---> -{ -stack: top{0<-1>} -heap: fun
, !!5, !!-5, ptr<1>, ptr<2>, !!5, !!-5, -env: main: fun
, -} result: 0 diff --git a/executable_semantics/testdata/tuple_match.golden b/executable_semantics/testdata/tuple_match.golden index 367151e15b6c..2db2755da426 100644 --- a/executable_semantics/testdata/tuple_match.golden +++ b/executable_semantics/testdata/tuple_match.golden @@ -1,318 +1 @@ -********** source program ********** -fn main () -> Int { -var auto: t = (0 = 5, 1 = 2); -match (t) { -case (0 = auto: a, 1 = auto: b) => -return ((a + b) - 7); -} - -} -********** type checking ********** ---- step exp Int ---> ---- step exp Int ---> ---- step exp auto ---> ---- step exp auto ---> ---- step exp auto ---> - -********** type checking complete ********** -fn main () -> Int { -var auto: t = (0 = 5, 1 = 2); -match (t) { -case (0 = auto: a, 1 = auto: b) => -return ((a + b) - 7); -} -} -********** starting execution ********** -********** initializing globals ********** ---- step exp () ---> -********** calling main function ********** -{ -stack: top{main()<-1>} -heap: fun
, -env: main: fun
, -} ---- step exp main() ---> -{ -stack: top{main<-1> :: main()<0>} -heap: fun
, -env: main: fun
, -} ---- step exp main ---> -{ -stack: top{fun
<-1> :: main()<0>} -heap: fun
, -env: main: fun
, -} ---- handle value fun
with main()<1>(fun
,) ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: fun
, -env: main: fun
, -} ---- step exp () ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: fun
, -env: main: fun
, -} ---- handle value () with main()<2>(fun
,(),) ---> -pattern_match((), ()) -{ -stack: main{var auto: t = (0 = 5, 1 = 2); ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step stmt var auto: t = (0 = 5, 1 = 2); ... ---> -{ -stack: main{var auto: t = (0 = 5, 1 = 2);<-1> :: match (t) {...}<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step stmt var auto: t = (0 = 5, 1 = 2); ---> -{ -stack: main{(0 = 5, 1 = 2)<-1> :: var auto: t = (0 = 5, 1 = 2);<0> :: match (t) {...}<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp (0 = 5, 1 = 2) ---> -{ -stack: main{5<-1> :: (0 = 5, 1 = 2)<0> :: var auto: t = (0 = 5, 1 = 2);<0> :: match (t) {...}<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp 5 ---> -{ -stack: main{5<-1> :: (0 = 5, 1 = 2)<0> :: var auto: t = (0 = 5, 1 = 2);<0> :: match (t) {...}<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value 5 with (0 = 5, 1 = 2)<1>(5,) ---> -{ -stack: main{2<-1> :: (0 = 5, 1 = 2)<1>(5,) :: var auto: t = (0 = 5, 1 = 2);<0> :: match (t) {...}<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp 2 ---> -{ -stack: main{2<-1> :: (0 = 5, 1 = 2)<1>(5,) :: var auto: t = (0 = 5, 1 = 2);<0> :: match (t) {...}<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value 2 with (0 = 5, 1 = 2)<2>(5,2,) ---> -{ -stack: main{(0 = 5@1, 1 = 2@2)<-1> :: var auto: t = (0 = 5, 1 = 2);<0> :: match (t) {...}<-1>} :: top{} -heap: fun
, 5, 2, -env: main: fun
, -} ---- handle value (0 = 5@1, 1 = 2@2) with var auto: t = (0 = 5, 1 = 2);<1>((0 = 5@1, 1 = 2@2),) ---> -{ -stack: main{auto: t<-1> :: var auto: t = (0 = 5, 1 = 2);<1>((0 = 5@1, 1 = 2@2),) :: match (t) {...}<-1>} :: top{} -heap: fun
, 5, 2, -env: main: fun
, -} ---- step exp auto: t ---> -{ -stack: main{auto<-1> :: auto: t<0> :: var auto: t = (0 = 5, 1 = 2);<1>((0 = 5@1, 1 = 2@2),) :: match (t) {...}<-1>} :: top{} -heap: fun
, 5, 2, -env: main: fun
, -} ---- step exp auto ---> -{ -stack: main{auto<-1> :: auto: t<0> :: var auto: t = (0 = 5, 1 = 2);<1>((0 = 5@1, 1 = 2@2),) :: match (t) {...}<-1>} :: top{} -heap: fun
, 5, 2, -env: main: fun
, -} ---- handle value auto with auto: t<1>(auto,) ---> -{ -stack: main{auto: t<-1> :: var auto: t = (0 = 5, 1 = 2);<1>((0 = 5@1, 1 = 2@2),) :: match (t) {...}<-1>} :: top{} -heap: fun
, 5, 2, -env: main: fun
, -} ---- handle value auto: t with var auto: t = (0 = 5, 1 = 2);<2>((0 = 5@1, 1 = 2@2),auto: t,) ---> -pattern_match(auto: t, (0 = 5@1, 1 = 2@2)) -{ -stack: main{match (t) {...}<-1>} :: top{} -heap: fun
, 5, 2, 5, 2, (0 = 5@3, 1 = 2@4), -env: t: (0 = 5@3, 1 = 2@4), main: fun
, -} ---- step stmt match (t) {...} ---> -{ -stack: main{t<-1> :: match (t) {...}<0>} :: top{} -heap: fun
, 5, 2, 5, 2, (0 = 5@3, 1 = 2@4), -env: t: (0 = 5@3, 1 = 2@4), main: fun
, -} ---- step exp t ---> -{ -stack: main{(0 = 5@3, 1 = 2@4)<-1> :: match (t) {...}<0>} :: top{} -heap: fun
, 5, 2, 5, 2, (0 = 5@3, 1 = 2@4), -env: t: (0 = 5@3, 1 = 2@4), main: fun
, -} ---- handle value (0 = 5@3, 1 = 2@4) with match (t) {...}<1>((0 = 5@3, 1 = 2@4),) ---> -{ -stack: main{(0 = auto: a, 1 = auto: b)<-1> :: match (t) {...}<1>((0 = 5@3, 1 = 2@4),)} :: top{} -heap: fun
, 5, 2, 5, 2, (0 = 5@3, 1 = 2@4), -env: t: (0 = 5@3, 1 = 2@4), main: fun
, -} ---- step exp (0 = auto: a, 1 = auto: b) ---> -{ -stack: main{auto: a<-1> :: (0 = auto: a, 1 = auto: b)<0> :: match (t) {...}<1>((0 = 5@3, 1 = 2@4),)} :: top{} -heap: fun
, 5, 2, 5, 2, (0 = 5@3, 1 = 2@4), -env: t: (0 = 5@3, 1 = 2@4), main: fun
, -} ---- step exp auto: a ---> -{ -stack: main{auto<-1> :: auto: a<0> :: (0 = auto: a, 1 = auto: b)<0> :: match (t) {...}<1>((0 = 5@3, 1 = 2@4),)} :: top{} -heap: fun
, 5, 2, 5, 2, (0 = 5@3, 1 = 2@4), -env: t: (0 = 5@3, 1 = 2@4), main: fun
, -} ---- step exp auto ---> -{ -stack: main{auto<-1> :: auto: a<0> :: (0 = auto: a, 1 = auto: b)<0> :: match (t) {...}<1>((0 = 5@3, 1 = 2@4),)} :: top{} -heap: fun
, 5, 2, 5, 2, (0 = 5@3, 1 = 2@4), -env: t: (0 = 5@3, 1 = 2@4), main: fun
, -} ---- handle value auto with auto: a<1>(auto,) ---> -{ -stack: main{auto: a<-1> :: (0 = auto: a, 1 = auto: b)<0> :: match (t) {...}<1>((0 = 5@3, 1 = 2@4),)} :: top{} -heap: fun
, 5, 2, 5, 2, (0 = 5@3, 1 = 2@4), -env: t: (0 = 5@3, 1 = 2@4), main: fun
, -} ---- handle value auto: a with (0 = auto: a, 1 = auto: b)<1>(auto: a,) ---> -{ -stack: main{auto: b<-1> :: (0 = auto: a, 1 = auto: b)<1>(auto: a,) :: match (t) {...}<1>((0 = 5@3, 1 = 2@4),)} :: top{} -heap: fun
, 5, 2, 5, 2, (0 = 5@3, 1 = 2@4), -env: t: (0 = 5@3, 1 = 2@4), main: fun
, -} ---- step exp auto: b ---> -{ -stack: main{auto<-1> :: auto: b<0> :: (0 = auto: a, 1 = auto: b)<1>(auto: a,) :: match (t) {...}<1>((0 = 5@3, 1 = 2@4),)} :: top{} -heap: fun
, 5, 2, 5, 2, (0 = 5@3, 1 = 2@4), -env: t: (0 = 5@3, 1 = 2@4), main: fun
, -} ---- step exp auto ---> -{ -stack: main{auto<-1> :: auto: b<0> :: (0 = auto: a, 1 = auto: b)<1>(auto: a,) :: match (t) {...}<1>((0 = 5@3, 1 = 2@4),)} :: top{} -heap: fun
, 5, 2, 5, 2, (0 = 5@3, 1 = 2@4), -env: t: (0 = 5@3, 1 = 2@4), main: fun
, -} ---- handle value auto with auto: b<1>(auto,) ---> -{ -stack: main{auto: b<-1> :: (0 = auto: a, 1 = auto: b)<1>(auto: a,) :: match (t) {...}<1>((0 = 5@3, 1 = 2@4),)} :: top{} -heap: fun
, 5, 2, 5, 2, (0 = 5@3, 1 = 2@4), -env: t: (0 = 5@3, 1 = 2@4), main: fun
, -} ---- handle value auto: b with (0 = auto: a, 1 = auto: b)<2>(auto: a,auto: b,) ---> -{ -stack: main{(0 = auto: a@6, 1 = auto: b@7)<-1> :: match (t) {...}<1>((0 = 5@3, 1 = 2@4),)} :: top{} -heap: fun
, 5, 2, 5, 2, (0 = 5@3, 1 = 2@4), auto: a, auto: b, -env: t: (0 = 5@3, 1 = 2@4), main: fun
, -} ---- handle value (0 = auto: a@6, 1 = auto: b@7) with match (t) {...}<2>((0 = 5@3, 1 = 2@4),(0 = auto: a@6, 1 = auto: b@7),) ---> -pattern_match((0 = auto: a@6, 1 = auto: b@7), (0 = 5@3, 1 = 2@4)) -pattern_match(auto: a, 5) -pattern_match(auto: b, 2) -{ -stack: main{return ((a + b) - 7);<-1> :: { - ... -} -<0>} :: top{} -heap: fun
, 5, 2, 5, 2, (0 = 5@3, 1 = 2@4), auto: a, auto: b, 5, 2, -env: b: 2, a: 5, t: (0 = 5@3, 1 = 2@4), main: fun
, -} ---- step stmt return ((a + b) - 7); ---> -{ -stack: main{((a + b) - 7)<-1> :: return ((a + b) - 7);<0> :: { - ... -} -<0>} :: top{} -heap: fun
, 5, 2, 5, 2, (0 = 5@3, 1 = 2@4), auto: a, auto: b, 5, 2, -env: b: 2, a: 5, t: (0 = 5@3, 1 = 2@4), main: fun
, -} ---- step exp ((a + b) - 7) ---> -{ -stack: main{(a + b)<-1> :: ((a + b) - 7)<0> :: return ((a + b) - 7);<0> :: { - ... -} -<0>} :: top{} -heap: fun
, 5, 2, 5, 2, (0 = 5@3, 1 = 2@4), auto: a, auto: b, 5, 2, -env: b: 2, a: 5, t: (0 = 5@3, 1 = 2@4), main: fun
, -} ---- step exp (a + b) ---> -{ -stack: main{a<-1> :: (a + b)<0> :: ((a + b) - 7)<0> :: return ((a + b) - 7);<0> :: { - ... -} -<0>} :: top{} -heap: fun
, 5, 2, 5, 2, (0 = 5@3, 1 = 2@4), auto: a, auto: b, 5, 2, -env: b: 2, a: 5, t: (0 = 5@3, 1 = 2@4), main: fun
, -} ---- step exp a ---> -{ -stack: main{5<-1> :: (a + b)<0> :: ((a + b) - 7)<0> :: return ((a + b) - 7);<0> :: { - ... -} -<0>} :: top{} -heap: fun
, 5, 2, 5, 2, (0 = 5@3, 1 = 2@4), auto: a, auto: b, 5, 2, -env: b: 2, a: 5, t: (0 = 5@3, 1 = 2@4), main: fun
, -} ---- handle value 5 with (a + b)<1>(5,) ---> -{ -stack: main{b<-1> :: (a + b)<1>(5,) :: ((a + b) - 7)<0> :: return ((a + b) - 7);<0> :: { - ... -} -<0>} :: top{} -heap: fun
, 5, 2, 5, 2, (0 = 5@3, 1 = 2@4), auto: a, auto: b, 5, 2, -env: b: 2, a: 5, t: (0 = 5@3, 1 = 2@4), main: fun
, -} ---- step exp b ---> -{ -stack: main{2<-1> :: (a + b)<1>(5,) :: ((a + b) - 7)<0> :: return ((a + b) - 7);<0> :: { - ... -} -<0>} :: top{} -heap: fun
, 5, 2, 5, 2, (0 = 5@3, 1 = 2@4), auto: a, auto: b, 5, 2, -env: b: 2, a: 5, t: (0 = 5@3, 1 = 2@4), main: fun
, -} ---- handle value 2 with (a + b)<2>(5,2,) ---> -{ -stack: main{7<-1> :: ((a + b) - 7)<0> :: return ((a + b) - 7);<0> :: { - ... -} -<0>} :: top{} -heap: fun
, 5, 2, 5, 2, (0 = 5@3, 1 = 2@4), auto: a, auto: b, 5, 2, -env: b: 2, a: 5, t: (0 = 5@3, 1 = 2@4), main: fun
, -} ---- handle value 7 with ((a + b) - 7)<1>(7,) ---> -{ -stack: main{7<-1> :: ((a + b) - 7)<1>(7,) :: return ((a + b) - 7);<0> :: { - ... -} -<0>} :: top{} -heap: fun
, 5, 2, 5, 2, (0 = 5@3, 1 = 2@4), auto: a, auto: b, 5, 2, -env: b: 2, a: 5, t: (0 = 5@3, 1 = 2@4), main: fun
, -} ---- step exp 7 ---> -{ -stack: main{7<-1> :: ((a + b) - 7)<1>(7,) :: return ((a + b) - 7);<0> :: { - ... -} -<0>} :: top{} -heap: fun
, 5, 2, 5, 2, (0 = 5@3, 1 = 2@4), auto: a, auto: b, 5, 2, -env: b: 2, a: 5, t: (0 = 5@3, 1 = 2@4), main: fun
, -} ---- handle value 7 with ((a + b) - 7)<2>(7,7,) ---> -{ -stack: main{0<-1> :: return ((a + b) - 7);<0> :: { - ... -} -<0>} :: top{} -heap: fun
, 5, 2, 5, 2, (0 = 5@3, 1 = 2@4), auto: a, auto: b, 5, 2, -env: b: 2, a: 5, t: (0 = 5@3, 1 = 2@4), main: fun
, -} ---- handle value 0 with return ((a + b) - 7);<1>(0,) ---> -{ -stack: top{0<-1>} -heap: fun
, 5, 2, !!5, !!2, !!(0 = !!5@3, 1 = !!2@4), auto: a, auto: b, !!5, !!2, -env: main: fun
, -} result: 0 diff --git a/executable_semantics/testdata/undef1.6c b/executable_semantics/testdata/undef1.6c deleted file mode 100644 index b83dcfc19f97..000000000000 --- a/executable_semantics/testdata/undef1.6c +++ /dev/null @@ -1,18 +0,0 @@ -// Part of the Carbon Language project, under the Apache License v2.0 with LLVM -// Exceptions. See /LICENSE for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -// The behavior of this program is undefined because it tries to -// access a local variable after its lifetime is over. - -fn f() -> Int* { - var int: x; - x = 0; - return &x; -} - -fn main() -> int { - var Ptr(int): p; - p = f(); - return *p; -} diff --git a/executable_semantics/testdata/undef1.golden b/executable_semantics/testdata/undef1.golden deleted file mode 100644 index 8da37a654b5d..000000000000 --- a/executable_semantics/testdata/undef1.golden +++ /dev/null @@ -1,2 +0,0 @@ -executable_semantics/testdata/undef1.6c:8: syntax error -EXIT CODE: 255 diff --git a/executable_semantics/testdata/undef2.6c b/executable_semantics/testdata/undef2.6c deleted file mode 100644 index 85df56eb4655..000000000000 --- a/executable_semantics/testdata/undef2.6c +++ /dev/null @@ -1,13 +0,0 @@ -// Part of the Carbon Language project, under the Apache License v2.0 with LLVM -// Exceptions. See /LICENSE for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -// Use-after-free. - -fun main() -> Int { - var Ptr(int): p; - p = malloc(Int); - *p = 0; - free(p); - return *p; -} diff --git a/executable_semantics/testdata/undef2.golden b/executable_semantics/testdata/undef2.golden deleted file mode 100644 index 1dd693f38c26..000000000000 --- a/executable_semantics/testdata/undef2.golden +++ /dev/null @@ -1,2 +0,0 @@ -executable_semantics/testdata/undef2.6c:7: syntax error -EXIT CODE: 255 diff --git a/executable_semantics/testdata/while1.golden b/executable_semantics/testdata/while1.golden index 3680ec3e5196..2db2755da426 100644 --- a/executable_semantics/testdata/while1.golden +++ b/executable_semantics/testdata/while1.golden @@ -1,464 +1 @@ -********** source program ********** -fn main () -> Int { -var auto: x = 2; -while ((! (x == 0))) -x = (x - 1); -return x; - -} -********** type checking ********** ---- step exp Int ---> ---- step exp Int ---> ---- step exp auto ---> - -********** type checking complete ********** -fn main () -> Int { -var auto: x = 2; -while ((! (x == 0))) -x = (x - 1); -return x; -} -********** starting execution ********** -********** initializing globals ********** ---- step exp () ---> -********** calling main function ********** -{ -stack: top{main()<-1>} -heap: fun
, -env: main: fun
, -} ---- step exp main() ---> -{ -stack: top{main<-1> :: main()<0>} -heap: fun
, -env: main: fun
, -} ---- step exp main ---> -{ -stack: top{fun
<-1> :: main()<0>} -heap: fun
, -env: main: fun
, -} ---- handle value fun
with main()<1>(fun
,) ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: fun
, -env: main: fun
, -} ---- step exp () ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: fun
, -env: main: fun
, -} ---- handle value () with main()<2>(fun
,(),) ---> -pattern_match((), ()) -{ -stack: main{var auto: x = 2; ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step stmt var auto: x = 2; ... ---> -{ -stack: main{var auto: x = 2;<-1> :: while ((! (x == 0))) - ... ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step stmt var auto: x = 2; ---> -{ -stack: main{2<-1> :: var auto: x = 2;<0> :: while ((! (x == 0))) - ... ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp 2 ---> -{ -stack: main{2<-1> :: var auto: x = 2;<0> :: while ((! (x == 0))) - ... ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value 2 with var auto: x = 2;<1>(2,) ---> -{ -stack: main{auto: x<-1> :: var auto: x = 2;<1>(2,) :: while ((! (x == 0))) - ... ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp auto: x ---> -{ -stack: main{auto<-1> :: auto: x<0> :: var auto: x = 2;<1>(2,) :: while ((! (x == 0))) - ... ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp auto ---> -{ -stack: main{auto<-1> :: auto: x<0> :: var auto: x = 2;<1>(2,) :: while ((! (x == 0))) - ... ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value auto with auto: x<1>(auto,) ---> -{ -stack: main{auto: x<-1> :: var auto: x = 2;<1>(2,) :: while ((! (x == 0))) - ... ... <-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value auto: x with var auto: x = 2;<2>(2,auto: x,) ---> -pattern_match(auto: x, 2) -{ -stack: main{while ((! (x == 0))) - ... ... <-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- step stmt while ((! (x == 0))) - ... ... ---> -{ -stack: main{while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- step stmt while ((! (x == 0))) - ... ---> -{ -stack: main{(! (x == 0))<-1> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- step exp (! (x == 0)) ---> -{ -stack: main{(x == 0)<-1> :: (! (x == 0))<0> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- step exp (x == 0) ---> -{ -stack: main{x<-1> :: (x == 0)<0> :: (! (x == 0))<0> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- step exp x ---> -{ -stack: main{2<-1> :: (x == 0)<0> :: (! (x == 0))<0> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- handle value 2 with (x == 0)<1>(2,) ---> -{ -stack: main{0<-1> :: (x == 0)<1>(2,) :: (! (x == 0))<0> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- step exp 0 ---> -{ -stack: main{0<-1> :: (x == 0)<1>(2,) :: (! (x == 0))<0> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- handle value 0 with (x == 0)<2>(2,0,) ---> -{ -stack: main{false<-1> :: (! (x == 0))<0> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- handle value false with (! (x == 0))<1>(false,) ---> -{ -stack: main{true<-1> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- handle value true with while ((! (x == 0))) - ... <1>(true,) ---> -{ -stack: main{x = (x - 1);<-1> :: while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- step stmt x = (x - 1); ---> -{ -stack: main{x<-1> :: x = (x - 1);<0> :: while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- step lvalue x ---> -{ -stack: main{ptr<1><-1> :: x = (x - 1);<0> :: while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- handle value ptr<1> with x = (x - 1);<1>(ptr<1>,) ---> -{ -stack: main{(x - 1)<-1> :: x = (x - 1);<1>(ptr<1>,) :: while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- step exp (x - 1) ---> -{ -stack: main{x<-1> :: (x - 1)<0> :: x = (x - 1);<1>(ptr<1>,) :: while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- step exp x ---> -{ -stack: main{2<-1> :: (x - 1)<0> :: x = (x - 1);<1>(ptr<1>,) :: while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- handle value 2 with (x - 1)<1>(2,) ---> -{ -stack: main{1<-1> :: (x - 1)<1>(2,) :: x = (x - 1);<1>(ptr<1>,) :: while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- step exp 1 ---> -{ -stack: main{1<-1> :: (x - 1)<1>(2,) :: x = (x - 1);<1>(ptr<1>,) :: while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- handle value 1 with (x - 1)<2>(2,1,) ---> -{ -stack: main{1<-1> :: x = (x - 1);<1>(ptr<1>,) :: while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 2, -env: x: 2, main: fun
, -} ---- handle value 1 with x = (x - 1);<2>(ptr<1>,1,) ---> -{ -stack: main{while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- step stmt while ((! (x == 0))) - ... ---> -{ -stack: main{(! (x == 0))<-1> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- step exp (! (x == 0)) ---> -{ -stack: main{(x == 0)<-1> :: (! (x == 0))<0> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- step exp (x == 0) ---> -{ -stack: main{x<-1> :: (x == 0)<0> :: (! (x == 0))<0> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- step exp x ---> -{ -stack: main{1<-1> :: (x == 0)<0> :: (! (x == 0))<0> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- handle value 1 with (x == 0)<1>(1,) ---> -{ -stack: main{0<-1> :: (x == 0)<1>(1,) :: (! (x == 0))<0> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- step exp 0 ---> -{ -stack: main{0<-1> :: (x == 0)<1>(1,) :: (! (x == 0))<0> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- handle value 0 with (x == 0)<2>(1,0,) ---> -{ -stack: main{false<-1> :: (! (x == 0))<0> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- handle value false with (! (x == 0))<1>(false,) ---> -{ -stack: main{true<-1> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- handle value true with while ((! (x == 0))) - ... <1>(true,) ---> -{ -stack: main{x = (x - 1);<-1> :: while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- step stmt x = (x - 1); ---> -{ -stack: main{x<-1> :: x = (x - 1);<0> :: while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- step lvalue x ---> -{ -stack: main{ptr<1><-1> :: x = (x - 1);<0> :: while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- handle value ptr<1> with x = (x - 1);<1>(ptr<1>,) ---> -{ -stack: main{(x - 1)<-1> :: x = (x - 1);<1>(ptr<1>,) :: while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- step exp (x - 1) ---> -{ -stack: main{x<-1> :: (x - 1)<0> :: x = (x - 1);<1>(ptr<1>,) :: while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- step exp x ---> -{ -stack: main{1<-1> :: (x - 1)<0> :: x = (x - 1);<1>(ptr<1>,) :: while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- handle value 1 with (x - 1)<1>(1,) ---> -{ -stack: main{1<-1> :: (x - 1)<1>(1,) :: x = (x - 1);<1>(ptr<1>,) :: while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- step exp 1 ---> -{ -stack: main{1<-1> :: (x - 1)<1>(1,) :: x = (x - 1);<1>(ptr<1>,) :: while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- handle value 1 with (x - 1)<2>(1,1,) ---> -{ -stack: main{0<-1> :: x = (x - 1);<1>(ptr<1>,) :: while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 1, -env: x: 1, main: fun
, -} ---- handle value 0 with x = (x - 1);<2>(ptr<1>,0,) ---> -{ -stack: main{while ((! (x == 0))) - ... <-1> :: return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- step stmt while ((! (x == 0))) - ... ---> -{ -stack: main{(! (x == 0))<-1> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- step exp (! (x == 0)) ---> -{ -stack: main{(x == 0)<-1> :: (! (x == 0))<0> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- step exp (x == 0) ---> -{ -stack: main{x<-1> :: (x == 0)<0> :: (! (x == 0))<0> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- step exp x ---> -{ -stack: main{0<-1> :: (x == 0)<0> :: (! (x == 0))<0> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- handle value 0 with (x == 0)<1>(0,) ---> -{ -stack: main{0<-1> :: (x == 0)<1>(0,) :: (! (x == 0))<0> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- step exp 0 ---> -{ -stack: main{0<-1> :: (x == 0)<1>(0,) :: (! (x == 0))<0> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- handle value 0 with (x == 0)<2>(0,0,) ---> -{ -stack: main{true<-1> :: (! (x == 0))<0> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- handle value true with (! (x == 0))<1>(true,) ---> -{ -stack: main{false<-1> :: while ((! (x == 0))) - ... <0> :: return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- handle value false with while ((! (x == 0))) - ... <1>(false,) ---> -{ -stack: main{return x;<-1>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- step stmt return x; ---> -{ -stack: main{x<-1> :: return x;<0>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- step exp x ---> -{ -stack: main{0<-1> :: return x;<0>} :: top{} -heap: fun
, 0, -env: x: 0, main: fun
, -} ---- handle value 0 with return x;<1>(0,) ---> -{ -stack: top{0<-1>} -heap: fun
, !!0, -env: main: fun
, -} result: 0 diff --git a/executable_semantics/testdata/zero.golden b/executable_semantics/testdata/zero.golden index 33c89ae16eea..2db2755da426 100644 --- a/executable_semantics/testdata/zero.golden +++ b/executable_semantics/testdata/zero.golden @@ -1,72 +1 @@ -********** source program ********** -fn main () -> Int { -return 0; - -} -********** type checking ********** ---- step exp Int ---> ---- step exp Int ---> - -********** type checking complete ********** -fn main () -> Int { -return 0; -} -********** starting execution ********** -********** initializing globals ********** ---- step exp () ---> -********** calling main function ********** -{ -stack: top{main()<-1>} -heap: fun
, -env: main: fun
, -} ---- step exp main() ---> -{ -stack: top{main<-1> :: main()<0>} -heap: fun
, -env: main: fun
, -} ---- step exp main ---> -{ -stack: top{fun
<-1> :: main()<0>} -heap: fun
, -env: main: fun
, -} ---- handle value fun
with main()<1>(fun
,) ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: fun
, -env: main: fun
, -} ---- step exp () ---> -{ -stack: top{()<-1> :: main()<1>(fun
,)} -heap: fun
, -env: main: fun
, -} ---- handle value () with main()<2>(fun
,(),) ---> -pattern_match((), ()) -{ -stack: main{return 0;<-1>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step stmt return 0; ---> -{ -stack: main{0<-1> :: return 0;<0>} :: top{} -heap: fun
, -env: main: fun
, -} ---- step exp 0 ---> -{ -stack: main{0<-1> :: return 0;<0>} :: top{} -heap: fun
, -env: main: fun
, -} ---- handle value 0 with return 0;<1>(0,) ---> -{ -stack: top{0<-1>} -heap: fun
, -env: main: fun
, -} result: 0 diff --git a/executable_semantics/tracing_flag.cpp b/executable_semantics/tracing_flag.cpp index 9b573c90c80b..0bdf55191420 100644 --- a/executable_semantics/tracing_flag.cpp +++ b/executable_semantics/tracing_flag.cpp @@ -7,6 +7,6 @@ namespace Carbon { // Program option to enable/disable tracing. -bool tracing_output = true; +bool tracing_output = false; } // namespace Carbon