summaryrefslogtreecommitdiff
path: root/module/system/base/language.scm
AgeCommit message (Collapse)AuthorFilesLines
2020-05-08Add compiler chooser implementation; fix bugs with previous commitAndy Wingo1-4/+5
* module/system/base/compile.scm (next-pass): Invoke the language's compiler chooser if there is more than one compiler. (compute-compiler): Ensure from and to are languages. * module/system/base/language.scm (<language>): Add compiler-chooser field. * module/language/brainfuck/spec.scm (choose-compiler, brainfuck): Define a compiler chooser.
2020-05-08Define new "lowering" phase in compilerAndy Wingo1-2/+2
* module/language/cps/compile-bytecode.scm (compile-bytecode): * module/language/tree-il/compile-bytecode.scm (compile-bytecode): * module/language/tree-il/compile-cps.scm (compile-cps): Rely on compiler to lower incoming term already. * module/language/tree-il/optimize.scm (make-lowerer): New procedure. * module/system/base/compile.scm (compute-lowerer): New procedure, replaceing add-default-optimizations. (compute-compiler): Lower before running compiler. * module/system/base/language.scm (<language>): Change optimizations-for-level field to "lowerer". * module/scripts/compile.scm (%options, compile): Parse -O0, -O1 and so on to #:optimization-level instead of expanding to all the optimization flags. * module/language/cps/optimize.scm (lower-cps): Move here from compile-bytecode.scm. (make-cps-lowerer): New function. * module/language/cps/spec.scm (cps): Declare lowerer.
2020-05-08Add language-specific analysis pass to compiler infrastructureAndy Wingo1-1/+5
* module/system/base/compile.scm (compute-analyzer): Compute analyzer to run on expressions before the compiler runs. (add-default-optimizations): Flesh out; still a stub.a (read-and-compile, compile, compile-and-load, compile-file): Default warning and optimization levels. (default-warning-level): New parameter, defaulting to 1. (default-optimization-level): New parameter, defaulting to 2. Currently unused. * module/system/base/language.scm (<language>): Add optimizations-for-level and analyzer fields. * module/language/tree-il/compile-bytecode.scm (compile-bytecode): * module/language/tree-il/compile-cps.scm (optimize-tree-il): No need to run warnings passes here; compilers infrastructure will run them. * module/language/tree-il/spec.scm (tree-il): Define make-analyzer as analyzer. * module/language/tree-il/analyze.scm (make-analyzer): New exported procedure. (%warning-passes): New private variable. * .dir-locals.el: Add with-test-prefix/c&e indent mode. * test-suite/tests/cross-compilation.test: * test-suite/tests/optargs.test: * test-suite/tests/tree-il.test: Adjust to disable default warnings.
2020-05-07Remove compilation order cacheAndy Wingo1-28/+13
* module/system/base/language.scm (define-language): Remove invalidate-compilation-cache! call. (invalidate-compilation-cache!): Deprecate. (*decompilation-cache*, *compilation-cache*): Remove. (lookup-compilation-order, lookup-decompilation-order): Don't use a cache. (*current-language*): Only define this when deprecation is enabled.
2013-01-27Add 'for-humans?' flag to <language> specifications.Mark H Weaver1-1/+3
* module/system/base/language.scm (<language>): Add 'for-humans?' field, and export new 'language-for-humans?' predicate. * doc/ref/compiler.texi (Compiler Tower): Document. * module/language/assembly/spec.scm, module/language/bytecode/spec.scm, module/language/glil/spec.scm, module/language/objcode/spec.scm, module/language/tree-il/spec.scm, module/language/value/spec.scm: Mark these languages as 'for-humans?'.
2013-01-22current-language is a parameter in boot-9Andy Wingo1-6/+6
* module/ice-9/boot-9.scm (current-language): New parameter. * module/system/base/language.scm (*current-language*): Pull fluid from parameter. (current-language): Now a re-exported parameter. * doc/ref/compiler.texi: Update reference from *current-language* fluid to current-language parameter. * module/system/base/compile.scm (compile-and-load): * module/ice-9/top-repl.scm (top-repl): Default to the current language, not to Scheme. * module/ice-9/eval-string.scm: * module/system/base/language.scm: * module/system/repl/command.scm: * module/system/repl/repl.scm: Update to use current-language parameter and parameterize.
2011-11-23Use default value for make-fluid in Scheme filesAndy Wingo1-2/+2
* module/ice-9/boot-9.scm (%exception-handler) (%running-exception-handlers, read-eval?, *repl-stack*) (make-mutable-parameter): * module/ice-9/getopt-long.scm (%program-name): * module/language/elisp/runtime.scm (built-in-macro, defspecial): * module/srfi/srfi-39.scm (make-parameter/helper): * module/system/base/language.scm (*current-language*): * module/system/base/message.scm (*current-warning-port*): (*current-warning-prefix*): * module/system/base/target.scm (%target-type, %target-endianness) (%target-word-size): * module/texinfo/plain-text.scm (*indent*, *itemizer*): * benchmark-suite/lib.scm (prefix-fluid): * test-suite/lib.scm (prefix-fluid): Give fluids a useful default value.
2011-06-17current-language really defaults to Scheme.Andy Wingo1-3/+2
* module/system/base/language.scm (current-language): Default to 'scheme here, rather than relying on *current-language* always being bound. Thanks to δΊšε…‰ε” <texnician@gmail.com> for the report.
2010-06-02current-language fluid refactoringAndy Wingo1-1/+15
* module/system/base/compile.scm: * module/system/base/language.scm (*current-language*, current-language): Move this fluid and thunk down to (system base language).
2010-05-02remove `version' field from <language>Andy Wingo1-3/+2
* module/system/base/language.scm (<language>): Remove the `version' field from languages. It just wasn't useful. * module/language/assembly/spec.scm: * module/language/brainfuck/spec.scm: * module/language/bytecode/spec.scm: * module/language/ecmascript/spec.scm: * module/language/elisp/spec.scm: * module/language/glil/spec.scm: * module/language/objcode/spec.scm: * module/language/scheme/spec.scm: * module/language/tree-il/spec.scm: * module/language/value/spec.scm: Remove #:version from all language definitions. Shorten some language names (e.g. "Guile Scheme" -> "Scheme").
2009-10-16compilation enviroments are always modules; simplifications & refactoringsAndy Wingo1-3/+9
* module/ice-9/boot-9.scm (make-fresh-user-module): New public function, makes an anonymous beautified module. * module/language/objcode/spec.scm: We used to have some things in here that allowed lexical variable names and values to be a part of the environment, but no more. Now an environment is just a module. If you want to "inject" free variables into code, just use lambda. * module/language/scheme/compile-tree-il.scm (compile-tree-il): Same here. Also, rely on the fact that an environment *will* be a module -- because (system base compile) guarantees that for us. * module/language/scheme/spec.scm (scheme): In the reader, rely on the environment being a module. Define a #:make-default-environment handler, which returns a beautified module, augmented with a fresh definition for current-reader, so that side effects to current-reader are restricted to the compilation unit. * module/language/tree-il/analyze.scm (report-possibly-unbound-variables): * module/language/tree-il/compile-glil.scm (compile-glil): * module/language/tree-il/optimize.scm (optimize!): The environment will be a module. * module/system/base/language.scm (<language>): New field, `make-default-environment'. Defaults to `make-fresh-user-module'. (default-environment): New accessor, returns a default environment for a language. * module/system/repl/common.scm (repl-compile): Always compile relative to the current module, because a module is always acceptable as an environment. * module/system/base/compile.scm (compile-file, compile-and-load): Both of these have a new keyword argument, #:env. For `compile-file', it defaults to the default environment of the source language, and for `compile-and-load', to the current module. (read-and-compile): If there are no expressions read, pass the joiner its default environment (via `default-environment joint').
2009-06-21add brainfuck->tree-il compilerAndy Wingo1-12/+12
* module/Makefile.am (BRAINFUCK_LANG_SOURCES): Compile at the end. Add compile-tree-il.scm. * module/language/brainfuck/compile-tree-il.scm: New compiler, compiles to tree-il instead of scheme. I thought it would be more illustrative, though there are some uncommented bits. * module/language/brainfuck/parse.scm: Modify not to put a header on the scheme representation. After all, we don't put <scheme> before scheme code, do we? :) * module/language/brainfuck/spec.scm: Add tree-il compiler. * module/language/tree-il.scm: Understand (set! (lexical foo) ...). * module/system/base/language.scm: Update license. Actually, updates licenses on all these.
2009-05-24update docs, clean up VM vestiges, macro docs, fix (/ a b c)Andy Wingo1-2/+1
* doc/ref/api-procedures.texi (Compiled Procedures): Fix for API changes. * doc/ref/compiler.texi (Compiling to the Virtual Machine): Replace GHIL docs with Tree-IL docs. Update the bits about the Scheme compiler to talk about Tree-IL and the expander instead of GHIL. Remove <glil-argument>. Add placeholder sections for assembly and bytecode. * doc/ref/vm.texi: Update examples with what currently happens. Reword some things. Fix a couple errors. * libguile/vm-i-system.c (externals): Remove this instruction, it's not used. * module/ice-9/documentation.scm (object-documentation): If the object is a macro, try to return documentation on the macro transformer. * module/language/assembly/disassemble.scm (disassemble-load-program): Fix problem in which we skipped the first element of the object vector, because of changes to procedure layouts a few months ago. * module/language/scheme/spec.scm (read-file): Remove read-file definition. * module/language/tree-il.scm: Reorder exports. Remove <lexical>, it was a compat shim to something that was never released. Fix `location'. * module/language/tree-il/primitives.scm (/): Fix expander for more than two args to /. * module/system/base/compile.scm (read-file-in): Remove unused definition. * module/system/base/language.scm (system): Remove language-read-file. * module/language/ecmascript/spec.scm (ecmascript): Remove read-file definition.
2009-04-16support expression-by-expression compilationAndy Wingo1-1/+3
* 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-02-13no keyword arguments in GHIL / GLIL, just optional args -- faster compilesAndy Wingo1-1/+1
* 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-01-30add decompilers that can take us back to assemblyAndy Wingo1-4/+6
* module/language/assembly/Makefile.am: * module/language/assembly/spec.scm: * module/language/assembly/decompile-bytecode.scm: Add a bytecode decompiler. Neat! * module/language/bytecode/spec.scm (decompile-objcode): * module/language/objcode/spec.scm (decompile-value): Add some "decompilers" here too. * module/system/base/compile.scm (current-language): Since we can refer to languages by name, do so here -- removes the previous anti-circularity hack. (compile-file, compile): Refer to target languages by name. (decompile): New public function. Neat! * module/system/base/language.scm (lookup-decompilation-order): Fix so we look for decompilers with the high-level language definition.
2009-01-30allow specification of languages by name; add decompilers to languagesAndy Wingo1-13/+34
* module/system/base/language.scm (lookup-decompilation-order): New function, like its compiling cousin, but backwards. (compute-translation-order): Rework so that languages can be specified either by name or by identity. Return a list of language - procedure pairs, without the "to" language in the list, instead of a list of languages. (invalidate-compilation-cache!): Invalidate the decompilation cache too. (<language>): Add a decompiler field. * module/system/base/compile.scm (compile-passes): Much simpler now that lookup-compilation-order gives us the procedures directly. * module/language/*/spec.scm: Specify compilers by name, so that we can avoid unnecessary module loads, and so that when we specify decompilers, we can avoid cycles.
2008-11-14nifty generic compiler infrastructure -- no more hardcoded passesAndy Wingo1-12/+38
* module/system/base/language.scm (<language>): Rework so that instead of hardcoding passes in the language, we define compilers that translate from one language to another. Add `parser' to the language fields, a bit of a hack but useful for languages with s-expression external representations but with record internal representations. (define-language, *compilation-cache*, invalidate-compilation-cache!) (compute-compilation-order, lookup-compilation-order): Add an algorithm that does a depth-first search for a translation path from a source language to a target language, caching the result in a lookup table. * module/language/scheme/spec.scm: * module/language/ghil/spec.scm: Update to the new language format. * module/language/glil/spec.scm: Add a language specification for GLIL, with a compiler to objcode. Also there are parsers and printers, for repl usage, but for some reason this doesn't work yet. * module/language/objcode/spec.scm: Define a language specification for object code. There is some sleight of hand here, in the "compiler" to values; but there is method behind the madness, because this way we higher levels can pass environments (a module + externals pair) to objcode->program. * module/language/value/spec.scm: Define a language specification for values. There is something intellectually dishonest about this, but it does serve its purpose as a foundation for the language hierarchy. * configure.in: * module/language/Makefile.am * module/language/ghil/Makefile.am * module/language/glil/Makefile.am * module/language/objcode/Makefile.am * module/language/value/Makefile.am: Autotomfoolery for the ghil, glil, objcode, and value languages. * module/language/scheme/translate.scm (translate): Import the bits that understand `compile-time-environment' here, and pass on the relevant portions of the environment to the next compiler pass. * module/system/base/compile.scm (current-language): New procedure, refs the current language fluid, or lazily sets it to scheme. (call-once, call-with-output-file/atomic): Refactor these bits to use with-throw-handler. No functional change. (compile-file, compile-and-load, compile-passes, compile-fold) (compile): Refactor the public interface of the compiler to be generic and simple. Uses `lookup-compilation-order' to find a path from the source language to the target language. * module/system/base/syntax.scm (define-type): Adapt to changes in define-record. (define-record): Instead of expecting all slots in the first form, expect them in the body, and let the first form hold the options. * module/system/il/compile.scm (compile): Adapt to the compilation pass API (three in and two out). * module/system/il/ghil.scm (<ghil-var>, <ghil-env>) (<ghil-toplevel-env>): Adapt to define-record changes. * module/system/il/glil.scm (<glil-vars>): Adapt to define-record changes. (<glil>, print-glil): Add a GLIL record printer that uses unparse. (parse-glil, unparse-glil): Update unparse (formerly known as pprint), and write a parse function. * module/system/repl/common.scm (<repl>): Adapt to define-record changes. (repl-parse): New function, parses the read form using the current language. Something of a hack. (repl-compile): Adapt to changes in `compile'. (repl-eval): Fix up the does-the-language-have-a-compiler check for changes in <language>. * module/system/repl/repl.scm (start-repl): Parse the form before eval. * module/system/repl/command.scm (describe): Parse. (compile): Be more generic. (compile-file): Adapt to changes in compile-file. (disassemble, time, profile, trace): Parse. * module/system/vm/debug.scm: * module/system/vm/assemble.scm: Adapt to define-record changes. * module/language/scheme/translate.scm (receive): Fix an important bug that gave `receive' letrec semantics instead of let semantics. Whoops!
2008-11-11add parsers and unparser for ghil; ,language ghil works nowAndy Wingo1-3/+4
* module/system/repl/common.scm (repl-print): Slightly refine the meaning of "language-printer": a language printer prints an expression of a language, not the result of evaluation. `write' prints values. * module/language/ghil/spec.scm (ghil): Define a language printer, and a translator for turning s-expressions (not scheme, mind you) into GHIL. * module/language/scheme/translate.scm (quote, quasiquote): Add some #:keyword action, so that we can (quote #:keywords). * module/system/base/language.scm (<language>): * module/system/base/compile.scm (read-file-in): Don't require that a language have a read-file; instead error when read-file is called. (compile-passes, compile-in): Refactor to call a helper method to turn the language + set of options into a set of compiler passes. * module/system/base/syntax.scm (define-type): Allow the type to be a list, with the car being the name and the cdr being keyword options. Interpret #:printer as a printer, and pass it down to... (define-record): Here. * module/system/il/ghil.scm (print-ghil, <ghil>): New printer for GHIL, yay! (parse-ghil, unparse-ghil): New lovely functions. Will document them in the manual.
2008-09-09use #:keywords in module/*.scm, not :keywordsAndy Wingo1-3/+3
* module/system/base/syntax.scm (keywords): Don't enable :keywords, it breaks code that may assume that ':foo is a symbol, like boot-9. * module/*.scm: Don't use :keywords, use #:keywords. The user can decide if she wants #:keywords in their .guile, and :keywords might make us compile modules differently.
2008-05-20guile-vm is completely self-compiling now!Andy Wingo1-2/+2
* module/language/scheme/translate.scm (*the-compile-toplevel-symbol*): Reset to compile-toplevel, which requires a patch to guile. * module/system/base/compile.scm (compile-file): Some foo so that we load up the scheme language before call-with-output-file. Fixes compilation of (language scheme) modules. * module/system/base/language.scm (define-language): Don't unquote in make-language; refer to it by name instead, and export it. * module/system/repl/Makefile.am (vm_DATA): Don't compile describe.scm, because we really can't deal with goops yet. * module/system/repl/repl.scm (compile-toplevel): If we're compiling, put in a stub definition of start-stack, which is closely tied to the interpreter. * src/vm_loader.c (load-program): Fix a very tricky corruption bug!
2008-05-04finish dedottifyingAndy Wingo1-1/+4
* module/system/base/compile.scm: Dedottify. * module/system/base/language.scm: Export language accessors. * module/system/repl/common.scm: Dedottify. It's ugly, I know.
2008-05-03unify variant types and records; also make-foo instead of <foo>Andy Wingo1-1/+1
* module/system/base/syntax.scm (define-record): Rework to separate the type and its constructor. Now (define-record (<foo> bar)) will create `make-foo' as the constructor, not `<foo>'. Also the constructor now takes either keyword or positional arguments, so that it can be used as the implementation of variant types as well. (|): Map directly to define-record instead of rolling our own thing. * module/language/scheme/translate.scm: * module/system/base/language.scm: * module/system/il/compile.scm: * module/system/il/ghil.scm: * module/system/il/glil.scm: * module/system/repl/common.scm: * module/system/vm/assemble.scm: * module/system/vm/debug.scm: Change instances of record creation to use the make-foo procedures instead of <foo>. Adjust module exports as necessary.
2008-04-25Tried compiling more code; augmented the doc.Ludovic Courtes1-1/+1
* module/language/Makefile.am: New. * module/language/scheme/Makefile.am: New. * configure.in: Produce these two new Makefiles. * doc/guile-vm.texi: Documented `compile-file', `compiled-file-name', and `compile-in'. * module/system/base/compile.scm: Cosmetic changes. * module/system/base/language.scm: Likewise. * module/system/il/Makefile.am: Tried (and failed) to compile more things. * module/system/vm/Makefile.am: All source files in here can now be compiled without harming further compilation. * module/system/vm/assemble.scm: Select only specific bindings from `(system vm core)'. (dump-object!): Show a more meaningful error message. * module/system/vm/conv.scm: Select only specific bindings from `(system vm core)'. * module/system/vm/debug.scm: Likewise. * module/system/vm/frame.scm: Changed the header. Use a renamer for `(system vm core)'. * src/guilec.in: Added options, via `getopt-long'. git-archimport-id: lcourtes@laas.fr--2005-mobile/guile-vm--mobile--0.6--patch-6
2001-04-22*** empty log message ***Keisuke Nishida1-14/+7
2001-04-16*** empty log message ***Keisuke Nishida1-49/+2
2001-04-15*** empty log message ***Keisuke Nishida1-32/+26
2001-04-09*** empty log message ***Keisuke Nishida1-9/+3
2001-04-07*** empty log message ***Keisuke Nishida1-1/+1
2001-04-05*** empty log message ***Keisuke Nishida1-1/+1
2001-04-04*** empty log message ***Keisuke Nishida1-1/+0
2001-04-04Better current module system support.Keisuke Nishida1-6/+1
2001-04-03Current module support hack.Keisuke Nishida1-1/+7
2001-04-01New VM.Keisuke Nishida1-0/+111