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

531 commits

Author SHA1 Message Date
Andy Wingo
eaba53b7c8 repl.scm: use print-exception
* module/system/repl/repl.scm: Remove custom exception printers in favor
  of print-exception.
2011-02-11 12:57:08 +01:00
Andy Wingo
f87db65719 (system repl error-handling) uses print-exception
* module/system/repl/error-handling.scm (error-string): Just use
  print-exception instead of rolling our own printer.
  (call-with-error-handling): Simplify.
2011-02-11 12:57:08 +01:00
Andy Wingo
423fca76e6 frame-source available in default environment
* libguile/frames.c (scm_frame_source): Don't call out to (system vm
  frames), as this routine is used when printing exceptions.  Make
  available in the default environment (ugh).

* module/system/vm/frame.scm: Remove frame-source definition and
  export.
2011-02-11 12:43:05 +01:00
Ludovic Courtès
de6fb1875d Have `define-wrapped-pointer-type' take a type name.
* module/system/foreign.scm (define-wrapped-pointer-type): Add a
  `type-name' argument instead of non-hygienically generating one.

* test-suite/tests/foreign.test (foo): Update.

* doc/ref/api-foreign.texi (Void Pointers and Byte Access): Update
  accordingly.
2011-02-08 22:42:45 +01:00
Andy Wingo
4b1eb2b27a hackily fix another case where display-exception would be apropos
* module/system/repl/error-handling.scm (display-syntax-error)
  (error-string): Until we get the exception-printing patch merged in,
  copy display-syntax-error into error-handling so that we avoid
  display-error.  Fixes bug 32365.
2011-02-08 22:41:36 +01:00
Ludovic Courtès
8a302b9f78 Hack around a defect in `define-wrapped-pointer-type'.
* module/system/foreign.scm (define-wrapped-pointer-type): Choose
  TYPE-NAME deterministically.
2011-02-07 23:53:25 +01:00
Michael Gran
e1b6a3f150 Use 'substring' instead of obsoleted 'make-shared-substring'
* module/system/repl/describe.scm (display-description): replace
  make-shared-substring with substring
2011-02-02 05:45:37 -08:00
Andreas Rottmann
de9a0f008f Fix `show' REPL meta-command
* module/system/repl/command.scm (warranty, copying, version): Use
  `define-meta-command' to define these procedures, so they are entered
  into the *command-infos* table.
2011-02-01 23:50:09 +01:00
Ludovic Courtès
6e0975603e Add `pointer?'.
* libguile/foreign.c (scm_pointer_p): New function.
* libguile/foreign.h (scm_pointer_p): New declaration.
* module/system/foreign.scm: Export `pointer?'.

* test-suite/tests/foreign.test ("null pointer")["pointer?"]: New
  test.
  ("make-pointer")["pointer?"]: New test.

* doc/ref/api-foreign.texi (Foreign Variables): Document `pointer?'.
2011-01-30 23:29:30 +01:00
Ludovic Courtès
1f4f7674bc Add `define-wrapped-pointer-type'.
* module/system/foreign.scm (define-wrapped-pointer-type): New macro.

* doc/ref/api-foreign.texi (Foreign Types): Mention the `*' symbol.
  (Void Pointers and Byte Access): Document `define-wrapped-pointer-type'.

* test-suite/tests/foreign.test ("define-wrapped-pointer-type"): New
  test prefix.
2011-01-30 23:29:29 +01:00
Andy Wingo
2183d66e13 more sensible error if compiled-file-name returns false in compile-file
* module/system/base/compile.scm (compile-file): Error if no output-file
  is given and compiled-file-name returns false.
2011-01-26 22:09:06 +01:00
Ludovic Courtès
eda0622095 Choose the input source file encoding in a locale-independent way.
This is so that compiling the same code on environments with different
locale settings yields the same result.

* module/system/base/compile.scm (compile-file): When ENC if #f, default
  to "UTF-8" instead of `(fluid-ref %default-port-encoding)'.

* doc/ref/api-evaluation.texi (Compilation): Document the default output
  file name and default source file encoding for `compile-file' and
  `guile-tools compile'.
2011-01-24 21:44:44 +01:00
Andy Wingo
cdab9fc625 add ,reload meta-command and document it and reload-module
* module/ice-9/boot-9.scm (reload-module): Add docstring.
* module/system/repl/command.scm (reload): New meta-command.

* doc/ref/scheme-using.texi (Module Commands): Document the ,reload
  meta-command.
* doc/ref/api-modules.texi (Module System Reflection): Document
  reload-module.
2010-12-17 13:27:43 +01:00
Andy Wingo
a6b1b27aad foreign: c-struct parsing simplification
* module/system/foreign.scm: Revert much of fb636a1cce. Short et al are
  not distinct types -- they are all aliases to e.g. int16. The only
  case that was not covered before was the pointer case.
  (bytevector-pointer-ref, bytevector-pointer-set!): Implement these,
  and use them for pointers.
2010-12-12 23:13:08 +01:00
Andreas Rottmann
8fdd85f834 Allow user-defined meta-commands
Besides allowing user-defined meta-commands, this change also refactors
the meta-command machinery to split reading a command's arguments from
the procedure actually implementing it, and hence allows nesting
meta-commands.  As an example of such a command, ",in" is added as a new
meta-command.

* module/system/repl/command.scm: Export `define-meta-command'.
  (*command-module*): Replaced by the hash table `*command-infos*'.
  (command-info, make-command-info, command-info-procedure)
  (command-info-arguments-reader): New procedures, encapsulating the
  information about a meta-command.
  (command-procedure): Adapted to use the `command-info' lookup
  procedure.
  (read-command-arguments): New auxiliary procedure invoking a command's
  argument reader procedure.
  (meta-command): Adapted to the split of reading arguments and
  executing a command.
  (add-meta-command!): New auxiliary procedure, registers a meta
  command's procedure and argument reader into `*command-infos* and
  `*command-table*.
  (define-meta-command): Extended to allow specification of the command's
  category; split the argument reader and actual command procedure.
  (guile:apropos, guile:load, guile:compile-file, guile:gc): Remove these
  aliases, they are unnecessary as we now use a hash table instead of the
  module to store the commands.
  (in): New meta-command, which evaluates an expression, or alternatively
  executes another meta-command, in the context of a specific module.
* doc/ref/scheme-using.texi (Module Commands): Document the `in'
  meta-command.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2010-11-20 23:55:19 +01:00
Andy Wingo
c372cd74fd repl read/write using current ports, not captured ports
Fixes bug in repl meta-commands after activating readline, which changes
the current input port.

* module/system/repl/common.scm (<repl>): Remove inport and outport
  fields.
  (make-repl): Adapt.
  (repl-read, repl-print): Just read and write to the current ports.

* module/system/repl/repl.scm (meta-reader): Meta-read from the current
  input port.

* module/system/repl/command.scm (read-command, define-meta-command):
  Read from the current input port.
2010-11-18 14:32:53 +01:00
Andy Wingo
6e699fed6b add source-location->source-properties to lalr
* module/system/base/lalr.scm (source-location->source-properties): New
  public function, to produce source properties that can be given to the
  compiler.
2010-11-18 12:31:28 +01:00
Andy Wingo
29de6ae2e8 repl.scm displays syntax errors on read as well
* module/system/repl/repl.scm (prompting-meta-read): Use
  display-syntax-error as appropriate.
2010-11-18 12:21:36 +01:00
Andy Wingo
2090f909b4 add proper pretty-printing for syntax errors
* module/system/repl/repl.scm (display-syntax-error): New helper,
  displays a syntax error.
  (abort-on-error, run-repl): Use it.

* libguile/throw.c (handler_message): Re-code the same thing in C.
2010-11-16 02:57:27 +01:00
Andy Wingo
6cb423613e remove syntax-error and call-with-compile-error-catch from compile.scm
* module/system/base/compile.scm: Remove unused syntax-error and
  call-with-compile-error-catch exports.
2010-11-16 02:57:27 +01:00
Andy Wingo
67d655849a call-with-error-handling pass-keys w/ procedural handlers fix
* module/system/repl/error-handling.scm (call-with-error-handling):
  Respect the pass-keys set for procedural on-error and post-error
  handlers.
2010-11-12 17:16:35 +01:00
Ludovic Courtès
42f7c01e0a Add FFI support for short' and unsigned short'.
* libguile/foreign.c (sym_short, sym_unsigned_short): New variables.
  (scm_init_foreign): Define Scheme variables SYM_SHORT and
  SYM_UNSIGNED_SHORT.

* module/system/foreign.scm (short, unsigned-short): New exports.
  (integer-ref, integer-set): Support (= (sizeof TYPE) 2).
  (%read-short, %write-short!, %read-unsigned-short,
  %write-unsigned-short!): New variables.
  (*writers*): Add support for `short' and `unsigned-short'.
  (*readers*): Likewise.

* test-suite/tests/foreign.test ("structs")["int8, pointer, short,
  double"]: New test.
2010-11-11 16:41:15 +01:00
Ludovic Courtès
fb636a1cce Have parse-c-struct' and make-c-struct' support `int', pointers, etc.
Reported by Tristan Colgate <tcolgate@gmail.com>.

* module/system/foreign.scm: Call `load-extension' at compile-time too.
  (compile-time-value): New macro.
  (integer-ref, integer-set): New procedures.
  (define-integer-reader, define-integer-writer): New macros.
  (%read-int, %read-long, %write-int!, %write-long!, %read-unsigned-int,
  %read-unsigned-long, %write-unsigned-int!, %write-unsigned-long!,
  %read-size_t, %write-size_t!, %read-pointer, %write-pointer!): New
  procedures.
  (*writers*): Add writers for `int', `unsigned-int', `long',
  `unsigned-long', `size_t', and `*'.
  (*readers*): Likewise.

* test-suite/tests/foreign.test ("structs")["int8, pointer",
  "unsigned-long, int8, size_t", "long, int, pointer"]: New tests.
2010-11-11 16:41:15 +01:00
Ludovic Courtès
1f864a1685 FFI: Honor alignment constraints in `parse-c-struct'.
* module/system/foreign.scm (parse-c-struct): Honor alignment
  constraints for TYPE.

* test-suite/tests/foreign.test ("structs")["alignment constraints
  honored"]: New test.
2010-11-11 16:41:15 +01:00
Andy Wingo
5aa12c699c ,frame and related commands handle for-trap? appropriately
* module/system/repl/debug.scm (print-frame): Add #:next-source? arg,
  for when print-frame should use frame-next-source instead of
  frame-source.
  (print-frames): Add #:for-trap? arg. If true, the 0th frame should be
  printed with frame-next-source.

* module/system/repl/command.scm (define-stack-command): Introduce
  for-trap? into the lexical env.
  (backtrace, up, down, frame): Update to do the right thing regarding
  #:for-trap?.
2010-10-12 13:24:46 +02:00
Andy Wingo
5414d33376 don't warn for (format #t fmt) -- format string actually named fmt
* module/language/tree-il/analyze.scm (format-analysis): Don't warn on
  non-literal format string if the format string is a lexical ref to a
  variable named "fmt". A slight hack, but effective :)
* module/system/repl/command.scm (display-stat): Rename the format
  string to "fmt".
2010-10-12 13:11:40 +02:00
Andy Wingo
a36c3a458e debug has for-trap? field
* module/system/repl/debug.scm (<debug>): New field, `for-trap?'. True
  if the stack is for a trap, and thus the top frame should use
  frame-next-source instead of frame-source.

* module/system/repl/command.scm (repl-pop-continuation-resumer)
  (repl-next-resumer):
* module/system/repl/error-handling.scm (call-with-error-handling):
  Update callers.
2010-10-12 13:09:48 +02:00
Ludovic Courtès
08002eae4d Fix typo.
* module/system/repl/command.scm (repl-pop-continuation-resumer): Remove
  extraneous argument to `format'.
2010-10-10 19:10:11 +02:00
Ludovic Courtès
8e6c15a6f0 Add warnings for obvious syntax errors in format strings.
* module/language/tree-il/analyze.scm (&syntax-error): New variable.
  (format-string-argument-count): Throw to &SYNTAX-ERROR when a syntax
  error in a format string is encountered.
  (format-analysis): Catch &SYNTAX-ERROR and convert as a warning of the
  appropriate type.

* module/system/base/message.scm (%warning-types)[format]: Handle
  `syntax-error' warnings.

* test-suite/tests/tree-il.test
  ("warnings")["conditionals"]("unterminated", "unexpected ~;",
  "unexpected ~]"): New tests.
  ["unterminated ~{...~}"]: New test.
2010-10-10 19:10:11 +02:00
Ludovic Courtès
60f01304ee Add new `format' warnings.
* module/language/tree-il/analyze.scm (format-analysis): Add new
  sub-warnings: `wrong-port', `wrong-format-string',
  `non-literal-format-string', and `wrong-num-args'.

* module/system/base/message.scm (%warning-types)[format]: Handle
  them.

* test-suite/tests/tree-il.test ("warnings")["wrong port arg",
  "wrong format string", "non-literal format string",
  "wrong number of args"]: New tests.
2010-10-10 19:10:11 +02:00
Ludovic Courtès
e06972410a Implement fancy format string analysis.
* module/language/tree-il/analyze.scm (format-string-argument-count):
  Return two values, the minimum and maximum number of arguments.
  Add support for most of `format' escapes, including conditionals.
  (format-analysis): Adjust accordingly.

* module/system/base/message.scm (%warning-types)[format]: Take two
  arguments, MIN and MAX, instead of EXPECTED.  Display warning
  accordingly.

* test-suite/tests/tree-il.test ("warnings")["format"]("~%, ~~, ~&, ~t,
  ~_, and ~\\n", "~{...~}", "~{...~}, too many args", "~@{...~}",
  "~@{...~}, too few args", "~(...~)", "~v", "~v:@y", "~*", "~?",
  "complex 1", "complex 2", "complex 3"): New tests.
  ("conditionals"): New test prefix.
2010-10-10 19:10:10 +02:00
Ludovic Courtès
89702c819c Escape newlines from format strings in warnings.
* module/system/base/message.scm (%warning-types)[format]: Escape
  newlines from FMT.
2010-10-10 19:10:10 +02:00
Andy Wingo
d30542c2b7 add (system repl server)
* module/system/repl/server.scm: New module, listens on a socket for
  connections, then serves repls to those sockets.

* module/Makefile.am: Add repl server.
2010-10-10 12:15:34 +02:00
Andy Wingo
a627100bf3 further repl tweaks
* module/system/repl/error-handling.scm (error-string): Refactor a
  little.
  (call-with-error-handling): Ensure a trailing newline when printing
  the error-msg.

* module/system/repl/repl.scm (run-repl): We don't know the name of the
  meta-command here.
2010-10-08 19:27:45 +02:00
Ludovic Courtès
75365375dd Add `-Wformat'.
* module/language/tree-il/analyze.scm (format-string-argument-count):
  New procedure.
  (format-analysis): New tree analysis.

* module/language/tree-il/compile-glil.scm (%warning-passes): Add
  `format'.

* module/system/base/message.scm (%warning-types): Add `format'.

* test-suite/tests/tree-il.test (%opts-w-format): New variable.
  ("warnings")["format"]: New test prefix.

* doc/ref/api-evaluation.texi (Compilation): Mention `format' warnings.
2010-10-08 16:25:57 +02:00
Ludovic Courtès
7390e4bd11 Fixlets for REPL error handling.
* module/system/repl/error-handling.scm (error-string): Don't call
  `display-error' when STACK is empty.
  (call-with-error-handling): Display ERROR-MSG instead of using
  `format', since ERROR-MSG may contain `format' escapes.

* module/system/repl/repl.scm (run-repl): Add missing argument to
  `format'.
2010-10-08 15:25:56 +02:00
Andy Wingo
aee24bac50 fix a bug in `finish'
* module/system/repl/command.scm (repl-pop-continuation-resumer)
  (finish): Fix a bug printing return values.
2010-10-08 12:31:56 +02:00
Andy Wingo
9b78275eb0 stepping traps use frame-next-source, not frame-source
* module/system/vm/trap-state.scm (add-ephemeral-stepping-trap!): Use
  frame-next-source in stepping traps.
2010-10-08 12:31:56 +02:00
Andy Wingo
b262b74b51 add program-sources-pre-retire to core and define frame-next-source
* libguile/programs.h:
* libguile/programs.c (scm_program_source): Add an optional arg, the
  sources table to traverse. Defaults to the result of
  scm_program_sources.

* module/system/vm/program.scm (program-sources-pre-retire): Move
  definition here from (system vm traps), and export.

* module/system/vm/traps.scm: Adapt.

* module/system/vm/frame.scm (frame-next-source): New exported binding,
  returns the source line corresponding to the next instruction instead
  of the previous instruction.
2010-10-08 12:31:56 +02:00
Andy Wingo
d608db1d59 fix error in frame-return-values
* module/system/vm/frame.scm (frame-return-values): Fix off-by-one
  error.
2010-10-08 12:31:56 +02:00
Andy Wingo
4388818adb fix tracing of mv returns
* module/system/vm/trace.scm (print-return): Fix multiple-value-return
  printing.
2010-10-08 12:31:56 +02:00
Andy Wingo
1ecf39a6a7 add repl debugging command docs
* doc/ref/scheme-using.texi (Debug Commands): Add docs for new debugging
  commands (break, step, registers, etc).
2010-10-08 12:31:50 +02:00
Andy Wingo
de03880abe document trap states
* module/system/vm/trap-state.scm: Export add-trap!.

* doc/ref/api-debug.texi (Trap States): Document.
2010-10-07 22:50:33 +02:00
Andy Wingo
e7544f39a4 rename vm-trace to call-with-trace
* module/system/vm/trace.scm (print-application, print-return): Change
  to add more whitespace, as (ice-9 debug) did.
  (call-with-trace): Rename from vm-trace, and make the vm a keyword
  argument.

* module/system/repl/command.scm: Don't autoload (system vm profile).
  (trace): Update for call-with-trace name change.
2010-10-07 12:55:37 +02:00
Andy Wingo
90966af895 update (system repl debug) todo
* module/system/repl/debug.scm: Update todo.
2010-10-06 21:19:49 +02:00
Andy Wingo
439e032b0b add ,step ,stepi ,next and ,nexti
* module/system/vm/traps.scm (trap-matching-instructions): New trap,
  just installs a next hook and runs the handler when a predicate
  succeeds.

* module/system/vm/trap-state.scm (add-ephemeral-stepping-trap!): New
  procedure, uses trap-matching-instructions with an appropriate
  predicate to handle step, stepi, next, and nexti repl metacommands.

* module/system/repl/command.scm (step, step-instruction, next)
  (next-instruction): New repl debugger commands.
2010-10-06 21:19:08 +02:00
Andy Wingo
e8e4e7310c cleanups to ,finish
* module/system/repl/command.scm (repl-pop-continuation-resumer): Factor
  out of finish.
  (finish): Adapt.

* module/system/vm/trap-state.scm (add-ephemeral-trap-at-frame-finish!):
  Rename to add "ephemeral" to the name.

* module/system/vm/traps.scm (trap-calls-to-procedure): Remove unused
  #:width kwarg.
2010-10-06 21:17:06 +02:00
Andy Wingo
c6025e76ff add ,finish repl meta-command
* module/system/repl/command.scm (finish): New REPL meta command. Uses
  fancy prompt stuff.
2010-10-05 21:53:58 +02:00
Andy Wingo
df067433a5 (system vm trap-state): add-trap-at-frame-finish!
* module/system/vm/traps.scm: Fix a comment.

* module/system/vm/trap-state.scm (<trap-state>): Add next-ephemeral-idx
  slot.
  (wrapper-at-index): Use eqv? instead of = to avoid type errors in user
  inputs.
  (next-ephemeral-index!, ephemeral-handler-for-index): New functions,
  allocate ephemeral trap ids for functions to be called only once.
  (add-trap-at-frame-finish!): New export, traps when a frame finishes.
2010-10-05 21:53:29 +02:00
Andy Wingo
6a4a1ef0f4 (system vm frame): frame-return-values
* module/system/vm/frame.scm (frame-return-values): New exported
  function, gives the return values for a frame.
* module/system/vm/trace.scm: Remove frame-return-values from here.
2010-10-05 21:51:44 +02:00