Commit Graph

15 Commits

Author SHA1 Message Date
Jesse D. McDonald 786258f144 Add the rest of the FP math primitives.
Improve detection of unsimplified primitive forms. Also hides %goto-end-*.
Automatically convert fixnum to FP in get_float(). (But not _get_float()!)
2012-07-14 13:45:01 -05:00
Jesse D. McDonald 67ea700ac2 Fix handling of (set! var (let (var) ...)) and similar cases.
Was moving (set!) into the (%bind) form, and thus setting the wrong variable.
Now, if set! var is bound, will create a temporary for result of %bind first,
and set! original variable to temporary in the proper scope.

Also, normalize rules for nested (%bind)s:
* The (%bind) inside a (%lambda) is always flat.
   - This is a responsiblity of simplify-lambda, and any function which
     may change structure after simplification (e.g. promote-to-box).
* Any other (%bind) may be nested, unless otherwise noted.
2012-07-14 13:44:56 -05:00
Jesse D. McDonald cc8dc5d9b6 Add many additional primitives, and centralize definitions.
Also:
- assume top-level free variables are constants, not boxes;
- bind variable 'argv' to top-level argument list, rather than assuming no arguments;
- make %values a first-class form, just like %apply and %call/cc (was: pseudo-primitive);
- fix case where 'rest' argument is sole item in argument list: (lambda argv ...); and
- perform misc. cleanup in output code.
2012-07-14 13:44:52 -05:00
Jesse D. McDonald 03fc616b7a Add basic support for outputting values suitable for the Rosella reader. 2012-07-14 13:44:51 -05:00
Jesse D. McDonald c5cf95b867 Implement basic value-propogation and support for multiple return values.
Also performed misc. cleanup, corrected use of temp variables in (let ...),
changed make-bindings-unique to preserve original names as prefixes, improved
detection of unused %set! forms in reduce-set!, and fixed map-variables to
extract the real value from (quote ...) literal forms.
2012-07-14 13:44:48 -05:00
Jesse D. McDonald 4ab23f6877 Thread context register (%ctx) through %apply and %call/cc forms.
Also remove top-level forms without side-effects during CPS transformation.
2012-07-14 13:44:46 -05:00
Jesse D. McDonald 35059dfebf Implement register allocation.
All that remains is to convert the result to bytecode & format as rosella source code.
2012-07-14 13:44:43 -05:00
Jesse D. McDonald c3e46525db Implement conversion of shared variables to boxes.
Also, narrow bindings to their minimal necessary scope. This reduces
the number of variables which must be considered 'shared'.
2012-07-14 13:44:39 -05:00
Jesse D. McDonald b899f0c3b0 Implement support for (call/cc), and shorthand form (let/cc).
Adds support for non-local returns, among other control-flow structures.
2012-07-14 13:44:35 -05:00
Jesse D. McDonald 14b2a1570a Add support for (quote) literal forms in compiler.ss. 2012-07-14 13:44:33 -05:00
Jesse D. McDonald 0b0b352dd6 Clean up handling of (let) and (%bind), plus misc. cleanup.
With this change, any (%bind) returned from (simplify-let) or (simplify-form)
can be assumed to be flat, with unique bound symbols. Before, this was only
true of (%lambda) forms and the output of (compile).
2012-07-14 13:44:30 -05:00
Jesse D. McDonald 6b51229c48 Raise an error if (set! ...) is applied to a form without a value.
Exception is (%tail-call ...) form, which is permitted simply because
(%tail-call ...) transfers control unidirectionally; the enclosing
(%set! ...) form wouldn't be run anyway.
2012-07-14 13:44:17 -05:00
Jesse D. McDonald 8e147f7989 Don't create extra lambdas when both results of (if ...) are trivial.
Also map () directly to %nil, and allow (%if ...) to provide a value to a set! form.
2012-07-14 13:44:05 -05:00
Jesse D. McDonald 46b18c07d6 Implement conversion to tail-call form (CPS).
Also add some basic optimizations concerning binding and setting
variables which will never be used.
2012-07-14 13:43:58 -05:00
Jesse D. McDonald 988d4264b2 Improve representation of tail-calls, and normalize primitive operations. 2012-07-14 13:43:45 -05:00