Commit e59d250a
e59d250ab7afMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 6 files · ~6 modified
Description
Merge PR #1292: spinel --debug / -g line-mapped builds
Adds --debug / -g modes that emit #line directives (with a
multi-file source map across require/require_relative) and keep methods
non-inlined, so a native debugger can step through the original Ruby.
Maintainer follow-ups applied during merge:
- Drop the
@file_table ||= []guard in compiler_helpers.rb#set_file_entry. The bare empty-array literal lowered to an IntArray default and collided with the StrArray/PolyArray-typed slot, breaking the windows-mingw self-host build. Both consumers already initialize the slot, so the helper can assume it exists. - Resolve the spinel_parse.c require-inlining conflict so the trailing
same-line modifier handling (
require 'x' rescue nil, CRLF-safe) runs before sp_wrap_included marker-wraps the inlined content.
Co-Authored-By: Claude Opus 4.8 [email protected]
Details
- Commit
- e59d250ab7af
- Parent
- 8ce5456abae4
- Merge parent
- da8b3bca7078
compiler_helpers.rbmodifiedView file
@@ -466,6 +466,8 @@
466466
@nd_type.push("")467467
@nd_name.push("")468468
@nd_value.push(0)469+
@nd_line.push(0) # keep the source-map arrays parallel with the rest, so a470+
@nd_file.push(0) # dynamically-allocated node can't drift them out of sync469471
@nd_content.push("")470472
@nd_flags.push(0)471473
@nd_operator.push("")@@ -528,6 +530,8 @@
528530
@nd_type = Array.new(n, "")529531
@nd_name = Array.new(n, "")530532
@nd_value = Array.new(n, 0)533+
@nd_line = Array.new(n, 0)534+
@nd_file = Array.new(n, 0)531535
@nd_content = Array.new(n, "")532536
@nd_flags = Array.new(n, 0)533537
@nd_operator = Array.new(n, "")@@ -665,6 +669,30 @@
665669
# location in the compile error.666670
@nd_value[nid] = val667671
end672+
# Debug builds only (SPINEL_DEBUG=1): the parser stamps every node673+
# with its 1-based source line in a dedicated slot so codegen can674+
# emit `#line` directives. Kept separate from @nd_value, which is675+
# overloaded for integer/float literal values, numbered-param max, etc.676+
if field == "node_line"677+
@nd_line[nid] = val678+
end679+
# Debug multi-file map: id into the FILE table (0 = toplevel source).680+
if field == "node_file"681+
@nd_file[nid] = val682+
end683+
end684+
685+
# Debug multi-file map: record a FILE <id> <path> table entry emitted by686+
# the parser. Grown on demand so ids can arrive in any order.687+
def set_file_entry(id, path)688+
# The analyze/codegen consumers initialize @file_table = []; this shared689+
# helper assumes the slot exists. A bare `@file_table ||= []` fallback is690+
# unsafe under self-host inference: the empty literal lowers to IntArray691+
# and collides with the PolyArray-typed slot, breaking the build.692+
while @file_table.length <= id693+
@file_table.push("")694+
end695+
@file_table[id] = path668696
end669697
670698
def set_ref_field(nid, field, ref_id)node_table_loader.rbmodifiedView file
Loading diff…
spinelmodifiedView file
Loading diff…
spinel_analyze.rbmodifiedView file
Loading diff…
spinel_codegen.rbmodifiedView file
Loading diff…
spinel_parse.cmodifiedView file
Loading diff…