Flatten the Frame tree. Now each function call produces a
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.
make every func literal expression allocate,
so that == on func means that the
functions originated in the same
execution of a func literal or definition.
Rob Pike [Wed, 29 Jul 2009 00:20:19 +0000 (17:20 -0700)]
change the encoding of uints to simplify overflow checking and to make them
easier and faster to read. they are now either a one-byte value or a n-byte value
preceded by a byte holding -n.
Robert Griesemer [Tue, 28 Jul 2009 23:38:59 +0000 (16:38 -0700)]
Intersperse comments nicely when printing an AST.
gofmt formatted source code looks pretty good already;
with a bit more fine-tuning it should be great.
printer.go:
- Implemented comment intersperse algorithm.
The approach is a result of many trial-and-error
experiments but at this point reasonably simple
and open to arbitrary fine-tuning.
parser.go:
- Simplified handling of lead and line comments
(formerly called leading and trailing comments).
- Use a comments list instead of an array (I may
change this back - this is not obviously better
and uses more space).
doc.go:
- Remove comments from AST nodes that have been
'consumed' in the documentation to avoid duplicate
printing of them. Allows for better control of
what is printed w/o use of printing control flags
(which are hard to use and not fine-grained enough).
Corresponding adjustments to various clients of these
files.
Robert Griesemer [Tue, 28 Jul 2009 21:54:49 +0000 (14:54 -0700)]
Ring ADT.
- Provides analogous functionality to a doubly-linked list
implementation.
- Completely symmetric set of operations.
- Operations on the ADT do not lead to results that are
outside the domain of the ADT (closed interface).
- Alternative to container/list.
Implement if, for (modulo ranges), break, continue, increment,
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.
Implement multi-valued functions, multi-valued return, and
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.
Implement single-valued, non-variadic function literals and
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.
if there is a goroutine waiting to run
and the init goroutine enters a system call,
entersyscall was trying to kick off a new
scheduler for the other goroutine, causing
a panic (new goroutines can't run until main.main).
Rob Pike [Tue, 21 Jul 2009 22:10:47 +0000 (15:10 -0700)]
make 6l produce dynamically linked binaries (although they are fully statically linked as far
as go is concerned). the -d flag is now flipped; as on the mac, -d disables dynamic.
much remains to be improved to move the output closer to the gcc format.
Cleanup of Type/Value interface. Add Type.ZeroVal, replace
all type-specific value functions, and use ZeroVal to create
new frames. Remove Value.Type; it was unused and difficult
for values with composite types. Add Value.Assign methods.
Some cleanup. Elem() on PtrType is now just Elem and matches
with ArrayType. Generators now switch over the result type
instead of the operand type. Delete unused diag function.
Gather errors in a go.scanner.ErrorList instead of printing
them as we go.
Lots of bug fixes. Let the parser toss illegal character and
string literals. Compile unary + correctly. Allow float OP
ideal. Compile unary * correctly. Implement min and max float
values.
Produce friendlier errors messages for malformed character
literals and when the parser hits an unexpected EOF. Also,
disallow newlines in character literals.
another step toward eliminating forward declarations.
introduce NodeList* type in compiler to replace OLIST.
this clarifies where lists can and cannot occur.
list append and concatenation are now cheap.
the _r rules are gone from yacc.
rev and unrev are gone.
no more lists of lists.
the representation of assignments is a bit clunkier.
split into OAS (1=1) and OAS2 (2 or more on one side).
Robert Griesemer [Fri, 17 Jul 2009 00:11:18 +0000 (17:11 -0700)]
ast:
- renamed Program -> SourceFile
- added Package node representing the AST for an entire package
- added filter function to create a source file mimicking the
interface of an entire package
parser:
- parser entry to parse entire packages
- unified naming of parser entry points
- factored out entry points into new file (interface.go)
gofmt:
- extended to accept single .go files, and package paths:
gofmt file.go // formatting of a single file
gofmt -x file.go // interface of a single file
gofmt -x ./MyPackage // interface of a local package
gofmt -x math // interface of a $GOROOT relative package
Various adjustments in dependent files, documentation.
Fix handling of non-waitable zombie threads. Now they are not
considered running, so WaitStop doesn't lock up and
breakpoints get installed and uninstalled. We also don't try
to detach from them, since that will fail.