1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 11:50:28 +02:00
Commit graph

252 commits

Author SHA1 Message Date
Ludovic Courtès
e1203ea00f Switch remaining GPLv2+ Guile-VM headers to LGPLv3+.
* 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-07-15 22:46:54 +02:00
Andy Wingo
5c27902e5e add brainfuck->tree-il compiler
* 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-06-21 15:06:04 +02:00
Andy Wingo
179fe33632 put autocompiled files into ~/.cache or $XDG_CACHE_HOME
* module/system/base/compile.scm (compiled-file-name): Remove unneeded
  path separator.

* libguile/load.c (scm_init_load_path): Change so the default cache path
  is ~/.cache/guile/ccache/1.9, and respect $XDG_CACHE_HOME.
2009-06-20 14:26:54 +02:00
Andy Wingo
25b82b3485 new function: canonicalize-path. use when autocompiling
* libguile/filesys.h:
* libguile/filesys.c (scm_canonicalize_path): New function,
  canonicalize-path.

* module/system/base/compile.scm (compiled-file-name): Canonicalize the
  filename so that compiling e.g. ../foo.scm doesn't compile to
  ~/.guile-ccache/1.9/../foo.scm.
2009-06-19 14:26:47 +02:00
Andy Wingo
535fb833b3 stamp .go with timestamp of .scm; a fresh go has same mtime of .scm
* libguile/load.c (compiled_is_fresh): Rename from compiled_is_newer.
  Check that the mtines of the .go and .scm match exactly, so we don't
  get fooled by rsync-like modifications of the filesystem.

* module/system/base/compile.scm (call-with-output-file/atomic): Add
  optional arg, a reference file. If present we utime the output file to
  match the source file, before the rename.
  (compile-file): Stamp the .go file with the timestamp of the .scm.
2009-06-05 10:51:21 +02:00
Andy Wingo
3c997c4ba9 simplify autocompilation some more
* libguile/load.c (scm_init_load_path): Set the fallback path even if
  GUILE_SYSTEM_COMPILED_PATH is set. Now that we store full paths in the
  autocompiled files, and the path contains the effective Guile version,
  there's no danger of accidental collisions.
  (do_try_autocompile, autocompile_catch_handler, scm_try_autocompile):
  Simplify again -- since there's only one place we put autocompiled
  files, and compile-file finds it itself, there's no need to pass along
  the compiled file path.
  (scm_primitive_load_path): Don't call out to compiled-file-name to get
  the fallback path, as we might not be autocompiling, and besides that
  we need to check if the file exists at all.

* module/system/base/compile.scm (compiled-file-name): Simplify again.
  The auto-compiled path is just fallback path + full source path + .go.
2009-06-05 10:06:39 +02:00
Andy Wingo
5ea401bffe further autocompilation tweaks
* module/system/base/compile.scm (compiled-file-name):
* libguile/load.c (scm_init_load_path, scm_try_autocompile)
  (scm_primitive_load_path): Rework so that we search for .go files in
  the load-compiled path and in the fallback path, but we only
  autocompile to the fallback path. Should produce a more desirable experience.
2009-06-05 01:20:19 +02:00
Andy Wingo
f3130a2ecf compiled-file-name tries to put the .go in the %load-compiled-path
* module/system/base/compile.scm (ensure-writable-dir): Rename from
  ensure-directory.
  (dsu-sort): Helper, does a decorate / sort / undecorate.
  (compiled-file-name): Refactor to only return a writable filename. The
  readable case is handled by load.c now, and the other case was silly.
  Hopefully it will do the right thing.
  (load-ensuring-compiled): Remove, load.c will call out to compile-file
  if necessary.
  (ensure-fallback-path): Remove, load.c will add the ~/.guile-ccache dir
  to the load-compiled path, which will prompt its creation if necessary.
2009-06-03 22:20:55 +02:00
Andy Wingo
4c9c9b9b98 install .go files under $libdir, not $datadir
* am/guilec: Install .go files to
  $(pkglibdir)/$GUILE_EFFECTIVE_VERSION/ccache.
2009-06-03 22:20:55 +02:00
Andy Wingo
34f3d47df9 add reader support for #; #` #' #, and #,@. fix bug in compile-and-load.
* libguile/read.c (flush_ws, scm_read_commented_expression)
  (scm_read_sharp): Add support for commenting out expressions with #;.
  (scm_read_syntax, scm_read_sharp): Add support for #', #`, #, and #,@.

* module/ice-9/boot-9.scm: Remove #' read-hash extension, which actually
  didn't do anything at all. It's been there since 1997, but no Guile
  code I've ever seen uses it, and it conflicts with #'x => (syntax x)
  from modern Scheme.

* module/system/base/compile.scm (compile-and-load): Whoops, fix a number
  of bugs here.
2009-05-28 14:49:33 +02:00
Andy Wingo
81fd315299 update docs, clean up VM vestiges, macro docs, fix (/ a b c)
* 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-05-24 13:09:01 +02:00
Andy Wingo
68623e8e78 remove compile-time-environment
* 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-20 17:41:21 +02:00
Andy Wingo
112edbaea3 inline calls to some primitives
* module/system/base/pmatch.scm: Wrap consequents in (let () ) instead of
  (begin ) so that they can have local definitions.

* module/language/tree-il/compile-glil.scm: Inline some calls to
  primitives.
2009-05-17 23:24:26 +02:00
Andy Wingo
7c72fe0bb5 ice-9 syncase now deprecated, woo
Remove #:use-module (ice-9 syncase) from lots of places, as it's no
longer needed.
2009-04-24 14:34:23 +02:00
Andy Wingo
c5cc65ac0c fix hygiene + modules + local macros
* module/ice-9/psyntax-pp.scm: Regenerate.

* module/ice-9/psyntax.scm (syntax-type): Look up the type of the car of
  a form relative to its module, if it is a syntax object. Fixes hygiene
  wrt modules and private macros.

* module/ice-9/syncase.scm (sc-macro): Add a comment.

* module/system/base/pmatch.scm: The big test case: just export pmatch,
  not ppat too.
2009-04-17 15:20:19 +02:00
Andy Wingo
b8076ec6cc support expression-by-expression compilation
* 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-16 17:49:59 +02:00
Andy Wingo
b41b92c9d1 compilation passes return third value: the continuation environment
* 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-04-16 15:20:40 +02:00
Andy Wingo
237f96e7f0 add separate expansion phase, to detwingle things a bit
* module/language/scheme/expand.scm: New module, implements a separate
  expansion phase, not interleaved with compilation.

* module/language/scheme/amatch.scm: Helper for expand.scm, it's pmatch
  with support for annotated source.

* module/ice-9/Makefile.am (SOURCES): Add annotate.scm to build list --
  early on because it will be used in the compiler.

* module/ice-9/annotate.scm: Fix the printer, default to unstripped
  (whatever that is), and add a deannotator.

* module/system/base/compile.scm (call-with-compile-error-catch): Fix for
  new representation of source locations.

* module/Makefile.am (SCHEME_LANG_SOURCES): Add amatch and expand.
2009-03-02 17:27:45 +01:00
Andy Wingo
3ca8401113 slight optimization in transform-record, note in optimize*
* 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-27 13:37:35 +01:00
Andy Wingo
89522052e2 introduce -> binding inside transform-record body expressions
* 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-27 13:24:38 +01:00
Andy Wingo
b106a3eddc first stabs as s-expression-driven transformation of GHIL
* 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-27 12:36:58 +01:00
Andy Wingo
246be37e48 common slot accessors are procedures-with-setters
* module/system/base/syntax.scm (define-type): Common slot accessors are
  also procedures-with-setters.
2009-02-27 10:56:15 +01:00
Andy Wingo
2c65f2d5a7 use common slots mechanism in ghil
* module/system/base/syntax.scm (define-type): Fix getter for common
  slot.

* module/language/ghil.scm (<ghil>): Use the common slots mechanism.
2009-02-27 10:53:00 +01:00
Andy Wingo
43e0c29305 define-type has #:common-slots
* module/system/base/syntax.scm (define-type): Accept a #:common-slots
  argument, defining slots that are in all instances of this type.
2009-02-27 10:44:47 +01:00
Ludovic Courtès
3bb299b3f0 Aggregate makefiles for module/system' and module/language'.
* am/guilec (.scm.go): Create the target's directory, in case
  $(builddir) != $(srcdir).

* configure.in: Don't output any makefile under `module/system' or
  `module/language'.

* module/Makefile.am (SUBDIRS): Remove `language' and `system'.  Add `.'
  to the front.
  (modpath, SOURCES, SCHEME_LANG_SOURCES, ECMASCRIPT_LANG_SOURCES,
  GHIL_LANG_SOURCES, GLIL_LANG_SOURCES, ASSEMBLY_LANG_SOURCES,
  BYTECODE_LANG_SOURCES, OBJCODE_LANG_SOURCES, VALUE_LANG_SOURCES): New
  variables, taken from former `Makefile.am' files in sub-directories.
2009-02-24 23:54:16 +01:00
Andy Wingo
a56db0f67e use umask when making permissions on .go files
* module/system/base/compile.scm (call-with-output-file/atomic): Temp
  files get created 0600. After we're done writing, chmod them to
  something in line with the user's umask.
2009-02-24 23:02:33 +01:00
Andy Wingo
594d9d4c48 be smarter about allocating local variables, reusing slots if possible
* 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-21 20:28:29 +01:00
Ludovic Courtès
73f4d8d1d2 Add -o'/--output' option to "guile-tools compile".
* module/system/base/compile.scm (compile-file): Add optional
  OUTPUT-FILE argument.

* scripts/compile (fail): New procedure.
  (%options): Add `-o'/`--output' option.
  (compile): Handle `-o'.
2009-02-21 00:38:06 +01:00
Ludovic Courtès
b96dac4d0e Change `compiled-file-name' to preserve the input file's directory.
* module/system/base/compile.scm (compiled-file-name): Prepend "(dirname
  file)" so that "guile-tools compile foo/bar.scm" produces
  "foo/bar.go", not "bar.go".
2009-02-14 22:17:47 +01:00
Andy Wingo
5a0df7be5f flush output when writing .go files
* module/system/base/compile.scm (call-with-output-file/atomic): Close
  the port we are writing to before renaming it, so that we flush output.
  Might fix some 0-length write errors that Jao was seeing.
2009-02-13 21:48:56 +01:00
Andy Wingo
34898db352 inline record predicates into record-case
* 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-13 00:16:44 +01:00
Andy Wingo
d9d671f76e no keyword arguments in GHIL / GLIL, just optional args -- faster compiles
* 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-13 00:01:47 +01:00
Andy Wingo
e14679bd52 speed up record-case
* 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.
2009-02-11 22:08:04 +01:00
Andy Wingo
8899057d65 match bare literals with eq? in pmatch, not equal?
* module/system/base/pmatch.scm (ppat): Match atoms with eq?, not equal?.
  This speeds up compilation considerably, as we never match against
  numbers or strings or what-have-you. Note, you can match against
  literals with equal? via quoting the literal in the pattern.
2009-02-10 13:18:36 +01:00
Andy Wingo
9892287960 minor cleanups
* 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-09 11:42:27 +01:00
Andy Wingo
d7236899f5 add disassembler that fits in with old compiler tower
* module/language/assembly/Makefile.am:
* module/language/assembly/disassemble.scm: Add a disassembler, based on
  the old one but fitting in with the decompiler tower.

* module/language/objcode/spec.scm (decompile-value): When decompiling
  programs, shove all the metadata that we know about into the "env".

* module/system/base/compile.scm (decompile-fold, decompile): Return the
  env from `decompile' as a second value. Not sure if `compile' should do
  this too.
2009-01-30 14:12:57 +01:00
Andy Wingo
7b107cceb9 add decompilers that can take us back to assembly
* 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-30 12:59:29 +01:00
Andy Wingo
5d6fb8bbeb allow specification of languages by name; add decompilers to languages
* 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.
2009-01-30 11:41:02 +01:00
Andy Wingo
b0b180d522 nifty generic compiler infrastructure -- no more hardcoded passes
* 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-14 22:42:31 +01:00
Andy Wingo
f38624b349 add parsers and unparser for ghil; ,language ghil works now
* 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-11-11 22:52:24 +01:00
Andy Wingo
f698d111b4 remove .cvsignore files 2008-11-10 12:17:18 +01:00
Andy Wingo
3f0bce1e14 move guilec.mk to am/guilec
* am/Makefile.am:
* am/guilec: guilec moved here from /guilec.mk.

All includers of guilec adapted.
2008-11-01 13:05:10 +01:00
Andy Wingo
03fa04dfe1 pass backtraces through the compiler
* module/system/base/compile.scm (call-with-nonlocal-exit-protect): New
  helper, like unwind-protect but only for nonlocal exits.
  (call-with-output-file/atomic): Use call-with-nonlocal-exit-protect so
  that we don't mess up backtraces by catching all and then rethrowing.
  Should fix this more comprehensively somewhere, though.
2008-10-31 13:28:06 +01:00
Andy Wingo
3de80ed52f recompiling with compile environments, fluid languages, cleanups
* 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-30 10:57:36 +01:00
Andy Wingo
1086fabdc9 define-type no longer expects `|' subform
* 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-10-25 22:58:48 +02:00
Andy Wingo
1e6ebf54db a number of small compilation fixes
* ice-9/boot-9.scm: Allow a compiled load of posix, networking, and
  deprecated files.

* module/language/scheme/translate.scm (lookup-transformer): Lookup the
  sc-macro by value, not by name. Works around the fact that compiled
  macros don't have names, which is probably a bug.

* module/system/base/compile.scm (syntax-error)
  (call-with-compile-error-catch): Throw and catch a key that's not used
  by anyone else. Write error messages to the error port.

* module/system/repl/repl.scm (default-catch-handler): Call display-error
  with the correct number of arguments.

* module/system/vm/frame.scm (frame-program-name): Guard against unbound
  variables.

* ice-9/optargs.scm (let-keywords-template): Don't unquote in a helper
  procedure. A bit irritating. I suppose we should fix the modules +
  syncase situation at some point, and then switch to syncase.
2008-09-25 13:46:09 +02:00
Andy Wingo
1a1a10d3a5 use #:keywords in module/*.scm, not :keywords
* 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-09-09 06:58:25 +02:00
Andy Wingo
75a09d5ae6 module compilation fixen, post-integration
Thanks to Dale Smith.

* guilec.mk: Rework to expect the includer to define $(modpath), then
  make $(moddir) from that.

* module/language/Makefile.am:
* module/language/scheme/Makefile.am:
* module/system/base/Makefile.am:
* module/system/il/Makefile.am:
* module/system/repl/Makefile.am:
* module/system/vm/Makefile.am: Define modpath instead.

* src/guilec.in: Don't import (system vm bootstrap), it is no more.
2008-08-25 13:05:16 -07:00
Andy Wingo
e6d4e05cbd don't truncate .go files, do an atomic rename to prevent SIGBUS
* module/system/base/compile.scm (call-with-output-file/atomic): New
  proc, outputs to a tempfile then does an atomic rename. Prevents SIGBUS
  if a compiled file is truncated and rewritten, as the file's objcode is
  mmap'd in.
  (compile-file): Use the new helper.
2008-08-09 14:11:35 +02:00
Andy Wingo
07e56b27a1 big reorg of scheme modules -- e.g. programs.c -> (system vm program)
This reorganization kills the ugly module-export-all hacks in
bootstrap.scm and core.scm. In fact, it gets rid of core.scm entirely,
breaking out its functionality into separate files.

* module/system/vm/trace.scm:
* module/system/vm/profile.scm:
* module/system/vm/disasm.scm:
* module/system/vm/debug.scm:
* module/system/vm/conv.scm:
* module/system/vm/assemble.scm:
* module/system/repl/repl.scm:
* module/system/repl/common.scm:
* module/system/base/compile.scm:
* module/system/repl/command.scm: Update for changes, and fix a bug in
  procedure-documentation.

* module/system/vm/bootstrap.scm: Just call scm_bootstrap_vm, which
  handles setting load-compiled for us.

* module/system/vm/core.scm: Removed, functionality folded into other
  modules.

* module/system/vm/frame.scm: Export the C frame procedures here; also
  move scheme functions from core.scm here.

* module/system/vm/instruction.scm: New file, exports procedures from
  instructions.c.

* module/system/vm/objcode.scm: New file, exports procedures from
  objcodes.c.

* module/system/vm/program.scm: New file, exports procedures from
  programs.c, and some scheme functions originally from core.scm.

* module/system/vm/vm.scm: New file, from vm.c and core.scm.

* src/Makefile.am (libguile_vm_la_SOURCES): Add bootstrap.h.

* src/bootstrap.h: New file, prototypes scm_bootstrap_vm (), which the
  scm_init_* functions call.

* src/frames.h:
* src/frames.c (scm_init_frames):
* src/frames.c (scm_bootstrap_frames):

* src/vm.h:
* src/instructions.h:
* src/instructions.c (scm_init_instructions):
* src/instructions.c (scm_bootstrap_instructions):
* src/objcodes.h:
* src/objcodes.c (scm_bootstrap_objcodes):
* src/objcodes.c (scm_init_objcodes):
* src/programs.h:
* src/programs.c (scm_bootstrap_programs):
* src/programs.c (scm_init_programs):
* src/vm.c (scm_bootstrap_vm):
* src/vm.c (scm_init_vm): Call scm_bootstrap_vm() before doing anything
  in an init function. Bootstrap_vm will call bootstrap_instructions(),
  etc to initialize types, then set load-compiled to point to
  load-compiled/vm.

* src/vm.c (scm_load_compiled_with_vm): Code to load .go files, if
  they're present.
2008-08-07 13:11:27 +02:00