summaryrefslogtreecommitdiff
path: root/module/system/base/syntax.scm
AgeCommit message (Collapse)AuthorFilesLines
2019-10-23make-record-type does more validation on the fieldsAndy Wingo1-3/+3
* module/ice-9/boot-9.scm (make-record-type): Validate that the fields are a unique list of symbols. Deprecate passing a string as a type name. * module/system/base/syntax.scm (define-record): Update to pass a symbol as a type name. * test-suite/tests/records.test (rtd-foo, rtd-fŏŏ, "records"): Adapt to make record types with symbol names.
2017-09-20Use make-struct/no-tail instead of make-structAndy Wingo1-1/+1
* module/ice-9/boot-9.scm: * module/language/cps/effects-analysis.scm: * module/language/elisp/falias.scm: * module/language/tree-il.scm: * module/language/tree-il/primitives.scm: * module/rnrs/records/procedural.scm: * module/srfi/srfi-35.scm: * module/system/base/syntax.scm: Change uses of make-struct to make-struct/no-tail.
2017-03-07psyntax: Generate identifiers in a deterministic fashion.Mark H Weaver1-4/+4
Fixes <http://bugs.gnu.org/20272>. * module/ice-9/boot-9.scm (module-generate-unique-id!) (module-gensym): New procedures. (module): Add 'next-unique-id' field. (the-root-module): Inherit 'next-unique-id' value from early stub. (make-module, make-autoload-interface): Adjust calls to module-constructor. * module/ice-9/psyntax.scm (gen-label, new-mark): Generate unique identifiers from the module name and the per-module unique-id. (build-lexical-var, generate-temporaries): Use 'module-gensym' instead of 'gensym'. * module/ice-9/psyntax-pp.scm: Regenerate. * module/language/tree-il/fix-letrec.scm (fix-letrec!): Use 'module-gensym' instead of 'gensym'. * module/system/base/syntax.scm (define-record): Likewise. (transform-record): Likewise. Co-authored-by: Ludovic Courtès <ludo@gnu.org>
2016-02-01Update statprof documentation; deprecate `with-statprof'Andy Wingo1-29/+1
* module/statprof.scm: Remove most of the commentary, as it was duplicated in the manual and was getting out of date. (stats): Remove self-secs-per-call and cum-secs-per-call fields as they can be computed from the other fields. (statprof-call-data->stats): Adapt. (statprof-stats-self-secs-per-call): (statprof-stats-cum-secs-per-call): New functions. (statprof-display/flat): Don't print the seconds-per-call fields, as we are no longer stopping the clock around call counters. Anyway these times were quite misleading. (with-statprof): Deprecate. It took its keyword arguments at the beginning; very complicated! Better to use the `statprof' function. (`statprof' was introduced after `with-statprof' and then `with-statprof' was adapted to use it.) * doc/ref/statprof.texi (Statprof): Port this documentation away from the automatically generated text and update it for the new interfaces like #:display-style. * module/system/base/syntax.scm (record-case): Remove comment that referenced with-statprof. Add comment indicating that record-case should be replaced. * doc/ref/scheme-using.texi (Profile Commands): Update to mention keyword arguments and to link to the statprof documentation.
2009-08-05let-values in terms of syntax-case, add make-tree-il-folderAndy Wingo1-24/+65
* module/language/tree-il.scm (tree-il-fold): Fix for let-values case. (make-tree-il-folder): New public macro, makes a multi-valued folder specific to the number of seeds that the user wants. * module/language/tree-il/optimize.scm (optimize!): Reverse the order of inline! and fix-letrec!, as the latter might expose opportunities for the former. * module/srfi/srfi-11.scm (let-values): Reimplement in terms of syntax-case, so that its expressions may reference hygienically bound variables. See the NEWS for the rationale. (let*-values): An empty let*-values still introduces a local `let' binding contour. * module/system/base/syntax.scm (record-case): Yukkkk. Reimplement in terms of syntax-case. Ug-ly, but see the NEWS again: "Lexical bindings introduced by hygienic macros may not be referenced by nonhygienic macros."
2009-07-15Switch remaining GPLv2+ Guile-VM headers to LGPLv3+.Ludovic Courtès1-14/+13
* module/system/base/compile.scm, module/system/base/syntax.scm, module/system/repl/common.scm, module/system/repl/describe.scm, module/system/vm/instruction.scm, module/system/vm/objcode.scm, module/system/vm/profile.scm, module/system/vm/program.scm, module/system/vm/trace.scm: Switch header from GPLv2+ to LGPLv3+.
2009-02-27slight optimization in transform-record, note in optimize*Andy Wingo1-3/+5
* module/language/ghil/compile-glil.scm (optimize*): Add a note. * module/system/base/syntax.scm (transform-record): Access the common slots once at the beginning. Cuts down on the number of toplevel refs needed by the generated code.
2009-02-27introduce -> binding inside transform-record body expressionsAndy Wingo1-1/+17
* module/system/base/syntax.scm (transform-record): Introduce a -> binding inside the body, that produces records of the same type. * module/language/ghil/compile-glil.scm (optimize*): Remove our ->ghil definition, as transform-record introduces a -> binding for us. Nice.
2009-02-27first stabs as s-expression-driven transformation of GHILAndy Wingo1-3/+72
* module/language/ghil/compile-glil.scm (optimize*): Rewritten optimizer -- not yet in use, but it's closer to the code that I'd like to write. * module/system/base/syntax.scm (transform-record): New crazy macro, makes GHIL a little less painful to work with.
2009-02-27common slot accessors are procedures-with-settersAndy Wingo1-4/+5
* module/system/base/syntax.scm (define-type): Common slot accessors are also procedures-with-setters.
2009-02-27use common slots mechanism in ghilAndy Wingo1-1/+1
* module/system/base/syntax.scm (define-type): Fix getter for common slot. * module/language/ghil.scm (<ghil>): Use the common slots mechanism.
2009-02-27define-type has #:common-slotsAndy Wingo1-6/+16
* module/system/base/syntax.scm (define-type): Accept a #:common-slots argument, defining slots that are in all instances of this type.
2009-02-21be smarter about allocating local variables, reusing slots if possibleAndy Wingo1-1/+1
* 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-13inline record predicates into record-caseAndy Wingo1-3/+5
* module/system/base/syntax.scm (record-case): Inline record predicates into the record-case. Shaves off a few more milliseconds from a GOOPS load.
2009-02-13no keyword arguments in GHIL / GLIL, just optional args -- faster compilesAndy Wingo1-1/+35
* 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-11speed up record-caseAndy Wingo1-7/+36
* module/language/ghil.scm: Whoops, export some unquote-splicing accessors that we didn't have exported before. * module/system/base/syntax.scm: Speed up record-case, by syntactically determining the predicates and accessors. Nasty, in a way; but also much faster.
2008-11-14nifty generic compiler infrastructure -- no more hardcoded passesAndy Wingo1-5/+9
* 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/+9
* 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-10-30recompiling with compile environments, fluid languages, cleanupsAndy Wingo1-1/+4
* ice-9/boot-9.scm (compile-time-environment): Remove definition from boot-9 -- instead, autoload it and `compile' from (system base compile). * libguile/objcodes.h: * libguile/objcodes.c (scm_objcode_to_program): Add an optional argument, `external', the external list to set on the returned program. * libguile/vm-i-system.c (externals): New instruction, returns the external list. Only used by (compile-time-environment). * libguile/vm.c (scm_load_compiled_with_vm): Adapt to scm_objcode_to_program change. * module/language/scheme/translate.scm (translate): Actually pay attention to the environment passed as an argument. (custom-transformer-table): Expand out (compile-time-environment) to something that can be passed to `compile'. * module/system/base/compile.scm (*current-language*): Instead of hard-coding `scheme' in various places, use a current language fluid, initialized to `scheme'. (compile-file, load-source-file): Adapt to *current-language*. (load-source-file): Ada (scheme-eval): Removed, no one used this. (compiled-file-name): Don't hard-code "scm" and "go"; instead use the %load-extensions and %load-compiled-extensions. (cenv-module, cenv-ghil-env, cenv-externals): Some accessors for compile-time environments. (compile-time-environment): Here we define (compile-time-environment) to something that will return #f; the compiler however produces different code as noted above. (compile): New function, compiles an expression into a thunk, then runs the thunk to get the value. Useful for procedures. The optional second argument can be either a module or a compile-time-environment; in the latter case, we can recompile even with lexical bindings. (compile-in): If the env specifies a module, set that module for the duration of the compilation. * module/system/base/syntax.scm (%compute-initargs): Fix a bug where the default value for a field would always replace a user-supplied value. Whoops. * module/system/il/ghil.scm (ghil-env-dereify): New function, takes the result of ghil-env-reify and turns it back into a GHIL environment. * scripts/compile (compile): Remove some of the tricky error handling, as the library procedures handle this for us. * test-suite/tests/compiler.test: Add a test for the dynamic compilation bits.
2008-10-25define-type no longer expects `|' subformAndy Wingo1-11/+3
* module/system/base/syntax.scm (define-type): Rework to not require the `|', which confuses Emacs. * module/system/il/ghil.scm (<ghil>): * module/system/il/glil.scm (<glil>): Adapt to define-type changes.
2008-09-09use #:keywords in module/*.scm, not :keywordsAndy Wingo1-9/+2
* 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-15avoid zealous unquotationAndy Wingo1-7/+6
* module/system/base/syntax.scm (define-record): Again, don't unquote in actual objects, because this is uncompilable. Ah well. At least now all of base/ is compiling. * module/system/vm/assemble.scm (dump-object!): More debug info.
2008-05-15fix else in cond, letrec env corruption, syntax.scm compile, define-module ↵Andy Wingo1-3/+4
side effects * module/language/scheme/translate.scm (primitive-syntax-table): Translate the `else' clause of a cond as (begin ...). We used to use trans-body, which processes internal defines, which are not legal syntax here. * module/system/base/syntax.scm (define-record): Unfortunately, we can't unquote in the actual procedure for `%compute-initargs', because that doesn't work with compilation. So reference %compute-initargs by name, and export it. * module/system/il/ghil.scm (apopq!): Gaaaaar. The order of the arguments to assq-remove! was reversed, which was the badness, causing corruption to the env after calling call-with-ghil-bindings. Grrrrrr. (fix-ghil-mod!, ghil-lookup, ghil-define): As amply commented in the code, deal with compile-time side effects to the current module by lazily noticing and patching up the compile-time environment. A hacky solution until such a time as we special-case something for `define-module'.
2008-05-11<foo>? -> foo?; some exports cleanupsAndy Wingo1-32/+6
* module/system/base/compile.scm: Export cenv? also. * module/system/base/syntax.scm: Clean up vestiges of the old structure code. Make accessors defined as foo? instead of <foo>?. * module/system/il/glil.scm: * module/system/il/ghil.scm: Remove <foo>-1 accessors, since we have named accessors.
2008-05-04Replace ice-9 match's structures with guile's recordsAndy Wingo1-66/+37
* module/system/base/syntax.scm (define-record): Rebase to implement on top of Guile's records, which are the substrate of srfi-9's records. (%compute-initargs): Rename from %make-struct, just return the list of values. (get-slot, set-slot!, slot): Removed, no longer used. (record-case): Allow slots of the form (MYNAME SLOTNAME), which binds SLOTNAME to MYNAME (instead of SLOTNAME to SLOTNAME). (record-case, record?): No more ice-9 match! * module/system/il/compile.scm (codegen): Tweaks so that the new record code works. * module/system/il/ghil.scm: Fix some slot references. * module/system/vm/assemble.scm (preprocess, codegen): Remove calls to `slot'. (codegen): Fix some slot references.
2008-05-04Removed dot-expander syntax fooAndy Wingo1-27/+1
* module/system/base/syntax.scm (expand-dot!, expand-symbol, syntax): Removed, we don't use this syntax any more.
2008-05-04procedures-with-setters, debitrot `optimize', dedottificationAndy Wingo1-5/+7
* module/system/base/syntax.scm (define-record): Define the accessors as procedures-with-setters, not just as getters. * module/system/il/compile.scm (optimize): This function was bitrotten since the addition of source locations in cb4cca12e719edfef1740f238d9187c21c8e1e35. Untested attempts to de-bitrot it. Dedottify as well. * module/system/il/ghil.scm: * module/system/il/glil.scm (unparse): * module/system/vm/debug.scm (debugger-repl): Ongoing dedottification.
2008-05-04Define named accessors for legacy record typesAndy Wingo1-6/+8
* module/system/base/syntax.scm (define-record): Define named accessors, to prepare the code for srfi-9 records switchover. * module/system/il/ghil.scm: * module/system/il/glil.scm: Export a bunch of named accessors.
2008-05-03convert a couple more modules to record-caseAndy Wingo1-1/+1
* module/system/base/syntax.scm (record-case): Capture the match macro. * module/system/il/glil.scm: * module/system/il/compile.scm: Convert to record-case.
2008-05-03unify variant types and records; also make-foo instead of <foo>Andy Wingo1-39/+40
* 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-05-03Convert assemble.scm to use record-case.Andy Wingo1-2/+12
* module/system/base/syntax.scm (record?): Temporarily export this thing, so that code will remain correct when I change to srfi-9 records. * module/system/vm/assemble.scm: Convert to use record-case.
2008-05-03fix to (system base syntax)'s syntaxAndy Wingo1-1/+1
* module/system/base/syntax.scm: Fix define-module
2008-05-03rebase record-case on `match'Andy Wingo1-0/+6
* module/system/base/syntax.scm (record-case): Rebase on `match', for transition purposes.
2008-05-03pull in srfi-9, implement record-caseAndy Wingo1-1/+19
* module/system/base/syntax.scm: Pull in srfi-9. Define a record-case macro that will replace (match foo (($ <type> slot ...) body...)).
2008-05-02clean up some syntax imports and exportsAndy Wingo1-4/+1
* module/system/base/syntax.scm (system): Don't re-export receive or and-let*; modules should explicitly import these if they want to. Don't export an empty stack-catch definition! * module/system/repl/command.scm (system): Pull in and-let*. * module/system/vm/disasm.scm (system): Don't import and-let*.
2008-05-02cleanups in syntax.scmAndy Wingo1-35/+38
* benchmark/lib.scm (fibo): Make fibo actually a fibonacci sequence. * module/system/base/syntax.scm (system): Forward-declare all exports. (expand-symbol, slot): Rewrite expand-symbol to expand to a non-recursive invocation of `slot', so that in the future when we get rid of this syntax, the replacement will be more palatable to the eyes.
2008-04-25Fixed a Scheme translation bug; cleaned compilation with GCC 4.Ludovic Courtes1-3/+4
* module/language/scheme/translate.scm (trans-pair): In the `set!' case, when a procedure-with-setter is passed, call `trans:pair' with an actual pair. This fixes a long-lasting bug which prevented compilation of `set!' statements with procedures-with-setter (this showed up when compiling `(system vm assemble)'). * module/system/base/compile.scm: Added `objcode->u8vector' to the `#:select' clause. * module/system/base/syntax.scm: Cosmetic changes. * module/system/vm/assemble.scm (preprocess): Removed debugging statements. * src/frames.c: Cosmetic changes. * src/frames.h (SCM_FRAME_SET_DYNAMIC_LINK): New. * src/objcodes.c: Use `scm_t_uint8' instead of `char' when relevant. * src/vm.c (vm_heapify_frames_1): Use `SCM_FRAME_SET_DYNAMIC_LINK ()'. * src/vm_loader.c: Added casts to mute GCC 4 warnings. * testsuite/run-vm-tests.scm (*scheme*): Renamed to `%scheme'. (run-test-from-file): Renamed to `compile/run-test-from-file'. (run-vm-tests): Run each test using both the VM and the interpreter; compare the results. * testsuite/t-proc-with-setter.scm: Try out `get/set'. * doc/Makefile.am (info_TEXINFOS): New. * doc/guile-vm.texi: Added index entries and indices. * doc/texinfo.tex: New file. git-archimport-id: lcourtes@laas.fr--2005-mobile/guile-vm--mobile--0.6--patch-5
2008-04-25Translation from Scheme to GHIL, and compilation to GLIL work.Ludovic Court`es1-2/+1
* src/*.c: Removed calls to `scm_must_malloc', `SCM_MUST_MALLOC' and `scm_must_free'. Same for `SCM_INUMP', `SCM_INUM', `SCM_STRING_CHARS', and the likes. * module/system/base/syntax.scm: Do not import `(ice-9 match)' and do not re-export `match', do not export `syntax-error' which was not defined here. * module/system/base/compile.scm (call-with-compile-error-catch): Use the `catch' form instead of `try'. * src/instructions.c: Use `scm_from_char ()' instead of the deprecated macro `SCM_MAKINUM ()'. * src/instructions.h (scm_instruction): Made `npop' a signed char. git-archimport-id: lcourtes@laas.fr--2004-libre/guile-vm--revival--0.6--patch-2
2001-04-25*** empty log message ***Keisuke Nishida1-2/+1
2001-04-22*** empty log message ***Keisuke Nishida1-36/+107
2001-04-19*** empty log message ***Keisuke Nishida1-1/+1
2001-04-01New VM.Keisuke Nishida1-0/+98