Commit e7b577b3
e7b577b37307Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 7 files · +2 added · ~5 modified
Description
parse,codegen: Kernel#dir as compile-time literal
Returns the dirname of the source file, computed at parse time
and baked into the generated C. The parser now emits a top-level
SOURCE_FILE <escaped-path> line so the codegen can recover the
path even when the source contains no __FILE__ reference.
Kernel#caller is intentionally not implemented -- it would
require per-call frame tracking that slows the dispatch hot
path. Out of scope for the AOT model.
Closes part of #878; caller portion deferred / declined.
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- e7b577b37307
- Parent
- 6d6d5954730f
compiler_helpers.rbmodifiedView file
@@ -571,6 +571,13 @@
571571
@root_id = root_id572572
end573573
574+
# Issue #878: parser emits SOURCE_FILE near the top so __dir__575+
# (and similar compile-time helpers) can recover the path576+
# without scanning for SourceFileNode entries.577+
def set_source_file_path(path)578+
@source_file_path = path579+
end580+
574581
def set_node_type(nid, node_type)575582
@nd_type[nid] = node_type576583
endnode_table_loader.rbmodifiedView file
Loading diff…
spinel_analyze.rbmodifiedView file
Loading diff…
spinel_codegen.rbmodifiedView file
Loading diff…
spinel_parse.cmodifiedView file
Loading diff…
test/kernel_dir.rbaddedView file
Loading diff…
test/kernel_dir.rb.expectedaddedView file
Loading diff…