annotate samples/bitwise.tp @ 251:2557ce4e671f

Fix a couple of compiler bugs. topenv was getting initialized in multiple places. This resulted in multiple copies of modules getting created which caused problems for macro expansion. Additionally, arguments were not being marked as declared during code generation so assigning to an argument that was not closed over generated invalid C code.
author Michael Pavone <pavone@retrodev.com>
date Fri, 11 Apr 2014 22:29:32 -0700
parents 4c7c3d3e0265
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
136
4c7c3d3e0265 Add bitwise operation sample
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
1 #{
4c7c3d3e0265 Add bitwise operation sample
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
2 main <- {
4c7c3d3e0265 Add bitwise operation sample
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
3 a <- 0x42
4c7c3d3e0265 Add bitwise operation sample
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
4 b <- 0x7A
4c7c3d3e0265 Add bitwise operation sample
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
5 print: "a or b = " . (string: a or b) . "\n"
4c7c3d3e0265 Add bitwise operation sample
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
6 print: "a and b = " . (string: a and b) . "\n"
4c7c3d3e0265 Add bitwise operation sample
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
7 print: "a xor b = " . (string: a xor b) . "\n"
4c7c3d3e0265 Add bitwise operation sample
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
8 print: "lshift: a by: 3 = " . (string: (lshift: a by: 3)) . "\n"
4c7c3d3e0265 Add bitwise operation sample
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
9 print: "rshift: b by: 1 = " . (string: (rshift: b by: 1)) . "\n"
4c7c3d3e0265 Add bitwise operation sample
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
10 }
4c7c3d3e0265 Add bitwise operation sample
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
11 }