debase-ruby_core_source 4.0.1 → 4.1.0.preview1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/addr2line.h +22 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/builtin.h +127 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/ccan/build_assert/build_assert.h +40 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/ccan/check_type/check_type.h +63 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/ccan/container_of/container_of.h +142 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/ccan/list/list.h +791 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/ccan/str/str.h +17 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/constant.h +53 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/darray.h +295 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/debug_counter.h +428 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/dln.h +33 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/encindex.h +70 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/eval_intern.h +356 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/hrtime.h +237 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/id.h +365 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/id_table.h +74 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/insns.inc +315 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/insns_info.inc +11637 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/array.h +158 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/basic_operators.h +67 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/bignum.h +249 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/bits.h +647 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/box.h +103 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/class.h +797 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/cmdlineopt.h +64 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/compar.h +30 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/compile.h +34 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/compilers.h +104 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/complex.h +29 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/concurrent_set.h +21 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/cont.h +33 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/coverage.h +51 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/dir.h +16 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/enc.h +19 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/encoding.h +40 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/enum.h +18 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/enumerator.h +21 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/error.h +287 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/eval.h +43 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/file.h +40 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/fixnum.h +185 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/gc.h +411 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/hash.h +220 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/imemo.h +302 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/inits.h +54 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/io.h +167 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/io_buffer.h +36 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/jit.h +23 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/load.h +20 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/loadpath.h +16 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/marshal.h +17 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/math.h +23 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/missing.h +19 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/numeric.h +326 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/object.h +88 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/objspace.h +24 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/parse.h +131 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/proc.h +34 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/process.h +124 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/ractor.h +9 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/random.h +17 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/range.h +46 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/rational.h +92 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/re.h +87 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/ruby_parser.h +109 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/sanitizers.h +346 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/scheduler.h +7 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/serial.h +23 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/set.h +20 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/set_table.h +77 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/signal.h +25 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/simd.h +18 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/st.h +32 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/static_assert.h +16 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/string.h +240 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/struct.h +120 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/symbol.h +46 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/thread.h +108 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/time.h +34 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/transcode.h +23 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/util.h +27 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/variable.h +81 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/vm.h +144 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/vm_map.h +95 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/warnings.h +16 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal.h +106 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/iseq.h +439 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/known_errors.inc +1419 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/method.h +279 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/node.h +122 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/node_name.inc +224 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/optinsn.inc +128 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/optunifs.inc +41 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/parse.h +246 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/parser_bits.h +647 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/parser_node.h +32 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/parser_st.h +161 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/parser_value.h +116 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/arena.h +37 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/ast.h +10371 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/buffer.h +52 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/comments.h +43 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/accel.h +19 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/align.h +36 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/assume.h +25 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/exported.h +24 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/fallthrough.h +22 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/filesystem.h +32 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/flex_array.h +19 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/force_inline.h +21 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/format.h +25 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/inline.h +17 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/nodiscard.h +22 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/nonnull.h +18 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/unused.h +18 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/constant_pool.h +81 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/diagnostic.h +93 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/errors_format.h +53 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/excludes.h +29 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/extension.h +19 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/integer.h +41 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/allocator.h +68 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/allocator_debug.h +88 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/arena.h +108 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/bit.h +42 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/buffer.h +91 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/char.h +139 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/comments.h +20 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/constant_pool.h +152 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/diagnostic.h +389 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/encoding.h +242 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/integer.h +68 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/isinf.h +16 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/line_offset_list.h +34 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/list.h +62 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/magic_comments.h +23 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/memchr.h +15 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/node.h +32 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/options.h +224 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/parser.h +971 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/regexp.h +42 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/serialize.h +39 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/source.h +72 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/static_literals.h +100 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/stringy.h +35 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/strncasecmp.h +18 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/strpbrk.h +33 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/tokens.h +11 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/json.h +32 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/line_offset_list.h +61 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/magic_comments.h +35 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/node.h +94 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/options.h +335 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/parser.h +348 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/prettyprint.h +31 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/prism.h +131 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/serialize.h +115 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/source.h +155 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/stream.h +28 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/string_query.h +63 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/stringy.h +72 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/version.h +38 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism_compile.h +204 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism_xallocator.h +6 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/probes_helper.h +42 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/ractor_core.h +421 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/regenc.h +261 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/regint.h +983 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/regparse.h +371 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/revision.h +5 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/ruby_assert.h +14 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/ruby_atomic.h +115 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/rubyparser.h +1389 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/shape.h +733 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/siphash.h +48 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/symbol.h +116 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/thread_none.h +25 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/thread_pthread.h +63 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/thread_sched.h +271 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/thread_win32.h +48 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/timev.h +58 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/transcode_data.h +138 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/variable.h +26 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/version.h +69 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/vm.inc +6457 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/vm_call_iseq_optimized.inc +244 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/vm_callinfo.h +688 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/vm_core.h +2509 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/vm_debug.h +124 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/vm_exec.h +202 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/vm_insnhelper.h +280 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/vm_opts.h +65 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/vm_sync.h +160 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/vmtc.inc +302 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/yjit.h +87 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/zjit.h +221 -0
- data/lib/debase/ruby_core_source/version.rb +1 -1
- metadata +2930 -2724
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#ifndef PRISM_EXT_NODE_H
|
|
2
|
+
#define PRISM_EXT_NODE_H
|
|
3
|
+
|
|
4
|
+
#define EXPECTED_PRISM_VERSION "1.9.0"
|
|
5
|
+
|
|
6
|
+
#include <ruby.h>
|
|
7
|
+
#include <ruby/encoding.h>
|
|
8
|
+
#include <ruby/version.h>
|
|
9
|
+
#include "prism.h"
|
|
10
|
+
|
|
11
|
+
VALUE pm_source_new(const pm_parser_t *parser, rb_encoding *encoding, bool freeze);
|
|
12
|
+
VALUE pm_token_new(const pm_parser_t *parser, const pm_token_t *token, rb_encoding *encoding, VALUE source, bool freeze);
|
|
13
|
+
VALUE pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encoding, VALUE source, bool freeze);
|
|
14
|
+
VALUE pm_integer_new(const pm_integer_t *integer);
|
|
15
|
+
|
|
16
|
+
void Init_prism_api_node(void);
|
|
17
|
+
RUBY_FUNC_EXPORTED void Init_prism(void);
|
|
18
|
+
|
|
19
|
+
#endif
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file integer.h
|
|
3
|
+
*
|
|
4
|
+
* This module provides functions for working with arbitrary-sized integers.
|
|
5
|
+
*/
|
|
6
|
+
#ifndef PRISM_INTEGER_H
|
|
7
|
+
#define PRISM_INTEGER_H
|
|
8
|
+
|
|
9
|
+
#include <stdbool.h>
|
|
10
|
+
#include <stddef.h>
|
|
11
|
+
#include <stdint.h>
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A structure represents an arbitrary-sized integer.
|
|
15
|
+
*/
|
|
16
|
+
typedef struct {
|
|
17
|
+
/**
|
|
18
|
+
* The number of allocated values. length is set to 0 if the integer fits
|
|
19
|
+
* into uint32_t.
|
|
20
|
+
*/
|
|
21
|
+
size_t length;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* List of 32-bit integers. Set to NULL if the integer fits into uint32_t.
|
|
25
|
+
*/
|
|
26
|
+
uint32_t *values;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Embedded value for small integer. This value is set to 0 if the value
|
|
30
|
+
* does not fit into uint32_t.
|
|
31
|
+
*/
|
|
32
|
+
uint32_t value;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Whether or not the integer is negative. It is stored this way so that a
|
|
36
|
+
* zeroed pm_integer_t is always positive zero.
|
|
37
|
+
*/
|
|
38
|
+
bool negative;
|
|
39
|
+
} pm_integer_t;
|
|
40
|
+
|
|
41
|
+
#endif
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#ifndef PRISM_INTERNAL_ALLOCATOR_H
|
|
2
|
+
#define PRISM_INTERNAL_ALLOCATOR_H
|
|
3
|
+
|
|
4
|
+
/* If you build Prism with a custom allocator, configure it with
|
|
5
|
+
* "-D PRISM_XALLOCATOR" to use your own allocator that defines xmalloc,
|
|
6
|
+
* xrealloc, xcalloc, and xfree.
|
|
7
|
+
*
|
|
8
|
+
* For example, your `prism_xallocator.h` file could look like this:
|
|
9
|
+
*
|
|
10
|
+
* ```
|
|
11
|
+
* #ifndef PRISM_XALLOCATOR_H
|
|
12
|
+
* #define PRISM_XALLOCATOR_H
|
|
13
|
+
* #define xmalloc my_malloc
|
|
14
|
+
* #define xrealloc my_realloc
|
|
15
|
+
* #define xcalloc my_calloc
|
|
16
|
+
* #define xfree my_free
|
|
17
|
+
* #define xrealloc_sized my_realloc_sized // (optional)
|
|
18
|
+
* #define xfree_sized my_free_sized // (optional)
|
|
19
|
+
* #endif
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
#ifdef PRISM_XALLOCATOR
|
|
23
|
+
#include "prism_xallocator.h"
|
|
24
|
+
#else
|
|
25
|
+
#ifndef xmalloc
|
|
26
|
+
/* The malloc function that should be used. This can be overridden with
|
|
27
|
+
* the PRISM_XALLOCATOR define. */
|
|
28
|
+
#define xmalloc malloc
|
|
29
|
+
#endif
|
|
30
|
+
|
|
31
|
+
#ifndef xrealloc
|
|
32
|
+
/* The realloc function that should be used. This can be overridden with
|
|
33
|
+
* the PRISM_XALLOCATOR define. */
|
|
34
|
+
#define xrealloc realloc
|
|
35
|
+
#endif
|
|
36
|
+
|
|
37
|
+
#ifndef xcalloc
|
|
38
|
+
/* The calloc function that should be used. This can be overridden with
|
|
39
|
+
* the PRISM_XALLOCATOR define. */
|
|
40
|
+
#define xcalloc calloc
|
|
41
|
+
#endif
|
|
42
|
+
|
|
43
|
+
#ifndef xfree
|
|
44
|
+
/* The free function that should be used. This can be overridden with
|
|
45
|
+
* the PRISM_XALLOCATOR define. */
|
|
46
|
+
#define xfree free
|
|
47
|
+
#endif
|
|
48
|
+
#endif
|
|
49
|
+
|
|
50
|
+
#ifndef xfree_sized
|
|
51
|
+
/* The free_sized function that should be used. This can be overridden with
|
|
52
|
+
* the PRISM_XALLOCATOR define. If not defined, defaults to calling xfree.
|
|
53
|
+
*/
|
|
54
|
+
#define xfree_sized(p, s) xfree(((void)(s), (p)))
|
|
55
|
+
#endif
|
|
56
|
+
|
|
57
|
+
#ifndef xrealloc_sized
|
|
58
|
+
/* The xrealloc_sized function that should be used. This can be overridden
|
|
59
|
+
* with the PRISM_XALLOCATOR define. If not defined, defaults to calling
|
|
60
|
+
* xrealloc. */
|
|
61
|
+
#define xrealloc_sized(p, ns, os) xrealloc((p), ((void)(os), (ns)))
|
|
62
|
+
#endif
|
|
63
|
+
|
|
64
|
+
#ifdef PRISM_BUILD_DEBUG
|
|
65
|
+
#include "prism/internal/allocator_debug.h"
|
|
66
|
+
#endif
|
|
67
|
+
|
|
68
|
+
#endif
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
#ifndef PRISM_INTERNAL_ALLOCATOR_DEBUG_H
|
|
2
|
+
#define PRISM_INTERNAL_ALLOCATOR_DEBUG_H
|
|
3
|
+
|
|
4
|
+
#include <string.h>
|
|
5
|
+
#include <stdio.h>
|
|
6
|
+
#include <stdlib.h>
|
|
7
|
+
|
|
8
|
+
static inline void *
|
|
9
|
+
pm_allocator_debug_malloc(size_t size) {
|
|
10
|
+
size_t *memory = xmalloc(size + sizeof(size_t));
|
|
11
|
+
memory[0] = size;
|
|
12
|
+
return memory + 1;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
static inline void *
|
|
16
|
+
pm_allocator_debug_calloc(size_t nmemb, size_t size) {
|
|
17
|
+
size_t total_size = nmemb * size;
|
|
18
|
+
void *ptr = pm_allocator_debug_malloc(total_size);
|
|
19
|
+
memset(ptr, 0, total_size);
|
|
20
|
+
return ptr;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static inline void *
|
|
24
|
+
pm_allocator_debug_realloc(void *ptr, size_t size) {
|
|
25
|
+
if (ptr == NULL) {
|
|
26
|
+
return pm_allocator_debug_malloc(size);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
size_t *memory = (size_t *)ptr;
|
|
30
|
+
void *raw_memory = memory - 1;
|
|
31
|
+
memory = (size_t *)xrealloc(raw_memory, size + sizeof(size_t));
|
|
32
|
+
memory[0] = size;
|
|
33
|
+
return memory + 1;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
static inline void
|
|
37
|
+
pm_allocator_debug_free(void *ptr) {
|
|
38
|
+
if (ptr != NULL) {
|
|
39
|
+
size_t *memory = (size_t *)ptr;
|
|
40
|
+
xfree(memory - 1);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
static inline void
|
|
45
|
+
pm_allocator_debug_free_sized(void *ptr, size_t old_size) {
|
|
46
|
+
if (ptr != NULL) {
|
|
47
|
+
size_t *memory = (size_t *)ptr;
|
|
48
|
+
if (old_size != memory[-1]) {
|
|
49
|
+
fprintf(stderr, "[BUG] buffer %p was allocated with size %lu but freed with size %lu\n", ptr, memory[-1], old_size);
|
|
50
|
+
abort();
|
|
51
|
+
}
|
|
52
|
+
xfree_sized(memory - 1, old_size + sizeof(size_t));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
static inline void *
|
|
57
|
+
pm_allocator_debug_realloc_sized(void *ptr, size_t size, size_t old_size) {
|
|
58
|
+
if (ptr == NULL) {
|
|
59
|
+
if (old_size != 0) {
|
|
60
|
+
fprintf(stderr, "[BUG] realloc_sized called with NULL pointer and old size %lu\n", old_size);
|
|
61
|
+
abort();
|
|
62
|
+
}
|
|
63
|
+
return pm_allocator_debug_malloc(size);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
size_t *memory = (size_t *)ptr;
|
|
67
|
+
if (old_size != memory[-1]) {
|
|
68
|
+
fprintf(stderr, "[BUG] buffer %p was allocated with size %lu but realloced with size %lu\n", ptr, memory[-1], old_size);
|
|
69
|
+
abort();
|
|
70
|
+
}
|
|
71
|
+
return pm_allocator_debug_realloc(ptr, size);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
#undef xmalloc
|
|
75
|
+
#undef xrealloc
|
|
76
|
+
#undef xcalloc
|
|
77
|
+
#undef xfree
|
|
78
|
+
#undef xrealloc_sized
|
|
79
|
+
#undef xfree_sized
|
|
80
|
+
|
|
81
|
+
#define xmalloc pm_allocator_debug_malloc
|
|
82
|
+
#define xrealloc pm_allocator_debug_realloc
|
|
83
|
+
#define xcalloc pm_allocator_debug_calloc
|
|
84
|
+
#define xfree pm_allocator_debug_free
|
|
85
|
+
#define xrealloc_sized pm_allocator_debug_realloc_sized
|
|
86
|
+
#define xfree_sized pm_allocator_debug_free_sized
|
|
87
|
+
|
|
88
|
+
#endif
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
#ifndef PRISM_INTERNAL_ARENA_H
|
|
2
|
+
#define PRISM_INTERNAL_ARENA_H
|
|
3
|
+
|
|
4
|
+
#include "prism/compiler/exported.h"
|
|
5
|
+
#include "prism/compiler/flex_array.h"
|
|
6
|
+
#include "prism/compiler/force_inline.h"
|
|
7
|
+
#include "prism/compiler/inline.h"
|
|
8
|
+
|
|
9
|
+
#include "prism/arena.h"
|
|
10
|
+
|
|
11
|
+
#include <stddef.h>
|
|
12
|
+
#include <string.h>
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
* A single block of memory in the arena. Blocks are linked via prev pointers so
|
|
16
|
+
* they can be freed by walking the chain.
|
|
17
|
+
*/
|
|
18
|
+
typedef struct pm_arena_block {
|
|
19
|
+
/* The previous block in the chain (for freeing). */
|
|
20
|
+
struct pm_arena_block *prev;
|
|
21
|
+
|
|
22
|
+
/* The total usable bytes in data[]. */
|
|
23
|
+
size_t capacity;
|
|
24
|
+
|
|
25
|
+
/* The number of bytes consumed so far. */
|
|
26
|
+
size_t used;
|
|
27
|
+
|
|
28
|
+
/* The block's data. */
|
|
29
|
+
char data[PM_FLEX_ARRAY_LENGTH];
|
|
30
|
+
} pm_arena_block_t;
|
|
31
|
+
|
|
32
|
+
/*
|
|
33
|
+
* A bump allocator. Allocations are made by bumping a pointer within the
|
|
34
|
+
* current block. When a block is full, a new block is allocated and linked to
|
|
35
|
+
* the previous one. All blocks are freed at once by walking the chain.
|
|
36
|
+
*/
|
|
37
|
+
struct pm_arena_t {
|
|
38
|
+
/* The active block (allocate from here). */
|
|
39
|
+
pm_arena_block_t *current;
|
|
40
|
+
|
|
41
|
+
/* The number of blocks allocated. */
|
|
42
|
+
size_t block_count;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/*
|
|
46
|
+
* Free all blocks in the arena. After this call, all pointers returned by
|
|
47
|
+
* pm_arena_alloc and pm_arena_zalloc are invalid.
|
|
48
|
+
*/
|
|
49
|
+
void pm_arena_cleanup(pm_arena_t *arena);
|
|
50
|
+
|
|
51
|
+
/*
|
|
52
|
+
* Ensure the arena has at least `capacity` bytes available in its current
|
|
53
|
+
* block, allocating a new block if necessary. This allows callers to
|
|
54
|
+
* pre-size the arena to avoid repeated small block allocations.
|
|
55
|
+
*/
|
|
56
|
+
void pm_arena_reserve(pm_arena_t *arena, size_t capacity);
|
|
57
|
+
|
|
58
|
+
/*
|
|
59
|
+
* Slow path for pm_arena_alloc: allocate a new block and return a pointer to
|
|
60
|
+
* the first `size` bytes. Do not call directly — use pm_arena_alloc instead.
|
|
61
|
+
*/
|
|
62
|
+
void * pm_arena_alloc_slow(pm_arena_t *arena, size_t size);
|
|
63
|
+
|
|
64
|
+
/*
|
|
65
|
+
* Allocate memory from the arena. The returned memory is NOT zeroed. This
|
|
66
|
+
* function is infallible — it aborts on allocation failure.
|
|
67
|
+
*
|
|
68
|
+
* The fast path (bump pointer within the current block) is inlined at each
|
|
69
|
+
* call site. The slow path (new block allocation) is out-of-line.
|
|
70
|
+
*/
|
|
71
|
+
static PRISM_FORCE_INLINE void *
|
|
72
|
+
pm_arena_alloc(pm_arena_t *arena, size_t size, size_t alignment) {
|
|
73
|
+
if (arena->current != NULL) {
|
|
74
|
+
size_t used_aligned = (arena->current->used + alignment - 1) & ~(alignment - 1);
|
|
75
|
+
size_t needed = used_aligned + size;
|
|
76
|
+
|
|
77
|
+
if (used_aligned >= arena->current->used && needed >= used_aligned && needed <= arena->current->capacity) {
|
|
78
|
+
arena->current->used = needed;
|
|
79
|
+
return arena->current->data + used_aligned;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return pm_arena_alloc_slow(arena, size);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/*
|
|
87
|
+
* Allocate zero-initialized memory from the arena. This function is infallible
|
|
88
|
+
* — it aborts on allocation failure.
|
|
89
|
+
*/
|
|
90
|
+
static PRISM_INLINE void *
|
|
91
|
+
pm_arena_zalloc(pm_arena_t *arena, size_t size, size_t alignment) {
|
|
92
|
+
void *ptr = pm_arena_alloc(arena, size, alignment);
|
|
93
|
+
memset(ptr, 0, size);
|
|
94
|
+
return ptr;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/*
|
|
98
|
+
* Allocate memory from the arena and copy the given data into it. This is a
|
|
99
|
+
* convenience wrapper around pm_arena_alloc + memcpy.
|
|
100
|
+
*/
|
|
101
|
+
static PRISM_INLINE void *
|
|
102
|
+
pm_arena_memdup(pm_arena_t *arena, const void *src, size_t size, size_t alignment) {
|
|
103
|
+
void *dst = pm_arena_alloc(arena, size, alignment);
|
|
104
|
+
memcpy(dst, src, size);
|
|
105
|
+
return dst;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
#endif
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#ifndef PRISM_INTERNAL_BIT_H
|
|
2
|
+
#define PRISM_INTERNAL_BIT_H
|
|
3
|
+
|
|
4
|
+
#include "prism/compiler/inline.h"
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
* Count trailing zero bits in a 64-bit value. Used by SWAR identifier scanning
|
|
8
|
+
* to find the first non-matching byte in a word.
|
|
9
|
+
*
|
|
10
|
+
* Precondition: v must be nonzero. The result is undefined when v == 0
|
|
11
|
+
* (matching the behavior of __builtin_ctzll and _BitScanForward64).
|
|
12
|
+
*/
|
|
13
|
+
#if defined(__GNUC__) || defined(__clang__)
|
|
14
|
+
#define pm_ctzll(v) ((unsigned) __builtin_ctzll(v))
|
|
15
|
+
#elif defined(_MSC_VER) && defined(_WIN64)
|
|
16
|
+
#include <intrin.h>
|
|
17
|
+
#include <stdint.h>
|
|
18
|
+
|
|
19
|
+
static PRISM_INLINE unsigned
|
|
20
|
+
pm_ctzll(uint64_t v) {
|
|
21
|
+
unsigned long index;
|
|
22
|
+
_BitScanForward64(&index, v);
|
|
23
|
+
return (unsigned) index;
|
|
24
|
+
}
|
|
25
|
+
#else
|
|
26
|
+
#include <stdint.h>
|
|
27
|
+
|
|
28
|
+
static PRISM_INLINE unsigned
|
|
29
|
+
pm_ctzll(uint64_t v) {
|
|
30
|
+
unsigned c = 0;
|
|
31
|
+
v &= (uint64_t) (-(int64_t) v);
|
|
32
|
+
if (v & 0x00000000FFFFFFFFULL) c += 0; else c += 32;
|
|
33
|
+
if (v & 0x0000FFFF0000FFFFULL) c += 0; else c += 16;
|
|
34
|
+
if (v & 0x00FF00FF00FF00FFULL) c += 0; else c += 8;
|
|
35
|
+
if (v & 0x0F0F0F0F0F0F0F0FULL) c += 0; else c += 4;
|
|
36
|
+
if (v & 0x3333333333333333ULL) c += 0; else c += 2;
|
|
37
|
+
if (v & 0x5555555555555555ULL) c += 0; else c += 1;
|
|
38
|
+
return c;
|
|
39
|
+
}
|
|
40
|
+
#endif
|
|
41
|
+
|
|
42
|
+
#endif
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
#ifndef PRISM_INTERNAL_BUFFER_H
|
|
2
|
+
#define PRISM_INTERNAL_BUFFER_H
|
|
3
|
+
|
|
4
|
+
#include "prism/compiler/format.h"
|
|
5
|
+
|
|
6
|
+
#include "prism/buffer.h"
|
|
7
|
+
|
|
8
|
+
#include <stdbool.h>
|
|
9
|
+
#include <stdint.h>
|
|
10
|
+
|
|
11
|
+
/*
|
|
12
|
+
* A simple memory buffer that stores data in a contiguous block of memory.
|
|
13
|
+
*/
|
|
14
|
+
struct pm_buffer_t {
|
|
15
|
+
/* The length of the buffer in bytes. */
|
|
16
|
+
size_t length;
|
|
17
|
+
|
|
18
|
+
/* The capacity of the buffer in bytes that has been allocated. */
|
|
19
|
+
size_t capacity;
|
|
20
|
+
|
|
21
|
+
/* A pointer to the start of the buffer. */
|
|
22
|
+
char *value;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/* Initialize a pm_buffer_t with the given capacity. */
|
|
26
|
+
void pm_buffer_init(pm_buffer_t *buffer, size_t capacity);
|
|
27
|
+
|
|
28
|
+
/* Free the memory held by the buffer. */
|
|
29
|
+
void pm_buffer_cleanup(pm_buffer_t *buffer);
|
|
30
|
+
|
|
31
|
+
/* Append the given amount of space as zeroes to the buffer. */
|
|
32
|
+
void pm_buffer_append_zeroes(pm_buffer_t *buffer, size_t length);
|
|
33
|
+
|
|
34
|
+
/* Append a formatted string to the buffer. */
|
|
35
|
+
void pm_buffer_append_format(pm_buffer_t *buffer, const char *format, ...) PRISM_ATTRIBUTE_FORMAT(2, 3);
|
|
36
|
+
|
|
37
|
+
/* Append a string to the buffer. */
|
|
38
|
+
void pm_buffer_append_string(pm_buffer_t *buffer, const char *value, size_t length);
|
|
39
|
+
|
|
40
|
+
/* Append a list of bytes to the buffer. */
|
|
41
|
+
void pm_buffer_append_bytes(pm_buffer_t *buffer, const uint8_t *value, size_t length);
|
|
42
|
+
|
|
43
|
+
/* Append a single byte to the buffer. */
|
|
44
|
+
void pm_buffer_append_byte(pm_buffer_t *buffer, uint8_t value);
|
|
45
|
+
|
|
46
|
+
/* Append a 32-bit unsigned integer to the buffer as a variable-length integer. */
|
|
47
|
+
void pm_buffer_append_varuint(pm_buffer_t *buffer, uint32_t value);
|
|
48
|
+
|
|
49
|
+
/* Append a 32-bit signed integer to the buffer as a variable-length integer. */
|
|
50
|
+
void pm_buffer_append_varsint(pm_buffer_t *buffer, int32_t value);
|
|
51
|
+
|
|
52
|
+
/* Append a double to the buffer. */
|
|
53
|
+
void pm_buffer_append_double(pm_buffer_t *buffer, double value);
|
|
54
|
+
|
|
55
|
+
/* Append a unicode codepoint to the buffer. */
|
|
56
|
+
bool pm_buffer_append_unicode_codepoint(pm_buffer_t *buffer, uint32_t value);
|
|
57
|
+
|
|
58
|
+
/*
|
|
59
|
+
* The different types of escaping that can be performed by the buffer when
|
|
60
|
+
* appending a slice of Ruby source code.
|
|
61
|
+
*/
|
|
62
|
+
typedef enum {
|
|
63
|
+
PM_BUFFER_ESCAPING_RUBY,
|
|
64
|
+
PM_BUFFER_ESCAPING_JSON
|
|
65
|
+
} pm_buffer_escaping_t;
|
|
66
|
+
|
|
67
|
+
/* Append a slice of source code to the buffer. */
|
|
68
|
+
void pm_buffer_append_source(pm_buffer_t *buffer, const uint8_t *source, size_t length, pm_buffer_escaping_t escaping);
|
|
69
|
+
|
|
70
|
+
/* Prepend the given string to the buffer. */
|
|
71
|
+
void pm_buffer_prepend_string(pm_buffer_t *buffer, const char *value, size_t length);
|
|
72
|
+
|
|
73
|
+
/* Concatenate one buffer onto another. */
|
|
74
|
+
void pm_buffer_concat(pm_buffer_t *destination, const pm_buffer_t *source);
|
|
75
|
+
|
|
76
|
+
/*
|
|
77
|
+
* Clear the buffer by reducing its size to 0. This does not free the allocated
|
|
78
|
+
* memory, but it does allow the buffer to be reused.
|
|
79
|
+
*/
|
|
80
|
+
void pm_buffer_clear(pm_buffer_t *buffer);
|
|
81
|
+
|
|
82
|
+
/* Strip the whitespace from the end of the buffer. */
|
|
83
|
+
void pm_buffer_rstrip(pm_buffer_t *buffer);
|
|
84
|
+
|
|
85
|
+
/* Checks if the buffer includes the given value. */
|
|
86
|
+
size_t pm_buffer_index(const pm_buffer_t *buffer, char value);
|
|
87
|
+
|
|
88
|
+
/* Insert the given string into the buffer at the given index. */
|
|
89
|
+
void pm_buffer_insert(pm_buffer_t *buffer, size_t index, const char *value, size_t length);
|
|
90
|
+
|
|
91
|
+
#endif
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
#ifndef PRISM_INTERNAL_CHAR_H
|
|
2
|
+
#define PRISM_INTERNAL_CHAR_H
|
|
3
|
+
|
|
4
|
+
#include "prism/compiler/force_inline.h"
|
|
5
|
+
|
|
6
|
+
#include "prism/arena.h"
|
|
7
|
+
#include "prism/line_offset_list.h"
|
|
8
|
+
|
|
9
|
+
#include <stdbool.h>
|
|
10
|
+
#include <stddef.h>
|
|
11
|
+
#include <stdint.h>
|
|
12
|
+
|
|
13
|
+
/* Bit flag for whitespace characters in pm_byte_table. */
|
|
14
|
+
#define PRISM_CHAR_BIT_WHITESPACE (1 << 0)
|
|
15
|
+
|
|
16
|
+
/* Bit flag for inline whitespace characters in pm_byte_table. */
|
|
17
|
+
#define PRISM_CHAR_BIT_INLINE_WHITESPACE (1 << 1)
|
|
18
|
+
|
|
19
|
+
/*
|
|
20
|
+
* A lookup table for classifying bytes. Each entry is a bitfield of
|
|
21
|
+
* PRISM_CHAR_BIT_* flags. Defined in char.c.
|
|
22
|
+
*/
|
|
23
|
+
extern const uint8_t pm_byte_table[256];
|
|
24
|
+
|
|
25
|
+
/* Returns true if the given character is a whitespace character. */
|
|
26
|
+
static PRISM_FORCE_INLINE bool
|
|
27
|
+
pm_char_is_whitespace(const uint8_t b) {
|
|
28
|
+
return (pm_byte_table[b] & PRISM_CHAR_BIT_WHITESPACE) != 0;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* Returns true if the given character is an inline whitespace character. */
|
|
32
|
+
static PRISM_FORCE_INLINE bool
|
|
33
|
+
pm_char_is_inline_whitespace(const uint8_t b) {
|
|
34
|
+
return (pm_byte_table[b] & PRISM_CHAR_BIT_INLINE_WHITESPACE) != 0;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/*
|
|
38
|
+
* Returns the number of characters at the start of the string that are inline
|
|
39
|
+
* whitespace (space/tab). Scans the byte table directly for use in hot paths.
|
|
40
|
+
*/
|
|
41
|
+
static PRISM_FORCE_INLINE size_t
|
|
42
|
+
pm_strspn_inline_whitespace(const uint8_t *string, ptrdiff_t length) {
|
|
43
|
+
if (length <= 0) return 0;
|
|
44
|
+
size_t size = 0;
|
|
45
|
+
size_t maximum = (size_t) length;
|
|
46
|
+
while (size < maximum && (pm_byte_table[string[size]] & PRISM_CHAR_BIT_INLINE_WHITESPACE)) size++;
|
|
47
|
+
return size;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/*
|
|
51
|
+
* Returns the number of characters at the start of the string that are
|
|
52
|
+
* whitespace. Disallows searching past the given maximum number of characters.
|
|
53
|
+
*/
|
|
54
|
+
size_t pm_strspn_whitespace(const uint8_t *string, ptrdiff_t length);
|
|
55
|
+
|
|
56
|
+
/*
|
|
57
|
+
* Returns the number of characters at the start of the string that are
|
|
58
|
+
* whitespace while also tracking the location of each newline. Disallows
|
|
59
|
+
* searching past the given maximum number of characters.
|
|
60
|
+
*/
|
|
61
|
+
size_t pm_strspn_whitespace_newlines(const uint8_t *string, ptrdiff_t length, pm_arena_t *arena, pm_line_offset_list_t *line_offsets, uint32_t start_offset);
|
|
62
|
+
|
|
63
|
+
/*
|
|
64
|
+
* Returns the number of characters at the start of the string that are decimal
|
|
65
|
+
* digits. Disallows searching past the given maximum number of characters.
|
|
66
|
+
*/
|
|
67
|
+
size_t pm_strspn_decimal_digit(const uint8_t *string, ptrdiff_t length);
|
|
68
|
+
|
|
69
|
+
/*
|
|
70
|
+
* Returns the number of characters at the start of the string that are
|
|
71
|
+
* hexadecimal digits. Disallows searching past the given maximum number of
|
|
72
|
+
* characters.
|
|
73
|
+
*/
|
|
74
|
+
size_t pm_strspn_hexadecimal_digit(const uint8_t *string, ptrdiff_t length);
|
|
75
|
+
|
|
76
|
+
/*
|
|
77
|
+
* Returns the number of characters at the start of the string that are octal
|
|
78
|
+
* digits or underscores. Disallows searching past the given maximum number of
|
|
79
|
+
* characters.
|
|
80
|
+
*
|
|
81
|
+
* If multiple underscores are found in a row or if an underscore is
|
|
82
|
+
* found at the end of the number, then the invalid pointer is set to the index
|
|
83
|
+
* of the first invalid underscore.
|
|
84
|
+
*/
|
|
85
|
+
size_t pm_strspn_octal_number(const uint8_t *string, ptrdiff_t length, const uint8_t **invalid);
|
|
86
|
+
|
|
87
|
+
/*
|
|
88
|
+
* Returns the number of characters at the start of the string that are decimal
|
|
89
|
+
* digits or underscores. Disallows searching past the given maximum number of
|
|
90
|
+
* characters.
|
|
91
|
+
*
|
|
92
|
+
* If multiple underscores are found in a row or if an underscore is
|
|
93
|
+
* found at the end of the number, then the invalid pointer is set to the index
|
|
94
|
+
* of the first invalid underscore.
|
|
95
|
+
*/
|
|
96
|
+
size_t pm_strspn_decimal_number(const uint8_t *string, ptrdiff_t length, const uint8_t **invalid);
|
|
97
|
+
|
|
98
|
+
/*
|
|
99
|
+
* Returns the number of characters at the start of the string that are
|
|
100
|
+
* hexadecimal digits or underscores. Disallows searching past the given maximum
|
|
101
|
+
* number of characters.
|
|
102
|
+
*
|
|
103
|
+
* If multiple underscores are found in a row or if an underscore is
|
|
104
|
+
* found at the end of the number, then the invalid pointer is set to the index
|
|
105
|
+
* of the first invalid underscore.
|
|
106
|
+
*/
|
|
107
|
+
size_t pm_strspn_hexadecimal_number(const uint8_t *string, ptrdiff_t length, const uint8_t **invalid);
|
|
108
|
+
|
|
109
|
+
/*
|
|
110
|
+
* Returns the number of characters at the start of the string that are regexp
|
|
111
|
+
* options. Disallows searching past the given maximum number of characters.
|
|
112
|
+
*/
|
|
113
|
+
size_t pm_strspn_regexp_option(const uint8_t *string, ptrdiff_t length);
|
|
114
|
+
|
|
115
|
+
/*
|
|
116
|
+
* Returns the number of characters at the start of the string that are binary
|
|
117
|
+
* digits or underscores. Disallows searching past the given maximum number of
|
|
118
|
+
* characters.
|
|
119
|
+
*
|
|
120
|
+
* If multiple underscores are found in a row or if an underscore is
|
|
121
|
+
* found at the end of the number, then the invalid pointer is set to the index
|
|
122
|
+
* of the first invalid underscore.
|
|
123
|
+
*/
|
|
124
|
+
size_t pm_strspn_binary_number(const uint8_t *string, ptrdiff_t length, const uint8_t **invalid);
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
/* Returns true if the given character is a binary digit. */
|
|
128
|
+
bool pm_char_is_binary_digit(const uint8_t b);
|
|
129
|
+
|
|
130
|
+
/* Returns true if the given character is an octal digit. */
|
|
131
|
+
bool pm_char_is_octal_digit(const uint8_t b);
|
|
132
|
+
|
|
133
|
+
/* Returns true if the given character is a decimal digit. */
|
|
134
|
+
bool pm_char_is_decimal_digit(const uint8_t b);
|
|
135
|
+
|
|
136
|
+
/* Returns true if the given character is a hexadecimal digit. */
|
|
137
|
+
bool pm_char_is_hexadecimal_digit(const uint8_t b);
|
|
138
|
+
|
|
139
|
+
#endif
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#ifndef PRISM_INTERNAL_COMMENTS_H
|
|
2
|
+
#define PRISM_INTERNAL_COMMENTS_H
|
|
3
|
+
|
|
4
|
+
#include "prism/comments.h"
|
|
5
|
+
|
|
6
|
+
#include "prism/internal/list.h"
|
|
7
|
+
|
|
8
|
+
/* A comment found while parsing. */
|
|
9
|
+
struct pm_comment_t {
|
|
10
|
+
/* The embedded base node. */
|
|
11
|
+
pm_list_node_t node;
|
|
12
|
+
|
|
13
|
+
/* The location of the comment in the source. */
|
|
14
|
+
pm_location_t location;
|
|
15
|
+
|
|
16
|
+
/* The type of the comment. */
|
|
17
|
+
pm_comment_type_t type;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
#endif
|