1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-01 04:10:18 +02:00
Commit graph

3636 commits

Author SHA1 Message Date
Ian Price
024bd93b0d modules should be passed current continuation
* module/language/js-il/runtime.js (primitive-load-path): modules
  should be passed the current continuation.
2017-08-11 14:02:13 +01:00
Ian Price
56439a88ae Add `guild jslink' to bundle JS programs
* module/Makefile.am (SOURCES): Install runtime.js and jslink.scm
* module/language/js-il/compile-javascript.scm (compile-exp):
  Compilation units take a continuation to facilitate linking.
* module/scripts/jslink.scm: New script.
2017-08-09 16:06:50 +01:00
Ian Price
7438a192f8 Unwind prompt frames
* module/language/js-il/runtime.js(unwind): Unwind prompts.
2017-08-03 00:26:02 +01:00
Ian Price
2da7a82d9d struct-set! primitive returns no values
* module/language/js-il/runtime.js (struct-set!): Don't return a value.
2017-08-03 00:23:45 +01:00
Ian Price
70c25b1290 Make child structs applicable.
* module/language/js-il/runtime.js (scheme.Struct): When certain flags
  are set, child structs should be marked as applicable.
2017-08-03 00:22:03 +01:00
Ian Price
46fa3b2fb8 Implement misc built-ins
* module/language/js-il/runtime.js
  (scm->u64): New primitive
  (integer?, char=?, make-fluid, read-hash-extend, make-hook,
  simple-format, scm-error): Implement built-ins.
  (syntax-session-id, macroexpand, %exception-handler,
  print-exception, *features*, %load-hook, current-reader): Stubbed
  variables.
2017-08-03 00:20:50 +01:00
Ian Price
3c62ab8185 Implement module built-ins.
* module/language/js-il/runtime.js
  (variable?): New Primitive.
  (primitive-load-path, module-local-variable, module-variable,
  %get-pre-modules-obarray, set-current-module): Implement built-ins.
2017-08-03 00:06:10 +01:00
Ian Price
3d29f2874f Implement procedure built-ins.
* module/language/js-il/runtime.js
  (procedure?, set-procedure-property!, make-procedure-with-setter): Implement.
2017-08-03 00:03:46 +01:00
Ian Price
bfaf07091a Implement hashtable built-ins
* module/language/js-il/runtime.js
  (scheme.HashTable): New Constructor.
  (make-hash-table, hash-clear!, hashq-remove!, hashq-ref, hashq-set!,
  hash-for-each): Implement built-ins.
2017-08-03 00:02:45 +01:00
Ian Price
30cc1e0751 scm_struct_init skips hidden fields.
* module/language/js-il/runtime.js (scm_struct_init): skip 'h' fields.
2017-08-02 22:55:00 +01:00
Ian Price
30dc57cb04 define! primitive only takes one argument.
* module/language/js-il/runtime.js (define!): Ignore argument.
2017-08-02 22:46:13 +01:00
Ian Price
ebe9d00153 Implement struct built-ins.
* module/language/js-il/runtime.js
  (struct?): New primitive.
  (<applicable-struct-vtable>, record-type-vtable,
  set-struct-vtable-name!, make-struct): Implement built-ins.
2017-08-02 22:44:27 +01:00
Ian Price
2273eb4d06 Implement built-in string procedures.
* module/language/js-il/runtime.js
  (string-append): Extend to more than 2 arguments.
  (string-join): New procedure.
2017-08-02 21:17:22 +01:00
Ian Price
2adebea5d0 Implement built-in symbol procedures.
* module/language/js-il/runtime.js
  (symbol->string, gensym): New procedures.
2017-08-02 21:14:57 +01:00
Ian Price
5d49a5be18 Implement built-in syntax procedures.
* module/language/js-il/runtime.js
  (syntax?, make-syntax, syntax-expression, syntax-wrap,
  syntax-module): New procedures.
2017-08-02 21:12:47 +01:00
Ian Price
2a3c43a5a9 Implement builtin list procedures.
* module/language/js-il/runtime.js
  (make-list, length, list?, reverse, append, memq, member, delete!):
  New procedures
2017-08-02 21:11:02 +01:00
Ian Price
0b9b08a28d Implement immediate version of vector primitives.
* module/language/js-il/runtime.js
  (make-vector/immediate, vector-set!/immediate,
  vector-ref/immediate): New Primitives.
2017-08-02 21:03:11 +01:00
Ian Price
cf1ddd466b Implement structs in runtime.js
* module/language/js-il/runtime.js:
  (scheme.Struct): new type.
  (allocate-struct/immediate, struct-vtable, struct-set!, struct-ref,
  struct-set!/immediate, struct-ref/immediate): Implement primitives.
  (def_guile_val): New helper.
  (string=?, string-append): Implement string functions.
  (standard-vtable-fields, <standard-vtable>, vtable-index-layout,
  vtable-index-printer, vtable-offset-user, make-struct/no-tail,
  make-vtable, struct-vtable?): Implement struct functions.
2017-06-28 17:15:57 +01:00
Ian Price
479294fc05 Implement Winding & Unwinding
* module/language/js-il/runtime.js
  (wind, unwind): Implement.
  (callcc): Wind when invoking continuation.
2017-06-28 15:03:03 +01:00
Ian Price
ff7fff920d Add macro type in runtime.js
* module/language/js-il/runtime.js
  (scheme.Macro): Add type.
  (make-syntax-transformer): Add guile procedure.
2017-06-28 10:38:00 +01:00
Ian Price
b3c0fcdb25 Implement cached-module-box
* module/language/js-il/runtime.js (scheme): Add module_cache field.
  (scheme.primitives) Add cached-module-box primitive.
  (def_guile0) Convenience for adding to (guile) module cache.
2017-06-22 16:59:02 +01:00
Ian Price
2204fb64f6 Add more variables to no-values-primitives
* module/language/js-il/inlining.scm (no-values-primitives):
  Add primitives
2017-06-20 23:12:09 +01:00
Ian Price
536d94feb3 Compile Syntax Objects to Javascript
* module/language/js-il/compile-javascript.scm (compile-const):
  Handle the new syntax object struct.
* module/language/js-il/runtime.js(scheme.Syntax): Add Syntax Object type
2017-06-20 22:50:06 +01:00
Ian Price
c2589b5c48 Rebuild nested scopes for js continuations
* module/language/cps/compile-js.scm (compile-cont, compile-clause):
  Rebuild nested scopes for $kargs, using dominator information.
  (compile-fun, compile-clauses): Pass down dominator information.
2017-06-20 19:05:59 +01:00
Ian Price
936050c657 Add some primitives to runtime.js
* module/language/js-il/runtime.js(add/immediate, sub/immediate,
  load-u64, u64-=-scm, handle-interrupts): Add primitives.
2017-06-16 21:48:27 +01:00
Ian Price
e771241020 JS-IL inliner has different count-calls for different clauses
* module/language/js-il/inlining.scm(inline-single-calls): Factor into
  another function inline-clause, so that count-calls is only called on
  the clause.
2017-06-16 17:42:49 +01:00
Ian Price
723fc850f6 Add #:js-inline? and #:js-flatten? debugging options
* module/language/js-il/compile-javascript.scm (compile-javascript):
  Check for #:js-inline? and #:js-flatten?, and turn off
  inline-single-calls and flatten-blocks respectively.
2017-06-15 22:34:39 +01:00
Ian Price
602bfb559d Update primitives in no-values-primitives
* module/language/js-il/inlining.scm (no-values-primitives): Update.
2017-06-15 20:25:24 +01:00
Ian Price
8777c20e94 Handle multiple conts in a function body
* module/language/cps/compile-js.scm (compile-clause, compile-clauses):
  Extract all conts in the function body, and bind in clauses.
  (extract-and-compile-conts): New Procedure
2017-06-15 20:21:47 +01:00
Ian Price
0e4fb0920f compile-js uses the new cps representation
* module/language/cps/compile-js.scm: Rewrite to use cps
2017-06-14 23:07:40 +01:00
Ian Price
23f829b175 Fix build of (language cps compile-js)
* module/language/cps/compile-js.scm (compile-js): Use lower-cps
  from (language cps compile-bytecode) rather than optimize, which is no
  longer there.
2017-06-14 21:27:05 +01:00
Ian Price
1b36a76ea4 Merge branch 'stable-2.2' into compile-to-js-2017 2017-06-14 21:13:10 +01:00
Andy Wingo
7095a536f3 web: add support for URI-reference
Based on a patch by Daniel Hartwig <mandyke@gmail.com>.

* NEWS: Update.
* doc/ref/web.texi (URIs): Fragments are properly part of a URI, so
  remove the incorrect note.  Add documentation on URI subtypes.
* module/web/uri.scm (uri-reference?): New base type predicate.
  (uri?, relative-ref?): Specific predicates.
  (validate-uri-reference): Strict validation.
  (validate-uri, validate-relative-ref): Specific validators.
  (build-uri-reference, build-relative-ref): New constructors.
  (string->uri-reference): Rename from string->uri.
  (string->uri, string->relative-ref): Specific constructors.
  (uri->string): Add #:include-fragment? keyword argument.
* module/web/http.scm (parse-request-uri): Use `build-uri-reference',
  and result is a URI-reference, not URI, object.  No longer infer an
  absent `uri-scheme' is `http'.
  (write-uri): Just use `uri->string'.
  (declare-uri-header!): Remove unused function.
  (declare-uri-reference-header!): Update.  Rename from
  `declare-relative-uri-header!'.
* test-suite/tests/web-uri.test ("build-uri-reference"):
  ("string->uri-reference"): Add.
  ("uri->string"): Also tests for relative-refs.
* test-suite/tests/web-http.test ("read-request-line"):
  ("write-request-line"): Update for no scheme in some URIs.
  ("entity headers", "request headers"): Content-location, Referer, and
  Location should also parse relative-URIs.
* test-suite/tests/web-request.test ("example-1"): Expect URI-reference
  with no scheme.
2017-05-21 13:42:29 +02:00
Andy Wingo
0c102b56e9 Fix reading of HTTPS responses that are smaller than port buffer
* module/web/client.scm (tls-wrap): Use get-bytevector-some instead of
  get-bytevector-n, to prevent Guile from attempting to read more bytes
  than are available.  Normally trying to read data on a shut-down
  socket is fine, but but gnutls issues an error if you attempt to read
  data from a shut-down socket, and that appears to be a security
  property.  Fixes HTTPS requests whose responses are smaller than the
  port buffer.
2017-04-28 13:38:41 +02:00
Ludovic Courtès
886ac3e2ab SRFI-19: Swap seconds and nanoseconds in 'current-time-monotonic'.
* module/srfi/srfi-19.scm (current-time-monotonic): Swap the 2nd and 3rd
arguments.  Fixes a regression introduced in
commit b11e2922c3.
2017-04-22 01:01:32 +02:00
Thomas Danckaert
02cf38514d SRFI-37: Account for zero-length arguments.
* module/srfi/srfi-37.scm (args-fold): When checking if an argument is
an option (starts with #\-), first check if the length is non-zero.
2017-04-20 10:58:54 +02:00
Freja Nordsiek
a7428a3172 Fixed bug: statprof flat display wasn't writing summary lines to port
* module/statprof.scm (statprof-display/flat): fixed bug where summary lines
  were written to (current-output-port) instead of the provided port.
2017-04-19 16:25:00 +02:00
Andy Wingo
4b39c1a9e5 Fix date->string ~f operator to not emit leading zeros
* module/srfi/srfi-19.scm (directives): Format ~f without leading
  zeroes.  Fixes https://bugs.gnu.org/26260.
* test-suite/tests/srfi-19.test ("SRFI date/time library"): Add test.
2017-04-19 15:42:03 +02:00
Andrew Moss
1978085b22 Fixed bug: ~N mishandles small nanoseconds value
Fixes <http://bugs.gnu.org/26261>.
Reported by Zefram <zefram@fysh.org>.

* module/srfi/srfi-19.scm ("define directives"): N padding increased from 7 to 9

* test-suite/tests/srfi-19.test ("date->string"): New test.
2017-04-19 15:13:09 +02:00
Andy Wingo
b11e2922c3 SRFI-19 current-time-monotonic returns time of right type
* module/srfi/srfi-19.scm (current-time-monotonic): Actually return a
  time with the correct type.  Fixes #26329.
2017-04-19 15:08:46 +02:00
Andy Wingo
e0502f3c77 Bump objcode version in a compatible way
* libguile/_scm.h (SCM_OBJCODE_MINIMUM_MINOR_VERSION): New definition,
  indicating the oldest objcode version that we support.
  (SCM_OBJCODE_MINOR_VERSION): Bump.
* libguile/loader.c (process_dynamic_segment): Support a range of
  versions.
* module/system/vm/assembler.scm (*bytecode-minor-version*): Bump.
2017-04-18 21:37:36 +02:00
Andy Wingo
7c71be0c7e Add sandboxed evaluation facility
* module/ice-9/sandbox.scm: New file.
* module/Makefile.am (SOURCES): Add new file.
* doc/ref/api-evaluation.texi (Sandboxed Evaluation): New section.
* NEWS: Update.
* test-suite/tests/sandbox.test: New file.
* test-suite/Makefile.am: Add new file.
2017-04-18 21:27:45 +02:00
Andy Wingo
7ed54fd36d All literal constants are read-only
* libguile/array-handle.c (initialize_vector_handle): Add mutable_p
  argument.  Unless the vector handle is mutable, null out its
  writable_elements member.
  (scm_array_get_handle): Adapt to determine mutability of the various
  arrays.
  (scm_array_handle_elements, scm_array_handle_writable_elements):
  Reverse the sense: instead of implementing read-only in terms of
  read-write, go the other way around, adding an assertion in the
  read-write case that the array handle is mutable.
* libguile/array-map.c (racp): Assert that the destination is mutable.
* libguile/bitvectors.c (SCM_F_BITVECTOR_IMMUTABLE, IS_BITVECTOR):
  (IS_MUTABLE_BITVECTOR): Add a flag to indicate immutability.
  (scm_i_bitvector_bits): Fix indentation.
  (scm_i_is_mutable_bitvector): New helper.
  (scm_array_handle_bit_elements)
  ((scm_array_handle_bit_writable_elements): Build writable_elements in
  terms of elements.
  (scm_bitvector_elements, scm_bitvector_writable_elements): Likewise.
  (scm_c_bitvector_set_x): Require a mutable bitvector for the
  fast-path.
  (scm_bitvector_to_list, scm_bit_count): Use read-only elements()
  function.
* libguile/bitvectors.h (scm_i_is_mutable_bitvector): New decl.
* libguile/bytevectors.c (INTEGER_ACCESSOR_PROLOGUE):
  (INTEGER_GETTER_PROLOGUE, INTEGER_SETTER_PROLOGUE):
  (INTEGER_REF, INTEGER_NATIVE_REF, INTEGER_SET, INTEGER_NATIVE_SET):
  (GENERIC_INTEGER_ACCESSOR_PROLOGUE):
  (GENERIC_INTEGER_GETTER_PROLOGUE, GENERIC_INTEGER_SETTER_PROLOGUE):
  (LARGE_INTEGER_NATIVE_REF, LARGE_INTEGER_NATIVE_SET):
  (IEEE754_GETTER_PROLOGUE, IEEE754_SETTER_PROLOGUE):
  (IEEE754_REF, IEEE754_NATIVE_REF, IEEE754_SET, IEEE754_NATIVE_SET):
  Setters require a mutable bytevector.
  (SCM_BYTEVECTOR_SET_FLAG): New helper.
  (SCM_BYTEVECTOR_SET_CONTIGUOUS_P, SCM_BYTEVECTOR_SET_ELEMENT_TYPE):
  Remove helpers.
  (SCM_VALIDATE_MUTABLE_BYTEVECTOR): New helper.
  (make_bytevector, make_bytevector_from_buffer): Use
  SCM_SET_BYTEVECTOR_FLAGS.
  (scm_c_bytevector_set_x, scm_bytevector_fill_x)
  (scm_bytevector_copy_x): Require a mutable bytevector.
* libguile/bytevectors.h (SCM_F_BYTEVECTOR_CONTIGUOUS)
  (SCM_F_BYTEVECTOR_IMMUTABLE, SCM_MUTABLE_BYTEVECTOR_P): New
  definitions.
* libguile/bytevectors.h (SCM_BYTEVECTOR_CONTIGUOUS_P): Just access one
  bit.
* libguile/srfi-4.c (DEFINE_SRFI_4_C_FUNCS): Implement
  writable_elements() in terms of elements().
* libguile/strings.c (scm_i_string_is_mutable): New helper.
* libguile/uniform.c (scm_array_handle_uniform_elements):
  (scm_array_handle_uniform_writable_elements): Implement
  writable_elements in terms of elements.
* libguile/vectors.c (SCM_VALIDATE_MUTABLE_VECTOR): New helper.
  (scm_vector_elements, scm_vector_writable_elements): Implement
  writable_elements in terms of elements.
  (scm_c_vector_set_x): Require a mutable vector.
* libguile/vectors.h (SCM_F_VECTOR_IMMUTABLE, SCM_I_IS_MUTABLE_VECTOR):
  New definitions.
* libguile/vm-engine.c (VM_VALIDATE_MUTABLE_BYTEVECTOR):
  (VM_VALIDATE_MUTABLE_VECTOR, vector-set!, vector-set!/immediate)
  (BV_BOUNDED_SET, BV_SET): Require mutable bytevector/vector.
* libguile/vm.c (vm_error_not_a_mutable_bytevector):
  (vm_error_not_a_mutable_vector): New definitions.
* module/system/vm/assembler.scm (link-data): Mark residualized vectors,
  bytevectors, and bitvectors as being read-only.
2017-04-18 21:27:45 +02:00
Ludovic Courtès
d7778b3d6a types: Hide one of the 'bytevector->string' procedures.
* module/system/base/types.scm: Hide 'bytevector->string' from (rnrs io
ports).
2017-04-14 23:26:41 +02:00
Andy Wingo
ce934bcd43 Add allow-legacy-syntax-objects? parameter
* module/ice-9/psyntax.scm (syntax?): Only recognize legacy syntax
  objects if the new allow-legacy-syntax-objects? parameter is true.
* module/ice-9/boot-9.scm (allow-legacy-syntax-objects?): New
  parameter.
* doc/ref/api-macros.texi (Syntax Transformer Helpers): Document the
  horrible situation with legacy syntax objects.
* NEWS: Add entry.
2017-03-28 21:27:11 +02:00
Andy Wingo
a42bfae65f Psyntax generates new syntax objects
* module/ice-9/psyntax.scm (make-syntax-object): Change to make
  new-style syntax objects.
* module/ice-9/psyntax-pp.scm: Regenerate.
* module/ice-9/compile-psyntax.scm (squeeze-syntax-object): Change to be
  functional.
  (squeeze-constant): Likewise.
  (squeeze-tree-il): Likewise.
  (translate-literal-syntax-objects): New pass.  The compiler can embed
  literal syntax objects into compiled objects, but syntax can no longer
  be read/written; otherwise users could forge syntax objects.  So for
  the bootstrap phase, rewrite literal constants to calls to
  make-syntax.
2017-03-28 19:23:13 +02:00
Andy Wingo
eb84c2f2da Beginnings of psyntax switch to new syntax objects
* module/ice-9/psyntax.scm: Baby steps towards support of a new
  representation of syntax objects.
* module/ice-9/psyntax-pp.scm: Regenerate.
2017-03-28 19:23:13 +02:00
Andy Wingo
64c5cc58fc Add disjoint syntax object type
* libguile/Makefile.am (libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES):
  (DOT_X_FILES, DOT_DOC_FILES, noinst_HEADERS): Add syntax.c and
  syntax.h.
* libguile/evalext.c (scm_self_evaluating_p):
* libguile/goops.c (class_syntax, scm_class_of, scm_goops_early_init):
* libguile/init.c (scm_init_guile):
* libguile/print.c (iprin1):
* libguile/tags.h (scm_tc7_syntax):
* module/oop/goops.scm (<syntax>):
* module/system/base/types.scm (%tc7-syntax, cell->object):
* module/system/vm/disassembler.scm (code-annotation): Wire up the new
  data type.
* libguile/syntax.c:
* libguile/syntax.h: New files.
* module/ice-9/boot-9.scm: Move new definitions to (system syntax
  internal).
* module/system/syntax.scm (print-syntax): New helper.
* module/system/vm/assembler.scm (statically-allocatable?)
  (intern-constant, link-data): Arrange to be able to write syntax
  objects into images.
* module/language/cps/types.scm (&syntax): New type.  Remove
  &hash-table; it was never detected, an internal binding, and we need
  the bit to avoid going into bignum territory.
2017-03-28 19:23:13 +02:00
Andy Wingo
6ba3f35f26 Plumbing changes to rename "syntax-module"
* module/ice-9/psyntax.scm (%syntax-module): Rename from syntax-module
  in order to make room for a new syntax-module primitive binding.
* module/ice-9/psyntax-pp.scm: Regenerate.
* module/ice-9/boot-9.scm: Push syntax bindings into an internal
  module.
* module/system/syntax.scm: New file.
* module/Makefile.am (SOURCES): Add system/syntax.scm.
2017-03-28 19:23:13 +02:00
Mike Gran
5d2aa5f1ad i18n: add international sign positions to %locale-dump
* module/ice-9/i18n.scm (%locale-dump): modified
2017-03-20 22:35:49 -07:00