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

86 commits

Author SHA1 Message Date
Mark H Weaver
a72e296176 elisp: Fix cross-compilation support.
* module/system/base/target.scm (with-native-target): New exported
procedure.
* module/language/elisp/spec.scm: In the top-level body expression, call
'compile-and-load' within 'with-native-target' to compile native code.
* module/language/elisp/compile-tree-il.scm
(eval-when-compile, defmacro): Compile native code.
2018-08-07 12:07:18 +02:00
Andy Wingo
72bb47ae4c compile-file adds #:to-disk? #t to opts
* module/system/base/compile.scm (compile-file): Pass #:to-disk? as an
  option to indicate that the result will be being loaded from disk.
  Perhaps a linker might want to page-align in that case.

* module/language/elisp/compile-tree-il.scm (process-options!): Accept
  and ignore the #:to-file compiler option.
2013-08-24 15:27:57 +02:00
Andy Wingo
c32b7c4cef Remove with-fluids; replaced by with-fluid* and inlined push-fluid primops
* libguile/vm-i-system.c (push-fluid, pop-fluid):
* doc/ref/vm.texi (Dynamic Environment Instructions): Rename wind-fluids
  to push-fluid, and unwind-fluids to pop-fluid.  They now only work on
  one fluid binding at a time.

* module/ice-9/boot-9.scm (with-fluid*): Implement in Scheme in terms of
  primcalls to push-fluid and pop-fluid.
  (custom-throw-handler, catch, with-throw-handler): Use with-fluid*
  instead of with-fluids, as with-fluids is no longer available before
  psyntax is loaded.
  (with-fluids): Define in Scheme in terms of with-fluid*.

* libguile/fluids.c (scm_with_fluid): Rename from scm_with_fluids, and
  don't expose to Scheme.

* libguile/eval.c (eval): Remove SCM_M_WITH_FLUIDS case.
* libguile/expand.c (expand_with_fluids): Remove with-fluids syntax.
  (DYNLET): Remove, no longer defining dynlet in the %expanded-vtables.
* libguile/expand.h: Remove dynlet definitions.
* module/ice-9/eval.scm (primitive-eval): Remove with-fluids case.
* libguile/memoize.c (do_push_fluid, do_pop_fluid): New primitive
  helpers, like wind and unwind.
  (memoize): Memoize wind and unwind primcalls.  Don't memoize dynlet to
  with-fluids.
  (scm_init_memoize): Initialize push_fluid and pop_fluid here.
* libguile/memoize.h (SCM_M_WITH_FLUIDS): Remove definition.

* module/ice-9/psyntax.scm (build-dynlet): Remove; this just supported
  with-fluids, which is now defined in boot-9.
* module/ice-9/psyntax-pp.scm: Regenerate.

* doc/ref/compiler.texi (Tree-IL):
* module/language/tree-il.scm:
* module/language/tree-il/analyze.scm:
* module/language/tree-il/canonicalize.scm:
* module/language/tree-il/compile-glil.scm:
* module/language/tree-il/cse.scm:
* module/language/tree-il/debug.scm:
* module/language/tree-il/effects.scm: Remove <dynlet>.  Add cases for
  primcalls to push-fluid and pop-fluid in compile-glil.scm and
  effects.scm.

* module/language/tree-il/peval.scm (peval): Factor out
  with-temporaries; probably a bad idea, but works for now.  Factor out
  make-begin0 (a better idea).  Inline primcalls to with-fluid*, and
  remove dynlet cases.

* module/language/tree-il/primitives.scm (*interesting-primitive-names*):
  Add with-fluid*.
2013-06-28 19:52:09 +02:00
BT Templeton
663c5875f5 use #nil as default for elisp rest parameters
* module/langauge/elisp/compile-tree-il.scm (compile-lambda): Bind the
  rest parameter to `#nil' instead of `()' by default.
2012-03-05 18:10:29 -05:00
BT Templeton
5ddd9645c9 Merge branch 'bt/elisp'
Conflicts:
	am/guilec
	libguile/_scm.h
	libguile/vm-i-scheme.c
	module/language/elisp/compile-tree-il.scm
	module/language/elisp/runtime.scm
	module/language/elisp/runtime/macros.scm
	module/language/tree-il/compile-glil.scm
	module/language/tree-il/primitives.scm
2012-03-05 16:52:05 -05:00
BT Templeton
eaeda0d550 function binding fixes
* module/language/elisp/bindings.scm (bindings): Add `function-bindings'
  field.
  (make-bindings): Initialize the `function-bindings' field.
  (get-function-binding, with-function-bindings): New functions.

  (access-variable, reference-variable, set-variable!): Remove the
  `module' argument and only handle references to the value cell. All
  callers changed. Callers passing `function-slot' as the module changed
  to use the corresponding functions for the function cell instead.

  (access-function, reference-function, set-function!): New procedures.

  (compile-flet, compile-labels): Use `with-function-bindings' instead
  of `with-lexical-bindings'.
2012-02-03 18:53:51 -05:00
BT Templeton
66be42cb38 improve management of global special variables
* module/language/elisp/bindings.scm (bindings): Remove `globals'
  field. (global?, mark-global!, map-globals): Remove. All callers
  changed.

* module/language/elisp/compile-tree-il.scm (generate-ensure-global,
  ensuring-globals): Remove. All callers changed.

  (global?, ensure-globals!): New procedures.

  (bind-lexically?): Use new `global?'.

  (compile-lambda, compile-let, compile-let*): Use `ensure-globals!'.
2012-02-03 18:53:50 -05:00
BT Templeton
c7e0d2f81c use `dynlet' for dynamic binding
* module/language/elisp/compile-tree-il.scm (let-dynamic): Remove. All
  callers changed to use `dynlet' instead.
2012-02-03 18:53:50 -05:00
BT Templeton
c64c51ebb0 inline generate-let' and generate-let*'
* module/language/elisp/compile-tree-il.scm (generate-let, compile-let):
  Inline the former into the latter.
  (generate-let*, compile-let*): Likewise.
2012-02-03 18:53:50 -05:00
BT Templeton
6bb004c435 define `flet' directly
* module/language/elisp/compile-tree-il.scm (compile-flet): Compile
  `flet' directly instead of using `generate-let'.
2012-02-03 18:53:50 -05:00
BT Templeton
9083c48d37 lexical binding macros
* module/language/elisp/boot.el (lexical-let, lexical-let*): New macros.

* module/language/elisp/compile-tree-il.scm (bind-lexically?): Remove
  the check for a `lexical' flag, since `lexical-let' and `lexical-let*'
  are no longer special operators.

  (compile-lexical-let, compile-lexical-let*): Remove.

* module/language/elisp/runtime/function-slot.scm: Update module
  definition.
2012-02-03 18:53:50 -05:00
BT Templeton
9b90b45398 elisp `while' macro
* module/language/elisp/compile-tree-il.scm (compile-while): Remove.

* module/language/elisp/boot.el (while): New macro.

* module/language/elisp/runtime/function-slot.scm: Update module
  definition.
2012-02-03 18:53:50 -05:00
BT Templeton
1c2f9636dc elisp `labels'
* module/language/elisp/compile-tree-il.scm (compile-labels): New
  special operator.

* module/language/elisp/runtime/function-slot.scm: Update module
  definition.
2012-02-03 18:53:50 -05:00
BT Templeton
0e5b7e74e4 fix `flet' syntax
* module/language/elisp/compile-tree-il.scm (process-let-bindings):
  Remove.

  (parse-let-binding, parse-flet-binding): New procedures.

  (generate-let, generate-let*): Now takes an association list mapping
  symbols to values for the `bindings' argument.

  (compile-let, compile-let*, compile-lexical-let)
  (compile-lexical-let*): Parse the bindings list with
  `parse-let-binding'.

  (compile-flet): Parse the bindings list with `parse-flet-binding'.
2012-02-03 18:53:50 -05:00
BT Templeton
f6e0a4a60c elisp binding declarations
* module/language/elisp/compile-tree-il.scm (bind-lexically?): Accept a
  new `decls' argument and check it for `lexical' declarations.
  Establish the same kind of binding whether or not a lexical binding
  for `sym' exists, whereas previously the presence of a lexical binding
  would cause newly-established bindings to be lexical bindings as well.

  (split-let-bindings): Remove. All callers changed.

  (generate-let, generate-let*, compile-lambda): Pass the declarations
  list to `bind-lexically?'.

* test-suite/tests/elisp-compiler.test: Explicitly disable the
  lexical-binding mode. Add `lexical' declarations where necessary.
2012-02-03 18:53:50 -05:00
BT Templeton
805b821189 declaration parsing
* module/language/elisp/compile-tree-il.scm (parse-body-1, parse-body)
  (parse-lambda-body, parse-declaration): New procedures.
  (generate-let, generate-let*): Use `parse-body'.
  (compile-lambda): Use `parse-lambda-body'.
2012-02-03 18:53:50 -05:00
BT Templeton
1631817977 elisp lambda list parsing
* module/language/elisp/compile-tree-il.scm (split-lambda-arguments):
  Remove.

  (parse-lambda-list, make-simple-lambda): New procedures.

  (compile-lambda): Use `parse-lambda-list' and `make-simple-lambda'.
  Set empty rest arguments to the empty list instead of `#nil'.

* test-suite/tests/elisp-compiler.test ("Lambda Expressions")["rest
  argument"]: Use Elisp `null' instead of a Scheme equality check.
2012-02-03 18:53:49 -05:00
BT Templeton
b05ca4abb9 elisp function subrs
* module/language/elisp/boot.el (null, consp, listp, car, cdr)
  (make-symbol, signal): Use `%funcall' instead of `funcall' or `fset'.
  (symbolp, symbol-function, eval): Use `%funcall', since `funcall' now
  calls these functions.

  (functionp, %indirect-function): New functions.
  (funcall): Define in terms of `%funcall' and `%indirect-function'.
  (apply): New function. Previously defined in
  "module/language/elisp/runtime/subrs.scm".

  (fset): If `definition' is not a function, set the function cell of
  `symbol' to an falias for `definition'.

* module/language/elisp/falias.scm: New file.

* module/language/elisp/subrs.scm: Remove file.
  (apply): Remove. Now defined in "boot.el".
* module/language/elisp/runtime/function-slot.scm: Update module
  definition.

* module/Makefile.am: Update.
2012-02-03 18:53:49 -05:00
BT Templeton
35724ee1dc remove dynamic function binding
* module/language/elisp/compile-tree-il.scm (find-operator): Assume that
  `name' is lexically bound.
* module/language/elisp/runtime.scm (symbol-fbound?, fmakunbound!):
  Assume that `symbol' is lexically bound.
  (defspecial): Bind special operators lexically.
2012-02-03 18:53:49 -05:00
BT Templeton
5bdd388cf0 remove unused code
* module/language/elisp/compile-tree-il.scm (runtime-error): Remove.
* module/language/elisp/runtime.scm (macro-error, runtime-error,
  elisp-bool, prim): Remove.
2012-02-03 18:53:49 -05:00
BT Templeton
d273b82656 new elisp special form `%funcall'
* module/language/elisp/compile-tree-il.scm (compile-%funcall): New
  procedure.
* module/language/elisp/runtime/function-slot.scm: Update module
  definition.
2012-02-03 18:53:49 -05:00
BT Templeton
48489836e2 evaluate the function position correctly
* module/language/elisp/compile-tree-il (compile-pair): Use `function'
  to perform functional evaluation. Previously, if the operator of a
  compound form was not a symbol, the operator would be evaluated as a
  normal expression. This happened to work only because there is a
  `lambda' macro. The compiler will now signal an error if the operator
  is neither a function name nor a lambda expression.

* test-suite/tests/elisp-compiler.test ("Lambda Expressions")["optional
  argument"]: Remove an erroneous use of `function' in the function
  position.
2012-02-03 18:53:49 -05:00
BT Templeton
d9806be144 record elisp function names
* language/elisp/compile-tree-il.scm (compile-lambda): Add a `meta'
  argument for the procedure's properties.

  (compile-function, compile-defmacro, compile-defun): Update
  accordingly, passing a `name' property to `compile-lambda' where
  possible.
2012-02-03 18:53:49 -05:00
BT Templeton
85bc6238bf simplify elisp symbol accessors
* module/language/elisp/boot.el (fset, symbol-value, symbol-function)
  (set, makunbound, fmakunbound, boundp, fboundp): Use procedures in
  `(language elisp runtime)'.
  (symbolp): New function.

* module/language/elisp/compile-tree-il.scm (set-variable!): Use
  `set-symbol-function!'.

* module/language/elisp/runtime.scm (reference-variable, set-variable!):
  Remove.
  (symbol-fluid, set-symbol-fluid!): New procedure.
  (symbol-value, set-symbol-value!, symbol-function)
  (set-symbol-function!, symbol-bound?, symbol-fbound?, makunbound!)
  (fmakunbound!): Moved from `(language elisp subrs)' and updated to
  avoid using `reference-variable' and `set-variable!'.

* module/language/elisp/runtime/subrs.scm (symbol-value)
  (symbol-function, set, fset, makunbound, fmakunbound, boundp)
  (fboundp): Move to `(language elisp runtime)'.
  (apply): Use `symbol-function'.
2012-02-03 18:53:49 -05:00
BT Templeton
0a32abc462 remove `flet*' elisp special form
* module/language/elisp/compile-tree-il.scm (compile-flet*): Remove.
* module/language/elisp/runtime/function-slot.scm: Update module
  definition.
* test-suite/tests/elisp-compiler.test
  ("Lambda Expressions")["flet and flet*"]: Remove `flet*' test.
2012-02-03 18:53:49 -05:00
BT Templeton
e5a361d1f9 remove `with-always-lexical' elisp special form
* module/language/elisp/compile-tree-il.scm: (always-lexical): Remove.
  All uses changed.
  (with-added-symbols): Remove.
  (compile-with-always-lexical): Remove.
  (process-options!): Remove support for the `#:always-lexical' option.
* module/language/elisp/runtime/function-slot.scm: Update import and
  re-export lists.
* test-suite/tests/elisp-compiler.test: Remove or update tests using
  `with-always-lexical'.
2012-02-03 18:53:49 -05:00
BT Templeton
03e00c5c9d emacs-compatible lexical binding
* module/language/elisp/bindings.scm (global?): New function.
* module/language/elisp/compile-tree-il.scm (lexical-binding): New
  variable.
  (bind-lexically?): If lexical binding is enabled, bind lexically
  unless a special binding exists.
  (compile-%set-lexical-binding-mode): New function.
* module/language/elisp/lexer.scm (lexical-binding-regexp): New
  variable.
  (lex): Return a `set-lexical-binding-mode!' token if a comment is
  found while reading the first line.
* module/language/elisp/parser.scm (get-expression): Add support for
  `set-lexical-binding-mode!' tokens.
* module/language/elisp/runtime/function-slot.scm: Import and re-export
  the `%set-lexical-binding-mode' special form.
* test-suite/tests/elisp-compiler.test
  ("Let and Let*")["lambda args inside lexical-let"]: Update.
2012-02-03 18:53:49 -05:00
BT Templeton
d4cb18ad9c remove `bind-arg-lexical?'
* module/language/elisp/compile-tree-il.scm (bind-arg-lexical?): Remove.
  All callers changed to use `bind-lexically?'.
2012-02-03 18:53:48 -05:00
BT Templeton
d5da7661c8 use srfi-9 for elisp bindings records
* module/language/elisp/bindings.scm: Use `(srfi srfi-9)'.
  (bindings-type): Remove low-level record type definition and replace
  with...
  (bindings): ...this, an SRFI-9 record type. All uses changed.
  (mark-global-needed!): Rename to...
  (mark-global!): ...this. All callers changed.
  (map-globals-needed): Rename to...
  (map-globals): ...this. All callers changed.
2012-02-03 18:53:48 -05:00
BT Templeton
d5ac6923c3 fix compilation of elisp forms with empty bodies
* module/language/elisp/compile-tree-il.scm (generate-let)
  (generate-let*, compile-lambda, compile-with-added-symbols)
  (compile-progn, compile-if): Return nil if the form's body is empty.
* test-suite/tests/elisp-compiler.test ("Sequencing")["empty progn"]:
  New test.
  ("Conditionals")["if with no else"]: New test.
  ("Let and Let*")["empty let, empty let*"]: New test.
  ("Lambda Expressions")["empty lambda"]: New test.
2012-02-03 18:53:48 -05:00
BT Templeton
80687f2e4b new elisp special form `eval-when-compile'
* module/language/elisp/compile-tree-il.scm (compile-eval-when-compile):
  New function.
* module/language/elisp/runtime/function-slot.scm: Update module
  definition.
2012-02-03 18:53:48 -05:00
BT Templeton
30439aa8bb use `nil?' for elisp conditionals
* module/language/elisp/compile-tree-il.scm (compile-if): Use the `nil?'
  primitive for conditionals.
2012-02-03 18:53:48 -05:00
BT Templeton
5d351f0b9b remove void-checking cruft
* module/language/elisp/compile-tree-il.scm: Don't export
  `compile-without-void-checks', which was removed. Remove unused
  `disable-void-check' variable. Update comments.
2011-11-22 15:04:12 -05:00
Andy Wingo
6fc3eae477 sequence of expressions -> seq of head and tail
* libguile/expand.h:
* module/language/tree-il.scm: Rename "sequence" to "seq", and instead
  of taking a list of expressions, take a head and a tail.

* module/language/tree-il/analyze.scm:
* module/language/tree-il/compile-glil.scm:
* module/language/tree-il/fix-letrec.scm:
* module/language/tree-il/spec.scm:
* module/language/elisp/compile-tree-il.scm:
* module/ice-9/psyntax.scm:
* module/ice-9/psyntax-pp.scm:
* module/ice-9/eval.scm:
* libguile/memoize.h:
* libguile/memoize.c:
* libguile/expand.c:
* libguile/eval.c: Adapt to the new seq format.
2011-06-02 19:13:32 +02:00
Andy Wingo
a881a4ae3b add <primcall> to tree-il
* libguile/expand.c:
* libguile/expand.h (SCM_EXPANDED_PRIMCALL_TYPE_NAME):
  (SCM_EXPANDED_PRIMCALL_FIELD_NAMES):
  (SCM_EXPANDED_PRIMCALL_SRC):
  (SCM_EXPANDED_PRIMCALL_NAME):
  (SCM_EXPANDED_PRIMCALL_ARGS):
  (SCM_MAKE_EXPANDED_PRIMCALL): Add "primcall" Tree-IL type.

* doc/ref/compiler.texi (Tree-IL): Update docs.

* libguile/memoize.c (memoize): Memoizer for primcalls.

* module/ice-9/psyntax.scm: Build primcalls, sometimes.  Also change
  build-primref to just make a primitive-ref.

* module/language/tree-il.scm: Add primcall to the exports, parsers,
  serializers, etc.

* module/language/tree-il/analyze.scm:
* module/language/tree-il/compile-glil.scm:
* module/language/tree-il/fix-letrec.scm:
* module/language/tree-il/inline.scm:
* module/language/tree-il/primitives.scm:
* module/language/elisp/compile-tree-il.scm: Add primcall support.

* test-suite/tests/tree-il.test: Use primcalls sometimes.
2011-06-02 17:45:58 +02:00
Andy Wingo
7081d4f981 rename <application> to <call>
* doc/ref/compiler.texi (The Scheme Compiler): Update docs.

* libguile/expand.h:
* libguile/expand.c:
* module/language/tree-il.scm: Rename <application> to <call>.  Change
  the external representation from (apply proc arg ...) to (call proc
  arg ...).

* libguile/memoize.c:
* module/ice-9/psyntax-pp.scm:
* module/ice-9/psyntax.scm:
* module/language/brainfuck/compile-tree-il.scm:
* module/language/ecmascript/compile-tree-il.scm:
* module/language/elisp/compile-tree-il.scm:
* module/language/tree-il/analyze.scm:
* module/language/tree-il/compile-glil.scm:
* module/language/tree-il/fix-letrec.scm:
* module/language/tree-il/inline.scm:
* module/language/tree-il/primitives.scm:
* test-suite/tests/tree-il.test: Update all callers.
2011-06-02 13:42:55 +02:00
Brian Templeton
c6920dc8ba lexical function binding for elisp
* module/language/elisp/compile-tree-il.scm (access-variable)
  (reference-variable, set-variable!): Handle globally-bound non-special
  variables.

  (bind-lexically?): Create lexical bindings for flet and flet*.

* module/language/elisp/runtime.scm (reference-variable, set-variable!):
  Handle globally-bound non-special variables.

  (built-in-func): Set the variable directly instead of storing the
  function in a fluid.

* module/language/elisp/runtime/subrs.scm (funcall): Call apply
  directly.

* test-suite/tests/elisp-compiler.test ("Function Definitions")["flet
  and flet*"]:

Signed-off-by: Andy Wingo <wingo@pobox.com>
2010-12-07 13:21:03 +01:00
Brian Templeton
3f70b2dc5c use unbound fluids instead of `void' sentinel value
* module/language/elisp/compile-tree-il.scm (reference-with-check)
  (compile-without-void-checks, want-void-check?): Remove.

  (compile-function, compile-pair): Use `reference-variable' instead of
  `reference-with-check'.

  (compile-defvar): Only set `sym' if `sym' is not bound to a bound
  fluid, rather than requiring that its value be `void'.

  (process-options!): Remove `#:disable-void-check' option handling.

* module/language/elisp/runtime.scm (void)
  (reference-variable-with-check): Remove.

  (ensure-fluid!): Use an undefined fluid as the initial value for
  global variables.

* module/language/elisp/runtime/function-slot.scm (without-void-checks):
  Don't import or re-export.

* module/language/elisp/runtime/macros.scm (prog1, cond, or, dolist):
  Don't use `without-void-checks'.

* module/language/elisp/runtime/subrs.scm (symbol-value)
  (symbol-function, apply): Use `reference-variable' instead of
  `reference-variable-with-check'.

  (makunbound, fmakunbound, boundp, fboundp): Unset the variable's fluid
  (or the variable itself, if it isn't bound to a fluid).

* test-suite/tests/elisp-compiler.test ("Variable
  Setting/Referencing")["disabled void check (all)", "disabled void
  check (symbol list)", "without-void-checks"]: Remove.

Signed-off-by: Andy Wingo <wingo@pobox.com>
2010-12-07 13:21:03 +01:00
Brian Templeton
67cb2c2761 function's argument can be a symbol
* module/language/elisp/compile-tree-il.scm (compile-function): the form
  `(function SYMBOL)' evaluates to the functional value of SYMBOL

Signed-off-by: Andy Wingo <wingo@pobox.com>
2010-12-07 13:21:03 +01:00
Brian Templeton
f5742cf042 setq can take any number of arguments
* module/language/elisp/compile-tree-il.scm (compile-setq): Return nil
  if called with no arguments, and set the last variable to nil if its
  value is omitted.

Signed-off-by: Andy Wingo <wingo@pobox.com>
2010-12-07 13:21:02 +01:00
Brian Templeton
0dbfdeefc6 use correct names for quasiquotation operators
Use #{`}#, #{,}# and #{,@}# as the quasiquote, unquote and
unquote-splicing operators, respectively. Previously they were named
escaping.

* module/language/elisp/compile-tree-il.scm (unquote?): Change "\," to
  "#{,}#".
  (unquote-splicing): Change "\,@" to "#{,@}#".
  (#{compile-`}#): Rename from #{compile-\`}#.
* module/language/elisp/runtime/function-slot.scm: Import #{compile-`}#
  instead of #{compile-\`}#, and re-export as #{`}# instead of as
  #{\`}#.
* module/language/elisp/parser.scm (quotation-symbols):
* test-suite/tests/elisp-compiler.test ("Eval", "Quotation"):
* test-suite/tests/elisp-reader.test ("Parser"): Change "\`", "\,", and
  "\,@" to "#{`}#", "#{,}#" and "#{,@}#", respectively.
2010-12-07 13:21:02 +01:00
Brian Templeton
44ae163d2c store special operators in the function slot
If the function slot of a symbol contains a pair with `special-operator'
in the car and a procedure in the cdr, the procedure is called to
compile the form to Tree-IL. This is similar to other Emacs Lisp
implementations, in which special operators are subrs.

* module/language/elisp/compile-tree-il.scm: Restructured to store
  special operator definitions in the function slot. Import `(language
  elisp runtime)' for `defspecial'. Export special operators so that
  `(language elisp runtime function-slot)' can re-export them.

  (backquote?): Removed; the backquote symbol is defined as a special
  operator, so it's no longer used in `compile-pair'.

  (is-macro?, get-macro): Replaced by `find-operator'.
  (find-operator): New procedure.

  (compile-progn, compile-if, compile-defconst, compile-defvar,
  compile-setq, compile-let, compile-lexical-let, compile-flet,
  compile-let*, compile-lexical-let*, compile-flet*,
  compile-without-void-checks, compile-with-always-lexical,
  compile-guile-ref, compile-guile-primitive, compile-while,
  compile-function, compile-defmacro, compile-defun, #{compile-`}#,
  compile-quote): New special operators with definitions taken from the
  pmatch form in `compile-pair'. There is no special operator `lambda';
  it is now a macro, as in other Elisp implementations.

  (compile-pair): Instead of directly compiling special forms, check for
  a special operator object in the function slot.

* module/language/elisp/runtime.scm: Export `defspecial'.
  (make-id): New function.
  (built-in-macro): Prefix macros with `macro-'.
  (defspecial): New syntax.

* module/language/elisp/runtime/function-slot.scm: Import and re-export
  special operators. Rename imported special operators and macros to
  remove prefixes. Re-export new macro `lambda'.

* module/language/elisp/runtime/macros.scm (macro-lambda): New Elisp
  macro.
2010-12-07 13:21:02 +01:00
Brian Templeton
2ce5e74073 make user-defined macros available at runtime
* module/language/elisp/compile-tree-il.scm (ensuring-globals): New
  procedure.
  (define-macro!): Remove.
  (compile-pair) <defmacro>: Make macro available at runtime, not only
  during compilation.
  (compile-tree-il): Use `ensuring-globals'.
2010-12-07 13:21:02 +01:00
Brian Templeton
65b46b7241 allow fluid macro bindings
* module/language/elisp/compile-tree-il.scm (define-macro!, get-macro):
  Allow fluid macro bindings.
2010-12-07 13:21:02 +01:00
Brian Templeton
3829919663 Ignore #:warnings compiler option
* module/language/elisp/compile-tree-il.scm (process-options!): Ignore
  #:warnings compiler option.
2010-12-07 13:21:02 +01:00
Brian Templeton
8295b7c4e5 store macro definitions in the function slot
Guile Emacs Lisp previously kept macros in a separate macro slot; now
macros are stored as macro objects in the function slot for
compatibility with other implementations.

* module/language/elisp/compile-tree-il.scm (macro-slot): Remove.
  (is-macro?): Check that the argument is a symbol. Now-unnecessary
  check removed in `compile-tree-il'.
  (macro?, define-macro!, get-macro): Store macro definitions in the
  function slot, not in a separate macro slot.
* module/language/elisp/runtime.scm (built-in-macro): Wrap the macro
  function in a macro object (i.e., cons the symbol `macro' onto it).
* module/language/elisp/runtime/function-slot.scm: Move contents to
  "subrs.scm". Re-export function and macro definitions instead of
  defining functions directly in this module.
* module/language/elisp/runtime/macro-slot.scm: Move contents to
  "macros.scm" and remove.
* module/language/elisp/runtime/macros.scm: New file containing macro
  definitions from "macro-slot.scm".
* module/language/elisp/runtime/subrs.scm: New file containing function
  definitions from "function-slot.scm".

Signed-off-by: Andy Wingo <wingo@pobox.com>
2010-12-07 13:21:02 +01:00
Brian Templeton
6e9ebc9179 use existing bindings record for defmacro
* module/language/elisp/compile-tree-il.scm (compile-pair): Use existing
  bindings record during macro definition.
2010-12-07 13:21:02 +01:00
Brian Templeton
eda83f0ac9 use tree-il's support for optional arguments
* module/language/elisp/compile-tree-il.scm (compile-lambda): Use
  Tree-IL's support for optional arguments.
  (process-optionals, process-rest): Remove.

Signed-off-by: Andy Wingo <wingo@pobox.com>
2010-12-07 13:21:01 +01:00
Brian Templeton
f4e5e4114d reindent
* module/language/elisp/bindings.scm:
* module/language/elisp/compile-tree-il.scm:
* module/language/elisp/lexer.scm:
* module/language/elisp/parser.scm:
* module/language/elisp/runtime.scm:
* module/language/elisp/runtime/function-slot.scm:
* module/language/elisp/runtime/macro-slot.scm:
* module/language/elisp/spec.scm: Reindent.

Signed-off-by: Andy Wingo <wingo@pobox.com>
2010-12-07 13:21:01 +01:00
Brian Templeton
c983a199d8 reformat comments
* module/language/elisp/bindings.scm:
* module/language/elisp/compile-tree-il.scm:
* module/language/elisp/lexer.scm:
* module/language/elisp/parser.scm:
* module/language/elisp/runtime.scm:
* module/language/elisp/runtime/function-slot.scm:
* module/language/elisp/runtime/macro-slot.scm:
* module/language/elisp/runtime/value-slot.scm: Reformat comments.

Signed-off-by: Andy Wingo <wingo@pobox.com>
2010-12-07 13:21:01 +01:00