the interpreter and update code to use ast.BasicDecl and
multi-type switch. There are still a lot of "switch _ :=
x.(type)" that should make use of the new type switch syntax,
but those will be a different CL.
R=rsc
APPROVED=rsc
DELTA=58 (16 added, 23 deleted, 19 changed)
OCL=34853
CL=34963
implementations can abort. Make genConstant get values lazily
since we need the Thread now.
R=rsc
APPROVED=rsc
DELTA=299 (8 added, 19 deleted, 272 changed)
OCL=34353
CL=34353
only visible change is that evaluating an expression returns a
interface{} instead of a Value.
R=rsc
APPROVED=rsc
DELTA=60 (15 added, 26 deleted, 19 changed)
OCL=34206
CL=34208
simplify expr by merging all simple eval functions
into a single eval interface{}.
R=austin
DELTA=1597 (730 added, 780 deleted, 87 changed)
OCL=34182
CL=34198
In the process, I made error handling in the statement
compiler much saner. Instead of separately tracking various
error flags with weird relations, I just track if any error
messages have been produced.
R=rsc
APPROVED=rsc
DELTA=308 (98 added, 135 deleted, 75 changed)
OCL=33870
CL=33961
statement compiler will be fixed in a later CL.
The input and output of the expression compiler are now
clearly distinguished. In the process, I made the individual
expression compilers operate on the compiled form of their
children instead of AST nodes. As a result, there are now
fewer places where I hand-craft intermediate expression nodes.
The diff looks scarier than it is, mostly because exprCompiler
has been split into the input and output types, resulting in
lots of little renames.
R=rsc
APPROVED=rsc
DELTA=774 (204 added, 199 deleted, 371 changed)
OCL=33851
CL=33851
the position where they were defined so I can produce good
error messages on redefinitions.
R=rsc
APPROVED=rsc
DELTA=204 (126 added, 13 deleted, 65 changed)
OCL=32599
CL=32605
Return checking is now done as a general flow check at the end
of function compilation, since break and goto complicated the
way I was doing return checking before. Goto-over-declaration
checking is also done as a final flow check.
Temporary variables used for effect extraction are now
actually temporary. Otherwise "op=", "++", and "--" appear as
declarations that cannot be jumped over.
R=rsc
APPROVED=rsc
DELTA=421 (344 added, 38 deleted, 39 changed)
OCL=32527
CL=32535
single frame and non-overlapping variables reuse frame slots.
As a result, entering and exiting blocks no longer requires
code execution, which means jumps across block boundaries
should be doable now. Frame slot initialization happens at
definition time now, instead of at frame creation time. As an
added bonus, Scope's are now exclusively compile-time objects
and we no longer need to specially track the function
activation frame for access to out vars.
R=rsc
APPROVED=rsc
DELTA=313 (102 added, 90 deleted, 121 changed)
OCL=32416
CL=32420
and decrement. blockCompilers now form a tree the mimics the
nesting of scopes and provide convenient ways to enter and
exit scopes. blockCompilers also track the break and continue
PC for the current block. The statement testing interface now
works in lists of statements, which simplifies a bunch of
things.
R=rsc
APPROVED=rsc
DELTA=401 (335 added, 44 deleted, 22 changed)
OCL=32308
CL=32317
unpacking for assignments, call arguments, and returns. This
change revamps the whole assignment compilation system to be
multi-valued, using the new MultiType type and multiV value.
Function calls, returns, and assignments now share a lot of
code and produce very consistent error messages.
R=rsc
APPROVED=rsc
DELTA=510 (335 added, 74 deleted, 101 changed)
OCL=32248
CL=32258
function calling. Implement a type compiler and named types.
Implement a universal scope containing built-in named types,
and some built-in constants. Implement a simple virtual
machine for executing statements and single-valued return.
Fix many places that incorrectly dealt with named types. In
particular, the Type.Zero methods now use the type's bit count
to determine the appropriate value representation. As a
result, a bit count of 0 now means architecture-dependent and
bounded types use unsafe.Sizeof to determine the correct
bounds. Previously, the bounds on a 32-bit machine would have
been wrong.
Eliminated Type.compatible, since the implementation is
equivalent for all types. Added Type.rep that shallowly
strips named types. Replaced almost all uses of Type.literal
with Type.rep.
Fix implementation of assign-op's so it only evaluates the
left side once. As part of this, there is now a generic way
to separate out the effect and value of an expression.
R=rsc
APPROVED=rsc
DELTA=1530 (1244 added, 68 deleted, 218 changed)
OCL=32184
CL=32230