summaryrefslogtreecommitdiff
path: root/module/language/scheme/compile-ghil.scm
AgeCommit message (Collapse)AuthorFilesLines
2009-10-16remove GHIL, Elisp, and R5RS languagesAndy Wingo1-494/+0
GHIL is obsolete, and it's about time we got rid of it. Elisp and R5RS were unmodified since their import from Guile-VM, so we ditch them too. R5RS compilation is supported via compiling Scheme within an R5RS environment. Elisp will be supported when we merge in Daniel's work.
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-05-20remove compile-time-environmentAndy Wingo1-10/+0
* module/ice-9/boot-9.scm (guile-user): Move the `compile' autoload to the guile-user module. Remove reference to compile-time-environment. * module/language/scheme/compile-ghil.scm: * module/language/tree-il/compile-glil.scm: * module/language/tree-il/optimize.scm: * module/system/base/compile.scm: * test-suite/tests/compiler.test: Remove definition of and references to compile-time-environment. While I do think that recompilation based on a lexical environment can be useful, I think it needs to be implemented differently. So for now we've lost nothing if we take it away, as it doesn't work with syncase anyway.
2009-05-08more work on tree-il compilationAndy Wingo1-2/+0
* module/language/scheme/amatch.scm: Remove, this approach won't be used. * module/Makefile.am: Adjust for additions and removals. * module/language/scheme/compile-ghil.scm: Remove an vestigial debugging statement. * module/language/scheme/spec.scm: * module/language/scheme/compile-tree-il.scm: * module/language/scheme/decompile-tree-il.scm: Add tree-il compiler and decompiler. * module/language/tree-il/compile-glil.scm: Add some notes. * module/language/tree-il/spec.scm: No need to wrap expressions in lambdas -- GHIL needs somewhere to put its variables, we don't.
2009-05-07new language: tree-il. psyntax generates it when run in compile mode.Andy Wingo1-2/+2
* module/Makefile.am: Add tree-il sources. * module/ice-9/compile-psyntax.scm: Adjust for sc-expand producing tree-il in compile mode. * module/ice-9/psyntax.scm: Switch from expand-support to tree-il for generating output in compile mode. Completely generate tree-il -- the output wasn't Scheme before, but now it's completely not Scheme. * module/ice-9/psyntax-pp.scm: Regenerated. * module/language/scheme/compile-ghil.scm: Strip structures using tree-il, not expand-support. * module/language/tree-il.scm: * module/language/tree-il/spec.scm * module/language/tree-il/compile-glil.scm: New language. It will compile to GLIL, though it doesn't yet.
2009-05-04sc-expand in compile mode produces (ice-9 expand-support) structuresAndy Wingo1-1/+3
* module/ice-9/psyntax.scm (*mode*): New moving part, a fluid. (sc-expand): Dynamically bind *mode* to the expansion mode. (build-global-reference): Change to be a procedure instead of local syntax. Import the logic about when to make a @ or @@ form to here, from boot-9.scm. If we are compiling, build output using (ice-9 expand-support)'s make-module-ref, otherwise just making the familiar s-expressions. (This will allow us to correctly expand in modules in which @ or @@ are not bound, at least when we are compiling.) (build-global-assignment): Use the result of build-global-reference. A bit hacky, but hey. (top-level-eval-hook, local-eval-hook): Strip expansion structures before evalling. * module/ice-9/boot-9.scm (make-module-ref): Remove, this logic is now back in psyntax.scm. * module/ice-9/compile-psyntax.scm (source): Since we expand in compile mode, we need to strip expansion structures. * module/ice-9/expand-support.scm (strip-expansion-structures): Remove the logic about whether and how to strip @/@@ from here, as it's part of psyntax now. * module/ice-9/psyntax-pp.scm: Regenerated. * module/language/scheme/compile-ghil.scm (compile-ghil): Strip expansion structures -- for now. In the future, we might translate directly from these structures into GHIL.
2009-05-04replace sc-expand with sc-expand3, removing binding for sc-expand3Andy Wingo1-1/+1
* module/ice-9/boot-9.scm (sc-expand3): * module/ice-9/psyntax.scm (sc-expand3): Replace sc-expand with sc-expand3, as expand3 with one argument is the same as sc-expand. * module/ice-9/psyntax-pp.scm: Regenerated. * module/ice-9/compile-psyntax.scm: * module/language/scheme/compile-ghil.scm: Change callers to sc-expand3 to use sc-expand.
2009-04-24fix @ and syncaseAndy Wingo1-3/+0
* module/ice-9/boot-9.scm (make-module-ref): equal?, not eq?, when matching on module name. (Module names don't have to come from an invocation of module-name in this process.) * module/ice-9/psyntax.scm (build-global-reference) (build-global-assignment, @): Rework the format of the module in syntax objects so that a car of #f indicates a public reference. Loading (foo %module-public-interface) didn't guarantee that (foo) was loaded and useful. * module/ice-9/psyntax-pp.scm: Regenerated. * module/language/scheme/compile-ghil.scm (lookup-transformer): primitive-macro? does not exist any more.
2009-04-24it is alive!!!!! + concision + fix to compile-ghilAndy Wingo1-24/+9
* module/ice-9/boot-9.scm: Remove lots of debugging prints. Remove some already-deprecated attempts to load modules from shared libraries. * module/ice-9/psyntax.scm: If we have to create a variable for a syntactic binding, initialize its contents to a gensym. I'd like something more meaningful, but at least this way we can tell different macros apart. Only warn about missing modules if modules are booted. Chi the value part of a (set! (@ ...) ) expression -- whoops! * module/ice-9/psyntax-pp.scm: Regenerated. * module/language/glil.scm (parse-glil): Fix an unquoting error. * module/language/scheme/compile-ghil.scm: No need to import syncase, we gots it. Rework compiler to expand only once, with syncase, instead of incrementally. Fix define-scheme-transformer to work with syncase, by not referencing bare keywords. It works!
2009-04-17hygienic compilationAndy Wingo1-6/+14
* module/language/scheme/compile-ghil.scm (lookup-transformer): Recognize macros as initial (@ ...) or (@@ ...) forms, enabling hygienic compilation.
2009-04-17more work on modules and hygiene, not finished yet, alas.Andy Wingo1-5/+3
* module/ice-9/compile-psyntax.scm: No more expansion-eval-closure. * module/ice-9/expand-support.scm (strip-expansion-structures): Only @@ names whose module is not the current module. Actually @@ serialization is disabled for this commit, just to get this one in and keep things working. * module/ice-9/psyntax-pp.scm: Recompiled. * module/ice-9/psyntax.scm (put-global-definition-hook) (get-global-definition-hook): Instead of going through that stupid getprop/putprop interface, let's just inline Guile-specific code here. (build-global-reference, build-global-assignment): Fix a bug where the module and public? were switched, which happily allowed things to compile. (We reintroduce a similar bug above in expand-support.) (lookup): Add a module argument. (global-extend): Adapt for put-global-definition-hook invocation. (syntax-type): Lookup with mod. Return mod even for lexicals and define-form -- why not. (chi-top, fluid-let-syntax, syntax, set!): Lookup with mod. Wrap with mod. * module/ice-9/syncase.scm (expansion-eval-closure) (current-eval-closure, env->eval-closure): OK! So the idea is: module hygiene is syncase's business, not ours. So lose the eval-closure fluid. Also, eval closures are so 1990s. (sc-macro): But, we have to take the module from the env, sadly. In the future this will be different. Remove the rest of the eval-closure bits. Enable source reporting, while we're debugging. * module/language/scheme/compile-ghil.scm (lookup-transformer): Adapt for eval closure fluid changes.
2009-04-17serialize module information into syncase's output -- getting ready for hygieneAndy Wingo1-1/+3
* module/ice-9/Makefile.am: Replace annotate.scm with expand-support.scm. * module/ice-9/annotate.scm: Removed; subsumed into expand-support.scm. * module/ice-9/compile-psyntax.scm: Strip out expansion structures before writing to disk. * module/ice-9/expand-support.scm: New file. Provides annotation support, and other compound data types for use by the expander. Currently the only one that is used is the toplevel reference, <module-ref>, but we will record lexicals this way soon. * module/ice-9/psyntax-pp.scm: Regenerate. * module/ice-9/psyntax.scm (build-global-reference) (build-global-assignment): Instead of expanding out global references as symbols, expand them as <module-ref> structures, with space to record the module that they should be scoped against. This is in anticipation of us actually threading the module info through the syntax transformation, so that we can get hygiene with respect to modules. * module/ice-9/syncase.scm: Replace eval-when. Since sc-expand will give us something that isn't Scheme because we put the <module-ref> structures in it, strip that info whenever we actually do need scheme. * module/language/scheme/compile-ghil.scm (lookup-transformer): Strip expansion structures here too. * module/language/scheme/expand.scm (language): Swap annotate for expand-support. But this file will die soon, I think.
2009-04-16support expression-by-expression compilationAndy Wingo1-9/+9
* module/language/ghil.scm (unparse-ghil): Fix unparsing of quasiquoted expressions. * module/language/ghil/spec.scm (join): Define a joiner for GHIL. * module/language/scheme/compile-ghil.scm (cenv-ghil-env): Expand the definition of a CENV so it can have an actual ghil-env, if available. (compile-ghil): Return the actual ghil env in the cenv. * module/system/base/compile.scm (compile-file): Rewrite. `output-file' is now a keyword argument, along with the new kwargs `env' and `from'. We now allow exceptions to propagate up, and instead of printing the output file to the console, we return a string corresponding to its location. (compile-and-load): Use read-and-compile. (compile-fold): Thread around the cenv as well. Return all three values. (find-language-joint, read-and-compile): New exciting helpers. The idea is that compiling a file should be semantically equivalent to compiling each expression in it, one by one. Compilation can have side effects, e.g. affecting the current language or the current reader. So what we do is find a point in the compilation path at which different expressions of a given language can be joined into one. Expressions from the source language are compiled to the joint language, then joined and compiled to the target. (compile): Just return the first value from compile-fold. * module/system/base/language.scm (language-joiner): New optional field. * scripts/compile: Rework for changes to compile-file.
2009-04-16compilation passes return third value: the continuation environmentAndy Wingo1-5/+10
* 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-03-06Replace eval-case with eval-whenAndy Wingo1-30/+7
* module/ice-9/boot-9.scm (eval-when): Replace eval-case with eval-when. Eval-when is *much* simpler, and more expressive to boot. Perhaps in the future we'll get 'visit and 'revisit too. * module/ice-9/deprecated.scm (eval-case): Provide mostly-working deprecated version of eval-case. * module/ice-9/boot-9.scm (defmacro, define-macro): Relax condition: we can make defmacros that are not at the toplevel now. But in the future we should replace this implementation of defmacros with one written in syntax-case. (define-module, use-modules, use-syntax): Allow at non-toplevel. (define-public, defmacro-public, export, re-export): Don't evaluate at compile-time, I can't see how that helps things. Allow `export' and `re-export' at non-toplevel. * module/ice-9/getopt-long.scm: * module/ice-9/i18n.scm: * module/oop/goops.scm: * module/oop/goops/compile.scm: * module/oop/goops/dispatch.scm: Switch to use eval-when, not eval-case. * module/language/scheme/compile-ghil.scm (eval-when): Replace eval-case transformer with eval-when transformer. Sooooo much simpler, and it will get better once we separate expansion from compilation. * module/language/scheme/expand.scm (quasiquote): Hm, expand quasiquote properly. Not hygienic. Syncase needed. (lambda): Handle internal defines with docstrings propertly.
2009-02-27use -> macro in scheme->ghil compilerAndy Wingo1-41/+46
* module/language/scheme/compile-ghil.scm (->): New macro, makes GHIL generation a bit more palatable. Use it in all the transformers.
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-9/+9
* 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-14generate the fixed-offset accessors at compile-timeAndy Wingo1-2/+3
* module/language/scheme/compile-ghil.scm (define-scheme-translator): Only add an else clause if the transformer didn't have one. * module/oop/goops.scm (min-fixnum, max-fixnum): Define at compile-time as well. (@slot-ref, @slot-set!): Only define transformers for these at compile-time. Avoids loading up the compiler unnecessarily. Also, allow for the `n' to be determined lexically, in which case we dispatch to the primitive. (num-standard-pre-cache, define-standard-accessor-method) (bound-check-get, standard-get, standard-set): Rework the fixed-offset getters and setters so that they can be computed at compile-time. Accessors to fields with n > num-standard-pre-cache will be dispatched to the primitive instead of within the VM.
2009-02-13no keyword arguments in GHIL / GLIL, just optional args -- faster compilesAndy Wingo1-3/+3
* module/system/base/syntax.scm (define-record): So, in the generated constructors, allow optional arguments, but not keyword arguments. Conses much less in the constructors. (define-record/keywords): And the old define-record is here. * module/language/ghil.scm (parse-ghil): * module/language/ghil/compile-glil.scm (codegen): * module/language/scheme/compile-ghil.scm (translate-1, quote) (quasiquote): Don't use keywords in this compiler hotpath. * module/system/base/language.scm (<language>): * module/system/repl/common.scm (<repl>): * module/system/vm/debug.scm (<debugger>): Use define-record/keywords.
2009-02-10propagate much more source info through compilationAndy Wingo1-5/+7
* module/language/ghil/compile-glil.scm (codegen): Record source location for offset 0 into a lambda, if we can. * module/language/scheme/compile-ghil.scm (translate-1) (define-scheme-translator): In the retrans procedures, propagate the location information from the enclosing expression if the subexpression has no location information. Gives source information to many more expressions. (location): Just propagate the source properties as they are, the glil->assembly compiler will interpret them. * module/language/glil.scm (<glil>): Change glil-source to take "props" and not "loc", as it's the source properties that we're interested in. * module/language/glil/compile-assembly.scm (limn-sources): New function, takes a list of addr-source property pairs and "compresses" them for serialization to disk. (glil->assembly): Limn the sources before writing them to disk. Avoid non-tail recursion when determining total byte length of code. * module/system/vm/program.scm (source:file, source:line, source:column): Update for new source representation. (program-source): Export. (write-program): Nicer pretty-printing of anonymous procedures. * libguile/backtrace.c (display_backtrace_get_file_line): Update for the new VM source representation. * libguile/programs.h: * libguile/programs.c (scm_program_sources): Update for the new serialized source representation, where the filename is not in the stream unless it changes. (scm_program_source): New exported function, looks up the source for a given ip offset. (scm_c_program_source): Update to return the last source information that was <= the given IP, because we only serialize source info when it changes.
2009-02-09nicety in the compilerAndy Wingo1-3/+2
* module/language/scheme/compile-ghil.scm (lookup-transformer): Use @@. Delightfully metacircular.
2009-02-09allow defmacros to unquote in macros into expanded expressionsAndy Wingo1-6/+11
* module/language/scheme/compile-ghil.scm (lookup-transformer): Allow macros to be unquoted into the car of any form that results from macro expansion. This lets modules export defmacros built on other defmacros that are not exported.
2009-02-09minor cleanupsAndy Wingo1-5/+5
* libguile/stacks.c (scm_make_stack): Instead of aborting when we misread the number of stack frames, just print a warning. I'd like to figure out what these cases are, exactly. * module/language/scheme/compile-ghil.scm (lambda): Reindent the lambda transformer. * module/system/base/compile.scm (call-with-compile-error-catch): Write the expression instead of displaying it. (call-with-output-file/atomic): Don't actually redirect output to this port, as it's not necessary -- the language-printer should respect the port that we pass.
2009-02-02Name anonymous let- or letrec-bound proceduresAndy Wingo1-2/+7
* module/language/scheme/compile-ghil.scm (let, letrec): Give names to procedures of the form (let ((foo (lambda ....)))).
2009-01-09rename translate.scm to compile-ghil.scm, and more work on compiler.texiAndy Wingo1-0/+514
* doc/ref/api-evaluation.texi: Fix some typos and xrefs. * doc/ref/compiler.texi (The Scheme Compiler): Document the scheme compiler, and start documenting the GHIL language. * doc/ref/guile.texi (Guile Implementation): Whoops, put autoconf after the implementation foo. Unless we want it before? * doc/ref/history.texi (The Emacs Thesis): Fix typo. * doc/ref/vm.texi (Environment Control Instructions): Rename offset to index. * module/language/ghil.scm (parse-ghil): Fix what I think was a bug -- the consumer in a mv-call shouldn't be a rest arg. * module/language/scheme/Makefile.am (SOURCES): * module/language/scheme/compile-ghil.scm: Rename this file from translate.scm. * module/oop/goops.scm: * module/language/scheme/spec.scm: Deal with renaming.