9904633b1dfc: Fix Linux build problems.
David Anderson <dvander@alliedmods.net> - Sat, 17 Nov 2012 19:07:49 -0800 - rev 196
Fix Linux build problems.

c1ba166f3fc4: Massive SemA/BC refactoring to support better type systems. Read on for more.
David Anderson <dvander@alliedmods.net> - Sat, 17 Nov 2012 18:41:01 -0800 - rev 195
Massive SemA/BC refactoring to support better type systems. Read on for more.

The previous compiler had a simple pipeline, best outlined as:
(1) Parsing and name binding -> AST
(2) Storage allocation -> AST
(3) Semantic Analysis (SemA) -> AST
(4) Bytecode Compilation (BC) -> Code

This pipeline, unfortunately, had two problems. First, name binding cannot be performed in one pass if we wish to have multi-file support in the form of modules. Name binding must be two-pass.

Second, because SemA was only capable of annotating AST nodes with a single type, most coercion work had to be duplicated in the BC phase, as coercion was not explicit in the SemA output. This made introducing new type rules extremely difficult, and all but precluded concepts like operator overloading (or overloading at all).

This patch rewrites most of Keima's backend. Of interest are the following changes:
(1) CompileContext has been refactored around future multi-file support.
(2) Parsing no longer performs any name binding.
(3) The grammar for type-and-name has been changed from:
(Label | Identifier)? Identifier
to:
Type? Identifier
where:
Type ::= OldType | NewType
OldType ::= Label
NewType ::= Identifier (. NewType)*


Although we do not implement the full production for Type yet, this
distinction is important. A type identifier is now affixed to the AST
as an Expression (right now, always a NameProxy), so it can fully
participate in name binding.

(4) Immediately after parsing, the AST goes through a NamePopulation phase.
This phase creates Scope objects for every scope which declares a name,
and if those names are declaring types or functions, a Symbol is created
and entered into the scope. Symbols entirely replace the old BoundName
classes.

(5) After NamePopulation comes NameBinding. This phase performs three steps:
(a) Links Scope objects together, to form a tree.
(b) Binds any free name to an existing name in the scope chain.
(c) Creates and registers any Symbols for names which have not yet been
added to the scope (for example, local variables).

In accordance, all "allocation" and "binding" concepts have been removed
from Scopes, which are now lightweight container classes.

(6) SemA now generates bytecode for each statement in the AST. Expression
compilation is performed via a separate mechanism called HIR (High-level
Intermediate Representation). To analyze an expression, SemA will walk
the AST, and produce a HIR object for each node. HIR is typed, and SemA
may insert coercion nodes, or even expand an AST node into multiple HIR
nodes. The result of evaluating an expression in SemA is therefore the
the root of a HIR tree, which SemA then sends to the HIRTranslator, which
performs bytecode generation.

As before, SemA still performs full semantic analysis. However, not it
also produces each function's bytecode.

This split allows us to decompose potentially complex semantics into
a more fine-grained, AST-like structure, which can have very simple
code-generation logic. For example, (1.0 + 5) might look like:

HAdd(HFloat(1.0), HConvert(HInteger(5), <Float>))

As part of this decomposition, many opcodes have been removed. Rather than
using typed jumps, we now expand jumps into longer tests. For example:
jge.f <label>
becomes:
ge.f
cvt.f2b
jt <label>

This simplifies the pipeline, and JITs should be able to melt the added
work away.

HIR is not used at a statement level, and HIR does not have any concept
of control-flow.

(7) The old BytecodeCompiler has been removed, as its work is now split
between SemA and HIRTranslator.


In addition, some minor refactorings have taken place:

(1) Opcodes.tbl no longer hardcodes numbers (aaah).
(2) Type has been split into smaller, typed structs.
(3) BytecodeEmitter no longer relies on Pools or RootScopes.
(4) SemA is now responsible for variable/storage allocation.
(5) Native table are now global, rather than per-module. As such, native
declarations now result in a Native object (which still requires a
CALLNATIVE opcode), which is an index into the global table. Natives
must be bound globally. This is in preparation for module support.
(6) Publics are no longer tracked, but rather registered via a global
callback upon module load. This callback can be set by embedders. This
is in preparation for multi-file support.
(7) The BytecodeEmitter now performs Symbol allocations itself, and it
also generates Code objects itself, which removes a good deal of
complexity.

Finally, a test harness has been added. This harness is a python script which finds *.test files, recursively, in the tests folder. For each file it runs the corresponding .sp. The contents of the .test file must match stdout+stderr.

b029d63565a2: Implement sizeof operator.
David Anderson <dvander@alliedmods.net> - Mon, 17 Sep 2012 00:10:01 -0700 - rev 194
Implement sizeof operator.

970abfc9f077: Fix bug where assigning string literals to references would not create copies.
David Anderson <dvander@alliedmods.net> - Sun, 16 Sep 2012 23:33:48 -0700 - rev 193
Fix bug where assigning string literals to references would not create copies.

23a804fa1d3e: Allow structs to contain arrays.
David Anderson <dvander@alliedmods.net> - Sun, 16 Sep 2012 23:15:13 -0700 - rev 192
Allow structs to contain arrays.

9d17f29fe16a: Allow returning arrays from functions.
David Anderson <dvander@alliedmods.net> - Sun, 16 Sep 2012 22:49:54 -0700 - rev 191
Allow returning arrays from functions.

dd04fce774cd: Enable dynamic array declarations.
David Anderson <dvander@alliedmods.net> - Sun, 16 Sep 2012 21:59:26 -0700 - rev 190
Enable dynamic array declarations.

eee18bf13c9b: Fix bugs where "new x[x]" or "new x = x" would compile.
David Anderson <dvander@alliedmods.net> - Sun, 16 Sep 2012 21:59:18 -0700 - rev 189
Fix bugs where "new x[x]" or "new x = x" would compile.

bab29bcec7fe: Restructure Array so the elements vector can be replaced.
David Anderson <dvander@alliedmods.net> - Sun, 16 Sep 2012 21:34:10 -0700 - rev 188
Restructure Array so the elements vector can be replaced.

9308d52205a0: Add support for SP1-style fixed array initializers.
David Anderson <dvander@alliedmods.net> - Sun, 16 Sep 2012 19:02:23 -0700 - rev 187
Add support for SP1-style fixed array initializers.

03a663e96860: Allow more empty array creation.
David Anderson <dvander@alliedmods.net> - Sat, 15 Sep 2012 19:33:24 -0700 - rev 186
Allow more empty array creation.

10936f3a2ba3: Added support for declaring empty-length arrays.
David Anderson <dvander@alliedmods.net> - Sat, 15 Sep 2012 18:25:54 -0700 - rev 185
Added support for declaring empty-length arrays.

387d76b1e981: Add support for array reference semantics.
David Anderson <dvander@alliedmods.net> - Sat, 15 Sep 2012 17:39:45 -0700 - rev 184
Add support for array reference semantics.

05571208642f: Fix bug in error reporting for array assignment dimension mismatches.
David Anderson <dvander@alliedmods.net> - Sat, 15 Sep 2012 13:32:01 -0700 - rev 183
Fix bug in error reporting for array assignment dimension mismatches.

c52ca323063f: Do not create LIFO arrays.
David Anderson <dvander@alliedmods.net> - Sat, 15 Sep 2012 13:15:51 -0700 - rev 182
Do not create LIFO arrays.

e731795f925c: Add Box source files to solution file (bug 5474, r=dvander).
Michael Busby <mibusby@gmail.com> - Fri, 14 Sep 2012 02:38:14 -0700 - rev 181
Add Box source files to solution file (bug 5474, r=dvander).

b98a56a533d0: Empty structs throw a compiler error instead of crashing the vm. (bug 5475, r=dvander).
Michael Busby <mibusby@gmail.com> - Tue, 04 Sep 2012 21:03:22 -0700 - rev 180
Empty structs throw a compiler error instead of crashing the vm. (bug 5475, r=dvander).

5f3c91fa6058: Fix some *VERY* confusing nomenclature in CopyArray().
David Anderson <dvander@alliedmods.net> - Thu, 13 Sep 2012 23:58:22 -0700 - rev 179
Fix some *VERY* confusing nomenclature in CopyArray().

9efe9a1456fd: Properly root CopyStruct/CopyArray.
David Anderson <dvander@alliedmods.net> - Thu, 13 Sep 2012 23:52:25 -0700 - rev 178
Properly root CopyStruct/CopyArray.

56f7e5b0243c: Fix bug in bytecode resizing.
David Anderson <dvander@alliedmods.net> - Sun, 02 Sep 2012 13:06:09 -0700 - rev 177
Fix bug in bytecode resizing.

2b9141b01023: Add hex literal support.
David Anderson <dvander@alliedmods.net> - Sat, 01 Sep 2012 17:11:06 -0700 - rev 176
Add hex literal support.

f875ce723f2c: Fix assign-op expressions on globals.
David Anderson <dvander@alliedmods.net> - Sat, 01 Sep 2012 17:10:56 -0700 - rev 175
Fix assign-op expressions on globals.

e718b56aba78: Implemented callbacks.
David Anderson <dvander@alliedmods.net> - Sat, 01 Sep 2012 16:36:20 -0700 - rev 174
Implemented callbacks.

bbf9f3809d55: Fix bug where slow switches do not pop the stack.
David Anderson <dvander@alliedmods.net> - Sun, 12 Aug 2012 20:51:31 -0700 - rev 173
Fix bug where slow switches do not pop the stack.

48cffae8c9e0: Implement switch.
David Anderson <dvander@alliedmods.net> - Sun, 12 Aug 2012 20:48:49 -0700 - rev 172
Implement switch.

023711891116: Fix bug where keywords can be used as labels.
David Anderson <dvander@alliedmods.net> - Sun, 12 Aug 2012 13:22:56 -0700 - rev 171
Fix bug where keywords can be used as labels.

5e4570966ece: Parser support for public variables.
David Anderson <dvander@alliedmods.net> - Sat, 11 Aug 2012 12:11:39 -0700 - rev 170
Parser support for public variables.

0456a16c2a63: Implement default string arguments.
David Anderson <dvander@alliedmods.net> - Mon, 06 Aug 2012 02:03:36 -0700 - rev 169
Implement default string arguments.

4d0fff61d65e: Added runtime support for default arguments.
David Anderson <dvander@alliedmods.net> - Sun, 05 Aug 2012 21:24:41 -0700 - rev 168
Added runtime support for default arguments.

cf82769eb136: Added bogo "unchecked" type that will evolve later.
David Anderson <dvander@alliedmods.net> - Sun, 05 Aug 2012 15:38:52 -0700 - rev 167
Added bogo "unchecked" type that will evolve later.