Commit graph

555 commits

Author SHA1 Message Date
Kevin Newton
a6dac9bb4f [PRISM] Parse stdin on CLI with prism 2024-03-11 12:51:32 -04:00
Kevin Newton
811296b4af [PRISM] Use new integer logic 2024-03-07 18:02:33 -05:00
cui fliter
226a889dc7
[DOC] fix some comments
Signed-off-by: cui fliter <imcusg@gmail.com>
2024-03-05 18:50:47 +09:00
Kevin Newton
a29c0e827f [PRISM] Handle implicit flip-flop bounds checking against $. 2024-02-28 13:26:00 -05:00
Kevin Newton
16c7144cd5 [PRISM] Only look up encoding once per file 2024-02-28 12:44:24 -05:00
Kevin Newton
f8355e88d6 [PRISM] Do not load -r until we check if main script can be read 2024-02-28 12:42:57 -05:00
Kevin Newton
4016535404 [PRISM] Integrate new number parsing 2024-02-22 22:42:44 -05:00
Kevin Newton
be96dc9f8c [PRISM] Support it local variable 2024-02-21 17:55:11 -05:00
Kevin Newton
5c02d97780 [PRISM] Remove more dummy line usage
* or
* optional parameter
* parentheses
* pre execution
* post execution
* range
* rational
* redo
2024-02-21 14:14:21 -05:00
Kevin Newton
e19fde52cc [PRISM] Remove more dummy line usage
* if
* unless
2024-02-21 14:14:21 -05:00
Kevin Newton
e1f6b477e0 [PRISM] Remove more dummy line usage
* regular expressions
* rescue
* rescue modifier
2024-02-21 14:14:21 -05:00
Kevin Newton
e7d480df5d [PRISM] Remove more dummy line usage
* returns
* retry
* self
* singleton class
2024-02-21 14:14:21 -05:00
Kevin Newton
61c5936da3 [PRISM] Remove more dummy line usage
* source files
* source encodings
* source lines
2024-02-21 14:14:21 -05:00
Kevin Newton
220ced7486 [PRISM] Remove more dummy line usage
* yields
* xstrings
* while
* until
* undef
* true
* symbol
* super
* string
* statements
* splat
2024-02-21 14:14:21 -05:00
Peter Zhu
777c4da0bf [PRISM] GC guard strings
Using RSTRING_PTR can cause the string object to not exist on the stack,
which could cause it to be GC'd or be moved by GC compaction. This can
cause RSTRING_PTR to point to the incorrect location if the string is
embedded and moved by GC compaction.

Fixes ruby/prism#2442.
2024-02-16 15:02:03 -05:00
Kevin Newton
9933377c34 [PRISM] Correctly hook up line numbers for eval 2024-02-14 15:29:26 -05:00
Kevin Newton
fc2c128e7e [PRISM] Set eval encoding based on string encoding 2024-02-14 13:24:43 -05:00
Matt Valentine-House
f70a4a0336 [PRISM] yield is invalid inside eval 2024-02-13 21:19:12 -05:00
Matt Valentine-House
0285b533e9 [PRISM] Don't rb_bug if redo/break/next used during eval 2024-02-13 21:19:12 -05:00
Peter Zhu
a5869e5d8c [PRISM] Replace assert with RUBY_ASSERT
assert does not print the bug report, only the file and line number of
the assertion that failed. RUBY_ASSERT prints the full bug report, which
makes it much easier to debug.
2024-02-13 15:54:04 -05:00
Peter Zhu
83c158fdfc [PRISM] Replace assert with rb_bug 2024-02-13 15:54:04 -05:00
Kevin Newton
4e481c772e [PRISM] Refactors to use more locations 2024-02-13 10:26:42 -05:00
Kevin Newton
fe31b682be [PRISM] Stop passing parser around so much 2024-02-13 10:26:42 -05:00
Kevin Newton
e967e06276 [PRISM] Switch to locations for PM_ALIAS_GLOBAL_VARIABLE_NODE, PM_ALIAS_METHOD_NODE, and PM_AND_NODE 2024-02-13 10:26:42 -05:00
Kevin Newton
76ab017f01 [PRISM] Brace style in prism_compile.c 2024-02-13 10:26:42 -05:00
Nikita Vasilevsky
d357d50f0a [PRISM] Fix lambda start column number
Co-Authored-By: Kevin Newton <kddnewton@gmail.com>
2024-02-13 09:39:28 -05:00
Kevin Newton
b662edf0a0 [PRISM] Combine hash compilation between hashes and keywords 2024-02-13 09:37:24 -05:00
Kevin Newton
c0e121420b [PRISM] Fix compilation of hash with multiple merges 2024-02-13 09:37:24 -05:00
Kevin Newton
1395838e18 [PRISM] Check full lines for invalid UTF-8 2024-02-12 14:48:09 -05:00
eileencodes
a3ceb69168 [PRISM] Fix error handling in pm_parse_prism
Following changes made in ruby/prism#2365 this implements error handling
for when `pm_string_mapped_init` returns `false`.

Related: ruby/prism#2207
2024-02-11 09:41:20 -05:00
Kevin Newton
f7467e70e1 Split line_no and node_id before new_insn_body
Before this commit, there were many places where we had to generate
dummy line nodes to hold both the line number and the node id that
would then immediately get pulled out from the created node. Now
we pass them explicitly so that we don't have to generate these
nodes.

This makes a clearer line between the parser and compiler, and also
makes it easier to generate instructions when we don't have a
specific node to tie them to. As such, it removes almost every
single place where we needed to previously generate dummy nodes.

This also makes it easier for the prism compiler, because now we
can pass in line number and node id instead of trying to generate
dummy nodes for every instruction that we compile.
2024-02-09 17:01:27 -05:00
Kevin Newton
e96c838ca4 [PRISM] Fix flaky memory in scope nodes 2024-02-09 16:30:07 -05:00
Kevin Newton
5c2d96df19 [PRISM] Implement opt_case_dispatch 2024-02-09 11:26:32 -05:00
Kevin Newton
a4ba62b6e5 [PRISM] Refactor case nodes for only one pass through when 2024-02-09 11:26:32 -05:00
Kevin Newton
3e03981f25 [PRISM] Compile constant paths with optimizations 2024-02-08 11:53:10 -05:00
Kevin Newton
54295ba5e1 [PRISM] Compile constant reads using opt_getconstant_path 2024-02-08 11:53:10 -05:00
Kevin Newton
b2d468fced [PRISM] Refactor call opts to only check for specific ids 2024-02-08 11:53:10 -05:00
Nikita Vasilevsky
c3403322df [PRISM] Use block node location when building block iseq
Co-Authored-By: Kevin Newton <kddnewton@gmail.com>
2024-02-06 14:56:10 -05:00
Kevin Newton
c1bc714720 [PRISM] Do not show source snippets if non-UTF-8 2024-02-06 14:31:10 -05:00
Kevin Newton
ccec209b2c [PRISM] Fix fsl coming from file 2024-02-06 12:36:46 -05:00
Kevin Newton
d77172b79b [PRISM] Fix deconstruct index for posts 2024-02-06 11:57:59 -05:00
Kevin Newton
26fac8f6fa [PRISM] Set correct call target flags 2024-02-06 11:21:52 -05:00
Kevin Newton
c6d4071c29 [PRISM] Handle match write popped 2024-02-06 11:08:14 -05:00
Kevin Newton
1c120023f1 [PRISM] Correctly handle popped attr write 2024-02-06 10:46:27 -05:00
Kevin Newton
b801a19c6a [PRISM] Handle empty interpolated statements at start of string 2024-02-06 10:13:11 -05:00
Kevin Newton
d6b7eae58e [PRISM] Correct spec for defined? parentheses 2024-02-06 09:51:25 -05:00
Kevin Newton
c5694c647a [PRISM] Raise ArgumentError for invalid encoding 2024-02-05 15:18:15 -05:00
Kevin Newton
10a182f597 [PRISM] Fix method return line 2024-02-05 14:42:20 -05:00
Kevin Newton
7eea066cb4 [PRISM] Fix pattern matching array with implicit rest 2024-02-05 12:54:52 -05:00
Kevin Newton
ae7816bc20
[PRISM] Fix up idUMinus optimization 2024-02-05 11:57:38 -05:00