mirror of
https://github.com/janet-lang/janet
synced 2024-12-26 08:20:27 +00:00
Merge remote-tracking branch 'upstream/master' into typed-array-work
This commit is contained in:
commit
c81bf42f6b
3
Makefile
3
Makefile
@ -244,5 +244,4 @@ uninstall:
|
||||
-rm -rf $(INCLUDEDIR)
|
||||
|
||||
.PHONY: clean install repl debug valgrind test amalg \
|
||||
valtest emscripten dist uninstall docs grammar format \
|
||||
$(TEST_PROGRAM_PHONIES) $(TEST_PROGRAM_VALPHONIES)
|
||||
valtest emscripten dist uninstall docs grammar format
|
||||
|
@ -32,6 +32,7 @@ static int is_whitespace(uint8_t c) {
|
||||
|| c == '\n'
|
||||
|| c == '\r'
|
||||
|| c == '\0'
|
||||
|| c == '\v'
|
||||
|| c == '\f';
|
||||
}
|
||||
|
||||
@ -207,6 +208,8 @@ static int checkescape(uint8_t c) {
|
||||
return '\0';
|
||||
case 'f':
|
||||
return '\f';
|
||||
case 'v':
|
||||
return '\v';
|
||||
case 'e':
|
||||
return 27;
|
||||
case '"':
|
||||
|
@ -989,15 +989,24 @@ static JanetAbstractType peg_type = {
|
||||
NULL
|
||||
};
|
||||
|
||||
/* Used to ensure that if we place several arrays in one memory chunk, each
|
||||
* array will be correctly aligned */
|
||||
static size_t size_padded(size_t offset, size_t size) {
|
||||
size_t x = size + offset - 1;
|
||||
return x - (x % size);
|
||||
}
|
||||
|
||||
/* Convert Builder to Peg (Janet Abstract Value) */
|
||||
static Peg *make_peg(Builder *b) {
|
||||
size_t bytecode_start = size_padded(sizeof(Peg), sizeof(uint32_t));
|
||||
size_t bytecode_size = janet_v_count(b->bytecode) * sizeof(uint32_t);
|
||||
size_t constants_start = size_padded(bytecode_start + bytecode_size, sizeof(Janet));
|
||||
size_t constants_size = janet_v_count(b->constants) * sizeof(Janet);
|
||||
size_t total_size = bytecode_size + constants_size + sizeof(Peg);
|
||||
size_t total_size = constants_start + constants_size;
|
||||
char *mem = janet_abstract(&peg_type, total_size);
|
||||
Peg *peg = (Peg *)mem;
|
||||
peg->bytecode = (uint32_t *)(mem + sizeof(Peg));
|
||||
peg->constants = (Janet *)(mem + sizeof(Peg) + bytecode_size);
|
||||
peg->bytecode = (uint32_t *)(mem + bytecode_start);
|
||||
peg->constants = (Janet *)(mem + constants_start);
|
||||
peg->num_constants = janet_v_count(b->constants);
|
||||
memcpy(peg->bytecode, b->bytecode, bytecode_size);
|
||||
memcpy(peg->constants, b->constants, constants_size);
|
||||
|
@ -136,6 +136,15 @@ static void janet_escape_string_impl(JanetBuffer *buffer, const uint8_t *str, in
|
||||
case '\0':
|
||||
janet_buffer_push_bytes(buffer, (const uint8_t *)"\\0", 2);
|
||||
break;
|
||||
case '\f':
|
||||
janet_buffer_push_bytes(buffer, (const uint8_t *)"\\f", 2);
|
||||
break;
|
||||
case '\v':
|
||||
janet_buffer_push_bytes(buffer, (const uint8_t *)"\\v", 2);
|
||||
break;
|
||||
case 27:
|
||||
janet_buffer_push_bytes(buffer, (const uint8_t *)"\\e", 2);
|
||||
break;
|
||||
case '\\':
|
||||
janet_buffer_push_bytes(buffer, (const uint8_t *)"\\\\", 2);
|
||||
break;
|
||||
|
@ -717,7 +717,7 @@ struct JanetAbstractHead {
|
||||
JanetGCObject gc;
|
||||
const JanetAbstractType *type;
|
||||
size_t size;
|
||||
char data[];
|
||||
long long data[]; /* Use long long to ensure most general alignment */
|
||||
};
|
||||
|
||||
/* Some function definition flags */
|
||||
|
@ -37,13 +37,13 @@
|
||||
(def should-color (or (specials sym) (core-env sym)))
|
||||
(paint (if should-color :coresym :symbol) text))
|
||||
|
||||
~{:ws (set " \t\r\f\n\0")
|
||||
~{:ws (set " \t\r\f\n\v\0")
|
||||
:readermac (set "';~,")
|
||||
:symchars (+ (range "09" "AZ" "az" "\x80\xFF") (set "!$%&*+-./:<?=>@^_|"))
|
||||
:token (some :symchars)
|
||||
:hex (range "09" "af" "AF")
|
||||
:escape (* "\\" (+ (set "ntrzf0\"\\e")
|
||||
(* "x" :hex :hex)
|
||||
:escape (* "\\" (+ (set "ntrvzf0\"\\e")
|
||||
(* "x" :hex :hex)
|
||||
(error (constant "bad hex escape"))))
|
||||
|
||||
:comment ,(<-c :comment ~(* "#" (any (if-not (+ "\n" -1) 1))))
|
||||
|
Loading…
Reference in New Issue
Block a user