Files
carbon-lang/executable_semantics/testdata/global_variable6.golden
T
Jeremy G. Siek ced98ef021 Global variables (#378)
* global variables

* implemented type checking of global variable, added test case

* added a comment

* improvements based on Dave's suggestions

* improvements based on Jon's suggestions

* added test cases about global variable ordering
2021-03-15 16:06:27 -04:00

83 lines
1.7 KiB
Plaintext

********** 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<main>,
env: main: fun<main>, y: 0, x: 0,
}
--- step exp main() --->
{
stack: top{main<-1> :: main()<0>}
heap: 0, 0, fun<main>,
env: main: fun<main>, y: 0, x: 0,
}
--- step exp main --->
{
stack: top{fun<main><-1> :: main()<0>}
heap: 0, 0, fun<main>,
env: main: fun<main>, y: 0, x: 0,
}
--- handle value fun<main> with main()<1>(fun<main>,) --->
{
stack: top{()<-1> :: main()<1>(fun<main>,)}
heap: 0, 0, fun<main>,
env: main: fun<main>, y: 0, x: 0,
}
--- step exp () --->
{
stack: top{()<-1> :: main()<1>(fun<main>,)}
heap: 0, 0, fun<main>,
env: main: fun<main>, y: 0, x: 0,
}
--- handle value () with main()<2>(fun<main>,(),) --->
pattern_match((), ())
{
stack: main{return y;<-1>} :: top{}
heap: 0, 0, fun<main>,
env: main: fun<main>, y: 0, x: 0,
}
--- step stmt return y; --->
{
stack: main{y<-1> :: return y;<0>} :: top{}
heap: 0, 0, fun<main>,
env: main: fun<main>, y: 0, x: 0,
}
--- step exp y --->
{
stack: main{0<-1> :: return y;<0>} :: top{}
heap: 0, 0, fun<main>,
env: main: fun<main>, y: 0, x: 0,
}
--- handle value 0 with return y;<1>(0,) --->
{
stack: top{0<-1>}
heap: 0, 0, fun<main>,
env: main: fun<main>, y: 0, x: 0,
}
result: 0