зеркало из https://github.com/github/ruby.git
[Feature #19719] Universal Parser
Introduce Universal Parser mode for the parser. This commit includes these changes: * Introduce `UNIVERSAL_PARSER` macro. All of CRuby related functions are passed via `struct rb_parser_config_struct` when this macro is enabled. * Add CI task with 'cppflags=-DUNIVERSAL_PARSER' for ubuntu.
This commit is contained in:
Родитель
b308f7cfe4
Коммит
b481b673d7
|
@ -43,6 +43,8 @@ jobs:
|
|||
- test_task: check
|
||||
configure: '--enable-shared --enable-load-relative'
|
||||
- test_task: test-all TESTS=--repeat-count=2
|
||||
- test_task: test-all TESTS=--repeat-count=2
|
||||
configure: 'cppflags=-DUNIVERSAL_PARSER'
|
||||
- test_task: test-bundler-parallel
|
||||
- test_task: test-bundled-gems
|
||||
fail-fast: false
|
||||
|
|
|
@ -205,8 +205,10 @@ lcov*.info
|
|||
|
||||
# /ext/ripper/
|
||||
/ext/ripper/eventids1.c
|
||||
/ext/ripper/eventids1.h
|
||||
/ext/ripper/.eventids2-check
|
||||
/ext/ripper/eventids2table.c
|
||||
/ext/ripper/ripper_init.c
|
||||
/ext/ripper/ripper.*
|
||||
/ext/ripper/ids1
|
||||
/ext/ripper/ids2
|
||||
|
|
2
ast.c
2
ast.c
|
@ -1,6 +1,6 @@
|
|||
/* indent-tabs-mode: nil */
|
||||
#include "internal.h"
|
||||
#include "internal/parse.h"
|
||||
#include "internal/ruby_parser.h"
|
||||
#include "internal/symbol.h"
|
||||
#include "internal/warnings.h"
|
||||
#include "iseq.h"
|
||||
|
|
488
common.mk
488
common.mk
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -15,6 +15,7 @@ coverage.o: $(hdrdir)/ruby/backward/2/long_long.h
|
|||
coverage.o: $(hdrdir)/ruby/backward/2/stdalign.h
|
||||
coverage.o: $(hdrdir)/ruby/backward/2/stdarg.h
|
||||
coverage.o: $(hdrdir)/ruby/defines.h
|
||||
coverage.o: $(hdrdir)/ruby/encoding.h
|
||||
coverage.o: $(hdrdir)/ruby/intern.h
|
||||
coverage.o: $(hdrdir)/ruby/internal/abi.h
|
||||
coverage.o: $(hdrdir)/ruby/internal/anyargs.h
|
||||
|
@ -87,6 +88,15 @@ coverage.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
|
|||
coverage.o: $(hdrdir)/ruby/internal/ctype.h
|
||||
coverage.o: $(hdrdir)/ruby/internal/dllexport.h
|
||||
coverage.o: $(hdrdir)/ruby/internal/dosish.h
|
||||
coverage.o: $(hdrdir)/ruby/internal/encoding/coderange.h
|
||||
coverage.o: $(hdrdir)/ruby/internal/encoding/ctype.h
|
||||
coverage.o: $(hdrdir)/ruby/internal/encoding/encoding.h
|
||||
coverage.o: $(hdrdir)/ruby/internal/encoding/pathname.h
|
||||
coverage.o: $(hdrdir)/ruby/internal/encoding/re.h
|
||||
coverage.o: $(hdrdir)/ruby/internal/encoding/sprintf.h
|
||||
coverage.o: $(hdrdir)/ruby/internal/encoding/string.h
|
||||
coverage.o: $(hdrdir)/ruby/internal/encoding/symbol.h
|
||||
coverage.o: $(hdrdir)/ruby/internal/encoding/transcode.h
|
||||
coverage.o: $(hdrdir)/ruby/internal/error.h
|
||||
coverage.o: $(hdrdir)/ruby/internal/eval.h
|
||||
coverage.o: $(hdrdir)/ruby/internal/event.h
|
||||
|
@ -156,6 +166,8 @@ coverage.o: $(hdrdir)/ruby/internal/variable.h
|
|||
coverage.o: $(hdrdir)/ruby/internal/warning_push.h
|
||||
coverage.o: $(hdrdir)/ruby/internal/xmalloc.h
|
||||
coverage.o: $(hdrdir)/ruby/missing.h
|
||||
coverage.o: $(hdrdir)/ruby/onigmo.h
|
||||
coverage.o: $(hdrdir)/ruby/oniguruma.h
|
||||
coverage.o: $(hdrdir)/ruby/ruby.h
|
||||
coverage.o: $(hdrdir)/ruby/st.h
|
||||
coverage.o: $(hdrdir)/ruby/subst.h
|
||||
|
@ -184,6 +196,7 @@ coverage.o: $(top_srcdir)/method.h
|
|||
coverage.o: $(top_srcdir)/node.h
|
||||
coverage.o: $(top_srcdir)/ruby_assert.h
|
||||
coverage.o: $(top_srcdir)/ruby_atomic.h
|
||||
coverage.o: $(top_srcdir)/rubyparser.h
|
||||
coverage.o: $(top_srcdir)/shape.h
|
||||
coverage.o: $(top_srcdir)/thread_pthread.h
|
||||
coverage.o: $(top_srcdir)/vm_core.h
|
||||
|
|
|
@ -15,6 +15,7 @@ object_tracing.o: $(hdrdir)/ruby/backward/2/stdalign.h
|
|||
object_tracing.o: $(hdrdir)/ruby/backward/2/stdarg.h
|
||||
object_tracing.o: $(hdrdir)/ruby/debug.h
|
||||
object_tracing.o: $(hdrdir)/ruby/defines.h
|
||||
object_tracing.o: $(hdrdir)/ruby/encoding.h
|
||||
object_tracing.o: $(hdrdir)/ruby/intern.h
|
||||
object_tracing.o: $(hdrdir)/ruby/internal/abi.h
|
||||
object_tracing.o: $(hdrdir)/ruby/internal/anyargs.h
|
||||
|
@ -87,6 +88,15 @@ object_tracing.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
|
|||
object_tracing.o: $(hdrdir)/ruby/internal/ctype.h
|
||||
object_tracing.o: $(hdrdir)/ruby/internal/dllexport.h
|
||||
object_tracing.o: $(hdrdir)/ruby/internal/dosish.h
|
||||
object_tracing.o: $(hdrdir)/ruby/internal/encoding/coderange.h
|
||||
object_tracing.o: $(hdrdir)/ruby/internal/encoding/ctype.h
|
||||
object_tracing.o: $(hdrdir)/ruby/internal/encoding/encoding.h
|
||||
object_tracing.o: $(hdrdir)/ruby/internal/encoding/pathname.h
|
||||
object_tracing.o: $(hdrdir)/ruby/internal/encoding/re.h
|
||||
object_tracing.o: $(hdrdir)/ruby/internal/encoding/sprintf.h
|
||||
object_tracing.o: $(hdrdir)/ruby/internal/encoding/string.h
|
||||
object_tracing.o: $(hdrdir)/ruby/internal/encoding/symbol.h
|
||||
object_tracing.o: $(hdrdir)/ruby/internal/encoding/transcode.h
|
||||
object_tracing.o: $(hdrdir)/ruby/internal/error.h
|
||||
object_tracing.o: $(hdrdir)/ruby/internal/eval.h
|
||||
object_tracing.o: $(hdrdir)/ruby/internal/event.h
|
||||
|
@ -156,6 +166,8 @@ object_tracing.o: $(hdrdir)/ruby/internal/variable.h
|
|||
object_tracing.o: $(hdrdir)/ruby/internal/warning_push.h
|
||||
object_tracing.o: $(hdrdir)/ruby/internal/xmalloc.h
|
||||
object_tracing.o: $(hdrdir)/ruby/missing.h
|
||||
object_tracing.o: $(hdrdir)/ruby/onigmo.h
|
||||
object_tracing.o: $(hdrdir)/ruby/oniguruma.h
|
||||
object_tracing.o: $(hdrdir)/ruby/ruby.h
|
||||
object_tracing.o: $(hdrdir)/ruby/st.h
|
||||
object_tracing.o: $(hdrdir)/ruby/subst.h
|
||||
|
@ -178,6 +190,7 @@ object_tracing.o: $(top_srcdir)/method.h
|
|||
object_tracing.o: $(top_srcdir)/node.h
|
||||
object_tracing.o: $(top_srcdir)/ruby_assert.h
|
||||
object_tracing.o: $(top_srcdir)/ruby_atomic.h
|
||||
object_tracing.o: $(top_srcdir)/rubyparser.h
|
||||
object_tracing.o: $(top_srcdir)/thread_pthread.h
|
||||
object_tracing.o: $(top_srcdir)/vm_core.h
|
||||
object_tracing.o: $(top_srcdir)/vm_opts.h
|
||||
|
@ -365,11 +378,6 @@ objspace.o: $(top_srcdir)/ccan/container_of/container_of.h
|
|||
objspace.o: $(top_srcdir)/ccan/list/list.h
|
||||
objspace.o: $(top_srcdir)/ccan/str/str.h
|
||||
objspace.o: $(top_srcdir)/constant.h
|
||||
objspace.o: $(hdrdir)/ruby/thread_native.h
|
||||
objspace.o: $(top_srcdir)/ccan/check_type/check_type.h
|
||||
objspace.o: $(top_srcdir)/ccan/container_of/container_of.h
|
||||
objspace.o: $(top_srcdir)/ccan/list/list.h
|
||||
objspace.o: $(top_srcdir)/ccan/str/str.h
|
||||
objspace.o: $(top_srcdir)/id_table.h
|
||||
objspace.o: $(top_srcdir)/internal.h
|
||||
objspace.o: $(top_srcdir)/internal/array.h
|
||||
|
@ -389,6 +397,7 @@ objspace.o: $(top_srcdir)/method.h
|
|||
objspace.o: $(top_srcdir)/node.h
|
||||
objspace.o: $(top_srcdir)/ruby_assert.h
|
||||
objspace.o: $(top_srcdir)/ruby_atomic.h
|
||||
objspace.o: $(top_srcdir)/rubyparser.h
|
||||
objspace.o: $(top_srcdir)/shape.h
|
||||
objspace.o: $(top_srcdir)/symbol.h
|
||||
objspace.o: $(top_srcdir)/thread_pthread.h
|
||||
|
@ -597,6 +606,7 @@ objspace_dump.o: $(top_srcdir)/method.h
|
|||
objspace_dump.o: $(top_srcdir)/node.h
|
||||
objspace_dump.o: $(top_srcdir)/ruby_assert.h
|
||||
objspace_dump.o: $(top_srcdir)/ruby_atomic.h
|
||||
objspace_dump.o: $(top_srcdir)/rubyparser.h
|
||||
objspace_dump.o: $(top_srcdir)/shape.h
|
||||
objspace_dump.o: $(top_srcdir)/symbol.h
|
||||
objspace_dump.o: $(top_srcdir)/thread_pthread.h
|
||||
|
|
|
@ -28,6 +28,10 @@ check: .eventids2-check
|
|||
$(Q) $(RUBY) $(GEN) --mode=check --ids1src=$(SRC1) --ids2src=$(SRC2)
|
||||
@exit > $@
|
||||
|
||||
eventids1.h: $(GEN) $(srcdir)/tools/dsl.rb $(SRC1)
|
||||
$(ECHO) generating $@ from $(SRC1)
|
||||
$(Q) $(RUBY) $(GEN) --mode=eventids1_h --ids1src=$(SRC1) --output=$@
|
||||
|
||||
eventids1.c: $(GEN) $(srcdir)/tools/dsl.rb $(SRC1)
|
||||
$(ECHO) generating $@ from $(SRC1)
|
||||
$(Q) $(RUBY) $(GEN) --mode=eventids1 --ids1src=$(SRC1) --output=$@
|
||||
|
@ -36,6 +40,10 @@ eventids2table.c: $(GEN) $(srcdir)/tools/dsl.rb $(SRC2)
|
|||
$(ECHO) generating $@ from $(SRC2)
|
||||
$(Q) $(RUBY) $(GEN) --mode=eventids2table --ids2src=$(SRC2) --output=$@
|
||||
|
||||
ripper_init.c: $(srcdir)/ripper_init.c.tmpl ripper.y $(srcdir)/tools/preproc.rb $(top_srcdir)/internal/ruby_parser.h
|
||||
$(ECHO) generating $@ from $(srcdir)/ripper_init.c.tmpl
|
||||
$(Q) $(RUBY) $(srcdir)/tools/preproc.rb --output=$@ --template=$(srcdir)/ripper_init.c.tmpl $(top_srcdir)/internal/ruby_parser.h
|
||||
|
||||
# Entries for Ripper maintainer
|
||||
|
||||
preproc: ripper.E
|
||||
|
@ -44,6 +52,342 @@ ripper.E: ripper.c
|
|||
$(Q) $(CC) -E $(INCFLAGS) $(CPPFLAGS) $< | $(RUBY) $(srcdir)/tools/strip.rb > $@
|
||||
|
||||
# AUTOGENERATED DEPENDENCIES START
|
||||
eventids1.o: $(RUBY_EXTCONF_H)
|
||||
eventids1.o: $(arch_hdrdir)/ruby/config.h
|
||||
eventids1.o: $(hdrdir)/ruby/assert.h
|
||||
eventids1.o: $(hdrdir)/ruby/backward.h
|
||||
eventids1.o: $(hdrdir)/ruby/backward/2/assume.h
|
||||
eventids1.o: $(hdrdir)/ruby/backward/2/attributes.h
|
||||
eventids1.o: $(hdrdir)/ruby/backward/2/bool.h
|
||||
eventids1.o: $(hdrdir)/ruby/backward/2/inttypes.h
|
||||
eventids1.o: $(hdrdir)/ruby/backward/2/limits.h
|
||||
eventids1.o: $(hdrdir)/ruby/backward/2/long_long.h
|
||||
eventids1.o: $(hdrdir)/ruby/backward/2/stdalign.h
|
||||
eventids1.o: $(hdrdir)/ruby/backward/2/stdarg.h
|
||||
eventids1.o: $(hdrdir)/ruby/defines.h
|
||||
eventids1.o: $(hdrdir)/ruby/intern.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/abi.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/anyargs.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/arithmetic.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/arithmetic/char.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/arithmetic/double.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/arithmetic/int.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/arithmetic/long.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/arithmetic/short.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/assume.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/attr/artificial.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/attr/cold.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/attr/const.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/attr/constexpr.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/attr/deprecated.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/attr/error.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/attr/forceinline.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/attr/format.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/attr/noalias.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/attr/noexcept.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/attr/noinline.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/attr/nonnull.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/attr/noreturn.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/attr/pure.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/attr/restrict.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/attr/warning.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/attr/weakref.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/cast.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/compiler_is.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/compiler_since.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/config.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/constant_p.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/core.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/core/rarray.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/core/rbasic.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/core/rbignum.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/core/rclass.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/core/rdata.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/core/rfile.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/core/rhash.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/core/robject.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/core/rregexp.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/core/rstring.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/core/rstruct.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/ctype.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/dllexport.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/dosish.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/error.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/eval.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/event.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/fl_type.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/gc.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/glob.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/globals.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/has/attribute.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/has/builtin.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/has/c_attribute.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/has/extension.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/has/feature.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/has/warning.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/intern/array.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/intern/bignum.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/intern/class.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/intern/compar.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/intern/complex.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/intern/cont.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/intern/dir.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/intern/enum.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/intern/enumerator.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/intern/error.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/intern/eval.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/intern/file.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/intern/hash.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/intern/io.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/intern/load.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/intern/marshal.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/intern/numeric.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/intern/object.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/intern/parse.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/intern/proc.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/intern/process.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/intern/random.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/intern/range.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/intern/rational.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/intern/re.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/intern/ruby.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/intern/select.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/intern/signal.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/intern/sprintf.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/intern/string.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/intern/struct.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/intern/thread.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/intern/time.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/intern/variable.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/intern/vm.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/interpreter.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/iterator.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/memory.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/method.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/module.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/newobj.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/scan_args.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/special_consts.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/static_assert.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/stdalign.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/stdbool.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/symbol.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/value.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/value_type.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/variable.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/warning_push.h
|
||||
eventids1.o: $(hdrdir)/ruby/internal/xmalloc.h
|
||||
eventids1.o: $(hdrdir)/ruby/missing.h
|
||||
eventids1.o: $(hdrdir)/ruby/ruby.h
|
||||
eventids1.o: $(hdrdir)/ruby/st.h
|
||||
eventids1.o: $(hdrdir)/ruby/subst.h
|
||||
eventids1.o: eventids1.h
|
||||
eventids1.o: {$(VPATH)}eventids1.c
|
||||
eventids1.o: {$(VPATH)}eventids1.h
|
||||
eventids2.o: $(RUBY_EXTCONF_H)
|
||||
eventids2.o: $(arch_hdrdir)/ruby/config.h
|
||||
eventids2.o: $(hdrdir)/ruby/assert.h
|
||||
eventids2.o: $(hdrdir)/ruby/backward.h
|
||||
eventids2.o: $(hdrdir)/ruby/backward/2/assume.h
|
||||
eventids2.o: $(hdrdir)/ruby/backward/2/attributes.h
|
||||
eventids2.o: $(hdrdir)/ruby/backward/2/bool.h
|
||||
eventids2.o: $(hdrdir)/ruby/backward/2/inttypes.h
|
||||
eventids2.o: $(hdrdir)/ruby/backward/2/limits.h
|
||||
eventids2.o: $(hdrdir)/ruby/backward/2/long_long.h
|
||||
eventids2.o: $(hdrdir)/ruby/backward/2/stdalign.h
|
||||
eventids2.o: $(hdrdir)/ruby/backward/2/stdarg.h
|
||||
eventids2.o: $(hdrdir)/ruby/defines.h
|
||||
eventids2.o: $(hdrdir)/ruby/encoding.h
|
||||
eventids2.o: $(hdrdir)/ruby/intern.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/abi.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/anyargs.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/arithmetic.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/arithmetic/char.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/arithmetic/double.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/arithmetic/int.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/arithmetic/long.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/arithmetic/short.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/assume.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/attr/artificial.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/attr/cold.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/attr/const.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/attr/constexpr.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/attr/deprecated.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/attr/error.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/attr/forceinline.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/attr/format.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/attr/noalias.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/attr/noexcept.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/attr/noinline.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/attr/nonnull.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/attr/noreturn.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/attr/pure.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/attr/restrict.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/attr/warning.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/attr/weakref.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/cast.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/compiler_is.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/compiler_since.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/config.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/constant_p.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/core.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/core/rarray.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/core/rbasic.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/core/rbignum.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/core/rclass.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/core/rdata.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/core/rfile.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/core/rhash.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/core/robject.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/core/rregexp.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/core/rstring.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/core/rstruct.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/ctype.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/dllexport.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/dosish.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/encoding/coderange.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/encoding/ctype.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/encoding/encoding.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/encoding/pathname.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/encoding/re.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/encoding/sprintf.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/encoding/string.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/encoding/symbol.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/encoding/transcode.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/error.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/eval.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/event.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/fl_type.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/gc.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/glob.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/globals.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/has/attribute.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/has/builtin.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/has/c_attribute.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/has/extension.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/has/feature.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/has/warning.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/intern/array.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/intern/bignum.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/intern/class.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/intern/compar.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/intern/complex.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/intern/cont.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/intern/dir.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/intern/enum.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/intern/enumerator.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/intern/error.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/intern/eval.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/intern/file.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/intern/hash.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/intern/io.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/intern/load.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/intern/marshal.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/intern/numeric.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/intern/object.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/intern/parse.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/intern/proc.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/intern/process.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/intern/random.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/intern/range.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/intern/rational.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/intern/re.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/intern/ruby.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/intern/select.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/intern/signal.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/intern/sprintf.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/intern/string.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/intern/struct.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/intern/thread.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/intern/time.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/intern/variable.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/intern/vm.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/interpreter.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/iterator.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/memory.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/method.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/module.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/newobj.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/scan_args.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/special_consts.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/static_assert.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/stdalign.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/stdbool.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/symbol.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/value.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/value_type.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/variable.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/warning_push.h
|
||||
eventids2.o: $(hdrdir)/ruby/internal/xmalloc.h
|
||||
eventids2.o: $(hdrdir)/ruby/missing.h
|
||||
eventids2.o: $(hdrdir)/ruby/onigmo.h
|
||||
eventids2.o: $(hdrdir)/ruby/oniguruma.h
|
||||
eventids2.o: $(hdrdir)/ruby/ruby.h
|
||||
eventids2.o: $(hdrdir)/ruby/st.h
|
||||
eventids2.o: $(hdrdir)/ruby/subst.h
|
||||
eventids2.o: $(top_srcdir)/internal.h
|
||||
eventids2.o: $(top_srcdir)/internal/static_assert.h
|
||||
eventids2.o: $(top_srcdir)/rubyparser.h
|
||||
eventids2.o: eventids2.c
|
||||
eventids2.o: eventids2.h
|
||||
eventids2.o: {$(VPATH)}eventids2table.c
|
||||
eventids2.o: {$(VPATH)}parse.h
|
||||
ripper.o: $(RUBY_EXTCONF_H)
|
||||
ripper.o: $(arch_hdrdir)/ruby/config.h
|
||||
ripper.o: $(hdrdir)/ruby.h
|
||||
|
@ -246,6 +590,7 @@ ripper.o: $(top_srcdir)/internal/numeric.h
|
|||
ripper.o: $(top_srcdir)/internal/parse.h
|
||||
ripper.o: $(top_srcdir)/internal/rational.h
|
||||
ripper.o: $(top_srcdir)/internal/re.h
|
||||
ripper.o: $(top_srcdir)/internal/ruby_parser.h
|
||||
ripper.o: $(top_srcdir)/internal/serial.h
|
||||
ripper.o: $(top_srcdir)/internal/static_assert.h
|
||||
ripper.o: $(top_srcdir)/internal/string.h
|
||||
|
@ -256,17 +601,22 @@ ripper.o: $(top_srcdir)/internal/vm.h
|
|||
ripper.o: $(top_srcdir)/internal/warnings.h
|
||||
ripper.o: $(top_srcdir)/method.h
|
||||
ripper.o: $(top_srcdir)/node.h
|
||||
ripper.o: $(top_srcdir)/parser_node.h
|
||||
ripper.o: $(top_srcdir)/regenc.h
|
||||
ripper.o: $(top_srcdir)/ruby_assert.h
|
||||
ripper.o: $(top_srcdir)/ruby_atomic.h
|
||||
ripper.o: $(top_srcdir)/rubyparser.h
|
||||
ripper.o: $(top_srcdir)/shape.h
|
||||
ripper.o: $(top_srcdir)/symbol.h
|
||||
ripper.o: $(top_srcdir)/thread_pthread.h
|
||||
ripper.o: $(top_srcdir)/vm_core.h
|
||||
ripper.o: $(top_srcdir)/vm_opts.h
|
||||
ripper.o: ../../probes.h
|
||||
ripper.o: eventids1.h
|
||||
ripper.o: eventids2.c
|
||||
ripper.o: eventids2.h
|
||||
ripper.o: ripper.y
|
||||
ripper.o: ripper_init.h
|
||||
ripper.o: {$(VPATH)}eventids1.c
|
||||
ripper.o: {$(VPATH)}eventids2table.c
|
||||
ripper.o: {$(VPATH)}id.h
|
||||
|
@ -274,4 +624,186 @@ ripper.o: {$(VPATH)}lex.c
|
|||
ripper.o: {$(VPATH)}parse.h
|
||||
ripper.o: {$(VPATH)}probes.dmyh
|
||||
ripper.o: {$(VPATH)}ripper.c
|
||||
ripper_init.o: $(RUBY_EXTCONF_H)
|
||||
ripper_init.o: $(arch_hdrdir)/ruby/config.h
|
||||
ripper_init.o: $(hdrdir)/ruby/assert.h
|
||||
ripper_init.o: $(hdrdir)/ruby/backward.h
|
||||
ripper_init.o: $(hdrdir)/ruby/backward/2/assume.h
|
||||
ripper_init.o: $(hdrdir)/ruby/backward/2/attributes.h
|
||||
ripper_init.o: $(hdrdir)/ruby/backward/2/bool.h
|
||||
ripper_init.o: $(hdrdir)/ruby/backward/2/inttypes.h
|
||||
ripper_init.o: $(hdrdir)/ruby/backward/2/limits.h
|
||||
ripper_init.o: $(hdrdir)/ruby/backward/2/long_long.h
|
||||
ripper_init.o: $(hdrdir)/ruby/backward/2/stdalign.h
|
||||
ripper_init.o: $(hdrdir)/ruby/backward/2/stdarg.h
|
||||
ripper_init.o: $(hdrdir)/ruby/defines.h
|
||||
ripper_init.o: $(hdrdir)/ruby/encoding.h
|
||||
ripper_init.o: $(hdrdir)/ruby/intern.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/abi.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/anyargs.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/arithmetic.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/arithmetic/char.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/arithmetic/double.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/arithmetic/int.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/arithmetic/long.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/arithmetic/short.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/assume.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/attr/artificial.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/attr/cold.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/attr/const.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/attr/constexpr.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/attr/deprecated.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/attr/error.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/attr/forceinline.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/attr/format.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/attr/noalias.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/attr/noexcept.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/attr/noinline.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/attr/nonnull.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/attr/noreturn.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/attr/pure.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/attr/restrict.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/attr/warning.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/attr/weakref.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/cast.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/compiler_is.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/compiler_since.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/config.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/constant_p.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/core.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/core/rarray.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/core/rbasic.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/core/rbignum.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/core/rclass.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/core/rdata.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/core/rfile.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/core/rhash.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/core/robject.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/core/rregexp.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/core/rstring.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/core/rstruct.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/ctype.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/dllexport.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/dosish.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/encoding/coderange.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/encoding/ctype.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/encoding/encoding.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/encoding/pathname.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/encoding/re.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/encoding/sprintf.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/encoding/string.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/encoding/symbol.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/encoding/transcode.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/error.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/eval.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/event.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/fl_type.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/gc.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/glob.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/globals.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/has/attribute.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/has/builtin.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/has/c_attribute.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/has/extension.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/has/feature.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/has/warning.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/intern/array.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/intern/bignum.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/intern/class.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/intern/compar.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/intern/complex.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/intern/cont.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/intern/dir.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/intern/enum.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/intern/enumerator.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/intern/error.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/intern/eval.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/intern/file.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/intern/hash.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/intern/io.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/intern/load.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/intern/marshal.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/intern/numeric.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/intern/object.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/intern/parse.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/intern/proc.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/intern/process.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/intern/random.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/intern/range.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/intern/rational.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/intern/re.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/intern/ruby.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/intern/select.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/intern/signal.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/intern/sprintf.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/intern/string.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/intern/struct.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/intern/thread.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/intern/time.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/intern/variable.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/intern/vm.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/interpreter.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/iterator.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/memory.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/method.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/module.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/newobj.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/scan_args.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/special_consts.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/static_assert.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/stdalign.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/stdbool.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/symbol.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/value.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/value_type.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/variable.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/warning_push.h
|
||||
ripper_init.o: $(hdrdir)/ruby/internal/xmalloc.h
|
||||
ripper_init.o: $(hdrdir)/ruby/missing.h
|
||||
ripper_init.o: $(hdrdir)/ruby/onigmo.h
|
||||
ripper_init.o: $(hdrdir)/ruby/oniguruma.h
|
||||
ripper_init.o: $(hdrdir)/ruby/ruby.h
|
||||
ripper_init.o: $(hdrdir)/ruby/st.h
|
||||
ripper_init.o: $(hdrdir)/ruby/subst.h
|
||||
ripper_init.o: $(top_srcdir)/internal.h
|
||||
ripper_init.o: $(top_srcdir)/internal/parse.h
|
||||
ripper_init.o: $(top_srcdir)/internal/ruby_parser.h
|
||||
ripper_init.o: $(top_srcdir)/internal/serial.h
|
||||
ripper_init.o: $(top_srcdir)/internal/static_assert.h
|
||||
ripper_init.o: $(top_srcdir)/internal/vm.h
|
||||
ripper_init.o: $(top_srcdir)/node.h
|
||||
ripper_init.o: $(top_srcdir)/rubyparser.h
|
||||
ripper_init.o: eventids1.h
|
||||
ripper_init.o: eventids2.h
|
||||
ripper_init.o: ripper_init.h
|
||||
ripper_init.o: {$(VPATH)}parse.h
|
||||
ripper_init.o: {$(VPATH)}ripper_init.c
|
||||
# AUTOGENERATED DEPENDENCIES END
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
#include "ruby/ruby.h"
|
||||
#include "rubyparser.h"
|
||||
#define YYSTYPE_IS_DECLARED
|
||||
#include "parse.h"
|
||||
#include "eventids2.h"
|
||||
#include "internal.h"
|
||||
#include "internal/static_assert.h"
|
||||
|
||||
typedef struct {
|
||||
ID ripper_id_backref;
|
||||
ID ripper_id_backtick;
|
||||
|
@ -57,7 +65,7 @@ static ripper_scanner_ids_t ripper_scanner_ids;
|
|||
|
||||
#include "eventids2table.c"
|
||||
|
||||
static void
|
||||
void
|
||||
ripper_init_eventids2(void)
|
||||
{
|
||||
#define set_id2(name) ripper_scanner_ids.ripper_id_##name = rb_intern_const("on_"#name)
|
||||
|
@ -118,7 +126,7 @@ ripper_init_eventids2(void)
|
|||
STATIC_ASSERT(k__END___range, k__END__ < SHRT_MAX);
|
||||
STATIC_ASSERT(ripper_scanner_ids_size, sizeof(ripper_scanner_ids) < SHRT_MAX);
|
||||
|
||||
static ID
|
||||
ID
|
||||
ripper_token2eventid(enum yytokentype tok)
|
||||
{
|
||||
#define O(member) (int)offsetof(ripper_scanner_ids_t, ripper_id_##member)+1
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
#ifndef RIPPER_EVENTIDS2
|
||||
#define RIPPER_EVENTIDS2
|
||||
|
||||
void ripper_init_eventids2(void);
|
||||
void ripper_init_eventids2_table(VALUE self);
|
||||
ID ripper_token2eventid(enum yytokentype tok);
|
||||
|
||||
#endif /* RIPPER_EVENTIDS2 */
|
|
@ -5,8 +5,8 @@ require 'mkmf'
|
|||
require 'rbconfig'
|
||||
|
||||
def main
|
||||
$objs = %w(ripper.o)
|
||||
$distcleanfiles.concat %w(ripper.y ripper.c eventids1.c eventids2table.c)
|
||||
$objs = %w(eventids1.o eventids2.o ripper.o ripper_init.o)
|
||||
$distcleanfiles.concat %w(ripper.y ripper.c eventids1.c eventids1.h eventids2table.c ripper_init.c)
|
||||
$cleanfiles.concat %w(ripper.E ripper.output y.output .eventids2-check)
|
||||
$defs << '-DRIPPER'
|
||||
$defs << '-DRIPPER_DEBUG' if $debug
|
||||
|
|
|
@ -0,0 +1,650 @@
|
|||
#include "ruby/ruby.h"
|
||||
#include "ruby/encoding.h"
|
||||
#include "internal.h"
|
||||
#include "internal/parse.h"
|
||||
#include "internal/ruby_parser.h"
|
||||
#include "node.h"
|
||||
#include "rubyparser.h"
|
||||
#include "eventids1.h"
|
||||
#define YYSTYPE_IS_DECLARED
|
||||
#include "parse.h"
|
||||
#include "eventids2.h"
|
||||
#include "ripper_init.h"
|
||||
|
||||
#define STR_NEW2(ptr) rb_enc_str_new((ptr),strlen(ptr),rb_ruby_parser_enc(p))
|
||||
#define NODE_RIPPER NODE_CDECL
|
||||
#define RIPPER_VERSION "0.1.0"
|
||||
|
||||
ID id_warn, id_warning, id_gets, id_assoc;
|
||||
|
||||
struct ripper {
|
||||
rb_parser_t *p;
|
||||
};
|
||||
|
||||
static void
|
||||
ripper_parser_mark2(void *ptr)
|
||||
{
|
||||
struct ripper *r = (struct ripper*)ptr;
|
||||
ripper_parser_mark(r->p);
|
||||
}
|
||||
|
||||
static void
|
||||
ripper_parser_free2(void *ptr)
|
||||
{
|
||||
struct ripper *r = (struct ripper*)ptr;
|
||||
ripper_parser_free(r->p);
|
||||
}
|
||||
|
||||
static size_t
|
||||
ripper_parser_memsize2(const void *ptr)
|
||||
{
|
||||
struct ripper *r = (struct ripper*)ptr;
|
||||
return ripper_parser_memsize(r->p);
|
||||
}
|
||||
|
||||
static const rb_data_type_t parser_data_type = {
|
||||
"ripper",
|
||||
{
|
||||
ripper_parser_mark2,
|
||||
ripper_parser_free2,
|
||||
ripper_parser_memsize2,
|
||||
},
|
||||
0, 0, RUBY_TYPED_FREE_IMMEDIATELY
|
||||
};
|
||||
|
||||
ID
|
||||
ripper_get_id(VALUE v)
|
||||
{
|
||||
NODE *nd;
|
||||
if (!RB_TYPE_P(v, T_NODE)) return 0;
|
||||
nd = (NODE *)v;
|
||||
if (!nd_type_p(nd, NODE_RIPPER)) return 0;
|
||||
return nd->nd_vid;
|
||||
}
|
||||
|
||||
VALUE
|
||||
ripper_get_value(VALUE v)
|
||||
{
|
||||
NODE *nd;
|
||||
if (UNDEF_P(v)) return Qnil;
|
||||
if (!RB_TYPE_P(v, T_NODE)) return v;
|
||||
nd = (NODE *)v;
|
||||
if (!nd_type_p(nd, NODE_RIPPER)) return Qnil;
|
||||
return nd->nd_rval;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
ripper_lex_get_generic(struct parser_params *p, VALUE src)
|
||||
{
|
||||
VALUE line = rb_funcallv_public(src, id_gets, 0, 0);
|
||||
if (!NIL_P(line) && !RB_TYPE_P(line, T_STRING)) {
|
||||
rb_raise(rb_eTypeError,
|
||||
"gets returned %"PRIsVALUE" (expected String or nil)",
|
||||
rb_obj_class(line));
|
||||
}
|
||||
return line;
|
||||
}
|
||||
|
||||
void
|
||||
ripper_compile_error(struct parser_params *p, const char *fmt, ...)
|
||||
{
|
||||
VALUE str;
|
||||
va_list args;
|
||||
|
||||
va_start(args, fmt);
|
||||
str = rb_vsprintf(fmt, args);
|
||||
va_end(args);
|
||||
rb_funcall(ripper_value(p), rb_intern("compile_error"), 1, str);
|
||||
ripper_error(p);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
ripper_lex_io_get(struct parser_params *p, VALUE src)
|
||||
{
|
||||
return rb_io_gets(src);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
ripper_s_allocate(VALUE klass)
|
||||
{
|
||||
struct ripper *r;
|
||||
|
||||
VALUE self = TypedData_Make_Struct(klass, struct ripper,
|
||||
&parser_data_type, r);
|
||||
|
||||
#ifdef UNIVERSAL_PARSER
|
||||
rb_parser_config_t *config;
|
||||
config = rb_ruby_parser_config_new(ruby_xmalloc);
|
||||
rb_parser_config_initialize(config);
|
||||
r->p = rb_ruby_parser_allocate(config);
|
||||
#else
|
||||
r->p = rb_ruby_ripper_parser_allocate();
|
||||
#endif
|
||||
rb_ruby_parser_set_value(r->p, self);
|
||||
return self;
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* ripper.error? -> Boolean
|
||||
*
|
||||
* Return true if parsed source has errors.
|
||||
*/
|
||||
static VALUE
|
||||
ripper_error_p(VALUE vparser)
|
||||
{
|
||||
struct ripper *r;
|
||||
|
||||
TypedData_Get_Struct(vparser, struct ripper, &parser_data_type, r);
|
||||
return RBOOL(rb_ruby_parser_error_p(r->p));
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* ripper.end_seen? -> Boolean
|
||||
*
|
||||
* Return true if parsed source ended by +\_\_END\_\_+.
|
||||
*/
|
||||
static VALUE
|
||||
ripper_parser_end_seen_p(VALUE vparser)
|
||||
{
|
||||
struct ripper *r;
|
||||
|
||||
TypedData_Get_Struct(vparser, struct ripper, &parser_data_type, r);
|
||||
return RBOOL(rb_ruby_parser_end_seen_p(r->p));
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* ripper.encoding -> encoding
|
||||
*
|
||||
* Return encoding of the source.
|
||||
*/
|
||||
static VALUE
|
||||
ripper_parser_encoding(VALUE vparser)
|
||||
{
|
||||
struct ripper *r;
|
||||
|
||||
TypedData_Get_Struct(vparser, struct ripper, &parser_data_type, r);
|
||||
return rb_ruby_parser_encoding(r->p);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* ripper.yydebug -> true or false
|
||||
*
|
||||
* Get yydebug.
|
||||
*/
|
||||
static VALUE
|
||||
ripper_parser_get_yydebug(VALUE self)
|
||||
{
|
||||
struct ripper *r;
|
||||
|
||||
TypedData_Get_Struct(self, struct ripper, &parser_data_type, r);
|
||||
return RBOOL(rb_ruby_parser_get_yydebug(r->p));
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* ripper.yydebug = flag
|
||||
*
|
||||
* Set yydebug.
|
||||
*/
|
||||
static VALUE
|
||||
ripper_parser_set_yydebug(VALUE self, VALUE flag)
|
||||
{
|
||||
struct ripper *r;
|
||||
|
||||
TypedData_Get_Struct(self, struct ripper, &parser_data_type, r);
|
||||
rb_ruby_parser_set_yydebug(r->p, RTEST(flag));
|
||||
return flag;
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* ripper.debug_output -> obj
|
||||
*
|
||||
* Get debug output.
|
||||
*/
|
||||
static VALUE
|
||||
ripper_parser_get_debug_output(VALUE self)
|
||||
{
|
||||
struct ripper *r;
|
||||
|
||||
TypedData_Get_Struct(self, struct ripper, &parser_data_type, r);
|
||||
return rb_ruby_parser_debug_output(r->p);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* ripper.debug_output = obj
|
||||
*
|
||||
* Set debug output.
|
||||
*/
|
||||
static VALUE
|
||||
ripper_parser_set_debug_output(VALUE self, VALUE output)
|
||||
{
|
||||
struct ripper *r;
|
||||
|
||||
TypedData_Get_Struct(self, struct ripper, &parser_data_type, r);
|
||||
rb_ruby_parser_set_debug_output(r->p, output);
|
||||
return output;
|
||||
}
|
||||
|
||||
#ifdef UNIVERSAL_PARSER
|
||||
struct dedent_string_arg {
|
||||
struct parser_params *p;
|
||||
VALUE input;
|
||||
VALUE width;
|
||||
};
|
||||
|
||||
static VALUE
|
||||
parser_dedent_string0(VALUE a)
|
||||
{
|
||||
struct dedent_string_arg *arg = (void *)a;
|
||||
int wid, col;
|
||||
|
||||
StringValue(arg->input);
|
||||
wid = NUM2UINT(arg->width);
|
||||
col = rb_ruby_ripper_dedent_string(arg->p, arg->input, wid);
|
||||
return INT2NUM(col);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
parser_config_free(VALUE a)
|
||||
{
|
||||
rb_parser_config_t *config = (void *)a;
|
||||
|
||||
rb_ruby_parser_config_free(config);
|
||||
return Qnil;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* Ripper.dedent_string(input, width) -> Integer
|
||||
*
|
||||
* USE OF RIPPER LIBRARY ONLY.
|
||||
*
|
||||
* Strips up to +width+ leading whitespaces from +input+,
|
||||
* and returns the stripped column width.
|
||||
*/
|
||||
#ifdef UNIVERSAL_PARSER
|
||||
static VALUE
|
||||
parser_dedent_string(VALUE self, VALUE input, VALUE width)
|
||||
{
|
||||
struct parser_params *p;
|
||||
rb_parser_config_t *config;
|
||||
struct dedent_string_arg args;
|
||||
|
||||
config = rb_ruby_parser_config_new(ruby_xmalloc);
|
||||
rb_parser_config_initialize(config);
|
||||
p = rb_ruby_parser_new(config);
|
||||
|
||||
args.p = p;
|
||||
args.input = input;
|
||||
args.width = width;
|
||||
return rb_ensure(parser_dedent_string0, (VALUE)&args, parser_config_free, (VALUE)config);
|
||||
}
|
||||
#else
|
||||
static VALUE
|
||||
parser_dedent_string(VALUE self, VALUE input, VALUE width)
|
||||
{
|
||||
int wid, col;
|
||||
|
||||
StringValue(input);
|
||||
wid = NUM2UINT(width);
|
||||
col = rb_ruby_ripper_dedent_string(0, input, wid);
|
||||
return INT2NUM(col);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* Ripper.new(src, filename="(ripper)", lineno=1) -> ripper
|
||||
*
|
||||
* Create a new Ripper object.
|
||||
* _src_ must be a String, an IO, or an Object which has #gets method.
|
||||
*
|
||||
* This method does not starts parsing.
|
||||
* See also Ripper#parse and Ripper.parse.
|
||||
*/
|
||||
static VALUE
|
||||
ripper_initialize(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
struct ripper *r;
|
||||
struct parser_params *p;
|
||||
VALUE src, fname, lineno;
|
||||
VALUE (*gets)(struct parser_params*,VALUE);
|
||||
VALUE input, sourcefile_string;
|
||||
const char *sourcefile;
|
||||
int sourceline;
|
||||
|
||||
TypedData_Get_Struct(self, struct ripper, &parser_data_type, r);
|
||||
p = r->p;
|
||||
rb_scan_args(argc, argv, "12", &src, &fname, &lineno);
|
||||
if (RB_TYPE_P(src, T_FILE)) {
|
||||
gets = ripper_lex_io_get;
|
||||
}
|
||||
else if (rb_respond_to(src, id_gets)) {
|
||||
gets = ripper_lex_get_generic;
|
||||
}
|
||||
else {
|
||||
StringValue(src);
|
||||
gets = rb_ruby_ripper_lex_get_str;
|
||||
}
|
||||
input = src;
|
||||
if (NIL_P(fname)) {
|
||||
fname = STR_NEW2("(ripper)");
|
||||
OBJ_FREEZE(fname);
|
||||
}
|
||||
else {
|
||||
StringValueCStr(fname);
|
||||
fname = rb_str_new_frozen(fname);
|
||||
}
|
||||
rb_ruby_ripper_parser_initialize(p);
|
||||
|
||||
sourcefile_string = fname;
|
||||
sourcefile = RSTRING_PTR(fname);
|
||||
sourceline = NIL_P(lineno) ? 0 : NUM2INT(lineno) - 1;
|
||||
|
||||
rb_ruby_parser_ripper_initialize(p, gets, input, sourcefile_string, sourcefile, sourceline);
|
||||
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
ripper_parse0(VALUE vparser)
|
||||
{
|
||||
struct ripper *r;
|
||||
struct parser_params *p;
|
||||
|
||||
TypedData_Get_Struct(vparser, struct ripper, &parser_data_type, r);
|
||||
p = r->p;
|
||||
// RB_GC_GUARD(vparser);
|
||||
rb_ruby_ripper_parse0(p);
|
||||
return rb_ruby_parser_result(p);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
ripper_ensure(VALUE vparser)
|
||||
{
|
||||
struct ripper *r;
|
||||
|
||||
TypedData_Get_Struct(vparser, struct ripper, &parser_data_type, r);
|
||||
rb_ruby_parser_set_parsing_thread(r->p, Qnil);
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* ripper.parse
|
||||
*
|
||||
* Start parsing and returns the value of the root action.
|
||||
*/
|
||||
static VALUE
|
||||
ripper_parse(VALUE self)
|
||||
{
|
||||
struct ripper *r;
|
||||
struct parser_params *p;
|
||||
|
||||
TypedData_Get_Struct(self, struct ripper, &parser_data_type, r);
|
||||
p = r->p;
|
||||
if (!rb_ruby_ripper_initialized_p(p)) {
|
||||
rb_raise(rb_eArgError, "method called for uninitialized object");
|
||||
}
|
||||
if (!NIL_P(rb_ruby_parser_parsing_thread(p))) {
|
||||
if (rb_ruby_parser_parsing_thread(p) == rb_thread_current())
|
||||
rb_raise(rb_eArgError, "Ripper#parse is not reentrant");
|
||||
else
|
||||
rb_raise(rb_eArgError, "Ripper#parse is not multithread-safe");
|
||||
}
|
||||
rb_ruby_parser_set_parsing_thread(p, rb_thread_current());
|
||||
rb_ensure(ripper_parse0, self, ripper_ensure, self);
|
||||
|
||||
return rb_ruby_parser_result(p);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* ripper.column -> Integer
|
||||
*
|
||||
* Return column number of current parsing line.
|
||||
* This number starts from 0.
|
||||
*/
|
||||
static VALUE
|
||||
ripper_column(VALUE self)
|
||||
{
|
||||
struct ripper *r;
|
||||
struct parser_params *p;
|
||||
long col;
|
||||
|
||||
TypedData_Get_Struct(self, struct ripper, &parser_data_type, r);
|
||||
p = r->p;
|
||||
if (!rb_ruby_ripper_initialized_p(p)) {
|
||||
rb_raise(rb_eArgError, "method called for uninitialized object");
|
||||
}
|
||||
if (NIL_P(rb_ruby_parser_parsing_thread(p))) return Qnil;
|
||||
col = rb_ruby_ripper_column(p);
|
||||
return LONG2NUM(col);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* ripper.filename -> String
|
||||
*
|
||||
* Return current parsing filename.
|
||||
*/
|
||||
static VALUE
|
||||
ripper_filename(VALUE self)
|
||||
{
|
||||
struct ripper *r;
|
||||
struct parser_params *p;
|
||||
|
||||
TypedData_Get_Struct(self, struct ripper, &parser_data_type, r);
|
||||
p = r->p;
|
||||
if (!rb_ruby_ripper_initialized_p(p)) {
|
||||
rb_raise(rb_eArgError, "method called for uninitialized object");
|
||||
}
|
||||
return rb_ruby_parser_ruby_sourcefile_string(p);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* ripper.lineno -> Integer
|
||||
*
|
||||
* Return line number of current parsing line.
|
||||
* This number starts from 1.
|
||||
*/
|
||||
static VALUE
|
||||
ripper_lineno(VALUE self)
|
||||
{
|
||||
struct ripper *r;
|
||||
struct parser_params *p;
|
||||
|
||||
TypedData_Get_Struct(self, struct ripper, &parser_data_type, r);
|
||||
p = r->p;
|
||||
if (!rb_ruby_ripper_initialized_p(p)) {
|
||||
rb_raise(rb_eArgError, "method called for uninitialized object");
|
||||
}
|
||||
if (NIL_P(rb_ruby_parser_parsing_thread(p))) return Qnil;
|
||||
return INT2NUM(rb_ruby_parser_ruby_sourceline(p));
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* ripper.state -> Integer
|
||||
*
|
||||
* Return scanner state of current token.
|
||||
*/
|
||||
static VALUE
|
||||
ripper_state(VALUE self)
|
||||
{
|
||||
struct ripper *r;
|
||||
struct parser_params *p;
|
||||
|
||||
TypedData_Get_Struct(self, struct ripper, &parser_data_type, r);
|
||||
p = r->p;
|
||||
if (!rb_ruby_ripper_initialized_p(p)) {
|
||||
rb_raise(rb_eArgError, "method called for uninitialized object");
|
||||
}
|
||||
if (NIL_P(rb_ruby_parser_parsing_thread(p))) return Qnil;
|
||||
return INT2NUM(rb_ruby_parser_lex_state(p));
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* ripper.token -> String
|
||||
*
|
||||
* Return the current token string.
|
||||
*/
|
||||
static VALUE
|
||||
ripper_token(VALUE self)
|
||||
{
|
||||
struct ripper *r;
|
||||
struct parser_params *p;
|
||||
long pos, len;
|
||||
|
||||
TypedData_Get_Struct(self, struct ripper, &parser_data_type, r);
|
||||
p = r->p;
|
||||
if (!rb_ruby_ripper_initialized_p(p)) {
|
||||
rb_raise(rb_eArgError, "method called for uninitialized object");
|
||||
}
|
||||
if (NIL_P(rb_ruby_parser_parsing_thread(p))) return Qnil;
|
||||
pos = rb_ruby_ripper_column(p);
|
||||
len = rb_ruby_ripper_token_len(p);
|
||||
return rb_str_subseq(rb_ruby_ripper_lex_lastline(p), pos, len);
|
||||
}
|
||||
|
||||
#ifdef RIPPER_DEBUG
|
||||
/* :nodoc: */
|
||||
static VALUE
|
||||
ripper_assert_Qundef(VALUE self, VALUE obj, VALUE msg)
|
||||
{
|
||||
StringValue(msg);
|
||||
if (UNDEF_P(obj)) {
|
||||
rb_raise(rb_eArgError, "%"PRIsVALUE, msg);
|
||||
}
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
/* :nodoc: */
|
||||
static VALUE
|
||||
ripper_raw_value(VALUE self, VALUE obj)
|
||||
{
|
||||
return ULONG2NUM(obj);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef UNIVERSAL_PARSER
|
||||
struct lex_state_name_arg {
|
||||
struct parser_params *p;
|
||||
VALUE state;
|
||||
};
|
||||
|
||||
static VALUE
|
||||
lex_state_name0(VALUE a)
|
||||
{
|
||||
struct lex_state_name_arg *arg = (void *)a;
|
||||
|
||||
return rb_ruby_ripper_lex_state_name(arg->p, NUM2INT(arg->state));
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* Ripper.lex_state_name(integer) -> string
|
||||
*
|
||||
* Returns a string representation of lex_state.
|
||||
*/
|
||||
#ifdef UNIVERSAL_PARSER
|
||||
static VALUE
|
||||
ripper_lex_state_name(VALUE self, VALUE state)
|
||||
{
|
||||
struct parser_params *p;
|
||||
rb_parser_config_t *config;
|
||||
struct lex_state_name_arg args;
|
||||
|
||||
config = rb_ruby_parser_config_new(ruby_xmalloc);
|
||||
rb_parser_config_initialize(config);
|
||||
p = rb_ruby_parser_new(config);
|
||||
|
||||
args.p = p;
|
||||
args.state = state;
|
||||
|
||||
return rb_ensure(lex_state_name0, (VALUE)&args, parser_config_free, (VALUE)config);
|
||||
}
|
||||
#else
|
||||
static VALUE
|
||||
ripper_lex_state_name(VALUE self, VALUE state)
|
||||
{
|
||||
return rb_ruby_ripper_lex_state_name(0, NUM2INT(state));
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
Init_ripper(void)
|
||||
{
|
||||
ripper_init_eventids1();
|
||||
ripper_init_eventids2();
|
||||
id_warn = rb_intern_const("warn");
|
||||
id_warning = rb_intern_const("warning");
|
||||
id_gets = rb_intern_const("gets");
|
||||
id_assoc = rb_intern_const("=>");
|
||||
|
||||
InitVM(ripper);
|
||||
}
|
||||
|
||||
void
|
||||
InitVM_ripper(void)
|
||||
{
|
||||
VALUE Ripper;
|
||||
|
||||
Ripper = rb_define_class("Ripper", rb_cObject);
|
||||
/* version of Ripper */
|
||||
rb_define_const(Ripper, "Version", rb_usascii_str_new2(RIPPER_VERSION));
|
||||
rb_define_alloc_func(Ripper, ripper_s_allocate);
|
||||
rb_define_method(Ripper, "initialize", ripper_initialize, -1);
|
||||
rb_define_method(Ripper, "parse", ripper_parse, 0);
|
||||
rb_define_method(Ripper, "column", ripper_column, 0);
|
||||
rb_define_method(Ripper, "filename", ripper_filename, 0);
|
||||
rb_define_method(Ripper, "lineno", ripper_lineno, 0);
|
||||
rb_define_method(Ripper, "state", ripper_state, 0);
|
||||
rb_define_method(Ripper, "token", ripper_token, 0);
|
||||
rb_define_method(Ripper, "end_seen?", ripper_parser_end_seen_p, 0);
|
||||
rb_define_method(Ripper, "encoding", ripper_parser_encoding, 0);
|
||||
rb_define_method(Ripper, "yydebug", ripper_parser_get_yydebug, 0);
|
||||
rb_define_method(Ripper, "yydebug=", ripper_parser_set_yydebug, 1);
|
||||
rb_define_method(Ripper, "debug_output", ripper_parser_get_debug_output, 0);
|
||||
rb_define_method(Ripper, "debug_output=", ripper_parser_set_debug_output, 1);
|
||||
rb_define_method(Ripper, "error?", ripper_error_p, 0);
|
||||
#ifdef RIPPER_DEBUG
|
||||
rb_define_method(Ripper, "assert_Qundef", ripper_assert_Qundef, 2);
|
||||
rb_define_method(Ripper, "rawVALUE", ripper_raw_value, 1);
|
||||
rb_define_method(Ripper, "validate_object", ripper_validate_object, 1);
|
||||
#endif
|
||||
|
||||
rb_define_singleton_method(Ripper, "dedent_string", parser_dedent_string, 2);
|
||||
rb_define_private_method(Ripper, "dedent_string", parser_dedent_string, 2);
|
||||
|
||||
rb_define_singleton_method(Ripper, "lex_state_name", ripper_lex_state_name, 1);
|
||||
|
||||
<% @exprs.each do |expr, desc| -%>
|
||||
/* <%=desc%> */
|
||||
rb_define_const(Ripper, "<%=expr%>", INT2NUM(<%=expr%>));
|
||||
<% end %>
|
||||
ripper_init_eventids1_table(Ripper);
|
||||
ripper_init_eventids2_table(Ripper);
|
||||
|
||||
# if 0
|
||||
/* Hack to let RDoc document SCRIPT_LINES__ */
|
||||
|
||||
/*
|
||||
* When a Hash is assigned to +SCRIPT_LINES__+ the contents of files loaded
|
||||
* after the assignment will be added as an Array of lines with the file
|
||||
* name as the key.
|
||||
*/
|
||||
rb_define_global_const("SCRIPT_LINES__", Qnil);
|
||||
#endif
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
#ifndef RIPPER_INIT_H
|
||||
#define RIPPER_INIT_H
|
||||
|
||||
VALUE ripper_get_value(VALUE v);
|
||||
ID ripper_get_id(VALUE v);
|
||||
PRINTF_ARGS(void ripper_compile_error(struct parser_params*, const char *fmt, ...), 2, 3);
|
||||
|
||||
#endif /* RIPPER_INIT_H */
|
|
@ -11,7 +11,7 @@ def main
|
|||
|
||||
parser = @parser = OptionParser.new
|
||||
parser.banner = "Usage: #{File.basename($0)} --mode=MODE [--ids1src=PATH] [--ids2src=PATH] [--output=PATH]"
|
||||
parser.on('--mode=MODE', 'check, eventids1, or eventids2table.') {|m|
|
||||
parser.on('--mode=MODE', 'check, eventids1_h, eventids1, or eventids2table.') {|m|
|
||||
mode = m
|
||||
}
|
||||
parser.on('--ids1src=PATH', 'A source file of event-IDs 1 (parse.y).') {|path|
|
||||
|
@ -45,6 +45,9 @@ def main
|
|||
abort "event crash: #{common.join(' ')}"
|
||||
end
|
||||
exit 0
|
||||
when 'eventids1_h'
|
||||
usage 'no --ids1src' unless ids1src
|
||||
result = generate_eventids1_h(read_ids1(ids1src))
|
||||
when 'eventids1'
|
||||
usage 'no --ids1src' unless ids1src
|
||||
result = generate_eventids1(read_ids1(ids1src))
|
||||
|
@ -67,19 +70,35 @@ def usage(msg)
|
|||
exit false
|
||||
end
|
||||
|
||||
def generate_eventids1(ids)
|
||||
def generate_eventids1_h(ids)
|
||||
buf = "".dup
|
||||
buf << %Q[static struct {\n]
|
||||
buf << %Q[#ifndef RIPPER_EVENTIDS1\n]
|
||||
buf << %Q[#define RIPPER_EVENTIDS1\n]
|
||||
buf << %Q[\n]
|
||||
buf << %Q[void ripper_init_eventids1(void);\n]
|
||||
buf << %Q[void ripper_init_eventids1_table(VALUE self);\n]
|
||||
buf << %Q[\n]
|
||||
buf << %Q[struct ripper_parser_ids {\n]
|
||||
ids.each do |id, arity|
|
||||
buf << %Q[ ID id_#{id};\n]
|
||||
end
|
||||
buf << %Q[} ripper_parser_ids;\n]
|
||||
buf << %Q[};\n]
|
||||
buf << %Q[\n]
|
||||
ids.each do |id, arity|
|
||||
buf << %Q[#define ripper_id_#{id} ripper_parser_ids.id_#{id}\n]
|
||||
end
|
||||
buf << %Q[#endif /* RIPPER_EVENTIDS1 */\n]
|
||||
buf << %Q[\n]
|
||||
buf << %Q[static void\n]
|
||||
end
|
||||
|
||||
def generate_eventids1(ids)
|
||||
buf = "".dup
|
||||
buf << %Q[#include "ruby/ruby.h"\n]
|
||||
buf << %Q[#include "eventids1.h"\n]
|
||||
buf << %Q[\n]
|
||||
buf << %Q[struct ripper_parser_ids ripper_parser_ids;\n]
|
||||
buf << %Q[\n]
|
||||
buf << %Q[void\n]
|
||||
buf << %Q[ripper_init_eventids1(void)\n]
|
||||
buf << %Q[{\n]
|
||||
buf << %Q[#define set_id1(name) ripper_id_##name = rb_intern_const("on_"#name)\n]
|
||||
|
@ -88,7 +107,9 @@ def generate_eventids1(ids)
|
|||
end
|
||||
buf << %Q[}\n]
|
||||
buf << %Q[\n]
|
||||
buf << %Q[static void\n]
|
||||
buf << %Q[#define intern_sym(name) ID2SYM(rb_intern_const(name))\n]
|
||||
buf << %Q[\n]
|
||||
buf << %Q[void\n]
|
||||
buf << %Q[ripper_init_eventids1_table(VALUE self)\n]
|
||||
buf << %Q[{\n]
|
||||
buf << %Q[ VALUE h = rb_hash_new();\n]
|
||||
|
@ -102,7 +123,11 @@ end
|
|||
|
||||
def generate_eventids2_table(ids)
|
||||
buf = "".dup
|
||||
buf << %Q[static void\n]
|
||||
buf << %Q[#include "ruby/ruby.h"\n]
|
||||
buf << %Q[\n]
|
||||
buf << %Q[#define intern_sym(name) ID2SYM(rb_intern_const(name))\n]
|
||||
buf << %Q[\n]
|
||||
buf << %Q[void\n]
|
||||
buf << %Q[ripper_init_eventids2_table(VALUE self)\n]
|
||||
buf << %Q[{\n]
|
||||
buf << %Q[ VALUE h = rb_hash_new();\n]
|
||||
|
|
|
@ -5,11 +5,15 @@ require 'optparse'
|
|||
|
||||
def main
|
||||
output = nil
|
||||
template = nil
|
||||
parser = OptionParser.new
|
||||
parser.banner = "Usage: #{File.basename($0)} [--output=PATH] <parse.y>"
|
||||
parser.banner = "Usage: #{File.basename($0)} [--output=PATH] [--template=PATH] <parse.y>"
|
||||
parser.on('--output=PATH', 'An output file.') {|path|
|
||||
output = path
|
||||
}
|
||||
parser.on('--template=PATH', 'An template file.') {|path|
|
||||
template = path
|
||||
}
|
||||
parser.on('--help', 'Prints this message and quit.') {
|
||||
puts parser.help
|
||||
exit true
|
||||
|
@ -25,13 +29,13 @@ def main
|
|||
unless ARGV.size == 2
|
||||
abort "wrong number of arguments (#{ARGV.size} for 2)"
|
||||
end
|
||||
process STDIN, out, ARGV[1]
|
||||
process STDIN, out, ARGV[1], template
|
||||
else
|
||||
unless ARGV.size == 1
|
||||
abort "wrong number of arguments (#{ARGV.size} for 1)"
|
||||
end
|
||||
File.open(ARGV[0]) {|f|
|
||||
process f, out, ARGV[0]
|
||||
process f, out, ARGV[0], template
|
||||
}
|
||||
end
|
||||
if output
|
||||
|
@ -41,10 +45,10 @@ def main
|
|||
end
|
||||
end
|
||||
|
||||
def process(f, out, path)
|
||||
def process(f, out, path, template)
|
||||
prelude f, out
|
||||
grammar f, out
|
||||
usercode f, out, path
|
||||
usercode f, out, path, template
|
||||
end
|
||||
|
||||
def prelude(f, out)
|
||||
|
@ -103,12 +107,25 @@ def grammar(f, out)
|
|||
end
|
||||
end
|
||||
|
||||
def usercode(f, out, path)
|
||||
def usercode(f, out, path, template)
|
||||
require 'erb'
|
||||
lineno = nil
|
||||
src = nil
|
||||
compiler = ERB::Compiler.new('%-')
|
||||
compiler.put_cmd = compiler.insert_cmd = "out.<<"
|
||||
|
||||
if template
|
||||
File.open(template) do |f|
|
||||
out.clear
|
||||
lineno = f.lineno
|
||||
src, = compiler.compile(f.read)
|
||||
path = template
|
||||
end
|
||||
else
|
||||
lineno = f.lineno
|
||||
src, = compiler.compile(f.read)
|
||||
end
|
||||
|
||||
eval(src, binding, path, lineno)
|
||||
end
|
||||
|
||||
|
|
|
@ -208,6 +208,7 @@ ancdata.o: $(top_srcdir)/method.h
|
|||
ancdata.o: $(top_srcdir)/node.h
|
||||
ancdata.o: $(top_srcdir)/ruby_assert.h
|
||||
ancdata.o: $(top_srcdir)/ruby_atomic.h
|
||||
ancdata.o: $(top_srcdir)/rubyparser.h
|
||||
ancdata.o: $(top_srcdir)/shape.h
|
||||
ancdata.o: $(top_srcdir)/thread_pthread.h
|
||||
ancdata.o: $(top_srcdir)/vm_core.h
|
||||
|
@ -415,6 +416,7 @@ basicsocket.o: $(top_srcdir)/method.h
|
|||
basicsocket.o: $(top_srcdir)/node.h
|
||||
basicsocket.o: $(top_srcdir)/ruby_assert.h
|
||||
basicsocket.o: $(top_srcdir)/ruby_atomic.h
|
||||
basicsocket.o: $(top_srcdir)/rubyparser.h
|
||||
basicsocket.o: $(top_srcdir)/shape.h
|
||||
basicsocket.o: $(top_srcdir)/thread_pthread.h
|
||||
basicsocket.o: $(top_srcdir)/vm_core.h
|
||||
|
@ -622,6 +624,7 @@ constants.o: $(top_srcdir)/method.h
|
|||
constants.o: $(top_srcdir)/node.h
|
||||
constants.o: $(top_srcdir)/ruby_assert.h
|
||||
constants.o: $(top_srcdir)/ruby_atomic.h
|
||||
constants.o: $(top_srcdir)/rubyparser.h
|
||||
constants.o: $(top_srcdir)/shape.h
|
||||
constants.o: $(top_srcdir)/thread_pthread.h
|
||||
constants.o: $(top_srcdir)/vm_core.h
|
||||
|
@ -830,6 +833,7 @@ ifaddr.o: $(top_srcdir)/method.h
|
|||
ifaddr.o: $(top_srcdir)/node.h
|
||||
ifaddr.o: $(top_srcdir)/ruby_assert.h
|
||||
ifaddr.o: $(top_srcdir)/ruby_atomic.h
|
||||
ifaddr.o: $(top_srcdir)/rubyparser.h
|
||||
ifaddr.o: $(top_srcdir)/shape.h
|
||||
ifaddr.o: $(top_srcdir)/thread_pthread.h
|
||||
ifaddr.o: $(top_srcdir)/vm_core.h
|
||||
|
@ -1037,6 +1041,7 @@ init.o: $(top_srcdir)/method.h
|
|||
init.o: $(top_srcdir)/node.h
|
||||
init.o: $(top_srcdir)/ruby_assert.h
|
||||
init.o: $(top_srcdir)/ruby_atomic.h
|
||||
init.o: $(top_srcdir)/rubyparser.h
|
||||
init.o: $(top_srcdir)/shape.h
|
||||
init.o: $(top_srcdir)/thread_pthread.h
|
||||
init.o: $(top_srcdir)/vm_core.h
|
||||
|
@ -1244,6 +1249,7 @@ ipsocket.o: $(top_srcdir)/method.h
|
|||
ipsocket.o: $(top_srcdir)/node.h
|
||||
ipsocket.o: $(top_srcdir)/ruby_assert.h
|
||||
ipsocket.o: $(top_srcdir)/ruby_atomic.h
|
||||
ipsocket.o: $(top_srcdir)/rubyparser.h
|
||||
ipsocket.o: $(top_srcdir)/shape.h
|
||||
ipsocket.o: $(top_srcdir)/thread_pthread.h
|
||||
ipsocket.o: $(top_srcdir)/vm_core.h
|
||||
|
@ -1451,6 +1457,7 @@ option.o: $(top_srcdir)/method.h
|
|||
option.o: $(top_srcdir)/node.h
|
||||
option.o: $(top_srcdir)/ruby_assert.h
|
||||
option.o: $(top_srcdir)/ruby_atomic.h
|
||||
option.o: $(top_srcdir)/rubyparser.h
|
||||
option.o: $(top_srcdir)/shape.h
|
||||
option.o: $(top_srcdir)/thread_pthread.h
|
||||
option.o: $(top_srcdir)/vm_core.h
|
||||
|
@ -1658,6 +1665,7 @@ raddrinfo.o: $(top_srcdir)/method.h
|
|||
raddrinfo.o: $(top_srcdir)/node.h
|
||||
raddrinfo.o: $(top_srcdir)/ruby_assert.h
|
||||
raddrinfo.o: $(top_srcdir)/ruby_atomic.h
|
||||
raddrinfo.o: $(top_srcdir)/rubyparser.h
|
||||
raddrinfo.o: $(top_srcdir)/shape.h
|
||||
raddrinfo.o: $(top_srcdir)/thread_pthread.h
|
||||
raddrinfo.o: $(top_srcdir)/vm_core.h
|
||||
|
@ -1865,6 +1873,7 @@ socket.o: $(top_srcdir)/method.h
|
|||
socket.o: $(top_srcdir)/node.h
|
||||
socket.o: $(top_srcdir)/ruby_assert.h
|
||||
socket.o: $(top_srcdir)/ruby_atomic.h
|
||||
socket.o: $(top_srcdir)/rubyparser.h
|
||||
socket.o: $(top_srcdir)/shape.h
|
||||
socket.o: $(top_srcdir)/thread_pthread.h
|
||||
socket.o: $(top_srcdir)/vm_core.h
|
||||
|
@ -2072,6 +2081,7 @@ sockssocket.o: $(top_srcdir)/method.h
|
|||
sockssocket.o: $(top_srcdir)/node.h
|
||||
sockssocket.o: $(top_srcdir)/ruby_assert.h
|
||||
sockssocket.o: $(top_srcdir)/ruby_atomic.h
|
||||
sockssocket.o: $(top_srcdir)/rubyparser.h
|
||||
sockssocket.o: $(top_srcdir)/shape.h
|
||||
sockssocket.o: $(top_srcdir)/thread_pthread.h
|
||||
sockssocket.o: $(top_srcdir)/vm_core.h
|
||||
|
@ -2279,6 +2289,7 @@ tcpserver.o: $(top_srcdir)/method.h
|
|||
tcpserver.o: $(top_srcdir)/node.h
|
||||
tcpserver.o: $(top_srcdir)/ruby_assert.h
|
||||
tcpserver.o: $(top_srcdir)/ruby_atomic.h
|
||||
tcpserver.o: $(top_srcdir)/rubyparser.h
|
||||
tcpserver.o: $(top_srcdir)/shape.h
|
||||
tcpserver.o: $(top_srcdir)/thread_pthread.h
|
||||
tcpserver.o: $(top_srcdir)/vm_core.h
|
||||
|
@ -2486,6 +2497,7 @@ tcpsocket.o: $(top_srcdir)/method.h
|
|||
tcpsocket.o: $(top_srcdir)/node.h
|
||||
tcpsocket.o: $(top_srcdir)/ruby_assert.h
|
||||
tcpsocket.o: $(top_srcdir)/ruby_atomic.h
|
||||
tcpsocket.o: $(top_srcdir)/rubyparser.h
|
||||
tcpsocket.o: $(top_srcdir)/shape.h
|
||||
tcpsocket.o: $(top_srcdir)/thread_pthread.h
|
||||
tcpsocket.o: $(top_srcdir)/vm_core.h
|
||||
|
@ -2693,6 +2705,7 @@ udpsocket.o: $(top_srcdir)/method.h
|
|||
udpsocket.o: $(top_srcdir)/node.h
|
||||
udpsocket.o: $(top_srcdir)/ruby_assert.h
|
||||
udpsocket.o: $(top_srcdir)/ruby_atomic.h
|
||||
udpsocket.o: $(top_srcdir)/rubyparser.h
|
||||
udpsocket.o: $(top_srcdir)/shape.h
|
||||
udpsocket.o: $(top_srcdir)/thread_pthread.h
|
||||
udpsocket.o: $(top_srcdir)/vm_core.h
|
||||
|
@ -2900,6 +2913,7 @@ unixserver.o: $(top_srcdir)/method.h
|
|||
unixserver.o: $(top_srcdir)/node.h
|
||||
unixserver.o: $(top_srcdir)/ruby_assert.h
|
||||
unixserver.o: $(top_srcdir)/ruby_atomic.h
|
||||
unixserver.o: $(top_srcdir)/rubyparser.h
|
||||
unixserver.o: $(top_srcdir)/shape.h
|
||||
unixserver.o: $(top_srcdir)/thread_pthread.h
|
||||
unixserver.o: $(top_srcdir)/vm_core.h
|
||||
|
@ -3107,6 +3121,7 @@ unixsocket.o: $(top_srcdir)/method.h
|
|||
unixsocket.o: $(top_srcdir)/node.h
|
||||
unixsocket.o: $(top_srcdir)/ruby_assert.h
|
||||
unixsocket.o: $(top_srcdir)/ruby_atomic.h
|
||||
unixsocket.o: $(top_srcdir)/rubyparser.h
|
||||
unixsocket.o: $(top_srcdir)/shape.h
|
||||
unixsocket.o: $(top_srcdir)/thread_pthread.h
|
||||
unixsocket.o: $(top_srcdir)/vm_core.h
|
||||
|
|
|
@ -302,6 +302,12 @@ ruby_sized_xfree_inlined(void *ptr, size_t size)
|
|||
|
||||
# define SIZED_REALLOC_N(x, y, z, w) REALLOC_N(x, y, z)
|
||||
|
||||
static inline void *
|
||||
ruby_sized_realloc_n(void *ptr, size_t new_count, size_t element_size, size_t old_count)
|
||||
{
|
||||
return ruby_xrealloc2(ptr, new_count, element_size);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static inline void *
|
||||
|
@ -325,6 +331,12 @@ ruby_sized_xfree_inlined(void *ptr, size_t size)
|
|||
# define SIZED_REALLOC_N(v, T, m, n) \
|
||||
((v) = (T *)ruby_sized_xrealloc2((void *)(v), (m), sizeof(T), (n)))
|
||||
|
||||
static inline void *
|
||||
ruby_sized_realloc_n(void *ptr, size_t new_count, size_t element_size, size_t old_count)
|
||||
{
|
||||
return ruby_sized_xrealloc2(ptr, new_count, element_size, old_count);
|
||||
}
|
||||
|
||||
#endif /* HAVE_MALLOC_USABLE_SIZE */
|
||||
|
||||
#define ruby_sized_xrealloc ruby_sized_xrealloc_inlined
|
||||
|
|
123
internal/parse.h
123
internal/parse.h
|
@ -8,18 +8,121 @@
|
|||
* file COPYING are met. Consult the file for details.
|
||||
* @brief Internal header for the parser.
|
||||
*/
|
||||
#include "ruby/ruby.h" /* for VALUE */
|
||||
#include <limits.h>
|
||||
#include "rubyparser.h"
|
||||
#include "internal/static_assert.h"
|
||||
|
||||
#ifdef UNIVERSAL_PARSER
|
||||
#define rb_encoding void
|
||||
#endif
|
||||
|
||||
struct rb_iseq_struct; /* in vm_core.h */
|
||||
|
||||
/* parse.y */
|
||||
VALUE rb_parser_set_yydebug(VALUE, VALUE);
|
||||
void *rb_parser_load_file(VALUE parser, VALUE name);
|
||||
void rb_parser_keep_script_lines(VALUE vparser);
|
||||
void rb_parser_error_tolerant(VALUE vparser);
|
||||
void rb_parser_keep_tokens(VALUE vparser);
|
||||
#define STRTERM_HEREDOC IMEMO_FL_USER0
|
||||
|
||||
RUBY_SYMBOL_EXPORT_BEGIN
|
||||
VALUE rb_parser_set_context(VALUE, const struct rb_iseq_struct *, int);
|
||||
RUBY_SYMBOL_EXPORT_END
|
||||
/* structs for managing terminator of string literal and heredocment */
|
||||
typedef struct rb_strterm_literal_struct {
|
||||
union {
|
||||
VALUE dummy;
|
||||
long nest;
|
||||
} u0;
|
||||
union {
|
||||
VALUE dummy;
|
||||
long func; /* STR_FUNC_* (e.g., STR_FUNC_ESCAPE and STR_FUNC_EXPAND) */
|
||||
} u1;
|
||||
union {
|
||||
VALUE dummy;
|
||||
long paren; /* '(' of `%q(...)` */
|
||||
} u2;
|
||||
union {
|
||||
VALUE dummy;
|
||||
long term; /* ')' of `%q(...)` */
|
||||
} u3;
|
||||
} rb_strterm_literal_t;
|
||||
|
||||
#define HERETERM_LENGTH_BITS ((SIZEOF_VALUE - 1) * CHAR_BIT - 1)
|
||||
|
||||
typedef struct rb_strterm_heredoc_struct {
|
||||
VALUE lastline; /* the string of line that contains `<<"END"` */
|
||||
long offset; /* the column of END in `<<"END"` */
|
||||
int sourceline; /* lineno of the line that contains `<<"END"` */
|
||||
unsigned length /* the length of END in `<<"END"` */
|
||||
#if HERETERM_LENGTH_BITS < SIZEOF_INT * CHAR_BIT
|
||||
: HERETERM_LENGTH_BITS
|
||||
# define HERETERM_LENGTH_MAX ((1U << HERETERM_LENGTH_BITS) - 1)
|
||||
#else
|
||||
# define HERETERM_LENGTH_MAX UINT_MAX
|
||||
#endif
|
||||
;
|
||||
#if HERETERM_LENGTH_BITS < SIZEOF_INT * CHAR_BIT
|
||||
unsigned quote: 1;
|
||||
unsigned func: 8;
|
||||
#else
|
||||
uint8_t quote;
|
||||
uint8_t func;
|
||||
#endif
|
||||
} rb_strterm_heredoc_t;
|
||||
STATIC_ASSERT(rb_strterm_heredoc_t, sizeof(rb_strterm_heredoc_t) <= 4 * SIZEOF_VALUE);
|
||||
|
||||
typedef struct rb_strterm_struct {
|
||||
VALUE flags;
|
||||
union {
|
||||
rb_strterm_literal_t literal;
|
||||
rb_strterm_heredoc_t heredoc;
|
||||
} u;
|
||||
} rb_strterm_t;
|
||||
|
||||
/* parse.y */
|
||||
void rb_ruby_parser_mark(void *ptr);
|
||||
size_t rb_ruby_parser_memsize(const void *ptr);
|
||||
|
||||
void rb_ruby_parser_set_options(rb_parser_t *p, int print, int loop, int chomp, int split);
|
||||
rb_parser_t *rb_ruby_parser_set_context(rb_parser_t *p, const struct rb_iseq_struct *base, int main);
|
||||
void rb_ruby_parser_keep_script_lines(rb_parser_t *p);
|
||||
void rb_ruby_parser_error_tolerant(rb_parser_t *p);
|
||||
rb_ast_t* rb_ruby_parser_compile_file_path(rb_parser_t *p, VALUE fname, VALUE file, int start);
|
||||
void rb_ruby_parser_keep_tokens(rb_parser_t *p);
|
||||
rb_ast_t* rb_ruby_parser_compile_generic(rb_parser_t *p, VALUE (*lex_gets)(VALUE, int), VALUE fname, VALUE input, int start);
|
||||
rb_ast_t* rb_ruby_parser_compile_string_path(rb_parser_t *p, VALUE f, VALUE s, int line);
|
||||
VALUE rb_ruby_parser_encoding(rb_parser_t *p);
|
||||
int rb_ruby_parser_end_seen_p(rb_parser_t *p);
|
||||
int rb_ruby_parser_set_yydebug(rb_parser_t *p, int flag);
|
||||
|
||||
int rb_reg_named_capture_assign_iter_impl(struct parser_params *p, const char *s, long len, rb_encoding *enc, NODE **succ_block, const rb_code_location_t *loc);
|
||||
|
||||
#ifdef RIPPER
|
||||
void ripper_parser_mark(void *ptr);
|
||||
void ripper_parser_free(void *ptr);
|
||||
size_t ripper_parser_memsize(const void *ptr);
|
||||
void ripper_error(struct parser_params *p);
|
||||
VALUE ripper_value(struct parser_params *p);
|
||||
int rb_ruby_parser_get_yydebug(rb_parser_t *p);
|
||||
void rb_ruby_parser_set_value(rb_parser_t *p, VALUE value);
|
||||
int rb_ruby_parser_error_p(rb_parser_t *p);
|
||||
VALUE rb_ruby_parser_debug_output(rb_parser_t *p);
|
||||
void rb_ruby_parser_set_debug_output(rb_parser_t *p, VALUE output);
|
||||
VALUE rb_ruby_parser_parsing_thread(rb_parser_t *p);
|
||||
void rb_ruby_parser_set_parsing_thread(rb_parser_t *p, VALUE parsing_thread);
|
||||
void rb_ruby_parser_ripper_initialize(rb_parser_t *p, VALUE (*gets)(struct parser_params*,VALUE), VALUE input, VALUE sourcefile_string, const char *sourcefile, int sourceline);
|
||||
VALUE rb_ruby_parser_result(rb_parser_t *p);
|
||||
rb_encoding *rb_ruby_parser_enc(rb_parser_t *p);
|
||||
VALUE rb_ruby_parser_ruby_sourcefile_string(rb_parser_t *p);
|
||||
int rb_ruby_parser_ruby_sourceline(rb_parser_t *p);
|
||||
int rb_ruby_parser_lex_state(rb_parser_t *p);
|
||||
void rb_ruby_ripper_parse0(rb_parser_t *p);
|
||||
int rb_ruby_ripper_dedent_string(rb_parser_t *p, VALUE string, int width);
|
||||
VALUE rb_ruby_ripper_lex_get_str(rb_parser_t *p, VALUE s);
|
||||
int rb_ruby_ripper_initialized_p(rb_parser_t *p);
|
||||
void rb_ruby_ripper_parser_initialize(rb_parser_t *p);
|
||||
long rb_ruby_ripper_column(rb_parser_t *p);
|
||||
long rb_ruby_ripper_token_len(rb_parser_t *p);
|
||||
VALUE rb_ruby_ripper_lex_lastline(rb_parser_t *p);
|
||||
VALUE rb_ruby_ripper_lex_state_name(struct parser_params *p, int state);
|
||||
struct parser_params *rb_ruby_ripper_parser_allocate(void);
|
||||
#endif
|
||||
|
||||
#ifdef UNIVERSAL_PARSER
|
||||
#undef rb_encoding
|
||||
#endif
|
||||
|
||||
#endif /* INTERNAL_PARSE_H */
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
#ifndef INTERNAL_RUBY_PARSE_H
|
||||
#define INTERNAL_RUBY_PARSE_H
|
||||
|
||||
#include "rubyparser.h"
|
||||
#include "internal.h"
|
||||
#include "vm.h"
|
||||
|
||||
RUBY_SYMBOL_EXPORT_BEGIN
|
||||
#ifdef UNIVERSAL_PARSER
|
||||
void rb_parser_config_initialize(rb_parser_config_t *config);
|
||||
#endif
|
||||
VALUE rb_parser_set_context(VALUE, const struct rb_iseq_struct *, int);
|
||||
RUBY_SYMBOL_EXPORT_END
|
||||
|
||||
VALUE rb_parser_new(void);
|
||||
VALUE rb_parser_end_seen_p(VALUE);
|
||||
VALUE rb_parser_encoding(VALUE);
|
||||
VALUE rb_parser_set_yydebug(VALUE, VALUE);
|
||||
void rb_parser_set_options(VALUE, int, int, int, int);
|
||||
void *rb_parser_load_file(VALUE parser, VALUE name);
|
||||
void rb_parser_keep_script_lines(VALUE vparser);
|
||||
void rb_parser_error_tolerant(VALUE vparser);
|
||||
void rb_parser_keep_tokens(VALUE vparser);
|
||||
|
||||
rb_ast_t *rb_parser_compile_string(VALUE, const char*, VALUE, int);
|
||||
rb_ast_t *rb_parser_compile_string_path(VALUE vparser, VALUE fname, VALUE src, int line);
|
||||
rb_ast_t *rb_parser_compile_file_path(VALUE vparser, VALUE fname, VALUE input, int line);
|
||||
rb_ast_t *rb_parser_compile_generic(VALUE vparser, VALUE (*lex_gets)(VALUE, int), VALUE fname, VALUE input, int line);
|
||||
|
||||
enum lex_state_bits {
|
||||
EXPR_BEG_bit, /* ignore newline, +/- is a sign. */
|
||||
EXPR_END_bit, /* newline significant, +/- is an operator. */
|
||||
EXPR_ENDARG_bit, /* ditto, and unbound braces. */
|
||||
EXPR_ENDFN_bit, /* ditto, and unbound braces. */
|
||||
EXPR_ARG_bit, /* newline significant, +/- is an operator. */
|
||||
EXPR_CMDARG_bit, /* newline significant, +/- is an operator. */
|
||||
EXPR_MID_bit, /* newline significant, +/- is an operator. */
|
||||
EXPR_FNAME_bit, /* ignore newline, no reserved words. */
|
||||
EXPR_DOT_bit, /* right after `.', `&.' or `::', no reserved words. */
|
||||
EXPR_CLASS_bit, /* immediate after `class', no here document. */
|
||||
EXPR_LABEL_bit, /* flag bit, label is allowed. */
|
||||
EXPR_LABELED_bit, /* flag bit, just after a label. */
|
||||
EXPR_FITEM_bit, /* symbol literal as FNAME. */
|
||||
EXPR_MAX_STATE
|
||||
};
|
||||
/* examine combinations */
|
||||
enum lex_state_e {
|
||||
#define DEF_EXPR(n) EXPR_##n = (1 << EXPR_##n##_bit)
|
||||
DEF_EXPR(BEG),
|
||||
DEF_EXPR(END),
|
||||
DEF_EXPR(ENDARG),
|
||||
DEF_EXPR(ENDFN),
|
||||
DEF_EXPR(ARG),
|
||||
DEF_EXPR(CMDARG),
|
||||
DEF_EXPR(MID),
|
||||
DEF_EXPR(FNAME),
|
||||
DEF_EXPR(DOT),
|
||||
DEF_EXPR(CLASS),
|
||||
DEF_EXPR(LABEL),
|
||||
DEF_EXPR(LABELED),
|
||||
DEF_EXPR(FITEM),
|
||||
EXPR_VALUE = EXPR_BEG,
|
||||
EXPR_BEG_ANY = (EXPR_BEG | EXPR_MID | EXPR_CLASS),
|
||||
EXPR_ARG_ANY = (EXPR_ARG | EXPR_CMDARG),
|
||||
EXPR_END_ANY = (EXPR_END | EXPR_ENDARG | EXPR_ENDFN),
|
||||
EXPR_NONE = 0
|
||||
};
|
||||
#endif /* INTERNAL_RUBY_PARSE_H */
|
2
iseq.c
2
iseq.c
|
@ -28,7 +28,7 @@
|
|||
#include "internal/file.h"
|
||||
#include "internal/gc.h"
|
||||
#include "internal/hash.h"
|
||||
#include "internal/parse.h"
|
||||
#include "internal/ruby_parser.h"
|
||||
#include "internal/sanitizers.h"
|
||||
#include "internal/symbol.h"
|
||||
#include "internal/thread.h"
|
||||
|
|
2
load.c
2
load.c
|
@ -9,7 +9,7 @@
|
|||
#include "internal/error.h"
|
||||
#include "internal/file.h"
|
||||
#include "internal/load.h"
|
||||
#include "internal/parse.h"
|
||||
#include "internal/ruby_parser.h"
|
||||
#include "internal/thread.h"
|
||||
#include "internal/variable.h"
|
||||
#include "iseq.h"
|
||||
|
|
1273
node.c
1273
node.c
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
535
node.h
535
node.h
|
@ -11,199 +11,99 @@
|
|||
|
||||
**********************************************************************/
|
||||
|
||||
#include "internal/compilers.h"
|
||||
#include <stdbool.h>
|
||||
#include "rubyparser.h"
|
||||
#include "ruby/backward/2/attributes.h"
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#if 0
|
||||
} /* satisfy cc-mode */
|
||||
#endif
|
||||
typedef void (*bug_report_func)(const char *fmt, ...);
|
||||
|
||||
typedef struct node_buffer_elem_struct {
|
||||
struct node_buffer_elem_struct *next;
|
||||
long len;
|
||||
NODE buf[FLEX_ARY_LEN];
|
||||
} node_buffer_elem_t;
|
||||
|
||||
typedef struct {
|
||||
long idx, len;
|
||||
node_buffer_elem_t *head;
|
||||
node_buffer_elem_t *last;
|
||||
} node_buffer_list_t;
|
||||
|
||||
#ifdef UNIVERSAL_PARSER
|
||||
typedef struct rb_parser_config_struct rb_parser_config_t;
|
||||
#endif
|
||||
|
||||
enum node_type {
|
||||
NODE_SCOPE,
|
||||
NODE_BLOCK,
|
||||
NODE_IF,
|
||||
NODE_UNLESS,
|
||||
NODE_CASE,
|
||||
NODE_CASE2,
|
||||
NODE_CASE3,
|
||||
NODE_WHEN,
|
||||
NODE_IN,
|
||||
NODE_WHILE,
|
||||
NODE_UNTIL,
|
||||
NODE_ITER,
|
||||
NODE_FOR,
|
||||
NODE_FOR_MASGN,
|
||||
NODE_BREAK,
|
||||
NODE_NEXT,
|
||||
NODE_REDO,
|
||||
NODE_RETRY,
|
||||
NODE_BEGIN,
|
||||
NODE_RESCUE,
|
||||
NODE_RESBODY,
|
||||
NODE_ENSURE,
|
||||
NODE_AND,
|
||||
NODE_OR,
|
||||
NODE_MASGN,
|
||||
NODE_LASGN,
|
||||
NODE_DASGN,
|
||||
NODE_GASGN,
|
||||
NODE_IASGN,
|
||||
NODE_CDECL,
|
||||
NODE_CVASGN,
|
||||
NODE_OP_ASGN1,
|
||||
NODE_OP_ASGN2,
|
||||
NODE_OP_ASGN_AND,
|
||||
NODE_OP_ASGN_OR,
|
||||
NODE_OP_CDECL,
|
||||
NODE_CALL,
|
||||
NODE_OPCALL,
|
||||
NODE_FCALL,
|
||||
NODE_VCALL,
|
||||
NODE_QCALL,
|
||||
NODE_SUPER,
|
||||
NODE_ZSUPER,
|
||||
NODE_LIST,
|
||||
NODE_ZLIST,
|
||||
NODE_VALUES,
|
||||
NODE_HASH,
|
||||
NODE_RETURN,
|
||||
NODE_YIELD,
|
||||
NODE_LVAR,
|
||||
NODE_DVAR,
|
||||
NODE_GVAR,
|
||||
NODE_IVAR,
|
||||
NODE_CONST,
|
||||
NODE_CVAR,
|
||||
NODE_NTH_REF,
|
||||
NODE_BACK_REF,
|
||||
NODE_MATCH,
|
||||
NODE_MATCH2,
|
||||
NODE_MATCH3,
|
||||
NODE_LIT,
|
||||
NODE_STR,
|
||||
NODE_DSTR,
|
||||
NODE_XSTR,
|
||||
NODE_DXSTR,
|
||||
NODE_EVSTR,
|
||||
NODE_DREGX,
|
||||
NODE_ONCE,
|
||||
NODE_ARGS,
|
||||
NODE_ARGS_AUX,
|
||||
NODE_OPT_ARG,
|
||||
NODE_KW_ARG,
|
||||
NODE_POSTARG,
|
||||
NODE_ARGSCAT,
|
||||
NODE_ARGSPUSH,
|
||||
NODE_SPLAT,
|
||||
NODE_BLOCK_PASS,
|
||||
NODE_DEFN,
|
||||
NODE_DEFS,
|
||||
NODE_ALIAS,
|
||||
NODE_VALIAS,
|
||||
NODE_UNDEF,
|
||||
NODE_CLASS,
|
||||
NODE_MODULE,
|
||||
NODE_SCLASS,
|
||||
NODE_COLON2,
|
||||
NODE_COLON3,
|
||||
NODE_DOT2,
|
||||
NODE_DOT3,
|
||||
NODE_FLIP2,
|
||||
NODE_FLIP3,
|
||||
NODE_SELF,
|
||||
NODE_NIL,
|
||||
NODE_TRUE,
|
||||
NODE_FALSE,
|
||||
NODE_ERRINFO,
|
||||
NODE_DEFINED,
|
||||
NODE_POSTEXE,
|
||||
NODE_DSYM,
|
||||
NODE_ATTRASGN,
|
||||
NODE_LAMBDA,
|
||||
NODE_ARYPTN,
|
||||
NODE_HSHPTN,
|
||||
NODE_FNDPTN,
|
||||
NODE_ERROR,
|
||||
NODE_LAST
|
||||
struct node_buffer_struct {
|
||||
node_buffer_list_t unmarkable;
|
||||
node_buffer_list_t markable;
|
||||
struct rb_ast_local_table_link *local_tables;
|
||||
VALUE mark_hash;
|
||||
// - id (sequence number)
|
||||
// - token_type
|
||||
// - text of token
|
||||
// - location info
|
||||
// Array, whose entry is array
|
||||
VALUE tokens;
|
||||
#ifdef UNIVERSAL_PARSER
|
||||
rb_parser_config_t *config;
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef struct rb_code_position_struct {
|
||||
int lineno;
|
||||
int column;
|
||||
} rb_code_position_t;
|
||||
RUBY_SYMBOL_EXPORT_BEGIN
|
||||
|
||||
typedef struct rb_code_location_struct {
|
||||
rb_code_position_t beg_pos;
|
||||
rb_code_position_t end_pos;
|
||||
} rb_code_location_t;
|
||||
#ifdef UNIVERSAL_PARSER
|
||||
rb_ast_t *rb_ast_new(rb_parser_config_t *config);
|
||||
#else
|
||||
rb_ast_t *rb_ast_new();
|
||||
#endif
|
||||
size_t rb_ast_memsize(const rb_ast_t*);
|
||||
void rb_ast_dispose(rb_ast_t*);
|
||||
VALUE rb_ast_tokens(rb_ast_t *ast);
|
||||
#if RUBY_DEBUG
|
||||
void rb_ast_node_type_change(NODE *n, enum node_type type);
|
||||
#endif
|
||||
const char *ruby_node_name(int node);
|
||||
void rb_node_init(NODE *n, enum node_type type, VALUE a0, VALUE a1, VALUE a2);
|
||||
|
||||
static inline rb_code_location_t
|
||||
code_loc_gen(const rb_code_location_t *loc1, const rb_code_location_t *loc2)
|
||||
{
|
||||
rb_code_location_t loc;
|
||||
loc.beg_pos = loc1->beg_pos;
|
||||
loc.end_pos = loc2->end_pos;
|
||||
return loc;
|
||||
}
|
||||
void rb_ast_mark(rb_ast_t*);
|
||||
void rb_ast_update_references(rb_ast_t*);
|
||||
void rb_ast_free(rb_ast_t*);
|
||||
void rb_ast_add_mark_object(rb_ast_t*, VALUE);
|
||||
void rb_ast_set_tokens(rb_ast_t*, VALUE);
|
||||
NODE *rb_ast_newnode(rb_ast_t*, enum node_type type);
|
||||
void rb_ast_delete_node(rb_ast_t*, NODE *n);
|
||||
rb_ast_id_table_t *rb_ast_new_local_table(rb_ast_t*, int);
|
||||
rb_ast_id_table_t *rb_ast_resize_latest_local_table(rb_ast_t*, int);
|
||||
|
||||
typedef struct rb_ast_id_table {
|
||||
int size;
|
||||
ID ids[FLEX_ARY_LEN];
|
||||
} rb_ast_id_table_t;
|
||||
VALUE rb_parser_dump_tree(const NODE *node, int comment);
|
||||
|
||||
typedef struct RNode {
|
||||
VALUE flags;
|
||||
union {
|
||||
struct RNode *node;
|
||||
ID id;
|
||||
VALUE value;
|
||||
rb_ast_id_table_t *tbl;
|
||||
} u1;
|
||||
union {
|
||||
struct RNode *node;
|
||||
ID id;
|
||||
long argc;
|
||||
VALUE value;
|
||||
} u2;
|
||||
union {
|
||||
struct RNode *node;
|
||||
ID id;
|
||||
long state;
|
||||
struct rb_args_info *args;
|
||||
struct rb_ary_pattern_info *apinfo;
|
||||
struct rb_fnd_pattern_info *fpinfo;
|
||||
VALUE value;
|
||||
} u3;
|
||||
rb_code_location_t nd_loc;
|
||||
int node_id;
|
||||
} NODE;
|
||||
const struct kwtable *rb_reserved_word(const char *, unsigned int);
|
||||
|
||||
#define RNODE(obj) ((struct RNode *)(obj))
|
||||
struct parser_params;
|
||||
void *rb_parser_malloc(struct parser_params *, size_t);
|
||||
void *rb_parser_realloc(struct parser_params *, void *, size_t);
|
||||
void *rb_parser_calloc(struct parser_params *, size_t, size_t);
|
||||
void rb_parser_free(struct parser_params *, void *);
|
||||
PRINTF_ARGS(void rb_parser_printf(struct parser_params *parser, const char *fmt, ...), 2, 3);
|
||||
VALUE rb_node_set_type(NODE *n, enum node_type t);
|
||||
|
||||
/* FL : 0..4: T_TYPES, 5: KEEP_WB, 6: PROMOTED, 7: FINALIZE, 8: UNUSED, 9: UNUSED, 10: EXIVAR, 11: FREEZE */
|
||||
/* NODE_FL: 0..4: T_TYPES, 5: KEEP_WB, 6: PROMOTED, 7: NODE_FL_NEWLINE,
|
||||
* 8..14: nd_type,
|
||||
* 15..: nd_line
|
||||
*/
|
||||
#define NODE_FL_NEWLINE (((VALUE)1)<<7)
|
||||
|
||||
#define NODE_TYPESHIFT 8
|
||||
#define NODE_TYPEMASK (((VALUE)0x7f)<<NODE_TYPESHIFT)
|
||||
|
||||
#define nd_type(n) ((int) (((n)->flags & NODE_TYPEMASK)>>NODE_TYPESHIFT))
|
||||
#define nd_set_type(n,t) \
|
||||
rb_node_set_type(n, t)
|
||||
#define nd_init_type(n,t) \
|
||||
(n)->flags=(((n)->flags&~NODE_TYPEMASK)|((((unsigned long)(t))<<NODE_TYPESHIFT)&NODE_TYPEMASK))
|
||||
RUBY_SYMBOL_EXPORT_END
|
||||
|
||||
#define NODE_LSHIFT (NODE_TYPESHIFT+7)
|
||||
#define NODE_LMASK (((SIGNED_VALUE)1<<(sizeof(VALUE)*CHAR_BIT-NODE_LSHIFT))-1)
|
||||
|
||||
#define nd_line(n) (int)(((SIGNED_VALUE)(n)->flags)>>NODE_LSHIFT)
|
||||
#define nd_set_line(n,l) \
|
||||
(n)->flags=(((n)->flags&~((VALUE)(-1)<<NODE_LSHIFT))|((VALUE)((l)&NODE_LMASK)<<NODE_LSHIFT))
|
||||
|
||||
|
||||
#define NODE_SPECIAL_REQUIRED_KEYWORD ((NODE *)-1)
|
||||
#define NODE_REQUIRED_KEYWORD_P(node) ((node)->nd_value == NODE_SPECIAL_REQUIRED_KEYWORD)
|
||||
#define NODE_SPECIAL_NO_NAME_REST ((NODE *)-1)
|
||||
#define NODE_NAMED_REST_P(node) ((node) != NODE_SPECIAL_NO_NAME_REST)
|
||||
#define NODE_SPECIAL_EXCESSIVE_COMMA ((ID)1)
|
||||
#define NODE_SPECIAL_NO_REST_KEYWORD ((NODE *)-1)
|
||||
|
||||
#define nd_first_column(n) ((int)((n)->nd_loc.beg_pos.column))
|
||||
#define nd_set_first_column(n, v) ((n)->nd_loc.beg_pos.column = (v))
|
||||
#define nd_first_lineno(n) ((int)((n)->nd_loc.beg_pos.lineno))
|
||||
|
@ -220,295 +120,10 @@ typedef struct RNode {
|
|||
#define nd_node_id(n) ((n)->node_id)
|
||||
#define nd_set_node_id(n,id) ((n)->node_id = (id))
|
||||
|
||||
#define nd_head u1.node
|
||||
#define nd_alen u2.argc
|
||||
#define nd_next u3.node
|
||||
|
||||
#define nd_cond u1.node
|
||||
#define nd_body u2.node
|
||||
#define nd_else u3.node
|
||||
|
||||
#define nd_resq u2.node
|
||||
#define nd_ensr u3.node
|
||||
|
||||
#define nd_1st u1.node
|
||||
#define nd_2nd u2.node
|
||||
|
||||
#define nd_stts u1.node
|
||||
|
||||
#define nd_entry u3.id
|
||||
#define nd_vid u1.id
|
||||
|
||||
#define nd_var u1.node
|
||||
#define nd_iter u3.node
|
||||
|
||||
#define nd_value u2.node
|
||||
#define nd_aid u3.id
|
||||
|
||||
#define nd_lit u1.value
|
||||
|
||||
#define nd_recv u1.node
|
||||
#define nd_mid u2.id
|
||||
#define nd_args u3.node
|
||||
#define nd_ainfo u3.args
|
||||
|
||||
#define nd_defn u3.node
|
||||
|
||||
#define nd_cpath u1.node
|
||||
#define nd_super u3.node
|
||||
|
||||
#define nd_beg u1.node
|
||||
#define nd_end u2.node
|
||||
#define nd_state u3.state
|
||||
|
||||
#define nd_nth u2.argc
|
||||
|
||||
#define nd_alias u1.id
|
||||
#define nd_orig u2.id
|
||||
#define nd_undef u2.node
|
||||
|
||||
#define nd_brace u2.argc
|
||||
|
||||
#define nd_pconst u1.node
|
||||
#define nd_pkwargs u2.node
|
||||
#define nd_pkwrestarg u3.node
|
||||
|
||||
#define nd_apinfo u3.apinfo
|
||||
|
||||
#define nd_fpinfo u3.fpinfo
|
||||
|
||||
// for NODE_SCOPE
|
||||
#define nd_tbl u1.tbl
|
||||
|
||||
// for NODE_ARGS_AUX
|
||||
#define nd_pid u1.id
|
||||
#define nd_plen u2.argc
|
||||
#define nd_cflag u2.id
|
||||
|
||||
// for ripper
|
||||
#define nd_cval u3.value
|
||||
#define nd_rval u2.value
|
||||
#define nd_tag u1.id
|
||||
|
||||
#define NEW_NODE(t,a0,a1,a2,loc) rb_node_newnode((t),(VALUE)(a0),(VALUE)(a1),(VALUE)(a2),loc)
|
||||
#define NEW_NODE_WITH_LOCALS(t,a1,a2,loc) node_newnode_with_locals(p, (t),(VALUE)(a1),(VALUE)(a2),loc)
|
||||
|
||||
#define NEW_DEFN(i,a,d,loc) NEW_NODE(NODE_DEFN,0,i,NEW_SCOPE(a,d,loc),loc)
|
||||
#define NEW_DEFS(r,i,a,d,loc) NEW_NODE(NODE_DEFS,r,i,NEW_SCOPE(a,d,loc),loc)
|
||||
#define NEW_SCOPE(a,b,loc) NEW_NODE_WITH_LOCALS(NODE_SCOPE,b,a,loc)
|
||||
#define NEW_BLOCK(a,loc) NEW_NODE(NODE_BLOCK,a,0,0,loc)
|
||||
#define NEW_IF(c,t,e,loc) NEW_NODE(NODE_IF,c,t,e,loc)
|
||||
#define NEW_UNLESS(c,t,e,loc) NEW_NODE(NODE_UNLESS,c,t,e,loc)
|
||||
#define NEW_CASE(h,b,loc) NEW_NODE(NODE_CASE,h,b,0,loc)
|
||||
#define NEW_CASE2(b,loc) NEW_NODE(NODE_CASE2,0,b,0,loc)
|
||||
#define NEW_CASE3(h,b,loc) NEW_NODE(NODE_CASE3,h,b,0,loc)
|
||||
#define NEW_WHEN(c,t,e,loc) NEW_NODE(NODE_WHEN,c,t,e,loc)
|
||||
#define NEW_IN(c,t,e,loc) NEW_NODE(NODE_IN,c,t,e,loc)
|
||||
#define NEW_WHILE(c,b,n,loc) NEW_NODE(NODE_WHILE,c,b,n,loc)
|
||||
#define NEW_UNTIL(c,b,n,loc) NEW_NODE(NODE_UNTIL,c,b,n,loc)
|
||||
#define NEW_FOR(i,b,loc) NEW_NODE(NODE_FOR,0,b,i,loc)
|
||||
#define NEW_FOR_MASGN(v,loc) NEW_NODE(NODE_FOR_MASGN,v,0,0,loc)
|
||||
#define NEW_ITER(a,b,loc) NEW_NODE(NODE_ITER,0,NEW_SCOPE(a,b,loc),0,loc)
|
||||
#define NEW_LAMBDA(a,b,loc) NEW_NODE(NODE_LAMBDA,0,NEW_SCOPE(a,b,loc),0,loc)
|
||||
#define NEW_BREAK(s,loc) NEW_NODE(NODE_BREAK,s,0,0,loc)
|
||||
#define NEW_NEXT(s,loc) NEW_NODE(NODE_NEXT,s,0,0,loc)
|
||||
#define NEW_REDO(loc) NEW_NODE(NODE_REDO,0,0,0,loc)
|
||||
#define NEW_RETRY(loc) NEW_NODE(NODE_RETRY,0,0,0,loc)
|
||||
#define NEW_BEGIN(b,loc) NEW_NODE(NODE_BEGIN,0,b,0,loc)
|
||||
#define NEW_RESCUE(b,res,e,loc) NEW_NODE(NODE_RESCUE,b,res,e,loc)
|
||||
#define NEW_RESBODY(a,ex,n,loc) NEW_NODE(NODE_RESBODY,n,ex,a,loc)
|
||||
#define NEW_ENSURE(b,en,loc) NEW_NODE(NODE_ENSURE,b,0,en,loc)
|
||||
#define NEW_RETURN(s,loc) NEW_NODE(NODE_RETURN,s,0,0,loc)
|
||||
#define NEW_YIELD(a,loc) NEW_NODE(NODE_YIELD,a,0,0,loc)
|
||||
#define NEW_LIST(a,loc) NEW_NODE(NODE_LIST,a,1,0,loc)
|
||||
#define NEW_ZLIST(loc) NEW_NODE(NODE_ZLIST,0,0,0,loc)
|
||||
#define NEW_HASH(a,loc) NEW_NODE(NODE_HASH,a,0,0,loc)
|
||||
#define NEW_MASGN(l,r,loc) NEW_NODE(NODE_MASGN,l,0,r,loc)
|
||||
#define NEW_GASGN(v,val,loc) NEW_NODE(NODE_GASGN,v,val,v,loc)
|
||||
#define NEW_LASGN(v,val,loc) NEW_NODE(NODE_LASGN,v,val,0,loc)
|
||||
#define NEW_DASGN(v,val,loc) NEW_NODE(NODE_DASGN,v,val,0,loc)
|
||||
#define NEW_IASGN(v,val,loc) NEW_NODE(NODE_IASGN,v,val,0,loc)
|
||||
#define NEW_CDECL(v,val,path,loc) NEW_NODE(NODE_CDECL,v,val,path,loc)
|
||||
#define NEW_CVASGN(v,val,loc) NEW_NODE(NODE_CVASGN,v,val,0,loc)
|
||||
#define NEW_OP_ASGN1(p,id,a,loc) NEW_NODE(NODE_OP_ASGN1,p,id,a,loc)
|
||||
#define NEW_OP_ASGN2(r,t,i,o,val,loc) NEW_NODE(NODE_OP_ASGN2,r,val,NEW_OP_ASGN22(i,o,t,loc),loc)
|
||||
#define NEW_OP_ASGN22(i,o,t,loc) NEW_NODE(NODE_OP_ASGN2,i,o,t,loc)
|
||||
#define NEW_OP_ASGN_OR(i,val,loc) NEW_NODE(NODE_OP_ASGN_OR,i,val,0,loc)
|
||||
#define NEW_OP_ASGN_AND(i,val,loc) NEW_NODE(NODE_OP_ASGN_AND,i,val,0,loc)
|
||||
#define NEW_OP_CDECL(v,op,val,loc) NEW_NODE(NODE_OP_CDECL,v,val,op,loc)
|
||||
#define NEW_GVAR(v,loc) NEW_NODE(NODE_GVAR,v,0,v,loc)
|
||||
#define NEW_LVAR(v,loc) NEW_NODE(NODE_LVAR,v,0,0,loc)
|
||||
#define NEW_DVAR(v,loc) NEW_NODE(NODE_DVAR,v,0,0,loc)
|
||||
#define NEW_IVAR(v,loc) NEW_NODE(NODE_IVAR,v,0,0,loc)
|
||||
#define NEW_CONST(v,loc) NEW_NODE(NODE_CONST,v,0,0,loc)
|
||||
#define NEW_CVAR(v,loc) NEW_NODE(NODE_CVAR,v,0,0,loc)
|
||||
#define NEW_NTH_REF(n,loc) NEW_NODE(NODE_NTH_REF,0,n,0,loc)
|
||||
#define NEW_BACK_REF(n,loc) NEW_NODE(NODE_BACK_REF,0,n,0,loc)
|
||||
#define NEW_MATCH(c,loc) NEW_NODE(NODE_MATCH,c,0,0,loc)
|
||||
#define NEW_MATCH2(n1,n2,loc) NEW_NODE(NODE_MATCH2,n1,n2,0,loc)
|
||||
#define NEW_MATCH3(r,n2,loc) NEW_NODE(NODE_MATCH3,r,n2,0,loc)
|
||||
#define NEW_LIT(l,loc) NEW_NODE(NODE_LIT,l,0,0,loc)
|
||||
#define NEW_STR(s,loc) NEW_NODE(NODE_STR,s,0,0,loc)
|
||||
#define NEW_DSTR(s,loc) NEW_NODE(NODE_DSTR,s,1,0,loc)
|
||||
#define NEW_XSTR(s,loc) NEW_NODE(NODE_XSTR,s,0,0,loc)
|
||||
#define NEW_DXSTR(s,loc) NEW_NODE(NODE_DXSTR,s,0,0,loc)
|
||||
#define NEW_DSYM(s,loc) NEW_NODE(NODE_DSYM,s,0,0,loc)
|
||||
#define NEW_EVSTR(n,loc) NEW_NODE(NODE_EVSTR,0,(n),0,loc)
|
||||
#define NEW_CALL(r,m,a,loc) NEW_NODE(NODE_CALL,r,m,a,loc)
|
||||
#define NEW_OPCALL(r,m,a,loc) NEW_NODE(NODE_OPCALL,r,m,a,loc)
|
||||
#define NEW_FCALL(m,a,loc) NEW_NODE(NODE_FCALL,0,m,a,loc)
|
||||
#define NEW_VCALL(m,loc) NEW_NODE(NODE_VCALL,0,m,0,loc)
|
||||
#define NEW_SUPER(a,loc) NEW_NODE(NODE_SUPER,0,0,a,loc)
|
||||
#define NEW_ZSUPER(loc) NEW_NODE(NODE_ZSUPER,0,0,0,loc)
|
||||
#define NEW_ARGS_AUX(r,b,loc) NEW_NODE(NODE_ARGS_AUX,r,b,0,loc)
|
||||
#define NEW_OPT_ARG(i,v,loc) NEW_NODE(NODE_OPT_ARG,i,v,0,loc)
|
||||
#define NEW_KW_ARG(i,v,loc) NEW_NODE(NODE_KW_ARG,i,v,0,loc)
|
||||
#define NEW_POSTARG(i,v,loc) NEW_NODE(NODE_POSTARG,i,v,0,loc)
|
||||
#define NEW_ARGSCAT(a,b,loc) NEW_NODE(NODE_ARGSCAT,a,b,0,loc)
|
||||
#define NEW_ARGSPUSH(a,b,loc) NEW_NODE(NODE_ARGSPUSH,a,b,0,loc)
|
||||
#define NEW_SPLAT(a,loc) NEW_NODE(NODE_SPLAT,a,0,0,loc)
|
||||
#define NEW_BLOCK_PASS(b,loc) NEW_NODE(NODE_BLOCK_PASS,0,b,0,loc)
|
||||
#define NEW_ALIAS(n,o,loc) NEW_NODE(NODE_ALIAS,n,o,0,loc)
|
||||
#define NEW_VALIAS(n,o,loc) NEW_NODE(NODE_VALIAS,n,o,0,loc)
|
||||
#define NEW_UNDEF(i,loc) NEW_NODE(NODE_UNDEF,0,i,0,loc)
|
||||
#define NEW_CLASS(n,b,s,loc) NEW_NODE(NODE_CLASS,n,NEW_SCOPE(0,b,loc),(s),loc)
|
||||
#define NEW_SCLASS(r,b,loc) NEW_NODE(NODE_SCLASS,r,NEW_SCOPE(0,b,loc),0,loc)
|
||||
#define NEW_MODULE(n,b,loc) NEW_NODE(NODE_MODULE,n,NEW_SCOPE(0,b,loc),0,loc)
|
||||
#define NEW_COLON2(c,i,loc) NEW_NODE(NODE_COLON2,c,i,0,loc)
|
||||
#define NEW_COLON3(i,loc) NEW_NODE(NODE_COLON3,0,i,0,loc)
|
||||
#define NEW_DOT2(b,e,loc) NEW_NODE(NODE_DOT2,b,e,0,loc)
|
||||
#define NEW_DOT3(b,e,loc) NEW_NODE(NODE_DOT3,b,e,0,loc)
|
||||
#define NEW_SELF(loc) NEW_NODE(NODE_SELF,0,0,1,loc)
|
||||
#define NEW_NIL(loc) NEW_NODE(NODE_NIL,0,0,0,loc)
|
||||
#define NEW_TRUE(loc) NEW_NODE(NODE_TRUE,0,0,0,loc)
|
||||
#define NEW_FALSE(loc) NEW_NODE(NODE_FALSE,0,0,0,loc)
|
||||
#define NEW_ERRINFO(loc) NEW_NODE(NODE_ERRINFO,0,0,0,loc)
|
||||
#define NEW_DEFINED(e,loc) NEW_NODE(NODE_DEFINED,e,0,0,loc)
|
||||
#define NEW_POSTEXE(b,loc) NEW_NODE(NODE_POSTEXE,0,b,0,loc)
|
||||
#define NEW_ATTRASGN(r,m,a,loc) NEW_NODE(NODE_ATTRASGN,r,m,a,loc)
|
||||
#define NEW_ERROR(loc) NEW_NODE(NODE_ERROR,0,0,0,loc)
|
||||
|
||||
#define NODE_SPECIAL_REQUIRED_KEYWORD ((NODE *)-1)
|
||||
#define NODE_REQUIRED_KEYWORD_P(node) ((node)->nd_value == NODE_SPECIAL_REQUIRED_KEYWORD)
|
||||
#define NODE_SPECIAL_NO_NAME_REST ((NODE *)-1)
|
||||
#define NODE_NAMED_REST_P(node) ((node) != NODE_SPECIAL_NO_NAME_REST)
|
||||
#define NODE_SPECIAL_EXCESSIVE_COMMA ((ID)1)
|
||||
#define NODE_SPECIAL_NO_REST_KEYWORD ((NODE *)-1)
|
||||
|
||||
VALUE rb_node_case_when_optimizable_literal(const NODE *const node);
|
||||
|
||||
RUBY_SYMBOL_EXPORT_BEGIN
|
||||
|
||||
typedef struct node_buffer_struct node_buffer_t;
|
||||
/* T_IMEMO/ast */
|
||||
typedef struct rb_ast_body_struct {
|
||||
const NODE *root;
|
||||
VALUE compile_option;
|
||||
VALUE script_lines;
|
||||
// script_lines is either:
|
||||
// - a Fixnum that represents the line count of the original source, or
|
||||
// - an Array that contains the lines of the original source
|
||||
} rb_ast_body_t;
|
||||
typedef struct rb_ast_struct {
|
||||
VALUE flags;
|
||||
node_buffer_t *node_buffer;
|
||||
rb_ast_body_t body;
|
||||
} rb_ast_t;
|
||||
rb_ast_t *rb_ast_new(void);
|
||||
void rb_ast_mark(rb_ast_t*);
|
||||
void rb_ast_update_references(rb_ast_t*);
|
||||
void rb_ast_dispose(rb_ast_t*);
|
||||
void rb_ast_free(rb_ast_t*);
|
||||
size_t rb_ast_memsize(const rb_ast_t*);
|
||||
void rb_ast_add_mark_object(rb_ast_t*, VALUE);
|
||||
void rb_ast_set_tokens(rb_ast_t*, VALUE);
|
||||
VALUE rb_ast_tokens(rb_ast_t *ast);
|
||||
NODE *rb_ast_newnode(rb_ast_t*, enum node_type type);
|
||||
void rb_ast_delete_node(rb_ast_t*, NODE *n);
|
||||
rb_ast_id_table_t *rb_ast_new_local_table(rb_ast_t*, int);
|
||||
rb_ast_id_table_t *rb_ast_resize_latest_local_table(rb_ast_t*, int);
|
||||
|
||||
VALUE rb_parser_new(void);
|
||||
VALUE rb_parser_end_seen_p(VALUE);
|
||||
VALUE rb_parser_encoding(VALUE);
|
||||
VALUE rb_parser_set_yydebug(VALUE, VALUE);
|
||||
VALUE rb_parser_dump_tree(const NODE *node, int comment);
|
||||
void rb_parser_set_options(VALUE, int, int, int, int);
|
||||
|
||||
rb_ast_t *rb_parser_compile_string(VALUE, const char*, VALUE, int);
|
||||
rb_ast_t *rb_parser_compile_string_path(VALUE vparser, VALUE fname, VALUE src, int line);
|
||||
rb_ast_t *rb_parser_compile_file_path(VALUE vparser, VALUE fname, VALUE input, int line);
|
||||
rb_ast_t *rb_parser_compile_generic(VALUE vparser, VALUE (*lex_gets)(VALUE, int), VALUE fname, VALUE input, int line);
|
||||
|
||||
void rb_node_init(NODE *n, enum node_type type, VALUE a0, VALUE a1, VALUE a2);
|
||||
const char *ruby_node_name(int node);
|
||||
|
||||
const struct kwtable *rb_reserved_word(const char *, unsigned int);
|
||||
|
||||
struct rb_args_info {
|
||||
NODE *pre_init;
|
||||
NODE *post_init;
|
||||
|
||||
int pre_args_num; /* count of mandatory pre-arguments */
|
||||
int post_args_num; /* count of mandatory post-arguments */
|
||||
|
||||
ID first_post_arg;
|
||||
|
||||
ID rest_arg;
|
||||
ID block_arg;
|
||||
|
||||
NODE *kw_args;
|
||||
NODE *kw_rest_arg;
|
||||
|
||||
NODE *opt_args;
|
||||
unsigned int no_kwarg: 1;
|
||||
unsigned int ruby2_keywords: 1;
|
||||
unsigned int forwarding: 1;
|
||||
|
||||
VALUE imemo;
|
||||
};
|
||||
|
||||
struct rb_ary_pattern_info {
|
||||
NODE *pre_args;
|
||||
NODE *rest_arg;
|
||||
NODE *post_args;
|
||||
};
|
||||
|
||||
struct rb_fnd_pattern_info {
|
||||
NODE *pre_rest_arg;
|
||||
NODE *args;
|
||||
NODE *post_rest_arg;
|
||||
};
|
||||
|
||||
struct parser_params;
|
||||
void *rb_parser_malloc(struct parser_params *, size_t);
|
||||
void *rb_parser_realloc(struct parser_params *, void *, size_t);
|
||||
void *rb_parser_calloc(struct parser_params *, size_t, size_t);
|
||||
void rb_parser_free(struct parser_params *, void *);
|
||||
PRINTF_ARGS(void rb_parser_printf(struct parser_params *parser, const char *fmt, ...), 2, 3);
|
||||
void rb_ast_node_type_change(NODE *n, enum node_type type);
|
||||
|
||||
RUBY_SYMBOL_EXPORT_END
|
||||
|
||||
static inline VALUE
|
||||
rb_node_set_type(NODE *n, enum node_type t)
|
||||
{
|
||||
#if RUBY_DEBUG
|
||||
rb_ast_node_type_change(n, t);
|
||||
#endif
|
||||
return nd_init_type(n, t);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
nd_type_p(const NODE *n, enum node_type t)
|
||||
{
|
||||
return (enum node_type)nd_type(n) == t;
|
||||
}
|
||||
#if defined(__cplusplus)
|
||||
#if 0
|
||||
{ /* satisfy cc-mode */
|
||||
#endif
|
||||
} /* extern "C" { */
|
||||
#endif
|
||||
|
||||
#endif /* RUBY_NODE_H */
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
1449
parse.y
1449
parse.y
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,564 @@
|
|||
#ifndef INTERNAL_BITS2_H /*-*-C-*-vi:se ft=c:*/
|
||||
#define INTERNAL_BITS2_H
|
||||
/**
|
||||
* @author Ruby developers <ruby-core@ruby-lang.org>
|
||||
* @copyright This file is a part of the programming language Ruby.
|
||||
* Permission is hereby granted, to either redistribute and/or
|
||||
* modify this file, provided that the conditions mentioned in the
|
||||
* file COPYING are met. Consult the file for details.
|
||||
* @brief Internal header for bitwise integer algorithms.
|
||||
* @see Henry S. Warren Jr., "Hacker's Delight" (2nd ed.), 2013.
|
||||
* @see SEI CERT C Coding Standard INT32-C. "Ensure that operations on
|
||||
* signed integers do not result in overflow"
|
||||
* @see https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html
|
||||
* @see https://clang.llvm.org/docs/LanguageExtensions.html#builtin-rotateleft
|
||||
* @see https://clang.llvm.org/docs/LanguageExtensions.html#builtin-rotateright
|
||||
* @see https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/byteswap-uint64-byteswap-ulong-byteswap-ushort
|
||||
* @see https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/rotl-rotl64-rotr-rotr64
|
||||
* @see https://docs.microsoft.com/en-us/cpp/intrinsics/bitscanforward-bitscanforward64
|
||||
* @see https://docs.microsoft.com/en-us/cpp/intrinsics/bitscanreverse-bitscanreverse64
|
||||
* @see https://docs.microsoft.com/en-us/cpp/intrinsics/lzcnt16-lzcnt-lzcnt64
|
||||
* @see https://docs.microsoft.com/en-us/cpp/intrinsics/popcnt16-popcnt-popcnt64
|
||||
* @see https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_lzcnt_u32
|
||||
* @see https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_tzcnt_u32
|
||||
* @see https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_rotl64
|
||||
* @see https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_rotr64
|
||||
* @see https://stackoverflow.com/a/776523
|
||||
*/
|
||||
#include "ruby/internal/config.h"
|
||||
#include <limits.h> /* for CHAR_BITS */
|
||||
#include <stdint.h> /* for uintptr_t */
|
||||
#include "internal/compilers.h" /* for MSC_VERSION_SINCE */
|
||||
|
||||
#if MSC_VERSION_SINCE(1310)
|
||||
# include <stdlib.h> /* for _byteswap_uint64 */
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_X86INTRIN_H)
|
||||
# include <x86intrin.h> /* for _lzcnt_u64 */
|
||||
#elif MSC_VERSION_SINCE(1310)
|
||||
# include <intrin.h> /* for the following intrinsics */
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && defined(__AVX__)
|
||||
# pragma intrinsic(__popcnt)
|
||||
# pragma intrinsic(__popcnt64)
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && defined(__AVX2__)
|
||||
# pragma intrinsic(__lzcnt)
|
||||
# pragma intrinsic(__lzcnt64)
|
||||
#endif
|
||||
|
||||
#if MSC_VERSION_SINCE(1310)
|
||||
# pragma intrinsic(_rotl)
|
||||
# pragma intrinsic(_rotr)
|
||||
# ifdef _WIN64
|
||||
# pragma intrinsic(_rotl64)
|
||||
# pragma intrinsic(_rotr64)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if MSC_VERSION_SINCE(1400)
|
||||
# pragma intrinsic(_BitScanForward)
|
||||
# pragma intrinsic(_BitScanReverse)
|
||||
# ifdef _WIN64
|
||||
# pragma intrinsic(_BitScanForward64)
|
||||
# pragma intrinsic(_BitScanReverse64)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include "parser_value.h" /* for VALUE */
|
||||
#include "internal/static_assert.h" /* for STATIC_ASSERT */
|
||||
|
||||
/* The most significant bit of the lower part of half-long integer.
|
||||
* If sizeof(long) == 4, this is 0x8000.
|
||||
* If sizeof(long) == 8, this is 0x80000000.
|
||||
*/
|
||||
#define HALF_LONG_MSB ((SIGNED_VALUE)1<<((SIZEOF_LONG*CHAR_BIT-1)/2))
|
||||
|
||||
#define SIGNED_INTEGER_TYPE_P(T) (0 > ((T)0)-1)
|
||||
|
||||
#define SIGNED_INTEGER_MIN(T) \
|
||||
((sizeof(T) == sizeof(int8_t)) ? ((T)INT8_MIN) : \
|
||||
((sizeof(T) == sizeof(int16_t)) ? ((T)INT16_MIN) : \
|
||||
((sizeof(T) == sizeof(int32_t)) ? ((T)INT32_MIN) : \
|
||||
((sizeof(T) == sizeof(int64_t)) ? ((T)INT64_MIN) : \
|
||||
0))))
|
||||
|
||||
#define SIGNED_INTEGER_MAX(T) ((T)(SIGNED_INTEGER_MIN(T) ^ ((T)~(T)0)))
|
||||
|
||||
#define UNSIGNED_INTEGER_MAX(T) ((T)~(T)0)
|
||||
|
||||
#if __has_builtin(__builtin_mul_overflow_p)
|
||||
# define MUL_OVERFLOW_P(a, b) \
|
||||
__builtin_mul_overflow_p((a), (b), (__typeof__(a * b))0)
|
||||
#elif __has_builtin(__builtin_mul_overflow)
|
||||
# define MUL_OVERFLOW_P(a, b) \
|
||||
__extension__ ({ __typeof__(a) c; __builtin_mul_overflow((a), (b), &c); })
|
||||
#endif
|
||||
|
||||
#define MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, min, max) ( \
|
||||
(a) == 0 ? 0 : \
|
||||
(a) == -1 ? (b) < -(max) : \
|
||||
(a) > 0 ? \
|
||||
((b) > 0 ? (max) / (a) < (b) : (min) / (a) > (b)) : \
|
||||
((b) > 0 ? (min) / (a) < (b) : (max) / (a) > (b)))
|
||||
|
||||
#if __has_builtin(__builtin_mul_overflow_p)
|
||||
/* __builtin_mul_overflow_p can take bitfield */
|
||||
/* and GCC permits bitfields for integers other than int */
|
||||
# define MUL_OVERFLOW_FIXNUM_P(a, b) \
|
||||
__extension__ ({ \
|
||||
struct { long fixnum : sizeof(long) * CHAR_BIT - 1; } c = { 0 }; \
|
||||
__builtin_mul_overflow_p((a), (b), c.fixnum); \
|
||||
})
|
||||
#else
|
||||
# define MUL_OVERFLOW_FIXNUM_P(a, b) \
|
||||
MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, FIXNUM_MIN, FIXNUM_MAX)
|
||||
#endif
|
||||
|
||||
#ifdef MUL_OVERFLOW_P
|
||||
# define MUL_OVERFLOW_LONG_LONG_P(a, b) MUL_OVERFLOW_P(a, b)
|
||||
# define MUL_OVERFLOW_LONG_P(a, b) MUL_OVERFLOW_P(a, b)
|
||||
# define MUL_OVERFLOW_INT_P(a, b) MUL_OVERFLOW_P(a, b)
|
||||
#else
|
||||
# define MUL_OVERFLOW_LONG_LONG_P(a, b) MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, LLONG_MIN, LLONG_MAX)
|
||||
# define MUL_OVERFLOW_LONG_P(a, b) MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, LONG_MIN, LONG_MAX)
|
||||
# define MUL_OVERFLOW_INT_P(a, b) MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, INT_MIN, INT_MAX)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UINT128_T
|
||||
# define bit_length(x) \
|
||||
(unsigned int) \
|
||||
(sizeof(x) <= sizeof(int32_t) ? 32 - nlz_int32((uint32_t)(x)) : \
|
||||
sizeof(x) <= sizeof(int64_t) ? 64 - nlz_int64((uint64_t)(x)) : \
|
||||
128 - nlz_int128((uint128_t)(x)))
|
||||
#else
|
||||
# define bit_length(x) \
|
||||
(unsigned int) \
|
||||
(sizeof(x) <= sizeof(int32_t) ? 32 - nlz_int32((uint32_t)(x)) : \
|
||||
64 - nlz_int64((uint64_t)(x)))
|
||||
#endif
|
||||
|
||||
#ifndef swap16
|
||||
# define swap16 ruby_swap16
|
||||
#endif
|
||||
|
||||
#ifndef swap32
|
||||
# define swap32 ruby_swap32
|
||||
#endif
|
||||
|
||||
#ifndef swap64
|
||||
# define swap64 ruby_swap64
|
||||
#endif
|
||||
|
||||
static inline uint16_t ruby_swap16(uint16_t);
|
||||
static inline uint32_t ruby_swap32(uint32_t);
|
||||
static inline uint64_t ruby_swap64(uint64_t);
|
||||
static inline unsigned nlz_int(unsigned x);
|
||||
static inline unsigned nlz_long(unsigned long x);
|
||||
static inline unsigned nlz_long_long(unsigned long long x);
|
||||
static inline unsigned nlz_intptr(uintptr_t x);
|
||||
static inline unsigned nlz_int32(uint32_t x);
|
||||
static inline unsigned nlz_int64(uint64_t x);
|
||||
#ifdef HAVE_UINT128_T
|
||||
static inline unsigned nlz_int128(uint128_t x);
|
||||
#endif
|
||||
static inline unsigned rb_popcount32(uint32_t x);
|
||||
static inline unsigned rb_popcount64(uint64_t x);
|
||||
static inline unsigned rb_popcount_intptr(uintptr_t x);
|
||||
static inline int ntz_int32(uint32_t x);
|
||||
static inline int ntz_int64(uint64_t x);
|
||||
static inline int ntz_intptr(uintptr_t x);
|
||||
static inline VALUE RUBY_BIT_ROTL(VALUE, int);
|
||||
static inline VALUE RUBY_BIT_ROTR(VALUE, int);
|
||||
|
||||
static inline uint16_t
|
||||
ruby_swap16(uint16_t x)
|
||||
{
|
||||
#if __has_builtin(__builtin_bswap16)
|
||||
return __builtin_bswap16(x);
|
||||
|
||||
#elif MSC_VERSION_SINCE(1310)
|
||||
return _byteswap_ushort(x);
|
||||
|
||||
#else
|
||||
return (x << 8) | (x >> 8);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
ruby_swap32(uint32_t x)
|
||||
{
|
||||
#if __has_builtin(__builtin_bswap32)
|
||||
return __builtin_bswap32(x);
|
||||
|
||||
#elif MSC_VERSION_SINCE(1310)
|
||||
return _byteswap_ulong(x);
|
||||
|
||||
#else
|
||||
x = ((x & 0x0000FFFF) << 16) | ((x & 0xFFFF0000) >> 16);
|
||||
x = ((x & 0x00FF00FF) << 8) | ((x & 0xFF00FF00) >> 8);
|
||||
return x;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline uint64_t
|
||||
ruby_swap64(uint64_t x)
|
||||
{
|
||||
#if __has_builtin(__builtin_bswap64)
|
||||
return __builtin_bswap64(x);
|
||||
|
||||
#elif MSC_VERSION_SINCE(1310)
|
||||
return _byteswap_uint64(x);
|
||||
|
||||
#else
|
||||
x = ((x & 0x00000000FFFFFFFFULL) << 32) | ((x & 0xFFFFFFFF00000000ULL) >> 32);
|
||||
x = ((x & 0x0000FFFF0000FFFFULL) << 16) | ((x & 0xFFFF0000FFFF0000ULL) >> 16);
|
||||
x = ((x & 0x00FF00FF00FF00FFULL) << 8) | ((x & 0xFF00FF00FF00FF00ULL) >> 8);
|
||||
return x;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline unsigned int
|
||||
nlz_int32(uint32_t x)
|
||||
{
|
||||
#if defined(_MSC_VER) && defined(__AVX2__)
|
||||
/* Note: It seems there is no such thing like __LZCNT__ predefined in MSVC.
|
||||
* AMD CPUs have had this instruction for decades (since K10) but for
|
||||
* Intel, Haswell is the oldest one. We need to use __AVX2__ for maximum
|
||||
* safety. */
|
||||
return (unsigned int)__lzcnt(x);
|
||||
|
||||
#elif defined(__x86_64__) && defined(__LZCNT__)
|
||||
return (unsigned int)_lzcnt_u32(x);
|
||||
|
||||
#elif MSC_VERSION_SINCE(1400) /* &&! defined(__AVX2__) */
|
||||
unsigned long r;
|
||||
return _BitScanReverse(&r, x) ? (31 - (int)r) : 32;
|
||||
|
||||
#elif __has_builtin(__builtin_clz)
|
||||
STATIC_ASSERT(sizeof_int, sizeof(int) * CHAR_BIT == 32);
|
||||
return x ? (unsigned int)__builtin_clz(x) : 32;
|
||||
|
||||
#else
|
||||
uint32_t y;
|
||||
unsigned n = 32;
|
||||
y = x >> 16; if (y) {n -= 16; x = y;}
|
||||
y = x >> 8; if (y) {n -= 8; x = y;}
|
||||
y = x >> 4; if (y) {n -= 4; x = y;}
|
||||
y = x >> 2; if (y) {n -= 2; x = y;}
|
||||
y = x >> 1; if (y) {return n - 2;}
|
||||
return (unsigned int)(n - x);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline unsigned int
|
||||
nlz_int64(uint64_t x)
|
||||
{
|
||||
#if defined(_MSC_VER) && defined(__AVX2__)
|
||||
return (unsigned int)__lzcnt64(x);
|
||||
|
||||
#elif defined(__x86_64__) && defined(__LZCNT__)
|
||||
return (unsigned int)_lzcnt_u64(x);
|
||||
|
||||
#elif defined(_WIN64) && MSC_VERSION_SINCE(1400) /* &&! defined(__AVX2__) */
|
||||
unsigned long r;
|
||||
return _BitScanReverse64(&r, x) ? (63u - (unsigned int)r) : 64;
|
||||
|
||||
#elif __has_builtin(__builtin_clzl)
|
||||
if (x == 0) {
|
||||
return 64;
|
||||
}
|
||||
else if (sizeof(long) * CHAR_BIT == 64) {
|
||||
return (unsigned int)__builtin_clzl((unsigned long)x);
|
||||
}
|
||||
else if (sizeof(long long) * CHAR_BIT == 64) {
|
||||
return (unsigned int)__builtin_clzll((unsigned long long)x);
|
||||
}
|
||||
else {
|
||||
/* :FIXME: Is there a way to make this branch a compile-time error? */
|
||||
UNREACHABLE_RETURN(~0);
|
||||
}
|
||||
|
||||
#else
|
||||
uint64_t y;
|
||||
unsigned int n = 64;
|
||||
y = x >> 32; if (y) {n -= 32; x = y;}
|
||||
y = x >> 16; if (y) {n -= 16; x = y;}
|
||||
y = x >> 8; if (y) {n -= 8; x = y;}
|
||||
y = x >> 4; if (y) {n -= 4; x = y;}
|
||||
y = x >> 2; if (y) {n -= 2; x = y;}
|
||||
y = x >> 1; if (y) {return n - 2;}
|
||||
return (unsigned int)(n - x);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef HAVE_UINT128_T
|
||||
static inline unsigned int
|
||||
nlz_int128(uint128_t x)
|
||||
{
|
||||
uint64_t y = (uint64_t)(x >> 64);
|
||||
|
||||
if (x == 0) {
|
||||
return 128;
|
||||
}
|
||||
else if (y == 0) {
|
||||
return (unsigned int)nlz_int64(x) + 64;
|
||||
}
|
||||
else {
|
||||
return (unsigned int)nlz_int64(y);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline unsigned int
|
||||
nlz_int(unsigned int x)
|
||||
{
|
||||
if (sizeof(unsigned int) * CHAR_BIT == 32) {
|
||||
return nlz_int32((uint32_t)x);
|
||||
}
|
||||
else if (sizeof(unsigned int) * CHAR_BIT == 64) {
|
||||
return nlz_int64((uint64_t)x);
|
||||
}
|
||||
else {
|
||||
UNREACHABLE_RETURN(~0);
|
||||
}
|
||||
}
|
||||
|
||||
static inline unsigned int
|
||||
nlz_long(unsigned long x)
|
||||
{
|
||||
if (sizeof(unsigned long) * CHAR_BIT == 32) {
|
||||
return nlz_int32((uint32_t)x);
|
||||
}
|
||||
else if (sizeof(unsigned long) * CHAR_BIT == 64) {
|
||||
return nlz_int64((uint64_t)x);
|
||||
}
|
||||
else {
|
||||
UNREACHABLE_RETURN(~0);
|
||||
}
|
||||
}
|
||||
|
||||
static inline unsigned int
|
||||
nlz_long_long(unsigned long long x)
|
||||
{
|
||||
if (sizeof(unsigned long long) * CHAR_BIT == 64) {
|
||||
return nlz_int64((uint64_t)x);
|
||||
}
|
||||
#ifdef HAVE_UINT128_T
|
||||
else if (sizeof(unsigned long long) * CHAR_BIT == 128) {
|
||||
return nlz_int128((uint128_t)x);
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
UNREACHABLE_RETURN(~0);
|
||||
}
|
||||
}
|
||||
|
||||
static inline unsigned int
|
||||
nlz_intptr(uintptr_t x)
|
||||
{
|
||||
if (sizeof(uintptr_t) == sizeof(unsigned int)) {
|
||||
return nlz_int((unsigned int)x);
|
||||
}
|
||||
if (sizeof(uintptr_t) == sizeof(unsigned long)) {
|
||||
return nlz_long((unsigned long)x);
|
||||
}
|
||||
if (sizeof(uintptr_t) == sizeof(unsigned long long)) {
|
||||
return nlz_long_long((unsigned long long)x);
|
||||
}
|
||||
else {
|
||||
UNREACHABLE_RETURN(~0);
|
||||
}
|
||||
}
|
||||
|
||||
static inline unsigned int
|
||||
rb_popcount32(uint32_t x)
|
||||
{
|
||||
#if defined(_MSC_VER) && defined(__AVX__)
|
||||
/* Note: CPUs since Nehalem and Barcelona have had this instruction so SSE
|
||||
* 4.2 should suffice, but it seems there is no such thing like __SSE_4_2__
|
||||
* predefined macro in MSVC. They do have __AVX__ so use it instead. */
|
||||
return (unsigned int)__popcnt(x);
|
||||
|
||||
#elif __has_builtin(__builtin_popcount)
|
||||
STATIC_ASSERT(sizeof_int, sizeof(int) * CHAR_BIT >= 32);
|
||||
return (unsigned int)__builtin_popcount(x);
|
||||
|
||||
#else
|
||||
x = (x & 0x55555555) + (x >> 1 & 0x55555555);
|
||||
x = (x & 0x33333333) + (x >> 2 & 0x33333333);
|
||||
x = (x & 0x0f0f0f0f) + (x >> 4 & 0x0f0f0f0f);
|
||||
x = (x & 0x001f001f) + (x >> 8 & 0x001f001f);
|
||||
x = (x & 0x0000003f) + (x >>16 & 0x0000003f);
|
||||
return (unsigned int)x;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline unsigned int
|
||||
rb_popcount64(uint64_t x)
|
||||
{
|
||||
#if defined(_MSC_VER) && defined(__AVX__)
|
||||
return (unsigned int)__popcnt64(x);
|
||||
|
||||
#elif __has_builtin(__builtin_popcount)
|
||||
if (sizeof(long) * CHAR_BIT == 64) {
|
||||
return (unsigned int)__builtin_popcountl((unsigned long)x);
|
||||
}
|
||||
else if (sizeof(long long) * CHAR_BIT == 64) {
|
||||
return (unsigned int)__builtin_popcountll((unsigned long long)x);
|
||||
}
|
||||
else {
|
||||
/* :FIXME: Is there a way to make this branch a compile-time error? */
|
||||
UNREACHABLE_RETURN(~0);
|
||||
}
|
||||
|
||||
#else
|
||||
x = (x & 0x5555555555555555) + (x >> 1 & 0x5555555555555555);
|
||||
x = (x & 0x3333333333333333) + (x >> 2 & 0x3333333333333333);
|
||||
x = (x & 0x0707070707070707) + (x >> 4 & 0x0707070707070707);
|
||||
x = (x & 0x001f001f001f001f) + (x >> 8 & 0x001f001f001f001f);
|
||||
x = (x & 0x0000003f0000003f) + (x >>16 & 0x0000003f0000003f);
|
||||
x = (x & 0x000000000000007f) + (x >>32 & 0x000000000000007f);
|
||||
return (unsigned int)x;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline unsigned int
|
||||
rb_popcount_intptr(uintptr_t x)
|
||||
{
|
||||
if (sizeof(uintptr_t) * CHAR_BIT == 64) {
|
||||
return rb_popcount64((uint64_t)x);
|
||||
}
|
||||
else if (sizeof(uintptr_t) * CHAR_BIT == 32) {
|
||||
return rb_popcount32((uint32_t)x);
|
||||
}
|
||||
else {
|
||||
UNREACHABLE_RETURN(~0);
|
||||
}
|
||||
}
|
||||
|
||||
static inline int
|
||||
ntz_int32(uint32_t x)
|
||||
{
|
||||
#if defined(__x86_64__) && defined(__BMI__)
|
||||
return (unsigned)_tzcnt_u32(x);
|
||||
|
||||
#elif MSC_VERSION_SINCE(1400)
|
||||
/* :FIXME: Is there any way to issue TZCNT instead of BSF, apart from using
|
||||
* assembly? Because issuing LZCNT seems possible (see nlz.h). */
|
||||
unsigned long r;
|
||||
return _BitScanForward(&r, x) ? (int)r : 32;
|
||||
|
||||
#elif __has_builtin(__builtin_ctz)
|
||||
STATIC_ASSERT(sizeof_int, sizeof(int) * CHAR_BIT == 32);
|
||||
return x ? (unsigned)__builtin_ctz(x) : 32;
|
||||
|
||||
#else
|
||||
return rb_popcount32((~x) & (x-1));
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int
|
||||
ntz_int64(uint64_t x)
|
||||
{
|
||||
#if defined(__x86_64__) && defined(__BMI__)
|
||||
return (unsigned)_tzcnt_u64(x);
|
||||
|
||||
#elif defined(_WIN64) && MSC_VERSION_SINCE(1400)
|
||||
unsigned long r;
|
||||
return _BitScanForward64(&r, x) ? (int)r : 64;
|
||||
|
||||
#elif __has_builtin(__builtin_ctzl)
|
||||
if (x == 0) {
|
||||
return 64;
|
||||
}
|
||||
else if (sizeof(long) * CHAR_BIT == 64) {
|
||||
return (unsigned)__builtin_ctzl((unsigned long)x);
|
||||
}
|
||||
else if (sizeof(long long) * CHAR_BIT == 64) {
|
||||
return (unsigned)__builtin_ctzll((unsigned long long)x);
|
||||
}
|
||||
else {
|
||||
/* :FIXME: Is there a way to make this branch a compile-time error? */
|
||||
UNREACHABLE_RETURN(~0);
|
||||
}
|
||||
|
||||
#else
|
||||
return rb_popcount64((~x) & (x-1));
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int
|
||||
ntz_intptr(uintptr_t x)
|
||||
{
|
||||
if (sizeof(uintptr_t) * CHAR_BIT == 64) {
|
||||
return ntz_int64((uint64_t)x);
|
||||
}
|
||||
else if (sizeof(uintptr_t) * CHAR_BIT == 32) {
|
||||
return ntz_int32((uint32_t)x);
|
||||
}
|
||||
else {
|
||||
UNREACHABLE_RETURN(~0);
|
||||
}
|
||||
}
|
||||
|
||||
static inline VALUE
|
||||
RUBY_BIT_ROTL(VALUE v, int n)
|
||||
{
|
||||
#if __has_builtin(__builtin_rotateleft32) && (SIZEOF_VALUE * CHAR_BIT == 32)
|
||||
return __builtin_rotateleft32(v, n);
|
||||
|
||||
#elif __has_builtin(__builtin_rotateleft64) && (SIZEOF_VALUE * CHAR_BIT == 64)
|
||||
return __builtin_rotateleft64(v, n);
|
||||
|
||||
#elif MSC_VERSION_SINCE(1310) && (SIZEOF_VALUE * CHAR_BIT == 32)
|
||||
return _rotl(v, n);
|
||||
|
||||
#elif MSC_VERSION_SINCE(1310) && (SIZEOF_VALUE * CHAR_BIT == 64)
|
||||
return _rotl64(v, n);
|
||||
|
||||
#elif defined(_lrotl) && (SIZEOF_VALUE == SIZEOF_LONG)
|
||||
return _lrotl(v, n);
|
||||
|
||||
#else
|
||||
const int m = (sizeof(VALUE) * CHAR_BIT) - 1;
|
||||
return (v << (n & m)) | (v >> (-n & m));
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline VALUE
|
||||
RUBY_BIT_ROTR(VALUE v, int n)
|
||||
{
|
||||
#if __has_builtin(__builtin_rotateright32) && (SIZEOF_VALUE * CHAR_BIT == 32)
|
||||
return __builtin_rotateright32(v, n);
|
||||
|
||||
#elif __has_builtin(__builtin_rotateright64) && (SIZEOF_VALUE * CHAR_BIT == 64)
|
||||
return __builtin_rotateright64(v, n);
|
||||
|
||||
#elif MSC_VERSION_SINCE(1310) && (SIZEOF_VALUE * CHAR_BIT == 32)
|
||||
return _rotr(v, n);
|
||||
|
||||
#elif MSC_VERSION_SINCE(1310) && (SIZEOF_VALUE * CHAR_BIT == 64)
|
||||
return _rotr64(v, n);
|
||||
|
||||
#elif defined(_lrotr) && (SIZEOF_VALUE == SIZEOF_LONG)
|
||||
return _lrotr(v, n);
|
||||
|
||||
#else
|
||||
const int m = (sizeof(VALUE) * CHAR_BIT) - 1;
|
||||
return (v << (-n & m)) | (v >> (n & m));
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* INTERNAL_BITS2_H */
|
|
@ -0,0 +1,133 @@
|
|||
#ifndef RUBY_PARSER_NODE_H
|
||||
#define RUBY_PARSER_NODE_H 1
|
||||
/*
|
||||
* This is a header file used by only "parse.y"
|
||||
*/
|
||||
#include "rubyparser.h"
|
||||
#include "internal/compilers.h"
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#if 0
|
||||
} /* satisfy cc-mode */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static inline rb_code_location_t
|
||||
code_loc_gen(const rb_code_location_t *loc1, const rb_code_location_t *loc2)
|
||||
{
|
||||
rb_code_location_t loc;
|
||||
loc.beg_pos = loc1->beg_pos;
|
||||
loc.end_pos = loc2->end_pos;
|
||||
return loc;
|
||||
}
|
||||
|
||||
#define RNODE(obj) ((struct RNode *)(obj))
|
||||
|
||||
|
||||
#define NEW_NODE(t,a0,a1,a2,loc) rb_node_newnode((t),(VALUE)(a0),(VALUE)(a1),(VALUE)(a2),loc)
|
||||
#define NEW_NODE_WITH_LOCALS(t,a1,a2,loc) node_newnode_with_locals(p, (t),(VALUE)(a1),(VALUE)(a2),loc)
|
||||
|
||||
#define NEW_DEFN(i,a,d,loc) NEW_NODE(NODE_DEFN,0,i,NEW_SCOPE(a,d,loc),loc)
|
||||
#define NEW_DEFS(r,i,a,d,loc) NEW_NODE(NODE_DEFS,r,i,NEW_SCOPE(a,d,loc),loc)
|
||||
#define NEW_SCOPE(a,b,loc) NEW_NODE_WITH_LOCALS(NODE_SCOPE,b,a,loc)
|
||||
#define NEW_BLOCK(a,loc) NEW_NODE(NODE_BLOCK,a,0,0,loc)
|
||||
#define NEW_IF(c,t,e,loc) NEW_NODE(NODE_IF,c,t,e,loc)
|
||||
#define NEW_UNLESS(c,t,e,loc) NEW_NODE(NODE_UNLESS,c,t,e,loc)
|
||||
#define NEW_CASE(h,b,loc) NEW_NODE(NODE_CASE,h,b,0,loc)
|
||||
#define NEW_CASE2(b,loc) NEW_NODE(NODE_CASE2,0,b,0,loc)
|
||||
#define NEW_CASE3(h,b,loc) NEW_NODE(NODE_CASE3,h,b,0,loc)
|
||||
#define NEW_WHEN(c,t,e,loc) NEW_NODE(NODE_WHEN,c,t,e,loc)
|
||||
#define NEW_IN(c,t,e,loc) NEW_NODE(NODE_IN,c,t,e,loc)
|
||||
#define NEW_WHILE(c,b,n,loc) NEW_NODE(NODE_WHILE,c,b,n,loc)
|
||||
#define NEW_UNTIL(c,b,n,loc) NEW_NODE(NODE_UNTIL,c,b,n,loc)
|
||||
#define NEW_FOR(i,b,loc) NEW_NODE(NODE_FOR,0,b,i,loc)
|
||||
#define NEW_FOR_MASGN(v,loc) NEW_NODE(NODE_FOR_MASGN,v,0,0,loc)
|
||||
#define NEW_ITER(a,b,loc) NEW_NODE(NODE_ITER,0,NEW_SCOPE(a,b,loc),0,loc)
|
||||
#define NEW_LAMBDA(a,b,loc) NEW_NODE(NODE_LAMBDA,0,NEW_SCOPE(a,b,loc),0,loc)
|
||||
#define NEW_BREAK(s,loc) NEW_NODE(NODE_BREAK,s,0,0,loc)
|
||||
#define NEW_NEXT(s,loc) NEW_NODE(NODE_NEXT,s,0,0,loc)
|
||||
#define NEW_REDO(loc) NEW_NODE(NODE_REDO,0,0,0,loc)
|
||||
#define NEW_RETRY(loc) NEW_NODE(NODE_RETRY,0,0,0,loc)
|
||||
#define NEW_BEGIN(b,loc) NEW_NODE(NODE_BEGIN,0,b,0,loc)
|
||||
#define NEW_RESCUE(b,res,e,loc) NEW_NODE(NODE_RESCUE,b,res,e,loc)
|
||||
#define NEW_RESBODY(a,ex,n,loc) NEW_NODE(NODE_RESBODY,n,ex,a,loc)
|
||||
#define NEW_ENSURE(b,en,loc) NEW_NODE(NODE_ENSURE,b,0,en,loc)
|
||||
#define NEW_RETURN(s,loc) NEW_NODE(NODE_RETURN,s,0,0,loc)
|
||||
#define NEW_YIELD(a,loc) NEW_NODE(NODE_YIELD,a,0,0,loc)
|
||||
#define NEW_LIST(a,loc) NEW_NODE(NODE_LIST,a,1,0,loc)
|
||||
#define NEW_ZLIST(loc) NEW_NODE(NODE_ZLIST,0,0,0,loc)
|
||||
#define NEW_HASH(a,loc) NEW_NODE(NODE_HASH,a,0,0,loc)
|
||||
#define NEW_MASGN(l,r,loc) NEW_NODE(NODE_MASGN,l,0,r,loc)
|
||||
#define NEW_GASGN(v,val,loc) NEW_NODE(NODE_GASGN,v,val,v,loc)
|
||||
#define NEW_LASGN(v,val,loc) NEW_NODE(NODE_LASGN,v,val,0,loc)
|
||||
#define NEW_DASGN(v,val,loc) NEW_NODE(NODE_DASGN,v,val,0,loc)
|
||||
#define NEW_IASGN(v,val,loc) NEW_NODE(NODE_IASGN,v,val,0,loc)
|
||||
#define NEW_CDECL(v,val,path,loc) NEW_NODE(NODE_CDECL,v,val,path,loc)
|
||||
#define NEW_CVASGN(v,val,loc) NEW_NODE(NODE_CVASGN,v,val,0,loc)
|
||||
#define NEW_OP_ASGN1(p,id,a,loc) NEW_NODE(NODE_OP_ASGN1,p,id,a,loc)
|
||||
#define NEW_OP_ASGN2(r,t,i,o,val,loc) NEW_NODE(NODE_OP_ASGN2,r,val,NEW_OP_ASGN22(i,o,t,loc),loc)
|
||||
#define NEW_OP_ASGN22(i,o,t,loc) NEW_NODE(NODE_OP_ASGN2,i,o,t,loc)
|
||||
#define NEW_OP_ASGN_OR(i,val,loc) NEW_NODE(NODE_OP_ASGN_OR,i,val,0,loc)
|
||||
#define NEW_OP_ASGN_AND(i,val,loc) NEW_NODE(NODE_OP_ASGN_AND,i,val,0,loc)
|
||||
#define NEW_OP_CDECL(v,op,val,loc) NEW_NODE(NODE_OP_CDECL,v,val,op,loc)
|
||||
#define NEW_GVAR(v,loc) NEW_NODE(NODE_GVAR,v,0,v,loc)
|
||||
#define NEW_LVAR(v,loc) NEW_NODE(NODE_LVAR,v,0,0,loc)
|
||||
#define NEW_DVAR(v,loc) NEW_NODE(NODE_DVAR,v,0,0,loc)
|
||||
#define NEW_IVAR(v,loc) NEW_NODE(NODE_IVAR,v,0,0,loc)
|
||||
#define NEW_CONST(v,loc) NEW_NODE(NODE_CONST,v,0,0,loc)
|
||||
#define NEW_CVAR(v,loc) NEW_NODE(NODE_CVAR,v,0,0,loc)
|
||||
#define NEW_NTH_REF(n,loc) NEW_NODE(NODE_NTH_REF,0,n,0,loc)
|
||||
#define NEW_BACK_REF(n,loc) NEW_NODE(NODE_BACK_REF,0,n,0,loc)
|
||||
#define NEW_MATCH(c,loc) NEW_NODE(NODE_MATCH,c,0,0,loc)
|
||||
#define NEW_MATCH2(n1,n2,loc) NEW_NODE(NODE_MATCH2,n1,n2,0,loc)
|
||||
#define NEW_MATCH3(r,n2,loc) NEW_NODE(NODE_MATCH3,r,n2,0,loc)
|
||||
#define NEW_LIT(l,loc) NEW_NODE(NODE_LIT,l,0,0,loc)
|
||||
#define NEW_STR(s,loc) NEW_NODE(NODE_STR,s,0,0,loc)
|
||||
#define NEW_DSTR(s,loc) NEW_NODE(NODE_DSTR,s,1,0,loc)
|
||||
#define NEW_XSTR(s,loc) NEW_NODE(NODE_XSTR,s,0,0,loc)
|
||||
#define NEW_DXSTR(s,loc) NEW_NODE(NODE_DXSTR,s,0,0,loc)
|
||||
#define NEW_DSYM(s,loc) NEW_NODE(NODE_DSYM,s,0,0,loc)
|
||||
#define NEW_EVSTR(n,loc) NEW_NODE(NODE_EVSTR,0,(n),0,loc)
|
||||
#define NEW_CALL(r,m,a,loc) NEW_NODE(NODE_CALL,r,m,a,loc)
|
||||
#define NEW_OPCALL(r,m,a,loc) NEW_NODE(NODE_OPCALL,r,m,a,loc)
|
||||
#define NEW_FCALL(m,a,loc) NEW_NODE(NODE_FCALL,0,m,a,loc)
|
||||
#define NEW_VCALL(m,loc) NEW_NODE(NODE_VCALL,0,m,0,loc)
|
||||
#define NEW_SUPER(a,loc) NEW_NODE(NODE_SUPER,0,0,a,loc)
|
||||
#define NEW_ZSUPER(loc) NEW_NODE(NODE_ZSUPER,0,0,0,loc)
|
||||
#define NEW_ARGS_AUX(r,b,loc) NEW_NODE(NODE_ARGS_AUX,r,b,0,loc)
|
||||
#define NEW_OPT_ARG(i,v,loc) NEW_NODE(NODE_OPT_ARG,i,v,0,loc)
|
||||
#define NEW_KW_ARG(i,v,loc) NEW_NODE(NODE_KW_ARG,i,v,0,loc)
|
||||
#define NEW_POSTARG(i,v,loc) NEW_NODE(NODE_POSTARG,i,v,0,loc)
|
||||
#define NEW_ARGSCAT(a,b,loc) NEW_NODE(NODE_ARGSCAT,a,b,0,loc)
|
||||
#define NEW_ARGSPUSH(a,b,loc) NEW_NODE(NODE_ARGSPUSH,a,b,0,loc)
|
||||
#define NEW_SPLAT(a,loc) NEW_NODE(NODE_SPLAT,a,0,0,loc)
|
||||
#define NEW_BLOCK_PASS(b,loc) NEW_NODE(NODE_BLOCK_PASS,0,b,0,loc)
|
||||
#define NEW_ALIAS(n,o,loc) NEW_NODE(NODE_ALIAS,n,o,0,loc)
|
||||
#define NEW_VALIAS(n,o,loc) NEW_NODE(NODE_VALIAS,n,o,0,loc)
|
||||
#define NEW_UNDEF(i,loc) NEW_NODE(NODE_UNDEF,0,i,0,loc)
|
||||
#define NEW_CLASS(n,b,s,loc) NEW_NODE(NODE_CLASS,n,NEW_SCOPE(0,b,loc),(s),loc)
|
||||
#define NEW_SCLASS(r,b,loc) NEW_NODE(NODE_SCLASS,r,NEW_SCOPE(0,b,loc),0,loc)
|
||||
#define NEW_MODULE(n,b,loc) NEW_NODE(NODE_MODULE,n,NEW_SCOPE(0,b,loc),0,loc)
|
||||
#define NEW_COLON2(c,i,loc) NEW_NODE(NODE_COLON2,c,i,0,loc)
|
||||
#define NEW_COLON3(i,loc) NEW_NODE(NODE_COLON3,0,i,0,loc)
|
||||
#define NEW_DOT2(b,e,loc) NEW_NODE(NODE_DOT2,b,e,0,loc)
|
||||
#define NEW_DOT3(b,e,loc) NEW_NODE(NODE_DOT3,b,e,0,loc)
|
||||
#define NEW_SELF(loc) NEW_NODE(NODE_SELF,0,0,1,loc)
|
||||
#define NEW_NIL(loc) NEW_NODE(NODE_NIL,0,0,0,loc)
|
||||
#define NEW_TRUE(loc) NEW_NODE(NODE_TRUE,0,0,0,loc)
|
||||
#define NEW_FALSE(loc) NEW_NODE(NODE_FALSE,0,0,0,loc)
|
||||
#define NEW_ERRINFO(loc) NEW_NODE(NODE_ERRINFO,0,0,0,loc)
|
||||
#define NEW_DEFINED(e,loc) NEW_NODE(NODE_DEFINED,e,0,0,loc)
|
||||
#define NEW_POSTEXE(b,loc) NEW_NODE(NODE_POSTEXE,0,b,0,loc)
|
||||
#define NEW_ATTRASGN(r,m,a,loc) NEW_NODE(NODE_ATTRASGN,r,m,a,loc)
|
||||
#define NEW_ERROR(loc) NEW_NODE(NODE_ERROR,0,0,0,loc)
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#if 0
|
||||
{ /* satisfy cc-mode */
|
||||
#endif
|
||||
} /* extern "C" { */
|
||||
#endif
|
||||
|
||||
#endif /* RUBY_PARSER_NODE_H */
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,165 @@
|
|||
/* This is a public domain general purpose hash table package
|
||||
originally written by Peter Moore @ UCB.
|
||||
|
||||
The hash table data structures were redesigned and the package was
|
||||
rewritten by Vladimir Makarov <vmakarov@redhat.com>. */
|
||||
|
||||
#ifndef RUBY_ST2_H
|
||||
#define RUBY_ST2_H 1
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#if 0
|
||||
} /* satisfy cc-mode */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include "ruby/config.h"
|
||||
#include "ruby/backward/2/long_long.h"
|
||||
#include "ruby/defines.h"
|
||||
|
||||
RUBY_SYMBOL_EXPORT_BEGIN
|
||||
|
||||
#if SIZEOF_LONG == SIZEOF_VOIDP
|
||||
typedef unsigned long parser_st_data_t;
|
||||
#elif SIZEOF_LONG_LONG == SIZEOF_VOIDP
|
||||
typedef unsigned LONG_LONG parser_st_data_t;
|
||||
#else
|
||||
# error ---->> parser_st.c requires sizeof(void*) == sizeof(long) or sizeof(LONG_LONG) to be compiled. <<----
|
||||
#endif
|
||||
#define ST2_DATA_T_DEFINED
|
||||
|
||||
#ifndef CHAR_BIT
|
||||
# ifdef HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
# else
|
||||
# define CHAR_BIT 8
|
||||
# endif
|
||||
#endif
|
||||
#ifndef _
|
||||
# define _(args) args
|
||||
#endif
|
||||
#ifndef ANYARGS
|
||||
# ifdef __cplusplus
|
||||
# define ANYARGS ...
|
||||
# else
|
||||
# define ANYARGS
|
||||
# endif
|
||||
#endif
|
||||
|
||||
typedef struct parser_st_table parser_st_table;
|
||||
|
||||
typedef parser_st_data_t parser_st_index_t;
|
||||
|
||||
/* Maximal value of unsigned integer type parser_st_index_t. */
|
||||
#define MAX_ST2_INDEX_VAL (~(parser_st_index_t) 0)
|
||||
|
||||
typedef int parser_st_compare_func(parser_st_data_t, parser_st_data_t);
|
||||
typedef parser_st_index_t parser_st_hash_func(parser_st_data_t);
|
||||
|
||||
typedef char st_check_for_sizeof_parser_st_index_t[SIZEOF_VOIDP == (int)sizeof(parser_st_index_t) ? 1 : -1];
|
||||
#define SIZEOF_ST_INDEX_T SIZEOF_VOIDP
|
||||
|
||||
struct parser_st_hash_type {
|
||||
int (*compare)(parser_st_data_t, parser_st_data_t); /* parser_st_compare_func* */
|
||||
parser_st_index_t (*hash)(parser_st_data_t); /* parser_st_hash_func* */
|
||||
};
|
||||
|
||||
typedef struct st_functions {
|
||||
void *(*nonempty_memcpy)(void *dest, const void *src, size_t t, size_t n);
|
||||
} st_functions_t;
|
||||
|
||||
#define ST_INDEX_BITS (SIZEOF_ST_INDEX_T * CHAR_BIT)
|
||||
|
||||
#if defined(HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR) && defined(HAVE_BUILTIN___BUILTIN_TYPES_COMPATIBLE_P)
|
||||
# define ST2_DATA_COMPATIBLE_P(type) \
|
||||
__builtin_choose_expr(__builtin_types_compatible_p(type, parser_st_data_t), 1, 0)
|
||||
#else
|
||||
# define ST2_DATA_COMPATIBLE_P(type) 0
|
||||
#endif
|
||||
|
||||
typedef struct parser_st_table_entry parser_st_table_entry;
|
||||
|
||||
struct parser_st_table_entry; /* defined in parser_st.c */
|
||||
|
||||
struct parser_st_table {
|
||||
/* Cached features of the table -- see st.c for more details. */
|
||||
unsigned char entry_power, bin_power, size_ind;
|
||||
/* How many times the table was rebuilt. */
|
||||
unsigned int rebuilds_num;
|
||||
const struct parser_st_hash_type *type;
|
||||
/* Number of entries currently in the table. */
|
||||
parser_st_index_t num_entries;
|
||||
/* Array of bins used for access by keys. */
|
||||
parser_st_index_t *bins;
|
||||
/* Start and bound index of entries in array entries.
|
||||
entries_starts and entries_bound are in interval
|
||||
[0,allocated_entries]. */
|
||||
parser_st_index_t entries_start, entries_bound;
|
||||
/* Array of size 2^entry_power. */
|
||||
parser_st_table_entry *entries;
|
||||
st_functions_t *functions;
|
||||
};
|
||||
|
||||
#define parser_st_is_member(table,key) rb_parser_st_lookup((table),(key),(parser_st_data_t *)0)
|
||||
|
||||
enum parser_st_retval {ST2_CONTINUE, ST2_STOP, ST2_DELETE, ST2_CHECK, ST2_REPLACE};
|
||||
|
||||
size_t rb_parser_st_table_size(const struct parser_st_table *tbl);
|
||||
parser_st_table *rb_parser_st_init_table(const struct parser_st_hash_type *, st_functions_t *);
|
||||
parser_st_table *rb_parser_st_init_table_with_size(const struct parser_st_hash_type *, st_functions_t *, parser_st_index_t);
|
||||
parser_st_table *rb_parser_st_init_numtable(st_functions_t *);
|
||||
parser_st_table *rb_parser_st_init_numtable_with_size(st_functions_t *, parser_st_index_t);
|
||||
parser_st_table *rb_parser_st_init_strtable(st_functions_t *);
|
||||
parser_st_table *rb_parser_st_init_strtable_with_size(st_functions_t *, parser_st_index_t);
|
||||
parser_st_table *rb_parser_st_init_strcasetable(st_functions_t *);
|
||||
parser_st_table *rb_parser_st_init_strcasetable_with_size(st_functions_t *, parser_st_index_t);
|
||||
int rb_parser_st_delete(parser_st_table *, parser_st_data_t *, parser_st_data_t *); /* returns 0:notfound 1:deleted */
|
||||
int rb_parser_st_delete_safe(parser_st_table *, parser_st_data_t *, parser_st_data_t *, parser_st_data_t);
|
||||
int rb_parser_st_shift(parser_st_table *, parser_st_data_t *, parser_st_data_t *); /* returns 0:notfound 1:deleted */
|
||||
int rb_parser_st_insert(parser_st_table *, parser_st_data_t, parser_st_data_t);
|
||||
int rb_parser_st_insert2(parser_st_table *, parser_st_data_t, parser_st_data_t, parser_st_data_t (*)(parser_st_data_t));
|
||||
int rb_parser_st_lookup(parser_st_table *, parser_st_data_t, parser_st_data_t *);
|
||||
int rb_parser_st_get_key(parser_st_table *, parser_st_data_t, parser_st_data_t *);
|
||||
typedef int parser_st_update_callback_func(parser_st_data_t *key, parser_st_data_t *value, parser_st_data_t arg, int existing);
|
||||
/* *key may be altered, but must equal to the old key, i.e., the
|
||||
* results of hash() are same and compare() returns 0, otherwise the
|
||||
* behavior is undefined */
|
||||
int rb_parser_st_update(parser_st_table *table, parser_st_data_t key, parser_st_update_callback_func *func, parser_st_data_t arg);
|
||||
typedef int parser_st_foreach_callback_func(parser_st_data_t, parser_st_data_t, parser_st_data_t);
|
||||
typedef int parser_st_foreach_check_callback_func(parser_st_data_t, parser_st_data_t, parser_st_data_t, int);
|
||||
int rb_parser_st_foreach_with_replace(parser_st_table *tab, parser_st_foreach_check_callback_func *func, parser_st_update_callback_func *replace, parser_st_data_t arg);
|
||||
int rb_parser_st_foreach(parser_st_table *, parser_st_foreach_callback_func *, parser_st_data_t);
|
||||
int rb_parser_st_foreach_check(parser_st_table *, parser_st_foreach_check_callback_func *, parser_st_data_t, parser_st_data_t);
|
||||
parser_st_index_t rb_parser_st_keys(parser_st_table *table, parser_st_data_t *keys, parser_st_index_t size);
|
||||
parser_st_index_t rb_parser_st_keys_check(parser_st_table *table, parser_st_data_t *keys, parser_st_index_t size, parser_st_data_t never);
|
||||
parser_st_index_t rb_parser_st_values(parser_st_table *table, parser_st_data_t *values, parser_st_index_t size);
|
||||
parser_st_index_t rb_parser_st_values_check(parser_st_table *table, parser_st_data_t *values, parser_st_index_t size, parser_st_data_t never);
|
||||
void rb_parser_st_add_direct(parser_st_table *, parser_st_data_t, parser_st_data_t);
|
||||
void rb_parser_st_free_table(parser_st_table *);
|
||||
void rb_parser_st_cleanup_safe(parser_st_table *, parser_st_data_t);
|
||||
void rb_parser_st_clear(parser_st_table *);
|
||||
parser_st_table *rb_parser_st_copy(parser_st_table *);
|
||||
CONSTFUNC(int rb_parser_st_numcmp(parser_st_data_t, parser_st_data_t));
|
||||
CONSTFUNC(parser_st_index_t rb_parser_st_numhash(parser_st_data_t));
|
||||
PUREFUNC(int rb_parser_st_locale_insensitive_strcasecmp(const char *s1, const char *s2));
|
||||
PUREFUNC(int rb_parser_st_locale_insensitive_strncasecmp(const char *s1, const char *s2, size_t n));
|
||||
PUREFUNC(size_t rb_parser_st_memsize(const parser_st_table *));
|
||||
PUREFUNC(parser_st_index_t rb_parser_st_hash(const void *ptr, size_t len, parser_st_index_t h));
|
||||
CONSTFUNC(parser_st_index_t rb_parser_st_hash_uint32(parser_st_index_t h, uint32_t i));
|
||||
CONSTFUNC(parser_st_index_t rb_parser_st_hash_uint(parser_st_index_t h, parser_st_index_t i));
|
||||
CONSTFUNC(parser_st_index_t rb_parser_st_hash_end(parser_st_index_t h));
|
||||
CONSTFUNC(parser_st_index_t rb_parser_st_hash_start(parser_st_index_t h));
|
||||
|
||||
RUBY_SYMBOL_EXPORT_END
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#if 0
|
||||
{ /* satisfy cc-mode */
|
||||
#endif
|
||||
} /* extern "C" { */
|
||||
#endif
|
||||
|
||||
#endif /* RUBY_ST2_H */
|
|
@ -0,0 +1,106 @@
|
|||
#ifndef EXTERNAL_VALUE_H
|
||||
#define EXTERNAL_VALUE_H
|
||||
|
||||
#include "ruby/config.h"
|
||||
|
||||
#if defined(__DOXYGEN__)
|
||||
|
||||
/**
|
||||
* Type that represents a Ruby object. It is an unsigned integer of some kind,
|
||||
* depending on platforms.
|
||||
*
|
||||
* ```CXX
|
||||
* VALUE value = rb_eval_string("ARGF.readlines.map.with_index");
|
||||
* ```
|
||||
*
|
||||
* @warning ::VALUE is not a pointer.
|
||||
* @warning ::VALUE can be wider than `long`.
|
||||
*/
|
||||
typedef uintptr_t VALUE;
|
||||
|
||||
/**
|
||||
* Type that represents a Ruby identifier such as a variable name.
|
||||
*
|
||||
* ```CXX
|
||||
* ID method = rb_intern("method");
|
||||
* VALUE result = rb_funcall(obj, method, 0);
|
||||
* ```
|
||||
*
|
||||
* @note ::rb_cSymbol is a Ruby-level data type for the same thing.
|
||||
*/
|
||||
typedef uintptr_t ID;
|
||||
|
||||
/**
|
||||
* A signed integer type that has the same width with ::VALUE.
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @shyouhei wonders: is it guaranteed that `uintptr_t` and `intptr_t` are the
|
||||
* same width? As far as I read ISO/IEC 9899:2018 section 7.20.1.4 paragraph 1
|
||||
* no such description is given... or defined elsewhere?
|
||||
*/
|
||||
typedef intptr_t SIGNED_VALUE;
|
||||
|
||||
/**
|
||||
* Identical to `sizeof(VALUE)`, except it is a macro that can also be used
|
||||
* inside of preprocessor directives such as `#if`. Handy on occasions.
|
||||
*/
|
||||
#define SIZEOF_VALUE SIZEOF_UINTPTR_T
|
||||
|
||||
/**
|
||||
* @private
|
||||
*
|
||||
* A compile-time constant of type ::VALUE whose value is 0.
|
||||
*/
|
||||
#define RBIMPL_VALUE_NULL UINTPTR_C(0)
|
||||
|
||||
/**
|
||||
* @private
|
||||
*
|
||||
* A compile-time constant of type ::VALUE whose value is 1.
|
||||
*/
|
||||
#define RBIMPL_VALUE_ONE UINTPTR_C(1)
|
||||
|
||||
/**
|
||||
* @private
|
||||
*
|
||||
* Maximum possible value that a ::VALUE can take.
|
||||
*/
|
||||
#define RBIMPL_VALUE_FULL UINTPTR_MAX
|
||||
|
||||
#elif defined HAVE_UINTPTR_T && 0
|
||||
typedef uintptr_t VALUE;
|
||||
typedef uintptr_t ID;
|
||||
# define SIGNED_VALUE intptr_t
|
||||
# define SIZEOF_VALUE SIZEOF_UINTPTR_T
|
||||
# undef PRI_VALUE_PREFIX
|
||||
# define RBIMPL_VALUE_NULL UINTPTR_C(0)
|
||||
# define RBIMPL_VALUE_ONE UINTPTR_C(1)
|
||||
# define RBIMPL_VALUE_FULL UINTPTR_MAX
|
||||
|
||||
#elif SIZEOF_LONG == SIZEOF_VOIDP
|
||||
typedef unsigned long VALUE;
|
||||
typedef unsigned long ID;
|
||||
# define SIGNED_VALUE long
|
||||
# define SIZEOF_VALUE SIZEOF_LONG
|
||||
# define PRI_VALUE_PREFIX "l"
|
||||
# define RBIMPL_VALUE_NULL 0UL
|
||||
# define RBIMPL_VALUE_ONE 1UL
|
||||
# define RBIMPL_VALUE_FULL ULONG_MAX
|
||||
|
||||
#elif SIZEOF_LONG_LONG == SIZEOF_VOIDP
|
||||
typedef unsigned LONG_LONG VALUE;
|
||||
typedef unsigned LONG_LONG ID;
|
||||
# define SIGNED_VALUE LONG_LONG
|
||||
# define LONG_LONG_VALUE 1
|
||||
# define SIZEOF_VALUE SIZEOF_LONG_LONG
|
||||
# define PRI_VALUE_PREFIX PRI_LL_PREFIX
|
||||
# define RBIMPL_VALUE_NULL 0ULL
|
||||
# define RBIMPL_VALUE_ONE 1ULL
|
||||
# define RBIMPL_VALUE_FULL ULLONG_MAX
|
||||
|
||||
#else
|
||||
# error ---->> ruby requires sizeof(void*) == sizeof(long) or sizeof(LONG_LONG) to be compiled. <<----
|
||||
#endif
|
||||
|
||||
#endif /* EXTERNAL_VALUE_H */
|
2
ruby.c
2
ruby.c
|
@ -53,7 +53,7 @@
|
|||
#include "internal/loadpath.h"
|
||||
#include "internal/missing.h"
|
||||
#include "internal/object.h"
|
||||
#include "internal/parse.h"
|
||||
#include "internal/ruby_parser.h"
|
||||
#include "internal/variable.h"
|
||||
#include "ruby/encoding.h"
|
||||
#include "ruby/thread.h"
|
||||
|
|
|
@ -0,0 +1,983 @@
|
|||
/* This is a wrapper for parse.y */
|
||||
#ifdef UNIVERSAL_PARSER
|
||||
|
||||
#include "internal.h"
|
||||
#include "internal/array.h"
|
||||
#include "internal/bignum.h"
|
||||
#include "internal/compile.h"
|
||||
#include "internal/complex.h"
|
||||
#include "internal/encoding.h"
|
||||
#include "internal/error.h"
|
||||
#include "internal/gc.h"
|
||||
#include "internal/hash.h"
|
||||
#include "internal/io.h"
|
||||
#include "internal/parse.h"
|
||||
#include "internal/rational.h"
|
||||
#include "internal/re.h"
|
||||
#include "internal/ruby_parser.h"
|
||||
#include "internal/string.h"
|
||||
#include "internal/symbol.h"
|
||||
#include "internal/thread.h"
|
||||
|
||||
#include "ruby/ractor.h"
|
||||
#include "ruby/ruby.h"
|
||||
#include "ruby/util.h"
|
||||
#include "node.h"
|
||||
#include "internal.h"
|
||||
#include "vm_core.h"
|
||||
#include "symbol.h"
|
||||
|
||||
struct ruby_parser {
|
||||
rb_parser_t *parser_params;
|
||||
};
|
||||
|
||||
static void
|
||||
parser_mark(void *ptr)
|
||||
{
|
||||
struct ruby_parser *parser = (struct ruby_parser*)ptr;
|
||||
rb_ruby_parser_mark(parser->parser_params);
|
||||
}
|
||||
|
||||
static void
|
||||
parser_free(void *ptr)
|
||||
{
|
||||
struct ruby_parser *parser = (struct ruby_parser*)ptr;
|
||||
rb_ruby_parser_free(parser->parser_params);
|
||||
}
|
||||
|
||||
static size_t
|
||||
parser_memsize(const void *ptr)
|
||||
{
|
||||
struct ruby_parser *parser = (struct ruby_parser*)ptr;
|
||||
return rb_ruby_parser_memsize(parser->parser_params);
|
||||
}
|
||||
|
||||
static const rb_data_type_t ruby_parser_data_type = {
|
||||
"parser",
|
||||
{
|
||||
parser_mark,
|
||||
parser_free,
|
||||
parser_memsize,
|
||||
},
|
||||
0, 0, RUBY_TYPED_FREE_IMMEDIATELY
|
||||
};
|
||||
|
||||
static void
|
||||
bignum_negate(VALUE b)
|
||||
{
|
||||
BIGNUM_NEGATE(b);
|
||||
}
|
||||
|
||||
static int
|
||||
is_ascii_string2(VALUE str)
|
||||
{
|
||||
return is_ascii_string(str);
|
||||
}
|
||||
|
||||
static void
|
||||
rational_set_num(VALUE r, VALUE n)
|
||||
{
|
||||
RATIONAL_SET_NUM(r, n);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rational_get_num(VALUE obj)
|
||||
{
|
||||
return RRATIONAL(obj)->num;
|
||||
}
|
||||
|
||||
static void
|
||||
rcomplex_set_real(VALUE cmp, VALUE r)
|
||||
{
|
||||
RCOMPLEX_SET_REAL(cmp, r);
|
||||
}
|
||||
|
||||
static void
|
||||
rcomplex_set_imag(VALUE cmp, VALUE i)
|
||||
{
|
||||
RCOMPLEX_SET_IMAG(cmp, i);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rcomplex_get_real(VALUE obj)
|
||||
{
|
||||
return RCOMPLEX(obj)->real;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rcomplex_get_imag(VALUE obj)
|
||||
{
|
||||
return RCOMPLEX(obj)->imag;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
syntax_error_append(VALUE exc, VALUE file, int line, int column,
|
||||
void *enc, const char *fmt, va_list args)
|
||||
{
|
||||
return rb_syntax_error_append(exc, file, line, column, (rb_encoding *)enc, fmt, args);
|
||||
}
|
||||
|
||||
static int
|
||||
vm_keep_script_lines(void)
|
||||
{
|
||||
return ruby_vm_keep_script_lines;
|
||||
}
|
||||
|
||||
static int
|
||||
local_defined(ID id, const void *p)
|
||||
{
|
||||
return rb_local_defined(id, (const rb_iseq_t *)p);
|
||||
}
|
||||
|
||||
static int
|
||||
dvar_defined(ID id, const void *p)
|
||||
{
|
||||
return rb_dvar_defined(id, (const rb_iseq_t *)p);
|
||||
}
|
||||
|
||||
static bool
|
||||
hash_literal_key_p(VALUE k)
|
||||
{
|
||||
switch (OBJ_BUILTIN_TYPE(k)) {
|
||||
case T_NODE:
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
literal_cmp(VALUE val, VALUE lit)
|
||||
{
|
||||
if (val == lit) return 0;
|
||||
if (!hash_literal_key_p(val) || !hash_literal_key_p(lit)) return -1;
|
||||
return rb_iseq_cdhash_cmp(val, lit);
|
||||
}
|
||||
|
||||
static st_index_t
|
||||
literal_hash(VALUE a)
|
||||
{
|
||||
if (!hash_literal_key_p(a)) return (st_index_t)a;
|
||||
return rb_iseq_cdhash_hash(a);
|
||||
}
|
||||
|
||||
static int
|
||||
is_usascii_enc(void *enc)
|
||||
{
|
||||
return rb_is_usascii_enc((rb_encoding *)enc);
|
||||
}
|
||||
|
||||
static int
|
||||
is_local_id2(ID id)
|
||||
{
|
||||
return is_local_id(id);
|
||||
}
|
||||
|
||||
static int
|
||||
is_attrset_id2(ID id)
|
||||
{
|
||||
return is_attrset_id(id);
|
||||
}
|
||||
|
||||
static int
|
||||
is_notop_id2(ID id)
|
||||
{
|
||||
return is_notop_id(id);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
enc_str_new(const char *ptr, long len, void *enc)
|
||||
{
|
||||
return rb_enc_str_new(ptr, len, (rb_encoding *)enc);
|
||||
}
|
||||
|
||||
static int
|
||||
enc_isalnum(OnigCodePoint c, void *enc)
|
||||
{
|
||||
return rb_enc_isalnum(c, (rb_encoding *)enc);
|
||||
}
|
||||
|
||||
static int
|
||||
enc_precise_mbclen(const char *p, const char *e, void *enc)
|
||||
{
|
||||
return rb_enc_precise_mbclen(p, e, (rb_encoding *)enc);
|
||||
}
|
||||
|
||||
static int
|
||||
mbclen_charfound_p(int len)
|
||||
{
|
||||
return MBCLEN_CHARFOUND_P(len);
|
||||
}
|
||||
|
||||
static const char *
|
||||
enc_name(void *enc)
|
||||
{
|
||||
return rb_enc_name((rb_encoding *)enc);
|
||||
}
|
||||
|
||||
static char *
|
||||
enc_prev_char(const char *s, const char *p, const char *e, void *enc)
|
||||
{
|
||||
return rb_enc_prev_char(s, p, e, (rb_encoding *)enc);
|
||||
}
|
||||
|
||||
static void *
|
||||
enc_get(VALUE obj)
|
||||
{
|
||||
return (void *)rb_enc_get(obj);
|
||||
}
|
||||
|
||||
static int
|
||||
enc_asciicompat(void *enc)
|
||||
{
|
||||
return rb_enc_asciicompat((rb_encoding *)enc);
|
||||
}
|
||||
|
||||
static void *
|
||||
utf8_encoding(void)
|
||||
{
|
||||
return (void *)rb_utf8_encoding();
|
||||
}
|
||||
|
||||
static VALUE
|
||||
enc_associate(VALUE obj, void *enc)
|
||||
{
|
||||
return rb_enc_associate(obj, (rb_encoding *)enc);
|
||||
}
|
||||
|
||||
static void *
|
||||
ascii8bit_encoding(void)
|
||||
{
|
||||
return (void *)rb_ascii8bit_encoding();
|
||||
}
|
||||
|
||||
static int
|
||||
enc_codelen(int c, void *enc)
|
||||
{
|
||||
return rb_enc_codelen(c, (rb_encoding *)enc);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
enc_str_buf_cat(VALUE str, const char *ptr, long len, void *enc)
|
||||
{
|
||||
return rb_enc_str_buf_cat(str, ptr, len, (rb_encoding *)enc);
|
||||
}
|
||||
|
||||
static int
|
||||
enc_mbcput(unsigned int c, void *buf, void *enc)
|
||||
{
|
||||
return rb_enc_mbcput(c, buf, (rb_encoding *)enc);
|
||||
}
|
||||
|
||||
static void *
|
||||
enc_from_index(int idx)
|
||||
{
|
||||
return (void *)rb_enc_from_index(idx);
|
||||
}
|
||||
|
||||
static int
|
||||
enc_isspace(OnigCodePoint c, void *enc)
|
||||
{
|
||||
return rb_enc_isspace(c, (rb_encoding *)enc);
|
||||
}
|
||||
|
||||
static ID
|
||||
intern3(const char *name, long len, void *enc)
|
||||
{
|
||||
return rb_intern3(name, len, (rb_encoding *)enc);
|
||||
}
|
||||
|
||||
static void *
|
||||
enc_compatible(VALUE str1, VALUE str2)
|
||||
{
|
||||
return (void *)rb_enc_compatible(str1, str2);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
enc_from_encoding(void *enc)
|
||||
{
|
||||
return rb_enc_from_encoding((rb_encoding *)enc);
|
||||
}
|
||||
|
||||
static int
|
||||
encoding_get(VALUE obj)
|
||||
{
|
||||
return ENCODING_GET(obj);
|
||||
}
|
||||
|
||||
static void
|
||||
encoding_set(VALUE obj, int encindex)
|
||||
{
|
||||
ENCODING_SET(obj, encindex);
|
||||
}
|
||||
|
||||
static int
|
||||
encoding_is_ascii8bit(VALUE obj)
|
||||
{
|
||||
return ENCODING_IS_ASCII8BIT(obj);
|
||||
}
|
||||
|
||||
static void *
|
||||
usascii_encoding(void)
|
||||
{
|
||||
return (void *)rb_usascii_encoding();
|
||||
}
|
||||
|
||||
static int
|
||||
enc_symname_type(const char *name, long len, void *enc, unsigned int allowed_attrset)
|
||||
{
|
||||
return rb_enc_symname_type(name, len, (rb_encoding *)enc, allowed_attrset);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
struct parser_params *parser;
|
||||
rb_encoding *enc;
|
||||
NODE *succ_block;
|
||||
const rb_code_location_t *loc;
|
||||
} reg_named_capture_assign_t;
|
||||
|
||||
static int
|
||||
reg_named_capture_assign_iter(const OnigUChar *name, const OnigUChar *name_end,
|
||||
int back_num, int *back_refs, OnigRegex regex, void *arg0)
|
||||
{
|
||||
reg_named_capture_assign_t *arg = (reg_named_capture_assign_t*)arg0;
|
||||
struct parser_params* p = arg->parser;
|
||||
rb_encoding *enc = arg->enc;
|
||||
const rb_code_location_t *loc = arg->loc;
|
||||
long len = name_end - name;
|
||||
const char *s = (const char *)name;
|
||||
|
||||
return rb_reg_named_capture_assign_iter_impl(p, s, len, (void *)enc, &arg->succ_block, loc);
|
||||
}
|
||||
|
||||
static NODE *
|
||||
reg_named_capture_assign(struct parser_params* p, VALUE regexp, const rb_code_location_t *loc)
|
||||
{
|
||||
reg_named_capture_assign_t arg;
|
||||
|
||||
arg.parser = p;
|
||||
arg.enc = rb_enc_get(regexp);
|
||||
arg.succ_block = 0;
|
||||
arg.loc = loc;
|
||||
onig_foreach_name(RREGEXP_PTR(regexp), reg_named_capture_assign_iter, &arg);
|
||||
|
||||
if (!arg.succ_block) return 0;
|
||||
return arg.succ_block->nd_next;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rbool(VALUE v)
|
||||
{
|
||||
return RBOOL(v);
|
||||
}
|
||||
|
||||
static int
|
||||
undef_p(VALUE v)
|
||||
{
|
||||
return RB_UNDEF_P(v);
|
||||
}
|
||||
|
||||
static int
|
||||
rtest(VALUE obj)
|
||||
{
|
||||
return (int)RB_TEST(obj);
|
||||
}
|
||||
|
||||
static int
|
||||
nil_p(VALUE obj)
|
||||
{
|
||||
return (int)NIL_P(obj);
|
||||
}
|
||||
|
||||
static int
|
||||
flonum_p(VALUE obj)
|
||||
{
|
||||
return (int)RB_FLONUM_P(obj);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
int2fix(long i)
|
||||
{
|
||||
return INT2FIX(i);
|
||||
}
|
||||
|
||||
static int
|
||||
script_lines_defined(void)
|
||||
{
|
||||
ID script_lines;
|
||||
CONST_ID(script_lines, "SCRIPT_LINES__");
|
||||
|
||||
return rb_const_defined_at(rb_cObject, script_lines);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
script_lines_get(void)
|
||||
{
|
||||
ID script_lines;
|
||||
CONST_ID(script_lines, "SCRIPT_LINES__");
|
||||
|
||||
return rb_const_get_at(rb_cObject, script_lines);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
syntax_error_new(void)
|
||||
{
|
||||
return rb_class_new_instance(0, 0, rb_eSyntaxError);
|
||||
}
|
||||
|
||||
static int
|
||||
obj_frozen(VALUE obj)
|
||||
{
|
||||
return (int)RB_OBJ_FROZEN(obj);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
obj_write(VALUE old, VALUE *slot, VALUE young)
|
||||
{
|
||||
return RB_OBJ_WRITE(old, slot, young);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
obj_written(VALUE old, VALUE slot, VALUE young)
|
||||
{
|
||||
return RB_OBJ_WRITTEN(old, slot, young);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
default_rs(void)
|
||||
{
|
||||
return rb_default_rs;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rational_raw1(VALUE x)
|
||||
{
|
||||
return rb_rational_raw1(x);
|
||||
}
|
||||
|
||||
static void *
|
||||
memmove2(void *dest, const void *src, size_t t, size_t n)
|
||||
{
|
||||
return memmove(dest, src, rbimpl_size_mul_or_raise(t, n));
|
||||
}
|
||||
|
||||
static void *
|
||||
nonempty_memcpy(void *dest, const void *src, size_t t, size_t n)
|
||||
{
|
||||
return ruby_nonempty_memcpy(dest, src, rbimpl_size_mul_or_raise(t, n));
|
||||
}
|
||||
|
||||
static VALUE
|
||||
ruby_verbose2(void)
|
||||
{
|
||||
return ruby_verbose;
|
||||
}
|
||||
|
||||
static int
|
||||
type_p(VALUE obj, int t)
|
||||
{
|
||||
return (int)RB_TYPE_P(obj, t);
|
||||
}
|
||||
|
||||
static int
|
||||
fixnum_p(VALUE obj)
|
||||
{
|
||||
return (int)RB_FIXNUM_P(obj);
|
||||
}
|
||||
|
||||
static int
|
||||
symbol_p(VALUE obj)
|
||||
{
|
||||
return (int)RB_SYMBOL_P(obj);
|
||||
}
|
||||
|
||||
static void *
|
||||
zalloc(size_t elemsiz)
|
||||
{
|
||||
return ruby_xcalloc(1, elemsiz);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
new_strterm(VALUE v1, VALUE v2, VALUE v3, VALUE v0, int heredoc)
|
||||
{
|
||||
rb_strterm_t *imemo = (rb_strterm_t *)rb_imemo_new(imemo_parser_strterm, v1, v2, v3, v0);
|
||||
if (heredoc) {
|
||||
imemo->flags |= STRTERM_HEREDOC;
|
||||
}
|
||||
|
||||
return (VALUE)imemo;
|
||||
}
|
||||
|
||||
static int
|
||||
strterm_is_heredoc(VALUE strterm)
|
||||
{
|
||||
return ((rb_strterm_t *)strterm)->flags & STRTERM_HEREDOC;
|
||||
}
|
||||
|
||||
static void
|
||||
gc_guard(VALUE obj)
|
||||
{
|
||||
RB_GC_GUARD(obj);
|
||||
}
|
||||
|
||||
void
|
||||
rb_strterm_mark(VALUE obj)
|
||||
{
|
||||
rb_strterm_t *strterm = (rb_strterm_t*)obj;
|
||||
if (RBASIC(obj)->flags & STRTERM_HEREDOC) {
|
||||
rb_strterm_heredoc_t *heredoc = &strterm->u.heredoc;
|
||||
rb_gc_mark(heredoc->lastline);
|
||||
}
|
||||
}
|
||||
|
||||
static rb_imemo_tmpbuf_t *
|
||||
tmpbuf_parser_heap(void *buf, rb_imemo_tmpbuf_t *old_heap, size_t cnt)
|
||||
{
|
||||
return rb_imemo_tmpbuf_parser_heap(buf, old_heap, cnt);
|
||||
}
|
||||
|
||||
static int
|
||||
special_const_p(VALUE obj)
|
||||
{
|
||||
return (int)RB_SPECIAL_CONST_P(obj);
|
||||
}
|
||||
|
||||
static int
|
||||
builtin_type(VALUE obj)
|
||||
{
|
||||
return (int)RB_BUILTIN_TYPE(obj);
|
||||
}
|
||||
|
||||
static rb_ast_t *
|
||||
ast_new(VALUE nb)
|
||||
{
|
||||
rb_ast_t *ast = (rb_ast_t *)rb_imemo_new(imemo_ast, 0, 0, 0, nb);
|
||||
return ast;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
static_id2sym(ID id)
|
||||
{
|
||||
return (((VALUE)(id)<<RUBY_SPECIAL_SHIFT)|SYMBOL_FLAG);
|
||||
}
|
||||
|
||||
static long
|
||||
str_coderange_scan_restartable(const char *s, const char *e, void *enc, int *cr)
|
||||
{
|
||||
return rb_str_coderange_scan_restartable(s, e, (rb_encoding *)enc, cr);
|
||||
}
|
||||
|
||||
VALUE rb_io_gets_internal(VALUE io);
|
||||
extern VALUE rb_mRubyVMFrozenCore;
|
||||
VALUE rb_node_case_when_optimizable_literal(const NODE *const node);
|
||||
|
||||
void
|
||||
rb_parser_config_initialize(rb_parser_config_t *config)
|
||||
{
|
||||
config->counter = 0;
|
||||
|
||||
config->st_functions.nonempty_memcpy = nonempty_memcpy;
|
||||
|
||||
config->malloc = ruby_xmalloc;
|
||||
config->calloc = ruby_xcalloc;
|
||||
config->realloc = ruby_xrealloc;
|
||||
config->free = ruby_xfree;
|
||||
config->alloc_n = ruby_xmalloc2;
|
||||
config->alloc = ruby_xmalloc;
|
||||
config->realloc_n = ruby_xrealloc2;
|
||||
config->zalloc = zalloc;
|
||||
config->rb_memmove = memmove2;
|
||||
config->nonempty_memcpy = nonempty_memcpy;
|
||||
config->xmalloc_mul_add = rb_xmalloc_mul_add;
|
||||
|
||||
config->new_strterm = new_strterm;
|
||||
config->strterm_is_heredoc = strterm_is_heredoc;
|
||||
config->tmpbuf_auto_free_pointer = rb_imemo_tmpbuf_auto_free_pointer;
|
||||
config->tmpbuf_set_ptr = rb_imemo_tmpbuf_set_ptr;
|
||||
config->tmpbuf_parser_heap = tmpbuf_parser_heap;
|
||||
config->ast_new = ast_new;
|
||||
|
||||
config->compile_callback = rb_suppress_tracing;
|
||||
config->reg_named_capture_assign = reg_named_capture_assign;
|
||||
config->script_lines_defined = script_lines_defined;
|
||||
config->script_lines_get = script_lines_get;
|
||||
|
||||
config->obj_freeze = rb_obj_freeze;
|
||||
config->obj_hide = rb_obj_hide;
|
||||
config->obj_frozen = obj_frozen;
|
||||
config->type_p = type_p;
|
||||
config->obj_freeze_raw = OBJ_FREEZE_RAW;
|
||||
|
||||
config->fixnum_p = fixnum_p;
|
||||
config->symbol_p = symbol_p;
|
||||
|
||||
config->attr_get = rb_attr_get;
|
||||
|
||||
config->ary_new = rb_ary_new;
|
||||
config->ary_push = rb_ary_push;
|
||||
config->ary_new_from_args = rb_ary_new_from_args;
|
||||
config->ary_pop = rb_ary_pop;
|
||||
config->ary_last = rb_ary_last;
|
||||
config->ary_unshift = rb_ary_unshift;
|
||||
config->ary_new2 = rb_ary_new2;
|
||||
config->ary_entry = rb_ary_entry;
|
||||
config->ary_join = rb_ary_join;
|
||||
config->ary_reverse = rb_ary_reverse;
|
||||
config->ary_clear = rb_ary_clear;
|
||||
config->array_len = rb_array_len;
|
||||
config->array_aref = RARRAY_AREF;
|
||||
|
||||
config->sym_intern_ascii_cstr = rb_sym_intern_ascii_cstr;
|
||||
config->make_temporary_id = rb_make_temporary_id;
|
||||
config->is_local_id = is_local_id2;
|
||||
config->is_attrset_id = is_attrset_id2;
|
||||
config->is_global_name_punct = is_global_name_punct;
|
||||
config->id_type = id_type;
|
||||
config->id_attrset = rb_id_attrset;
|
||||
config->intern = rb_intern;
|
||||
config->intern2 = rb_intern2;
|
||||
config->intern3 = intern3;
|
||||
config->intern_str = rb_intern_str;
|
||||
config->is_notop_id = is_notop_id2;
|
||||
config->enc_symname_type = enc_symname_type;
|
||||
config->str_intern = rb_str_intern;
|
||||
config->id2name = rb_id2name;
|
||||
config->id2str = rb_id2str;
|
||||
config->id2sym = rb_id2sym;
|
||||
config->sym2id = rb_sym2id;
|
||||
|
||||
config->str_catf = rb_str_catf;
|
||||
config->str_cat_cstr = rb_str_cat_cstr;
|
||||
config->str_subseq = rb_str_subseq;
|
||||
config->str_dup = rb_str_dup;
|
||||
config->str_new_frozen = rb_str_new_frozen;
|
||||
config->str_buf_new = rb_str_buf_new;
|
||||
config->str_buf_cat = rb_str_buf_cat;
|
||||
config->str_modify = rb_str_modify;
|
||||
config->str_set_len = rb_str_set_len;
|
||||
config->str_cat = rb_str_cat;
|
||||
config->str_resize = rb_str_resize;
|
||||
config->str_new = rb_str_new;
|
||||
config->str_new_cstr = rb_str_new_cstr;
|
||||
config->fstring = rb_fstring;
|
||||
config->is_ascii_string = is_ascii_string2;
|
||||
config->enc_str_new = enc_str_new;
|
||||
config->enc_str_buf_cat = enc_str_buf_cat;
|
||||
config->str_buf_append = rb_str_buf_append;
|
||||
config->str_vcatf = rb_str_vcatf;
|
||||
config->string_value_cstr = rb_string_value_cstr;
|
||||
config->rb_sprintf = rb_sprintf;
|
||||
config->rstring_ptr = RSTRING_PTR;
|
||||
config->rstring_end = RSTRING_END;
|
||||
config->rstring_len = RSTRING_LEN;
|
||||
config->filesystem_str_new_cstr = rb_filesystem_str_new_cstr;
|
||||
config->obj_as_string = rb_obj_as_string;
|
||||
|
||||
config->hash_clear = rb_hash_clear;
|
||||
config->hash_new = rb_hash_new;
|
||||
config->hash_aset = rb_hash_aset;
|
||||
config->hash_lookup = rb_hash_lookup;
|
||||
config->ident_hash_new = rb_ident_hash_new;
|
||||
|
||||
config->int2fix = int2fix;
|
||||
|
||||
config->bignum_negate = bignum_negate;
|
||||
config->big_norm = rb_big_norm;
|
||||
config->int2big = rb_int2big;
|
||||
config->cstr_to_inum = rb_cstr_to_inum;
|
||||
|
||||
config->float_new = rb_float_new;
|
||||
config->float_value = rb_float_value;
|
||||
|
||||
config->fix2int = rb_fix2int;
|
||||
config->num2int = rb_num2int_inline;
|
||||
config->int_positive_pow = rb_int_positive_pow;
|
||||
config->int2num = rb_int2num_inline;
|
||||
config->fix2long = rb_fix2long;
|
||||
|
||||
config->rational_new = rb_rational_new;
|
||||
config->rational_raw = rb_rational_raw;
|
||||
config->rational_raw1 = rational_raw1;
|
||||
config->rational_set_num = rational_set_num;
|
||||
config->rational_get_num = rational_get_num;
|
||||
|
||||
config->complex_raw = rb_complex_raw;
|
||||
config->rcomplex_set_real = rcomplex_set_real;
|
||||
config->rcomplex_set_imag = rcomplex_set_imag;
|
||||
config->rcomplex_get_real = rcomplex_get_real;
|
||||
config->rcomplex_get_imag = rcomplex_get_imag;
|
||||
|
||||
config->stderr_tty_p = rb_stderr_tty_p;
|
||||
config->write_error_str = rb_write_error_str;
|
||||
config->default_rs = default_rs;
|
||||
config->io_write = rb_io_write;
|
||||
config->io_flush = rb_io_flush;
|
||||
config->io_puts = rb_io_puts;
|
||||
config->io_gets_internal= rb_io_gets_internal;
|
||||
|
||||
config->debug_output_stdout = rb_ractor_stdout;
|
||||
config->debug_output_stderr = rb_ractor_stderr;
|
||||
|
||||
config->is_usascii_enc = is_usascii_enc;
|
||||
config->enc_isalnum = enc_isalnum;
|
||||
config->enc_precise_mbclen = enc_precise_mbclen;
|
||||
config->mbclen_charfound_p = mbclen_charfound_p;
|
||||
config->enc_name = enc_name;
|
||||
config->enc_prev_char = enc_prev_char;
|
||||
config->enc_get = enc_get;
|
||||
config->enc_asciicompat = enc_asciicompat;
|
||||
config->utf8_encoding = utf8_encoding;
|
||||
config->enc_associate = enc_associate;
|
||||
config->ascii8bit_encoding = ascii8bit_encoding;
|
||||
config->enc_codelen = enc_codelen;
|
||||
config->enc_mbcput = enc_mbcput;
|
||||
config->char_to_option_kcode = rb_char_to_option_kcode;
|
||||
config->ascii8bit_encindex = rb_ascii8bit_encindex;
|
||||
config->enc_find_index = rb_enc_find_index;
|
||||
config->enc_from_index = enc_from_index;
|
||||
config->enc_associate_index = rb_enc_associate_index;
|
||||
config->enc_isspace = enc_isspace;
|
||||
config->enc_coderange_7bit = ENC_CODERANGE_7BIT;
|
||||
config->enc_coderange_unknown = ENC_CODERANGE_UNKNOWN;
|
||||
config->enc_compatible = enc_compatible;
|
||||
config->enc_from_encoding = enc_from_encoding;
|
||||
config->encoding_get = encoding_get;
|
||||
config->encoding_set = encoding_set;
|
||||
config->encoding_is_ascii8bit = encoding_is_ascii8bit;
|
||||
config->usascii_encoding = usascii_encoding;
|
||||
|
||||
config->ractor_make_shareable = rb_ractor_make_shareable;
|
||||
|
||||
config->vm_keep_script_lines = vm_keep_script_lines;
|
||||
config->local_defined = local_defined;
|
||||
config->dvar_defined = dvar_defined;
|
||||
|
||||
config->literal_cmp = literal_cmp;
|
||||
config->literal_hash = literal_hash;
|
||||
|
||||
config->builtin_class_name = rb_builtin_class_name;
|
||||
config->syntax_error_append = syntax_error_append;
|
||||
config->raise = rb_raise;
|
||||
config->syntax_error_new = syntax_error_new;
|
||||
|
||||
config->errinfo = rb_errinfo;
|
||||
config->set_errinfo = rb_set_errinfo;
|
||||
config->exc_raise = rb_exc_raise;
|
||||
config->make_exception = rb_make_exception;
|
||||
|
||||
config->sized_xfree = ruby_sized_xfree;
|
||||
config->sized_realloc_n = ruby_sized_realloc_n;
|
||||
config->obj_write = obj_write;
|
||||
config->obj_written = obj_written;
|
||||
config->gc_register_mark_object = rb_gc_register_mark_object;
|
||||
config->gc_guard = gc_guard;
|
||||
config->gc_mark = rb_gc_mark;
|
||||
config->gc_mark_movable = rb_gc_mark_movable;
|
||||
config->gc_location = rb_gc_location;
|
||||
|
||||
config->reg_compile = rb_reg_compile;
|
||||
config->reg_check_preprocess = rb_reg_check_preprocess;
|
||||
config->memcicmp = rb_memcicmp;
|
||||
|
||||
config->compile_warn = rb_compile_warn;
|
||||
config->compile_warning = rb_compile_warning;
|
||||
config->bug = rb_bug;
|
||||
config->fatal = rb_fatal;
|
||||
config->verbose = ruby_verbose2;
|
||||
|
||||
config->make_backtrace = rb_make_backtrace;
|
||||
|
||||
config->scan_hex = ruby_scan_hex;
|
||||
config->scan_oct = ruby_scan_oct;
|
||||
config->scan_digits = ruby_scan_digits;
|
||||
config->strtod = ruby_strtod;
|
||||
|
||||
config->isspace = rb_isspace;
|
||||
config->isascii = rb_isascii;
|
||||
config->iscntrl = rb_iscntrl;
|
||||
config->isalpha = rb_isalpha;
|
||||
config->isdigit = rb_isdigit;
|
||||
config->isalnum = rb_isalnum;
|
||||
config->isxdigit = rb_isxdigit;
|
||||
config->strcasecmp = st_locale_insensitive_strcasecmp;
|
||||
config->strncasecmp = st_locale_insensitive_strncasecmp;
|
||||
|
||||
config->rbool = rbool;
|
||||
config->undef_p = undef_p;
|
||||
config->rtest = rtest;
|
||||
config->nil_p = nil_p;
|
||||
config->flonum_p = flonum_p;
|
||||
config->qnil = Qnil;
|
||||
config->qtrue = Qtrue;
|
||||
config->qfalse = Qfalse;
|
||||
config->qundef = Qundef;
|
||||
config->eArgError = rb_eArgError;
|
||||
config->mRubyVMFrozenCore = rb_mRubyVMFrozenCore;
|
||||
config->long2int = rb_long2int;
|
||||
config->special_const_p = special_const_p;
|
||||
config->builtin_type = builtin_type;
|
||||
config->snprintf = snprintf;
|
||||
|
||||
config->node_case_when_optimizable_literal = rb_node_case_when_optimizable_literal;
|
||||
|
||||
/* For Ripper */
|
||||
config->static_id2sym = static_id2sym;
|
||||
config->str_coderange_scan_restartable = str_coderange_scan_restartable;
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_parser_new(void)
|
||||
{
|
||||
struct ruby_parser *parser;
|
||||
rb_parser_config_t *config;
|
||||
rb_parser_t *parser_params;
|
||||
|
||||
config = rb_ruby_parser_config_new(ruby_xmalloc);
|
||||
rb_parser_config_initialize(config);
|
||||
|
||||
/*
|
||||
* Create parser_params ahead of vparser because
|
||||
* rb_ruby_parser_new can run GC so if create vparser
|
||||
* first, parser_mark tries to mark not initialized parser_params.
|
||||
*/
|
||||
parser_params = rb_ruby_parser_new(config);
|
||||
VALUE vparser = TypedData_Make_Struct(0, struct ruby_parser,
|
||||
&ruby_parser_data_type, parser);
|
||||
parser->parser_params = parser_params;
|
||||
|
||||
return vparser;
|
||||
}
|
||||
|
||||
void
|
||||
rb_parser_set_options(VALUE vparser, int print, int loop, int chomp, int split)
|
||||
{
|
||||
struct ruby_parser *parser;
|
||||
|
||||
TypedData_Get_Struct(vparser, struct ruby_parser, &ruby_parser_data_type, parser);
|
||||
rb_ruby_parser_set_options(parser->parser_params, print, loop, chomp, split);
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_parser_set_context(VALUE vparser, const struct rb_iseq_struct *base, int main)
|
||||
{
|
||||
struct ruby_parser *parser;
|
||||
|
||||
TypedData_Get_Struct(vparser, struct ruby_parser, &ruby_parser_data_type, parser);
|
||||
rb_ruby_parser_set_context(parser->parser_params, base, main);
|
||||
return vparser;
|
||||
}
|
||||
|
||||
void
|
||||
rb_parser_keep_script_lines(VALUE vparser)
|
||||
{
|
||||
struct ruby_parser *parser;
|
||||
|
||||
TypedData_Get_Struct(vparser, struct ruby_parser, &ruby_parser_data_type, parser);
|
||||
rb_ruby_parser_keep_script_lines(parser->parser_params);
|
||||
}
|
||||
|
||||
void
|
||||
rb_parser_error_tolerant(VALUE vparser)
|
||||
{
|
||||
struct ruby_parser *parser;
|
||||
|
||||
TypedData_Get_Struct(vparser, struct ruby_parser, &ruby_parser_data_type, parser);
|
||||
rb_ruby_parser_error_tolerant(parser->parser_params);
|
||||
}
|
||||
|
||||
rb_ast_t*
|
||||
rb_parser_compile_file_path(VALUE vparser, VALUE fname, VALUE file, int start)
|
||||
{
|
||||
struct ruby_parser *parser;
|
||||
rb_ast_t *ast;
|
||||
|
||||
TypedData_Get_Struct(vparser, struct ruby_parser, &ruby_parser_data_type, parser);
|
||||
ast = rb_ruby_parser_compile_file_path(parser->parser_params, fname, file, start);
|
||||
RB_GC_GUARD(vparser);
|
||||
|
||||
return ast;
|
||||
}
|
||||
|
||||
void
|
||||
rb_parser_keep_tokens(VALUE vparser)
|
||||
{
|
||||
struct ruby_parser *parser;
|
||||
|
||||
TypedData_Get_Struct(vparser, struct ruby_parser, &ruby_parser_data_type, parser);
|
||||
rb_ruby_parser_keep_tokens(parser->parser_params);
|
||||
}
|
||||
|
||||
rb_ast_t*
|
||||
rb_parser_compile_generic(VALUE vparser, VALUE (*lex_gets)(VALUE, int), VALUE fname, VALUE input, int start)
|
||||
{
|
||||
struct ruby_parser *parser;
|
||||
rb_ast_t *ast;
|
||||
|
||||
TypedData_Get_Struct(vparser, struct ruby_parser, &ruby_parser_data_type, parser);
|
||||
ast = rb_ruby_parser_compile_generic(parser->parser_params, lex_gets, fname, input, start);
|
||||
RB_GC_GUARD(vparser);
|
||||
|
||||
return ast;
|
||||
}
|
||||
|
||||
rb_ast_t*
|
||||
rb_parser_compile_string(VALUE vparser, const char *f, VALUE s, int line)
|
||||
{
|
||||
struct ruby_parser *parser;
|
||||
rb_ast_t *ast;
|
||||
|
||||
TypedData_Get_Struct(vparser, struct ruby_parser, &ruby_parser_data_type, parser);
|
||||
ast = rb_ruby_parser_compile_string(parser->parser_params, f, s, line);
|
||||
RB_GC_GUARD(vparser);
|
||||
|
||||
return ast;
|
||||
}
|
||||
|
||||
rb_ast_t*
|
||||
rb_parser_compile_string_path(VALUE vparser, VALUE f, VALUE s, int line)
|
||||
{
|
||||
struct ruby_parser *parser;
|
||||
rb_ast_t *ast;
|
||||
|
||||
TypedData_Get_Struct(vparser, struct ruby_parser, &ruby_parser_data_type, parser);
|
||||
ast = rb_ruby_parser_compile_string_path(parser->parser_params, f, s, line);
|
||||
RB_GC_GUARD(vparser);
|
||||
|
||||
return ast;
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_parser_encoding(VALUE vparser)
|
||||
{
|
||||
struct ruby_parser *parser;
|
||||
|
||||
TypedData_Get_Struct(vparser, struct ruby_parser, &ruby_parser_data_type, parser);
|
||||
return rb_ruby_parser_encoding(parser->parser_params);
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_parser_end_seen_p(VALUE vparser)
|
||||
{
|
||||
struct ruby_parser *parser;
|
||||
|
||||
TypedData_Get_Struct(vparser, struct ruby_parser, &ruby_parser_data_type, parser);
|
||||
return RBOOL(rb_ruby_parser_end_seen_p(parser->parser_params));
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_parser_set_yydebug(VALUE vparser, VALUE flag)
|
||||
{
|
||||
struct ruby_parser *parser;
|
||||
|
||||
TypedData_Get_Struct(vparser, struct ruby_parser, &ruby_parser_data_type, parser);
|
||||
rb_ruby_parser_set_yydebug(parser->parser_params, RTEST(flag));
|
||||
return flag;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/* For "ISO C requires a translation unit to contain at least one declaration" */
|
||||
void
|
||||
rb_parser_dummy(void)
|
||||
{}
|
||||
#endif
|
|
@ -0,0 +1,642 @@
|
|||
#ifndef RUBY_RUBYPARSER_H
|
||||
#define RUBY_RUBYPARSER_H 1
|
||||
/*
|
||||
* This is a header file for librubyparser interface
|
||||
*/
|
||||
|
||||
#ifdef UNIVERSAL_PARSER
|
||||
|
||||
#define rb_encoding void
|
||||
#define OnigCodePoint unsigned int
|
||||
#include "parser_st.h"
|
||||
#include "parser_value.h"
|
||||
|
||||
#else
|
||||
|
||||
#include "ruby/encoding.h"
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* AST Node
|
||||
*/
|
||||
enum node_type {
|
||||
NODE_SCOPE,
|
||||
NODE_BLOCK,
|
||||
NODE_IF,
|
||||
NODE_UNLESS,
|
||||
NODE_CASE,
|
||||
NODE_CASE2,
|
||||
NODE_CASE3,
|
||||
NODE_WHEN,
|
||||
NODE_IN,
|
||||
NODE_WHILE,
|
||||
NODE_UNTIL,
|
||||
NODE_ITER,
|
||||
NODE_FOR,
|
||||
NODE_FOR_MASGN,
|
||||
NODE_BREAK,
|
||||
NODE_NEXT,
|
||||
NODE_REDO,
|
||||
NODE_RETRY,
|
||||
NODE_BEGIN,
|
||||
NODE_RESCUE,
|
||||
NODE_RESBODY,
|
||||
NODE_ENSURE,
|
||||
NODE_AND,
|
||||
NODE_OR,
|
||||
NODE_MASGN,
|
||||
NODE_LASGN,
|
||||
NODE_DASGN,
|
||||
NODE_GASGN,
|
||||
NODE_IASGN,
|
||||
NODE_CDECL,
|
||||
NODE_CVASGN,
|
||||
NODE_OP_ASGN1,
|
||||
NODE_OP_ASGN2,
|
||||
NODE_OP_ASGN_AND,
|
||||
NODE_OP_ASGN_OR,
|
||||
NODE_OP_CDECL,
|
||||
NODE_CALL,
|
||||
NODE_OPCALL,
|
||||
NODE_FCALL,
|
||||
NODE_VCALL,
|
||||
NODE_QCALL,
|
||||
NODE_SUPER,
|
||||
NODE_ZSUPER,
|
||||
NODE_LIST,
|
||||
NODE_ZLIST,
|
||||
NODE_VALUES,
|
||||
NODE_HASH,
|
||||
NODE_RETURN,
|
||||
NODE_YIELD,
|
||||
NODE_LVAR,
|
||||
NODE_DVAR,
|
||||
NODE_GVAR,
|
||||
NODE_IVAR,
|
||||
NODE_CONST,
|
||||
NODE_CVAR,
|
||||
NODE_NTH_REF,
|
||||
NODE_BACK_REF,
|
||||
NODE_MATCH,
|
||||
NODE_MATCH2,
|
||||
NODE_MATCH3,
|
||||
NODE_LIT,
|
||||
NODE_STR,
|
||||
NODE_DSTR,
|
||||
NODE_XSTR,
|
||||
NODE_DXSTR,
|
||||
NODE_EVSTR,
|
||||
NODE_DREGX,
|
||||
NODE_ONCE,
|
||||
NODE_ARGS,
|
||||
NODE_ARGS_AUX,
|
||||
NODE_OPT_ARG,
|
||||
NODE_KW_ARG,
|
||||
NODE_POSTARG,
|
||||
NODE_ARGSCAT,
|
||||
NODE_ARGSPUSH,
|
||||
NODE_SPLAT,
|
||||
NODE_BLOCK_PASS,
|
||||
NODE_DEFN,
|
||||
NODE_DEFS,
|
||||
NODE_ALIAS,
|
||||
NODE_VALIAS,
|
||||
NODE_UNDEF,
|
||||
NODE_CLASS,
|
||||
NODE_MODULE,
|
||||
NODE_SCLASS,
|
||||
NODE_COLON2,
|
||||
NODE_COLON3,
|
||||
NODE_DOT2,
|
||||
NODE_DOT3,
|
||||
NODE_FLIP2,
|
||||
NODE_FLIP3,
|
||||
NODE_SELF,
|
||||
NODE_NIL,
|
||||
NODE_TRUE,
|
||||
NODE_FALSE,
|
||||
NODE_ERRINFO,
|
||||
NODE_DEFINED,
|
||||
NODE_POSTEXE,
|
||||
NODE_DSYM,
|
||||
NODE_ATTRASGN,
|
||||
NODE_LAMBDA,
|
||||
NODE_ARYPTN,
|
||||
NODE_HSHPTN,
|
||||
NODE_FNDPTN,
|
||||
NODE_ERROR,
|
||||
NODE_LAST
|
||||
};
|
||||
|
||||
|
||||
#define nd_head u1.node
|
||||
#define nd_alen u2.argc
|
||||
#define nd_next u3.node
|
||||
|
||||
#define nd_cond u1.node
|
||||
#define nd_body u2.node
|
||||
#define nd_else u3.node
|
||||
|
||||
#define nd_resq u2.node
|
||||
#define nd_ensr u3.node
|
||||
|
||||
#define nd_1st u1.node
|
||||
#define nd_2nd u2.node
|
||||
|
||||
#define nd_stts u1.node
|
||||
|
||||
#define nd_entry u3.id
|
||||
#define nd_vid u1.id
|
||||
|
||||
#define nd_var u1.node
|
||||
#define nd_iter u3.node
|
||||
|
||||
#define nd_value u2.node
|
||||
#define nd_aid u3.id
|
||||
|
||||
#define nd_lit u1.value
|
||||
|
||||
#define nd_recv u1.node
|
||||
#define nd_mid u2.id
|
||||
#define nd_args u3.node
|
||||
#define nd_ainfo u3.args
|
||||
|
||||
#define nd_defn u3.node
|
||||
|
||||
#define nd_cpath u1.node
|
||||
#define nd_super u3.node
|
||||
|
||||
#define nd_beg u1.node
|
||||
#define nd_end u2.node
|
||||
#define nd_state u3.state
|
||||
|
||||
#define nd_nth u2.argc
|
||||
|
||||
#define nd_alias u1.id
|
||||
#define nd_orig u2.id
|
||||
#define nd_undef u2.node
|
||||
|
||||
#define nd_brace u2.argc
|
||||
|
||||
#define nd_pconst u1.node
|
||||
#define nd_pkwargs u2.node
|
||||
#define nd_pkwrestarg u3.node
|
||||
|
||||
#define nd_apinfo u3.apinfo
|
||||
|
||||
#define nd_fpinfo u3.fpinfo
|
||||
|
||||
// for NODE_SCOPE
|
||||
#define nd_tbl u1.tbl
|
||||
|
||||
// for NODE_ARGS_AUX
|
||||
#define nd_pid u1.id
|
||||
#define nd_plen u2.argc
|
||||
#define nd_cflag u2.id
|
||||
|
||||
// for ripper
|
||||
#define nd_cval u3.value
|
||||
#define nd_rval u2.value
|
||||
#define nd_tag u1.id
|
||||
|
||||
#ifndef FLEX_ARY_LEN
|
||||
/* From internal/compilers.h */
|
||||
/* A macro for defining a flexible array, like: VALUE ary[FLEX_ARY_LEN]; */
|
||||
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
|
||||
# define FLEX_ARY_LEN /* VALUE ary[]; */
|
||||
#elif defined(__GNUC__) && !defined(__STRICT_ANSI__)
|
||||
# define FLEX_ARY_LEN 0 /* VALUE ary[0]; */
|
||||
#else
|
||||
# define FLEX_ARY_LEN 1 /* VALUE ary[1]; */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef struct rb_ast_id_table {
|
||||
int size;
|
||||
ID ids[FLEX_ARY_LEN];
|
||||
} rb_ast_id_table_t;
|
||||
|
||||
typedef struct rb_code_position_struct {
|
||||
int lineno;
|
||||
int column;
|
||||
} rb_code_position_t;
|
||||
|
||||
typedef struct rb_code_location_struct {
|
||||
rb_code_position_t beg_pos;
|
||||
rb_code_position_t end_pos;
|
||||
} rb_code_location_t;
|
||||
|
||||
typedef struct RNode {
|
||||
VALUE flags;
|
||||
union {
|
||||
struct RNode *node;
|
||||
ID id;
|
||||
VALUE value;
|
||||
rb_ast_id_table_t *tbl;
|
||||
} u1;
|
||||
union {
|
||||
struct RNode *node;
|
||||
ID id;
|
||||
long argc;
|
||||
VALUE value;
|
||||
} u2;
|
||||
union {
|
||||
struct RNode *node;
|
||||
ID id;
|
||||
long state;
|
||||
struct rb_args_info *args;
|
||||
struct rb_ary_pattern_info *apinfo;
|
||||
struct rb_fnd_pattern_info *fpinfo;
|
||||
VALUE value;
|
||||
} u3;
|
||||
rb_code_location_t nd_loc;
|
||||
int node_id;
|
||||
} NODE;
|
||||
|
||||
/* FL : 0..4: T_TYPES, 5: KEEP_WB, 6: PROMOTED, 7: FINALIZE, 8: UNUSED, 9: UNUSED, 10: EXIVAR, 11: FREEZE */
|
||||
/* NODE_FL: 0..4: T_TYPES, 5: KEEP_WB, 6: PROMOTED, 7: NODE_FL_NEWLINE,
|
||||
* 8..14: nd_type,
|
||||
* 15..: nd_line
|
||||
*/
|
||||
#define NODE_FL_NEWLINE (((VALUE)1)<<7)
|
||||
|
||||
#define NODE_TYPESHIFT 8
|
||||
#define NODE_TYPEMASK (((VALUE)0x7f)<<NODE_TYPESHIFT)
|
||||
|
||||
#define nd_type(n) ((int) (((n)->flags & NODE_TYPEMASK)>>NODE_TYPESHIFT))
|
||||
#define nd_set_type(n,t) \
|
||||
rb_node_set_type(n, t)
|
||||
#define nd_init_type(n,t) \
|
||||
(n)->flags=(((n)->flags&~NODE_TYPEMASK)|((((unsigned long)(t))<<NODE_TYPESHIFT)&NODE_TYPEMASK))
|
||||
|
||||
struct rb_args_info {
|
||||
NODE *pre_init;
|
||||
NODE *post_init;
|
||||
|
||||
int pre_args_num; /* count of mandatory pre-arguments */
|
||||
int post_args_num; /* count of mandatory post-arguments */
|
||||
|
||||
ID first_post_arg;
|
||||
|
||||
ID rest_arg;
|
||||
ID block_arg;
|
||||
|
||||
NODE *kw_args;
|
||||
NODE *kw_rest_arg;
|
||||
|
||||
NODE *opt_args;
|
||||
unsigned int no_kwarg: 1;
|
||||
unsigned int ruby2_keywords: 1;
|
||||
unsigned int forwarding: 1;
|
||||
|
||||
VALUE imemo;
|
||||
};
|
||||
|
||||
struct rb_ary_pattern_info {
|
||||
NODE *pre_args;
|
||||
NODE *rest_arg;
|
||||
NODE *post_args;
|
||||
};
|
||||
|
||||
struct rb_fnd_pattern_info {
|
||||
NODE *pre_rest_arg;
|
||||
NODE *args;
|
||||
NODE *post_rest_arg;
|
||||
};
|
||||
|
||||
typedef struct node_buffer_struct node_buffer_t;
|
||||
/* T_IMEMO/ast */
|
||||
typedef struct rb_ast_body_struct {
|
||||
const NODE *root;
|
||||
VALUE compile_option;
|
||||
VALUE script_lines;
|
||||
// script_lines is either:
|
||||
// - a Fixnum that represents the line count of the original source, or
|
||||
// - an Array that contains the lines of the original source
|
||||
} rb_ast_body_t;
|
||||
typedef struct rb_ast_struct {
|
||||
VALUE flags;
|
||||
node_buffer_t *node_buffer;
|
||||
rb_ast_body_t body;
|
||||
} rb_ast_t;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Parser Interface
|
||||
*/
|
||||
|
||||
typedef struct parser_params rb_parser_t;
|
||||
typedef struct rb_imemo_tmpbuf_struct rb_imemo_tmpbuf_t;
|
||||
|
||||
#ifdef UNIVERSAL_PARSER
|
||||
typedef struct rb_parser_config_struct {
|
||||
/*
|
||||
* Reference counter.
|
||||
* This is needed because both parser and ast refer
|
||||
* same config pointer.
|
||||
* We can remove this, once decuple parser and ast from Ruby GC.
|
||||
*/
|
||||
int counter;
|
||||
|
||||
/* For parser_st */
|
||||
st_functions_t st_functions;
|
||||
|
||||
/* Memory */
|
||||
void *(*malloc)(size_t size);
|
||||
void *(*calloc)(size_t number, size_t size);
|
||||
void *(*realloc)(void *ptr, size_t newsiz);
|
||||
void (*free)(void *ptr);
|
||||
void *(*alloc_n)(size_t nelems, size_t elemsiz);
|
||||
void *(*alloc)(size_t elemsiz);
|
||||
void *(*realloc_n)(void *ptr, size_t newelems, size_t newsiz);
|
||||
void *(*zalloc)(size_t elemsiz);
|
||||
void *(*rb_memmove)(void *dest, const void *src, size_t t, size_t n);
|
||||
void *(*nonempty_memcpy)(void *dest, const void *src, size_t t, size_t n);
|
||||
void *(*xmalloc_mul_add)(size_t x, size_t y, size_t z);
|
||||
|
||||
/* imemo */
|
||||
// TODO: Should it return `rb_strterm_t *'?
|
||||
VALUE (*new_strterm)(VALUE v1, VALUE v2, VALUE v3, VALUE v0, int heredoc);
|
||||
int (*strterm_is_heredoc)(VALUE strterm);
|
||||
VALUE (*tmpbuf_auto_free_pointer)(void);
|
||||
void *(*tmpbuf_set_ptr)(VALUE v, void *ptr);
|
||||
rb_imemo_tmpbuf_t *(*tmpbuf_parser_heap)(void *buf, rb_imemo_tmpbuf_t *old_heap, size_t cnt);
|
||||
rb_ast_t *(*ast_new)(VALUE nb);
|
||||
|
||||
// VALUE rb_suppress_tracing(VALUE (*func)(VALUE), VALUE arg);
|
||||
VALUE (*compile_callback)(VALUE (*func)(VALUE), VALUE arg);
|
||||
NODE *(*reg_named_capture_assign)(struct parser_params* p, VALUE regexp, const rb_code_location_t *loc);
|
||||
int (*script_lines_defined)(void);
|
||||
VALUE (*script_lines_get)(void);
|
||||
|
||||
/* Object */
|
||||
VALUE (*obj_freeze)(VALUE obj);
|
||||
VALUE (*obj_hide)(VALUE obj);
|
||||
int (*obj_frozen)(VALUE obj);
|
||||
int (*type_p)(VALUE, int);
|
||||
void (*obj_freeze_raw)(VALUE obj);
|
||||
|
||||
int (*fixnum_p)(VALUE);
|
||||
int (*symbol_p)(VALUE);
|
||||
|
||||
/* Variable */
|
||||
VALUE (*attr_get)(VALUE obj, ID id);
|
||||
|
||||
/* Array */
|
||||
VALUE (*ary_new)(void);
|
||||
VALUE (*ary_push)(VALUE ary, VALUE elem);
|
||||
VALUE (*ary_new_from_args)(long n, ...);
|
||||
VALUE (*ary_pop)(VALUE ary);
|
||||
VALUE (*ary_last)(int argc, const VALUE *argv, VALUE ary);
|
||||
VALUE (*ary_unshift)(VALUE ary, VALUE item);
|
||||
VALUE (*ary_new2)(long capa); // ary_new_capa
|
||||
VALUE (*ary_entry)(VALUE ary, long offset);
|
||||
VALUE (*ary_join)(VALUE ary, VALUE sep);
|
||||
VALUE (*ary_reverse)(VALUE ary);
|
||||
VALUE (*ary_clear)(VALUE ary);
|
||||
long (*array_len)(VALUE a);
|
||||
VALUE (*array_aref)(VALUE, long);
|
||||
|
||||
/* Symbol */
|
||||
VALUE (*sym_intern_ascii_cstr)(const char *ptr);
|
||||
ID (*make_temporary_id)(size_t n);
|
||||
int (*is_local_id)(ID);
|
||||
int (*is_attrset_id)(ID);
|
||||
int (*is_global_name_punct)(const int c);
|
||||
int (*id_type)(ID id);
|
||||
ID (*id_attrset)(ID);
|
||||
ID (*intern)(const char *name);
|
||||
ID (*intern2)(const char *name, long len);
|
||||
ID (*intern3)(const char *name, long len, rb_encoding *enc);
|
||||
ID (*intern_str)(VALUE str);
|
||||
int (*is_notop_id)(ID);
|
||||
int (*enc_symname_type)(const char *name, long len, rb_encoding *enc, unsigned int allowed_attrset);
|
||||
VALUE (*str_intern)(VALUE str);
|
||||
const char *(*id2name)(ID id);
|
||||
VALUE (*id2str)(ID id);
|
||||
VALUE (*id2sym)(ID x);
|
||||
ID (*sym2id)(VALUE sym);
|
||||
|
||||
/* String */
|
||||
VALUE (*str_catf)(VALUE str, const char *format, ...);
|
||||
VALUE (*str_cat_cstr)(VALUE str, const char *ptr);
|
||||
VALUE (*str_subseq)(VALUE str, long beg, long len);
|
||||
VALUE (*str_dup)(VALUE str);
|
||||
VALUE (*str_new_frozen)(VALUE orig);
|
||||
VALUE (*str_buf_new)(long capa);
|
||||
VALUE (*str_buf_cat)(VALUE, const char*, long);
|
||||
void (*str_modify)(VALUE str);
|
||||
void (*str_set_len)(VALUE str, long len);
|
||||
VALUE (*str_cat)(VALUE str, const char *ptr, long len);
|
||||
VALUE (*str_resize)(VALUE str, long len);
|
||||
VALUE (*str_new)(const char *ptr, long len);
|
||||
VALUE (*str_new_cstr)(const char *ptr);
|
||||
VALUE (*fstring)(VALUE);
|
||||
int (*is_ascii_string)(VALUE str);
|
||||
VALUE (*enc_str_new)(const char *ptr, long len, rb_encoding *enc);
|
||||
VALUE (*enc_str_buf_cat)(VALUE str, const char *ptr, long len, rb_encoding *enc);
|
||||
VALUE (*str_buf_append)(VALUE str, VALUE str2);
|
||||
VALUE (*str_vcatf)(VALUE str, const char *fmt, va_list ap);
|
||||
char *(*string_value_cstr)(volatile VALUE *ptr);
|
||||
VALUE (*rb_sprintf)(const char *format, ...);
|
||||
char *(*rstring_ptr)(VALUE str);
|
||||
char *(*rstring_end)(VALUE str);
|
||||
long (*rstring_len)(VALUE str);
|
||||
VALUE (*filesystem_str_new_cstr)(const char *ptr);
|
||||
VALUE (*obj_as_string)(VALUE);
|
||||
|
||||
/* Hash */
|
||||
VALUE (*hash_clear)(VALUE hash);
|
||||
VALUE (*hash_new)(void);
|
||||
VALUE (*hash_aset)(VALUE hash, VALUE key, VALUE val);
|
||||
VALUE (*hash_lookup)(VALUE hash, VALUE key);
|
||||
VALUE (*ident_hash_new)(void);
|
||||
|
||||
/* Fixnum */
|
||||
VALUE (*int2fix)(long i);
|
||||
|
||||
/* Bignum */
|
||||
void (*bignum_negate)(VALUE b);
|
||||
VALUE (*big_norm)(VALUE x);
|
||||
VALUE (*int2big)(intptr_t n);
|
||||
VALUE (*cstr_to_inum)(const char *str, int base, int badcheck);
|
||||
|
||||
/* Float */
|
||||
VALUE (*float_new)(double d);
|
||||
double (*float_value)(VALUE v);
|
||||
|
||||
/* Numeric */
|
||||
long (*fix2int)(VALUE val);
|
||||
int (*num2int)(VALUE val);
|
||||
VALUE (*int_positive_pow)(long x, unsigned long y);
|
||||
VALUE (*int2num)(int v);
|
||||
long (*fix2long)(VALUE val);
|
||||
|
||||
/* Rational */
|
||||
VALUE (*rational_new)(VALUE x, VALUE y);
|
||||
VALUE (*rational_raw)(VALUE x, VALUE y);
|
||||
VALUE (*rational_raw1)(VALUE x);
|
||||
void (*rational_set_num)(VALUE r, VALUE n);
|
||||
VALUE (*rational_get_num)(VALUE obj);
|
||||
|
||||
/* Complex */
|
||||
VALUE (*complex_raw)(VALUE x, VALUE y);
|
||||
void (*rcomplex_set_real)(VALUE cmp, VALUE r);
|
||||
void (*rcomplex_set_imag)(VALUE cmp, VALUE i);
|
||||
VALUE (*rcomplex_get_real)(VALUE obj);
|
||||
VALUE (*rcomplex_get_imag)(VALUE obj);
|
||||
|
||||
/* IO */
|
||||
int (*stderr_tty_p)(void);
|
||||
void (*write_error_str)(VALUE mesg);
|
||||
VALUE (*default_rs)(void);
|
||||
VALUE (*io_write)(VALUE io, VALUE str);
|
||||
VALUE (*io_flush)(VALUE io);
|
||||
VALUE (*io_puts)(int argc, const VALUE *argv, VALUE out);
|
||||
VALUE (*io_gets_internal)(VALUE io);
|
||||
|
||||
/* IO (Ractor) */
|
||||
VALUE (*debug_output_stdout)(void);
|
||||
VALUE (*debug_output_stderr)(void);
|
||||
|
||||
/* Encoding */
|
||||
int (*is_usascii_enc)(rb_encoding *enc);
|
||||
int (*enc_isalnum)(OnigCodePoint c, rb_encoding *enc);
|
||||
int (*enc_precise_mbclen)(const char *p, const char *e, rb_encoding *enc);
|
||||
int (*mbclen_charfound_p)(int len);
|
||||
const char *(*enc_name)(rb_encoding *enc);
|
||||
char *(*enc_prev_char)(const char *s, const char *p, const char *e, rb_encoding *enc);
|
||||
rb_encoding* (*enc_get)(VALUE obj);
|
||||
int (*enc_asciicompat)(rb_encoding *enc);
|
||||
rb_encoding *(*utf8_encoding)(void);
|
||||
VALUE (*enc_associate)(VALUE obj, rb_encoding *enc);
|
||||
rb_encoding *(*ascii8bit_encoding)(void);
|
||||
int (*enc_codelen)(int c, rb_encoding *enc);
|
||||
int (*enc_mbcput)(unsigned int c, void *buf, rb_encoding *enc);
|
||||
int (*char_to_option_kcode)(int c, int *option, int *kcode);
|
||||
int (*ascii8bit_encindex)(void);
|
||||
int (*enc_find_index)(const char *name);
|
||||
rb_encoding *(*enc_from_index)(int idx);
|
||||
VALUE (*enc_associate_index)(VALUE obj, int encindex);
|
||||
int (*enc_isspace)(OnigCodePoint c, rb_encoding *enc);
|
||||
int enc_coderange_7bit;
|
||||
int enc_coderange_unknown;
|
||||
rb_encoding *(*enc_compatible)(VALUE str1, VALUE str2);
|
||||
VALUE (*enc_from_encoding)(rb_encoding *enc);
|
||||
int (*encoding_get)(VALUE obj);
|
||||
void (*encoding_set)(VALUE obj, int encindex);
|
||||
int (*encoding_is_ascii8bit)(VALUE obj);
|
||||
rb_encoding *(*usascii_encoding)(void);
|
||||
|
||||
/* Ractor */
|
||||
VALUE (*ractor_make_shareable)(VALUE obj);
|
||||
|
||||
/* Compile */
|
||||
int (*vm_keep_script_lines)(void);
|
||||
// int rb_local_defined(ID id, const rb_iseq_t *iseq);
|
||||
int (*local_defined)(ID, const void*);
|
||||
// int rb_dvar_defined(ID id, const rb_iseq_t *iseq);
|
||||
int (*dvar_defined)(ID, const void*);
|
||||
|
||||
/* Compile (parse.y) */
|
||||
int (*literal_cmp)(VALUE val, VALUE lit);
|
||||
parser_st_index_t (*literal_hash)(VALUE a);
|
||||
|
||||
/* Error (Exception) */
|
||||
const char *(*builtin_class_name)(VALUE x);
|
||||
VALUE (*syntax_error_append)(VALUE, VALUE, int, int, rb_encoding*, const char*, va_list);
|
||||
void (*raise)(VALUE exc, const char *fmt, ...);
|
||||
VALUE (*syntax_error_new)(void);
|
||||
|
||||
/* Eval */
|
||||
VALUE (*errinfo)(void);
|
||||
void (*set_errinfo)(VALUE err);
|
||||
void (*exc_raise)(VALUE mesg);
|
||||
VALUE (*make_exception)(int argc, const VALUE *argv);
|
||||
|
||||
/* GC */
|
||||
void (*sized_xfree)(void *x, size_t size);
|
||||
void *(*sized_realloc_n)(void *ptr, size_t new_count, size_t element_size, size_t old_count);
|
||||
VALUE (*obj_write)(VALUE, VALUE *, VALUE);
|
||||
VALUE (*obj_written)(VALUE, VALUE, VALUE);
|
||||
void (*gc_register_mark_object)(VALUE object);
|
||||
void (*gc_guard)(VALUE);
|
||||
void (*gc_mark)(VALUE);
|
||||
void (*gc_mark_movable)(VALUE ptr);
|
||||
VALUE (*gc_location)(VALUE value);
|
||||
|
||||
/* Re */
|
||||
VALUE (*reg_compile)(VALUE str, int options, const char *sourcefile, int sourceline);
|
||||
VALUE (*reg_check_preprocess)(VALUE str);
|
||||
int (*memcicmp)(const void *x, const void *y, long len);
|
||||
|
||||
/* Error */
|
||||
void (*compile_warn)(const char *file, int line, const char *fmt, ...);
|
||||
void (*compile_warning)(const char *file, int line, const char *fmt, ...);
|
||||
void (*bug)(const char *fmt, ...);
|
||||
void (*fatal)(const char *fmt, ...);
|
||||
VALUE (*verbose)(void);
|
||||
|
||||
/* VM */
|
||||
VALUE (*make_backtrace)(void);
|
||||
|
||||
/* Util */
|
||||
unsigned long (*scan_hex)(const char *start, size_t len, size_t *retlen);
|
||||
unsigned long (*scan_oct)(const char *start, size_t len, size_t *retlen);
|
||||
unsigned long (*scan_digits)(const char *str, ssize_t len, int base, size_t *retlen, int *overflow);
|
||||
double (*strtod)(const char *s00, char **se);
|
||||
|
||||
/* ctype */
|
||||
int (*isspace)(int c);
|
||||
int (*isascii)(int c);
|
||||
int (*iscntrl)(int c);
|
||||
int (*isalpha)(int c);
|
||||
int (*isdigit)(int c);
|
||||
int (*isalnum)(int c);
|
||||
int (*isxdigit)(int c);
|
||||
int (*strcasecmp)(const char *s1, const char *s2);
|
||||
int (*strncasecmp)(const char *s1, const char *s2, size_t n);
|
||||
|
||||
/* Misc */
|
||||
VALUE (*rbool)(VALUE);
|
||||
int (*undef_p)(VALUE);
|
||||
int (*rtest)(VALUE obj);
|
||||
int (*nil_p)(VALUE obj);
|
||||
int (*flonum_p)(VALUE obj);
|
||||
VALUE qnil;
|
||||
VALUE qtrue;
|
||||
VALUE qfalse;
|
||||
VALUE qundef;
|
||||
VALUE eArgError;
|
||||
VALUE mRubyVMFrozenCore;
|
||||
int (*long2int)(long);
|
||||
int (*special_const_p)(VALUE);
|
||||
int (*builtin_type)(VALUE);
|
||||
int (*snprintf)(char *str, size_t n, char const *fmt, ...);
|
||||
|
||||
VALUE (*node_case_when_optimizable_literal)(const NODE *const node);
|
||||
|
||||
/* For Ripper */
|
||||
VALUE (*static_id2sym)(ID id);
|
||||
long (*str_coderange_scan_restartable)(const char *s, const char *e, rb_encoding *enc, int *cr);
|
||||
} rb_parser_config_t;
|
||||
|
||||
#undef rb_encoding
|
||||
#undef OnigCodePoint
|
||||
#endif /* UNIVERSAL_PARSER */
|
||||
|
||||
RUBY_SYMBOL_EXPORT_BEGIN
|
||||
void rb_ruby_parser_free(void *ptr);
|
||||
rb_ast_t* rb_ruby_parser_compile_string(rb_parser_t *p, const char *f, VALUE s, int line);
|
||||
|
||||
#ifdef UNIVERSAL_PARSER
|
||||
rb_parser_config_t *rb_ruby_parser_config_new(void *(*malloc)(size_t size));
|
||||
void rb_ruby_parser_config_free(rb_parser_config_t *config);
|
||||
rb_parser_t *rb_ruby_parser_allocate(rb_parser_config_t *config);
|
||||
rb_parser_t *rb_ruby_parser_new(rb_parser_config_t *config);
|
||||
#endif
|
||||
RUBY_SYMBOL_EXPORT_END
|
||||
|
||||
#endif /* RUBY_RUBYPARSER_H */
|
|
@ -86,6 +86,7 @@ Prelude.new(output, ARGV, vpath).instance_eval do
|
|||
*/
|
||||
%unless @preludes.empty?
|
||||
#include "internal.h"
|
||||
#include "internal/ruby_parser.h"
|
||||
#include "internal/warnings.h"
|
||||
#include "iseq.h"
|
||||
#include "ruby/ruby.h"
|
||||
|
|
|
@ -111,6 +111,7 @@ FILES_NEED_VPATH = %w[
|
|||
ext/ripper/eventids1.c
|
||||
ext/ripper/eventids2table.c
|
||||
ext/ripper/ripper.c
|
||||
ext/ripper/ripper_init.c
|
||||
golf_prelude.c
|
||||
id.c
|
||||
id.h
|
||||
|
|
|
@ -0,0 +1,400 @@
|
|||
#include <alloca.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
/* Dependency */
|
||||
#include "internal/parse.h"
|
||||
#include "node.h"
|
||||
#include "id.h"
|
||||
|
||||
#include "internal/compilers.h"
|
||||
#include "ruby/backward/2/inttypes.h"
|
||||
#include "probes.h"
|
||||
|
||||
#define LIKELY(x) RB_LIKELY(x)
|
||||
#define UNLIKELY(x) RB_UNLIKELY(x)
|
||||
#ifndef TRUE
|
||||
# define TRUE 1
|
||||
#endif
|
||||
|
||||
#ifndef FALSE
|
||||
# define FALSE 0
|
||||
#endif
|
||||
#define numberof(array) ((int)(sizeof(array) / sizeof((array)[0])))
|
||||
#define rb_strlen_lit(str) (sizeof(str "") - 1)
|
||||
#undef FIXNUM_MAX
|
||||
#define FIXNUM_MAX (LONG_MAX / 2)
|
||||
#undef RSTRING_GETMEM
|
||||
#define RSTRING_GETMEM(str, ptrvar, lenvar) \
|
||||
((ptrvar) = RSTRING_PTR(str), \
|
||||
(lenvar) = RSTRING_LEN(str))
|
||||
#if defined(USE_FLONUM)
|
||||
# /* Take that. */
|
||||
#elif SIZEOF_VALUE >= SIZEOF_DOUBLE
|
||||
# define USE_FLONUM 1
|
||||
#else
|
||||
# define USE_FLONUM 0
|
||||
#endif
|
||||
|
||||
/* parser_st */
|
||||
#define st_table parser_st_table
|
||||
#define st_data_t parser_st_data_t
|
||||
#define st_hash_type parser_st_hash_type
|
||||
#define ST_CONTINUE ST2_CONTINUE
|
||||
#define ST_STOP ST2_STOP
|
||||
#define ST_DELETE ST2_DELETE
|
||||
#define ST_CHECK ST2_CHECK
|
||||
#define ST_REPLACE ST2_REPLACE
|
||||
#undef st_init_numtable
|
||||
#define st_init_numtable() rb_parser_st_init_numtable((&p->config->st_functions))
|
||||
#undef st_free_table
|
||||
#define st_free_table rb_parser_st_free_table
|
||||
#undef st_init_table_with_size
|
||||
#define st_init_table_with_size rb_parser_st_init_table_with_size
|
||||
#undef st_insert
|
||||
#define st_insert rb_parser_st_insert
|
||||
#undef st_foreach
|
||||
#define st_foreach rb_parser_st_foreach
|
||||
#undef st_delete
|
||||
#define st_delete rb_parser_st_delete
|
||||
#undef st_is_member
|
||||
#define st_is_member parser_st_is_member
|
||||
|
||||
#define rb_encoding void
|
||||
|
||||
#undef T_FLOAT
|
||||
#define T_FLOAT 0x04
|
||||
#undef T_REGEXP
|
||||
#define T_REGEXP 0x06
|
||||
#undef T_HASH
|
||||
#define T_HASH 0x08
|
||||
#undef T_BIGNUM
|
||||
#define T_BIGNUM 0x0a
|
||||
#undef T_COMPLEX
|
||||
#define T_COMPLEX 0x0e
|
||||
#undef T_RATIONAL
|
||||
#define T_RATIONAL 0x0f
|
||||
|
||||
struct rb_imemo_tmpbuf_struct {
|
||||
VALUE flags;
|
||||
VALUE reserved;
|
||||
VALUE *ptr; /* malloc'ed buffer */
|
||||
struct rb_imemo_tmpbuf_struct *next; /* next imemo */
|
||||
size_t cnt; /* buffer size in VALUE */
|
||||
};
|
||||
|
||||
#undef xmalloc
|
||||
#define xmalloc p->config->malloc
|
||||
#undef xcalloc
|
||||
#define xcalloc p->config->calloc
|
||||
#undef xrealloc
|
||||
#define xrealloc p->config->realloc
|
||||
#undef ALLOC_N
|
||||
#define ALLOC_N(type,n) ((type *)p->config->alloc_n((n), sizeof(type)))
|
||||
#undef ALLOC
|
||||
#define ALLOC(type) ((type *)p->config->alloc(sizeof(type)))
|
||||
#undef xfree
|
||||
#define xfree p->config->free
|
||||
#undef ALLOCA_N
|
||||
// alloca(rbimpl_size_mul_or_raise(x, y));
|
||||
#define ALLOCA_N(type,n) ((type *)alloca(sizeof(type) * (n)))
|
||||
#undef REALLOC_N
|
||||
#define REALLOC_N(var,type,n) ((var) = (type *)p->config->realloc_n((void *)var, n, sizeof(type)))
|
||||
#undef ZALLOC
|
||||
#define ZALLOC(type) ((type *)p->config->zalloc(sizeof(type)))
|
||||
#undef MEMMOVE
|
||||
#define MEMMOVE(p1,p2,type,n) (p->config->rb_memmove((p1), (p2), sizeof(type), (n)))
|
||||
#undef MEMCPY
|
||||
#define MEMCPY(p1,p2,type,n) (p->config->nonempty_memcpy((p1), (p2), sizeof(type), (n)))
|
||||
|
||||
#define new_strterm p->config->new_strterm
|
||||
#define strterm_is_heredoc p->config->strterm_is_heredoc
|
||||
#define rb_imemo_tmpbuf_auto_free_pointer p->config->tmpbuf_auto_free_pointer
|
||||
#define rb_imemo_tmpbuf_set_ptr p->config->tmpbuf_set_ptr
|
||||
#define rb_imemo_tmpbuf_parser_heap p->config->tmpbuf_parser_heap
|
||||
|
||||
#define compile_callback p->config->compile_callback
|
||||
#define reg_named_capture_assign p->config->reg_named_capture_assign
|
||||
#define script_lines_defined p->config->script_lines_defined
|
||||
#define script_lines_get p->config->script_lines_get
|
||||
|
||||
#define rb_obj_freeze p->config->obj_freeze
|
||||
#define rb_obj_hide p->config->obj_hide
|
||||
#undef RB_OBJ_FROZEN
|
||||
#define RB_OBJ_FROZEN p->config->obj_frozen
|
||||
#undef RB_TYPE_P
|
||||
#define RB_TYPE_P p->config->type_p
|
||||
#undef OBJ_FREEZE_RAW
|
||||
#define OBJ_FREEZE_RAW p->config->obj_freeze_raw
|
||||
|
||||
#undef FIXNUM_P
|
||||
#define FIXNUM_P p->config->fixnum_p
|
||||
#undef SYMBOL_P
|
||||
#define SYMBOL_P p->config->symbol_p
|
||||
|
||||
#define rb_attr_get p->config->attr_get
|
||||
|
||||
#define rb_ary_new p->config->ary_new
|
||||
#define rb_ary_push p->config->ary_push
|
||||
#undef rb_ary_new_from_args
|
||||
#define rb_ary_new_from_args p->config->ary_new_from_args
|
||||
#define rb_ary_pop p->config->ary_pop
|
||||
#define rb_ary_last p->config->ary_last
|
||||
#define rb_ary_unshift p->config->ary_unshift
|
||||
#undef rb_ary_new2
|
||||
#define rb_ary_new2 p->config->ary_new2
|
||||
#define rb_ary_entry p->config->ary_entry
|
||||
#define rb_ary_join p->config->ary_join
|
||||
#define rb_ary_reverse p->config->ary_reverse
|
||||
#define rb_ary_clear p->config->ary_clear
|
||||
#undef RARRAY_LEN
|
||||
#define RARRAY_LEN p->config->array_len
|
||||
#define RARRAY_AREF p->config->array_aref
|
||||
|
||||
#undef rb_sym_intern_ascii_cstr
|
||||
#define rb_sym_intern_ascii_cstr p->config->sym_intern_ascii_cstr
|
||||
#define rb_make_temporary_id p->config->make_temporary_id
|
||||
#define is_local_id p->config->is_local_id
|
||||
#define is_attrset_id p->config->is_attrset_id
|
||||
#define is_global_name_punct p->config->is_global_name_punct
|
||||
#define id_type p->config->id_type
|
||||
#define rb_id_attrset p->config->id_attrset
|
||||
#undef rb_intern
|
||||
#define rb_intern p->config->intern
|
||||
#define rb_intern2 p->config->intern2
|
||||
#define rb_intern3 p->config->intern3
|
||||
#define rb_intern_str p->config->intern_str
|
||||
#define is_notop_id p->config->is_notop_id
|
||||
#define rb_enc_symname_type p->config->enc_symname_type
|
||||
#define rb_str_intern p->config->str_intern
|
||||
#define rb_id2name p->config->id2name
|
||||
#define rb_id2str p->config->id2str
|
||||
#define rb_id2sym p->config->id2sym
|
||||
#undef ID2SYM
|
||||
#define ID2SYM p->config->id2sym
|
||||
#undef SYM2ID
|
||||
#define SYM2ID p->config->sym2id
|
||||
|
||||
#define rb_str_catf p->config->str_catf
|
||||
#undef rb_str_cat_cstr
|
||||
#define rb_str_cat_cstr p->config->str_cat_cstr
|
||||
#define rb_str_subseq p->config->str_subseq
|
||||
#define rb_str_dup p->config->str_dup
|
||||
#define rb_str_new_frozen p->config->str_new_frozen
|
||||
#define rb_str_buf_new p->config->str_buf_new
|
||||
#undef rb_str_buf_cat
|
||||
#define rb_str_buf_cat p->config->str_buf_cat
|
||||
#define rb_str_modify p->config->str_modify
|
||||
#define rb_str_set_len p->config->str_set_len
|
||||
#define rb_str_cat p->config->str_cat
|
||||
#define rb_str_resize p->config->str_resize
|
||||
#undef rb_str_new
|
||||
#define rb_str_new p->config->str_new
|
||||
#undef rb_str_new_cstr
|
||||
#define rb_str_new_cstr p->config->str_new_cstr
|
||||
#define rb_fstring p->config->fstring
|
||||
#define is_ascii_string p->config->is_ascii_string
|
||||
#define rb_enc_str_new p->config->enc_str_new
|
||||
#define rb_enc_str_buf_cat p->config->enc_str_buf_cat
|
||||
#define rb_str_buf_append p->config->str_buf_append
|
||||
#define rb_str_vcatf p->config->str_vcatf
|
||||
#undef StringValueCStr
|
||||
#define StringValueCStr(v) p->config->string_value_cstr(&(v))
|
||||
#define rb_sprintf p->config->rb_sprintf
|
||||
#undef RSTRING_PTR
|
||||
#define RSTRING_PTR p->config->rstring_ptr
|
||||
#undef RSTRING_END
|
||||
#define RSTRING_END p->config->rstring_end
|
||||
#undef RSTRING_LEN
|
||||
#define RSTRING_LEN p->config->rstring_len
|
||||
#define rb_filesystem_str_new_cstr p->config->filesystem_str_new_cstr
|
||||
#define rb_obj_as_string p->config->obj_as_string
|
||||
|
||||
#define rb_hash_clear p->config->hash_clear
|
||||
#define rb_hash_new p->config->hash_new
|
||||
#define rb_hash_aset p->config->hash_aset
|
||||
#define rb_hash_lookup p->config->hash_lookup
|
||||
#define rb_ident_hash_new p->config->ident_hash_new
|
||||
|
||||
#undef INT2FIX
|
||||
#define INT2FIX p->config->int2fix
|
||||
#undef LONG2FIX
|
||||
#define LONG2FIX p->config->int2fix
|
||||
|
||||
#define bignum_negate p->config->bignum_negate
|
||||
#define rb_big_norm p->config->big_norm
|
||||
#define rb_int2big p->config->int2big
|
||||
#define rb_cstr_to_inum p->config->cstr_to_inum
|
||||
|
||||
#define rb_float_new p->config->float_new
|
||||
#undef RFLOAT_VALUE
|
||||
#define RFLOAT_VALUE p->config->float_value
|
||||
#undef DBL2NUM
|
||||
#define DBL2NUM p->config->float_new
|
||||
|
||||
#define rb_fix2int p->config->fix2int
|
||||
#undef NUM2INT
|
||||
#define NUM2INT p->config->num2int
|
||||
#define rb_int_positive_pow p->config->int_positive_pow
|
||||
#undef INT2NUM
|
||||
#define INT2NUM p->config->int2num
|
||||
#undef FIX2LONG
|
||||
#define FIX2LONG p->config->fix2long
|
||||
|
||||
#define rb_rational_new p->config->rational_new
|
||||
#define rb_rational_raw p->config->rational_raw
|
||||
#undef rb_rational_raw1
|
||||
#define rb_rational_raw1 p->config->rational_raw1
|
||||
#define rational_set_num p->config->rational_set_num
|
||||
#define rational_get_num p->config->rational_get_num
|
||||
|
||||
#define rb_complex_raw p->config->complex_raw
|
||||
#define rcomplex_set_real p->config->rcomplex_set_real
|
||||
#define rcomplex_set_imag p->config->rcomplex_set_imag
|
||||
#define rcomplex_get_real p->config->rcomplex_get_real
|
||||
#define rcomplex_get_imag p->config->rcomplex_get_imag
|
||||
|
||||
#define rb_stderr_tty_p p->config->stderr_tty_p
|
||||
#define rb_write_error_str p->config->write_error_str
|
||||
#define rb_default_rs p->config->default_rs()
|
||||
#define rb_io_write p->config->io_write
|
||||
#define rb_io_flush p->config->io_flush
|
||||
#define rb_io_puts p->config->io_puts
|
||||
#define rb_io_gets_internal p->config->io_gets_internal
|
||||
|
||||
#define rb_ractor_stdout p->config->debug_output_stdout
|
||||
#define rb_ractor_stderr p->config->debug_output_stderr
|
||||
|
||||
#define rb_is_usascii_enc p->config->is_usascii_enc
|
||||
#define rb_enc_isalnum p->config->enc_isalnum
|
||||
#define rb_enc_precise_mbclen p->config->enc_precise_mbclen
|
||||
#define MBCLEN_CHARFOUND_P p->config->mbclen_charfound_p
|
||||
#define rb_enc_name p->config->enc_name
|
||||
#define rb_enc_prev_char p->config->enc_prev_char
|
||||
#define rb_enc_get p->config->enc_get
|
||||
#define rb_enc_asciicompat p->config->enc_asciicompat
|
||||
#define rb_utf8_encoding p->config->utf8_encoding
|
||||
#define rb_enc_associate p->config->enc_associate
|
||||
#define rb_ascii8bit_encoding p->config->ascii8bit_encoding
|
||||
#define rb_enc_codelen p->config->enc_codelen
|
||||
#define rb_enc_mbcput p->config->enc_mbcput
|
||||
#define rb_char_to_option_kcode p->config->char_to_option_kcode
|
||||
#define rb_ascii8bit_encindex p->config->ascii8bit_encindex
|
||||
#define rb_enc_find_index p->config->enc_find_index
|
||||
#define rb_enc_from_index p->config->enc_from_index
|
||||
#define rb_enc_associate_index p->config->enc_associate_index
|
||||
#define rb_enc_isspace p->config->enc_isspace
|
||||
#define ENC_CODERANGE_7BIT p->config->enc_coderange_7bit
|
||||
#define ENC_CODERANGE_UNKNOWN p->config->enc_coderange_unknown
|
||||
#define rb_enc_compatible p->config->enc_compatible
|
||||
#define rb_enc_from_encoding p->config->enc_from_encoding
|
||||
#define ENCODING_GET p->config->encoding_get
|
||||
#define ENCODING_SET p->config->encoding_set
|
||||
#define ENCODING_IS_ASCII8BIT p->config->encoding_is_ascii8bit
|
||||
#define rb_usascii_encoding p->config->usascii_encoding
|
||||
|
||||
#define rb_ractor_make_shareable p->config->ractor_make_shareable
|
||||
|
||||
#define ruby_vm_keep_script_lines p->config->vm_keep_script_lines()
|
||||
#define rb_local_defined p->config->local_defined
|
||||
#define rb_dvar_defined p->config->dvar_defined
|
||||
|
||||
#define literal_cmp p->config->literal_cmp
|
||||
#define literal_hash p->config->literal_hash
|
||||
|
||||
#define rb_builtin_class_name p->config->builtin_class_name
|
||||
#define rb_syntax_error_append p->config->syntax_error_append
|
||||
#define rb_raise p->config->raise
|
||||
#define syntax_error_new p->config->syntax_error_new
|
||||
|
||||
#define rb_errinfo p->config->errinfo
|
||||
#define rb_set_errinfo p->config->set_errinfo
|
||||
#define rb_exc_raise p->config->exc_raise
|
||||
#define rb_make_exception p->config->make_exception
|
||||
|
||||
#define ruby_sized_xfree p->config->sized_xfree
|
||||
#define SIZED_REALLOC_N(v, T, m, n) ((v) = (T *)p->config->sized_realloc_n((void *)(v), (m), sizeof(T), (n)))
|
||||
#undef RB_OBJ_WRITE
|
||||
#define RB_OBJ_WRITE(old, slot, young) p->config->obj_write((VALUE)(old), (VALUE *)(slot), (VALUE)(young))
|
||||
#undef RB_OBJ_WRITTEN
|
||||
#define RB_OBJ_WRITTEN(old, oldv, young) p->config->obj_written((VALUE)(old), (VALUE)(oldv), (VALUE)(young))
|
||||
#define rb_gc_register_mark_object p->config->gc_register_mark_object
|
||||
#undef RB_GC_GUARD
|
||||
#define RB_GC_GUARD p->config->gc_guard
|
||||
#define rb_gc_mark p->config->gc_mark
|
||||
|
||||
#define rb_reg_compile p->config->reg_compile
|
||||
#define rb_reg_check_preprocess p->config->reg_check_preprocess
|
||||
#define rb_memcicmp p->config->memcicmp
|
||||
|
||||
#define rb_compile_warn p->config->compile_warn
|
||||
#define rb_compile_warning p->config->compile_warning
|
||||
#define rb_bug p->config->bug
|
||||
#define rb_fatal p->config->fatal
|
||||
#undef ruby_verbose
|
||||
#define ruby_verbose p->config->verbose()
|
||||
|
||||
#define rb_make_backtrace p->config->make_backtrace
|
||||
|
||||
#define ruby_scan_hex p->config->scan_hex
|
||||
#define ruby_scan_oct p->config->scan_oct
|
||||
#define ruby_scan_digits p->config->scan_digits
|
||||
#define strtod p->config->strtod
|
||||
|
||||
#undef ISSPACE
|
||||
#define ISSPACE(c) ((p->config->isspace)(c))
|
||||
#undef ISASCII
|
||||
#define ISASCII(c) ((p->config->isascii)(c))
|
||||
#undef ISCNTRL
|
||||
#define ISCNTRL(c) ((p->config->iscntrl)(c))
|
||||
#undef ISALPHA
|
||||
#define ISALPHA(c) ((p->config->isalpha)(c))
|
||||
#undef ISDIGIT
|
||||
#define ISDIGIT(c) ((p->config->isdigit)(c))
|
||||
#undef ISALNUM
|
||||
#define ISALNUM(c) ((p->config->isalnum)(c))
|
||||
#undef ISXDIGIT
|
||||
#define ISXDIGIT(c) ((p->config->isxdigit)(c))
|
||||
#undef STRCASECMP
|
||||
#define STRCASECMP p->config->strcasecmp
|
||||
#undef STRNCASECMP
|
||||
#define STRNCASECMP p->config->strncasecmp
|
||||
|
||||
#undef RBOOL
|
||||
#define RBOOL p->config->rbool
|
||||
#undef UNDEF_P
|
||||
#define UNDEF_P p->config->undef_p
|
||||
#undef RTEST
|
||||
#define RTEST p->config->rtest
|
||||
#undef NIL_P
|
||||
#define NIL_P p->config->nil_p
|
||||
#undef FLONUM_P
|
||||
#define FLONUM_P p->config->flonum_p
|
||||
#undef Qnil
|
||||
#define Qnil p->config->qnil
|
||||
#undef Qtrue
|
||||
#define Qtrue p->config->qtrue
|
||||
#undef Qfalse
|
||||
#define Qfalse p->config->qfalse
|
||||
#undef Qundef
|
||||
#define Qundef p->config->qundef
|
||||
#define rb_eArgError p->config->eArgError
|
||||
#define rb_mRubyVMFrozenCore p->config->mRubyVMFrozenCore
|
||||
#undef rb_long2int
|
||||
#define rb_long2int p->config->long2int
|
||||
#undef SPECIAL_CONST_P
|
||||
#define SPECIAL_CONST_P p->config->special_const_p
|
||||
#undef BUILTIN_TYPE
|
||||
#define BUILTIN_TYPE p->config->builtin_type
|
||||
#define ruby_snprintf p->config->snprintf
|
||||
|
||||
#define rb_node_case_when_optimizable_literal p->config->node_case_when_optimizable_literal
|
||||
|
||||
#undef st_init_table_with_size
|
||||
#define st_init_table_with_size(type, size) \
|
||||
rb_parser_st_init_table_with_size(type, &p->config->st_functions, size)
|
||||
|
||||
#define rb_ast_new() \
|
||||
rb_ast_new(p->config)
|
2
vm.c
2
vm.c
|
@ -20,9 +20,9 @@
|
|||
#include "internal/gc.h"
|
||||
#include "internal/inits.h"
|
||||
#include "internal/object.h"
|
||||
#include "internal/parse.h"
|
||||
#include "internal/proc.h"
|
||||
#include "internal/re.h"
|
||||
#include "internal/ruby_parser.h"
|
||||
#include "internal/symbol.h"
|
||||
#include "internal/thread.h"
|
||||
#include "internal/vm.h"
|
||||
|
|
Загрузка…
Ссылка в новой задаче