summaryrefslogtreecommitdiff
path: root/module/language/ecmascript/compile-ghil.scm
AgeCommit message (Collapse)AuthorFilesLines
2009-08-12debitrot the ecmascript compilerAndy Wingo1-561/+0
* module/Makefile.am (ECMASCRIPT_LANG_SOURCES): * module/language/ecmascript/compile-ghil.scm: * module/language/ecmascript/compile-tree-il.scm: SOURCES): Replace the GHIL compiler with a ->tree-il compiler. Not fully functional, but the basics work. * module/language/ecmascript/spec.scm: Only include the tree-il compiler. * module/language/ecmascript/tokenize.scm (read-punctuation): Avoid mutating a constant.
2009-06-17Change Guile license to LGPLv3+Neil Jerram1-14/+13
(Not quite finished, the following will be done tomorrow. module/srfi/*.scm module/rnrs/*.scm module/scripts/*.scm testsuite/*.scm guile-readline/* )
2009-06-09some attempts to solve the ecmascript stack overflow problemAndy Wingo1-12/+1
* module/language/ecmascript/compile-ghil.scm (comp): Just use pmatch, not ormatch. Now with syncase running over everything, it doesn't matter. * module/ice-9/boot-9.scm (false-if-exception): Avoid saving stacks inside false-if-exception. There's probably a more general solution to this, though. Fixes getting bogus backtraces sometimes. * module/Makefile.am (ECMASCRIPT_LANG_SOURCES): Reorder things so that spec comes last.
2009-04-16compilation passes return third value: the continuation environmentAndy Wingo1-0/+1
* module/system/base/compile.scm: Expect compile passes to produce three values, not two. The third is the "continuation environment", the environment that can be used to compile a subsequent expression from the same source language. For example, expansion-time side effects can set the current module, which would be reflected appropriately in the continuation environment. * module/language/assembly/compile-bytecode.scm: * module/language/bytecode/spec.scm: * module/language/ecmascript/compile-ghil.scm: * module/language/ghil/compile-glil.scm: * module/language/glil/spec.scm: * module/language/objcode/spec.scm: * module/language/scheme/compile-ghil.scm: * module/system/base/compile.scm: Update compile passes to return a continuation environment.
2009-02-27make the ES compiler more readable via use of ->Andy Wingo1-303/+314
* module/language/ecmascript/compile-ghil.scm: Use -> to make the ES compiler more readable. Fix bugs in do, while, and for, whereby we were missing ->boolean calls.
2009-02-22compile for-inAndy Wingo1-1/+33
* module/language/ecmascript/base.scm (prop-keys): New method, returns the list of keys of props of this instance. * module/language/ecmascript/impl.scm: Refactor the global object into a special kind of module object. Provide a prop-keys implementation for module objects. * module/language/ecmascript/compile-ghil.scm (comp): Compile for-in. * module/language/ecmascript/impl.scm: Reshuffly things, and implement make-enumerator, a helper for use in for-in statements. * module/language/ecmascript/parse.scm (parse-ecmascript): Fix parsing of for (var foo in bar) {}...
2009-02-22fix "for" compilationAndy Wingo1-2/+2
* module/language/ecmascript/compile-ghil.scm (comp): Whoops, fix `for' compilation.
2009-02-22more arithmetic on non-numbersAndy Wingo1-1/+2
* module/language/ecmascript/compile-ghil.scm (comp): Convert to number on unary +. * module/language/ecmascript/impl.scm: Define -, *, /, <, <=, >=, > operations on non-numbers.
2009-02-22+ for strings, global js object, new Foo() worksAndy Wingo1-12/+15
* module/language/ecmascript/array.scm (*array-prototype*): Declare the constructor. * module/language/ecmascript/base.scm (pput, pdel): Remove some needless checks. (new): Move definition of new here, and use the constructor. * module/language/ecmascript/compile-ghil.scm (compile-ghil): Add a stub so that when we load a compiled JS program, we make sure the runtime has been booted. * module/language/ecmascript/function.scm (js-constructor): Export a js-constructor method instead of a new method. * module/language/ecmascript/impl.scm (<js-global-object>): Define a new class for the global "this" object, wrapping bindings from the current module. (init-js-bindings!): Define the dozen or so global properties, in the current module. (+): Define addition operations for non-numbers. This is efficient because the generics are only dispatched if the fast-path fails.
2009-02-21compile ecmascript's parser. yay! instant load-time!Andy Wingo1-0/+2
* module/language/ghil/compile-glil.scm (codegen): If there are more than 255 arguments, make a list and use apply instead of calling directly. * module/language/Makefile.am: Now we can compile parse.scm. Yay! * module/language/scheme/compile-ghil.scm: Add a note. * module/language/ecmascript/compile-ghil.scm: Add a note.
2009-02-21be smarter about allocating local variables, reusing slots if possibleAndy Wingo1-3/+10
* module/language/Makefile.am: OK, we can compile compile-ghil.scm now, thankfully. * module/language/ecmascript/compile-ghil.scm (ormatch): New macro, a wrapper around pmatch to avoid some of the more egregious non-tail recursiveness. (comp): Use ormatch. * module/language/ghil.scm (unparse-ghil): The body of bind and mv-bind is a single expression, not a list of expressions. * module/language/ghil/compile-glil.scm (codegen): Be more clever when allocating "local" variables -- if a variable goes out of scope, its index can be re-used later. * module/language/glil.scm (parse-glil, unparse-ghil): The "rest" of a mv-bind is a flag, not a list. The "ra" of an mv-call is a label, not a GLIL expression. * module/language/objcode/spec.scm (collapse-locals, decompile-value): When decompiling a value, process the bindings list differently. Comments in the code. * module/language/scheme/compile-ghil.scm (define-scheme-translator): Fix the generated error procedure. (let): Re-indent. (letrec): Re-indent. * module/system/base/syntax.scm (record-case): If the body of a clause is null, fill it with the unspecified value.
2009-02-21implement break and continue, work around overly recursive pmatch expansionAndy Wingo1-0/+14
* libguile/vm-i-system.c (goto/args): On a tail call to a different procedure, init the locals to valid scheme values. Shouldn't matter for well-compiled scheme, but inspecting uninitialized locals could give garbage, or badly-compiled code could cause a crash. * module/language/Makefile.am (NOCOMP_SOURCES): For the moment, don't compile compile-ghil.scm. I need to fix this. * module/language/ecmascript/compile-ghil.scm (load-toplevel): Sigh, and disable stack checking in the evaluator too. Grr. (comp): Implement (unnamed) break and continue. * module/language/ecmascript/parse.scm (parse-ecmascript): Fix var statements in `for' -- though it still doesn't work.
2009-02-21implement do, while, forAndy Wingo1-6/+79
* module/language/ecmascript/compile-ghil.scm (comp): Use ghil-bind when making temp vars, so that disassembly understands things. Implement do, while, and for. * module/language/ecmascript/parse.scm (parse-ecmascript): Some tweaks. * module/language/ecmascript/impl.scm (language): Export ->boolean.
2009-02-21implement more operationsAndy Wingo1-1/+76
* module/language/ecmascript/base.scm: Implement some more robust property getters that convert strings to symbols. Implement has-property?. * module/language/ecmascript/compile-ghil.scm (comp): Implement lots more mathematical operators. We now do all expressions; on to statements. * module/language/ecmascript/impl.scm: Define some math helpers. They probably need to call ->number on some things. * module/language/ecmascript/parse.scm (parse-ecmascript): Fix a typo.
2009-02-21clean up ++ and -- a little bitAndy Wingo1-116/+125
* module/language/ecmascript/compile-ghil.scm (comp): Define let1 and begin1 helpers. Use them in pre- and post- increment and decrement.
2009-02-21implement ++, --, new, delete, void, typeofAndy Wingo1-6/+147
* module/language/ecmascript/compile-ghil.scm (@impl): Implement with @implv. (comp): Implement ++ and -- (pre- and post-). Quite a pain. I'll be looking for ways to simplify this notation. Also implement new, delete, and void. * module/language/ecmascript/impl.scm: Implement typeof.
2009-02-21handle "this" in ecmascriptAndy Wingo1-0/+16
* module/language/ecmascript/base.scm: * module/language/ecmascript/compile-ghil.scm: * module/language/ecmascript/impl.scm: * module/language/ecmascript/parse.scm: Compile "method calls" in such a way that "this" gets propagated correctly.
2009-02-19support foo["bar"] in addition to foo.barAndy Wingo1-0/+4
* module/language/ecmascript/parse.scm (parse-ecmascript): And update the function declaration forms for the new var syntax. * module/language/ecmascript/compile-ghil.scm (comp): Support foo["bar"] in addition to foo.bar. * module/language/ecmascript/impl.scm (pget, pput): Some fixes for when we get non-symbols -- it can happen, yo. I suppose we should allow for non-string keys too..
2009-02-19implement object literalsAndy Wingo1-0/+11
* module/language/ecmascript/impl.scm: * module/language/ecmascript/compile-ghil.scm (comp): Object literals. * module/language/ecmascript/parse.scm (parse-ecmascript): Fix some object literal parsing.
2009-02-19var at toplevel works tooAndy Wingo1-3/+19
* module/language/ecmascript/compile-ghil.scm (comp): Fix the var form at toplevel.
2009-02-19property gets and puts implemented, yaysAndy Wingo1-6/+14
* module/language/ecmascript/compile-ghil.scm (@impl): Ok, don't recurse on args here. (comp): Implement property gets and puts and lexical assignment. (comp-body): Fix scanning of var forms. * module/language/ecmascript/impl.scm (prop-attrs): Allow for the prop attr array to be #f. * module/language/ecmascript/parse.scm (parse-ecmascript): Fix assignment parsing.
2009-02-19add array supportAndy Wingo1-3/+7
* module/language/ecmascript/compile-ghil.scm (@impl): Whoops, fix this macro. (comp): Handle array literals. * module/language/ecmascript/impl.scm: Add support for arrays.
2009-02-19further ecmascript workAndy Wingo1-8/+73
* libguile/vm-i-system.c (drop, return): Declare drop and return as popping one arg from the stack. * module/language/ghil/compile-glil.scm: * module/language/glil/compile-assembly.scm (make-meta): Adjust so that we declare 'drop and 'return calls as popping one arg from the stack. * module/language/ecmascript/compile-ghil.scm (comp, comp-body): Flesh out a bit more. Most significantly, scoping within functions obeys javascript semantics better, modulo bits about with() forms. * module/language/ecmascript/impl.scm: Define some runtime helper routines. * module/language/Makefile.am (SOURCES): Add impl.scm. * module/language/ecmascript/parse.scm (parse-ecmascript): Minor tweaks. * module/language/ecmascript/tokenize.scm (read-identifier): Identifiers now read as symbols, not strings.
2009-02-18add more ecmascript compilation -- functions work nowAndy Wingo1-0/+13
* module/language/ecmascript/parse.scm (parse-ecmascript): Lambdas always just have one member in their bodies. * module/language/ecmascript/compile-ghil.scm (comp): Add some more silly compilers.
2009-02-18world's stupidest ecmascript compilerAndy Wingo1-0/+67
* module/language/ecmascript/spec.scm: Add language spec for ecmascript. * module/language/ecmascript/compile-ghil.scm: Add a stupid compiler. * module/language/Makefile.am: Buildage.