diff options
author | Jari Vetoniemi <jari.vetoniemi@indooratlas.com> | 2020-03-16 18:49:26 +0900 |
---|---|---|
committer | Jari Vetoniemi <jari.vetoniemi@indooratlas.com> | 2020-03-30 00:39:06 +0900 |
commit | fcbf63e62c627deae76c1b8cb8c0876c536ed811 (patch) | |
tree | 64cb17de3f41a2b6fef2368028fbd00349946994 /jni/ruby/defs |
Fresh start
Diffstat (limited to 'jni/ruby/defs')
-rw-r--r-- | jni/ruby/defs/default_gems | 4 | ||||
-rw-r--r-- | jni/ruby/defs/gmake.mk | 63 | ||||
-rw-r--r-- | jni/ruby/defs/id.def | 122 | ||||
-rw-r--r-- | jni/ruby/defs/keywords | 53 | ||||
-rw-r--r-- | jni/ruby/defs/known_errors.def | 148 | ||||
-rw-r--r-- | jni/ruby/defs/lex.c.src | 53 | ||||
-rw-r--r-- | jni/ruby/defs/opt_insn_unif.def | 29 | ||||
-rw-r--r-- | jni/ruby/defs/opt_operand.def | 22 |
8 files changed, 494 insertions, 0 deletions
diff --git a/jni/ruby/defs/default_gems b/jni/ruby/defs/default_gems new file mode 100644 index 0000000..ce90109 --- /dev/null +++ b/jni/ruby/defs/default_gems @@ -0,0 +1,4 @@ +# gem base directory versioning file [executable files under bin] +rake lib/rake lib/rake.rb [rake] +rdoc lib/rdoc lib/rdoc.rb [rdoc ri] +json ext/json ext/json/lib/json/version.rb diff --git a/jni/ruby/defs/gmake.mk b/jni/ruby/defs/gmake.mk new file mode 100644 index 0000000..f5033b2 --- /dev/null +++ b/jni/ruby/defs/gmake.mk @@ -0,0 +1,63 @@ +# -*- makefile-gmake -*- +gnumake = yes + +TEST_TARGETS := $(filter check test check% test% btest%,$(MAKECMDGOALS)) +TEST_TARGETS += $(subst check,test-all,$(patsubst check-%,test-%,$(TEST_TARGETS))) +TEST_TARGETS := $(patsubst test-%,yes-test-%,$(patsubst btest-%,yes-btest-%,$(TEST_TARGETS))) +TEST_DEPENDS := $(if $(TEST_TARGETS),$(filter all main exts,$(MAKECMDGOALS))) +TEST_DEPENDS += $(TEST_DEPENDS) $(if $(filter check%,$(MAKECMDGOALS)),main) +TEST_DEPENDS += $(if $(filter all,$(INSTALLDOC)),docs) + +ifneq ($(filter -O0 -Od,$(optflags)),) +override XCFLAGS := $(filter-out -D_FORTIFY_SOURCE=%,$(XCFLAGS)) +endif + +ifneq ($(filter universal-%,$(arch)),) +define archcmd +%.$(1).S: %.c + @$$(ECHO) translating $$< with $(2) + $$(Q) $$(CC) $$(CFLAGS_NO_ARCH) $(2) $$(XCFLAGS) $$(CPPFLAGS) $$(COUTFLAG)$$@ -S $$< + +%.S: %.$(1).S + +%.$(1).i: %.c + @$$(ECHO) preprocessing $$< with $(2) + $$(Q) $$(CPP) $$(warnflags) $(2) $$(XCFLAGS) $$(CPPFLAGS) $$(COUTFLAG)$$@ -E $$< > $$@ + +%.i: %.$(1).i +endef + +$(foreach arch,$(filter -arch=%,$(subst -arch ,-arch=,$(ARCH_FLAG))),\ + $(eval $(call archcmd,$(patsubst -arch=%,%,$(value arch)),$(patsubst -arch=%,-arch %,$(value arch))))) +endif + +ifneq ($(filter love check% test,$(MAKECMDGOALS)),) +yes-test-knownbug: $(TEST_DEPENDS) yes-btest-ruby +yes-btest-ruby: $(TEST_DEPENDS) yes-test-sample +yes-test-sample: $(TEST_DEPENDS) +endif +ifneq ($(filter love check%,$(MAKECMDGOALS)) $(filter test-all,$(TEST_TARGETS)),) +yes-test-all yes-test-ruby: $(filter-out %test-all %test-ruby check%,$(TEST_TARGETS)) +endif +ifneq ($(filter love check%,$(MAKECMDGOALS))$(if $(filter test-all,$(MAKECMDGOALS)),$(filter test-knownbug,$(MAKECMDGOALS))),) +yes-test-all yes-test-ruby: yes-test-knownbug +endif + +$(TEST_TARGETS): $(TEST_DEPENDS) + +ifneq ($(if $(filter install,$(MAKECMDGOALS)),$(filter uninstall,$(MAKECMDGOALS))),) +install-targets := $(filter install uninstall,$(MAKECMDGOALS)) +$(word 1,$(install-targets)): $(word 0,$(install-targets)) +endif + +ifneq ($(filter reinstall,$(MAKECMDGOALS)),) +install-prereq: uninstall +uninstall sudo-precheck: all $(if $(filter all,$(INSTALLDOC)),docs) +endif + +ifneq ($(filter love,$(MAKECMDGOALS)),) +showflags: up +sudo-precheck: test +install-prereq: sudo-precheck +yes-test-all no-test-all: install +endif diff --git a/jni/ruby/defs/id.def b/jni/ruby/defs/id.def new file mode 100644 index 0000000..d4cd5e7 --- /dev/null +++ b/jni/ruby/defs/id.def @@ -0,0 +1,122 @@ +# -*- mode: ruby; coding: us-ascii -*- +firstline, predefined = __LINE__+1, %[\ + freeze + inspect + intern + object_id + const_missing + method_missing MethodMissing + method_added + singleton_method_added + method_removed + singleton_method_removed + method_undefined + singleton_method_undefined + length + size + gets + succ + each + proc + lambda + send + __send__ + __attached__ + initialize + initialize_copy + initialize_clone + initialize_dup + to_int + to_ary + to_str + to_sym + to_hash + to_proc + to_io + to_a + to_s + to_i + bt + bt_locations + call + mesg + exception + + _ UScore + "/*NULL*/" NULL + empty? + eql? + respond_to? Respond_to + respond_to_missing? Respond_to_missing + <IFUNC> + <CFUNC> + core#set_method_alias + core#set_variable_alias + core#undef_method + core#define_method + core#define_singleton_method + core#set_postexe + core#hash_from_ary + core#hash_merge_ary + core#hash_merge_ptr + core#hash_merge_kwd +] + +class KeywordError < RuntimeError + def self.raise(mesg, line) + super(self, mesg, ["#{__FILE__}:#{line}", *caller]) + end +end + +predefined_ids = {} +preserved_ids = [] +local_ids = [] +instance_ids = [] +global_ids = [] +const_ids = [] +class_ids = [] +attrset_ids = [] +names = {} +predefined.split(/^/).each_with_index do |line, num| + next if /^#/ =~ line + line.sub!(/\s+#.*/, '') + name, token = line.split + next unless name + token ||= name + if /#/ =~ token + token = "_#{token.gsub(/\W+/, '_')}" + else + token = token.sub(/\?/, 'P').sub(/\A[a-z]/) {$&.upcase} + token.sub!(/\A\$/, "_G_") + token.sub!(/\A@@/, "_C_") + token.sub!(/\A@/, "_I_") + token.gsub!(/\W+/, "") + end + if prev = names[name] + KeywordError.raise("#{name} is already registered at line #{prev+firstline}", firstline+num) + end + if prev = predefined_ids[token] + KeywordError.raise("#{token} is already used for #{prev} at line #{names[prev]+firstline}", firstline+num) + end + names[name] = num + case name + when /\A[A-Z]\w*\z/; const_ids + when /\A(?!\d)\w+\z/; local_ids + when /\A\$(?:\d+|(?!\d)\w+)\z/; global_ids + when /\A@@(?!\d)\w+\z/; class_ids + when /\A@(?!\d)\w+\z/; instance_ids + when /\A((?!\d)\w+)=\z/; attrset_ids + else preserved_ids + end << token + predefined_ids[token] = name +end +{ + "LOCAL" => local_ids, + "INSTANCE" => instance_ids, + "GLOBAL" => global_ids, + "CONST" => const_ids, + "CLASS" => class_ids, + "ATTRSET" => attrset_ids, + :preserved => preserved_ids, + :predefined => predefined_ids, +} diff --git a/jni/ruby/defs/keywords b/jni/ruby/defs/keywords new file mode 100644 index 0000000..1b5719a --- /dev/null +++ b/jni/ruby/defs/keywords @@ -0,0 +1,53 @@ +%{ +struct kwtable {const char *name; int id[2]; enum lex_state_e state;}; +const struct kwtable *rb_reserved_word(const char *, unsigned int); +#ifndef RIPPER +static const struct kwtable *reserved_word(const char *, unsigned int); +#define rb_reserved_word(str, len) reserved_word(str, len) +%} + +struct kwtable; +%% +__ENCODING__, {keyword__ENCODING__, keyword__ENCODING__}, EXPR_END +__LINE__, {keyword__LINE__, keyword__LINE__}, EXPR_END +__FILE__, {keyword__FILE__, keyword__FILE__}, EXPR_END +BEGIN, {keyword_BEGIN, keyword_BEGIN}, EXPR_END +END, {keyword_END, keyword_END}, EXPR_END +alias, {keyword_alias, keyword_alias}, EXPR_FNAME +and, {keyword_and, keyword_and}, EXPR_VALUE +begin, {keyword_begin, keyword_begin}, EXPR_BEG +break, {keyword_break, keyword_break}, EXPR_MID +case, {keyword_case, keyword_case}, EXPR_VALUE +class, {keyword_class, keyword_class}, EXPR_CLASS +def, {keyword_def, keyword_def}, EXPR_FNAME +defined?, {keyword_defined, keyword_defined}, EXPR_ARG +do, {keyword_do, keyword_do}, EXPR_BEG +else, {keyword_else, keyword_else}, EXPR_BEG +elsif, {keyword_elsif, keyword_elsif}, EXPR_VALUE +end, {keyword_end, keyword_end}, EXPR_END +ensure, {keyword_ensure, keyword_ensure}, EXPR_BEG +false, {keyword_false, keyword_false}, EXPR_END +for, {keyword_for, keyword_for}, EXPR_VALUE +if, {keyword_if, modifier_if}, EXPR_VALUE +in, {keyword_in, keyword_in}, EXPR_VALUE +module, {keyword_module, keyword_module}, EXPR_VALUE +next, {keyword_next, keyword_next}, EXPR_MID +nil, {keyword_nil, keyword_nil}, EXPR_END +not, {keyword_not, keyword_not}, EXPR_ARG +or, {keyword_or, keyword_or}, EXPR_VALUE +redo, {keyword_redo, keyword_redo}, EXPR_END +rescue, {keyword_rescue, modifier_rescue}, EXPR_MID +retry, {keyword_retry, keyword_retry}, EXPR_END +return, {keyword_return, keyword_return}, EXPR_MID +self, {keyword_self, keyword_self}, EXPR_END +super, {keyword_super, keyword_super}, EXPR_ARG +then, {keyword_then, keyword_then}, EXPR_BEG +true, {keyword_true, keyword_true}, EXPR_END +undef, {keyword_undef, keyword_undef}, EXPR_FNAME +unless, {keyword_unless, modifier_unless}, EXPR_VALUE +until, {keyword_until, modifier_until}, EXPR_VALUE +when, {keyword_when, keyword_when}, EXPR_VALUE +while, {keyword_while, modifier_while}, EXPR_VALUE +yield, {keyword_yield, keyword_yield}, EXPR_ARG +%% +#endif diff --git a/jni/ruby/defs/known_errors.def b/jni/ruby/defs/known_errors.def new file mode 100644 index 0000000..b9c490d --- /dev/null +++ b/jni/ruby/defs/known_errors.def @@ -0,0 +1,148 @@ +EPERM +ENOENT +ESRCH +EINTR +EIO +ENXIO +E2BIG +ENOEXEC +EBADF +ECHILD +EAGAIN +ENOMEM +EACCES +EFAULT +ENOTBLK +EBUSY +EEXIST +EXDEV +ENODEV +ENOTDIR +EISDIR +EINVAL +ENFILE +EMFILE +ENOTTY +ETXTBSY +EFBIG +ENOSPC +ESPIPE +EROFS +EMLINK +EPIPE +EDOM +ERANGE +EDEADLK +ENAMETOOLONG +ENOLCK +ENOSYS +ENOTEMPTY +ELOOP +EWOULDBLOCK +ENOMSG +EIDRM +ECHRNG +EL2NSYNC +EL3HLT +EL3RST +ELNRNG +EUNATCH +ENOCSI +EL2HLT +EBADE +EBADR +EXFULL +ENOANO +EBADRQC +EBADSLT +EDEADLOCK +EBFONT +ENOSTR +ENODATA +ETIME +ENOSR +ENONET +ENOPKG +EREMOTE +ENOLINK +EADV +ESRMNT +ECOMM +EPROTO +EMULTIHOP +EDOTDOT +EBADMSG +EOVERFLOW +ENOTUNIQ +EBADFD +EREMCHG +ELIBACC +ELIBBAD +ELIBSCN +ELIBMAX +ELIBEXEC +EILSEQ +ERESTART +ESTRPIPE +EUSERS +ENOTSOCK +EDESTADDRREQ +EMSGSIZE +EPROTOTYPE +ENOPROTOOPT +EPROTONOSUPPORT +ESOCKTNOSUPPORT +EOPNOTSUPP +EPFNOSUPPORT +EAFNOSUPPORT +EADDRINUSE +EADDRNOTAVAIL +ENETDOWN +ENETUNREACH +ENETRESET +ECONNABORTED +ECONNRESET +ENOBUFS +EISCONN +ENOTCONN +ESHUTDOWN +ETOOMANYREFS +ETIMEDOUT +ECONNREFUSED +EHOSTDOWN +EHOSTUNREACH +EALREADY +EINPROGRESS +ESTALE +EUCLEAN +ENOTNAM +ENAVAIL +EISNAM +EREMOTEIO +EDQUOT +ECANCELED +EKEYEXPIRED +EKEYREJECTED +EKEYREVOKED +EMEDIUMTYPE +ENOKEY +ENOMEDIUM +ENOTRECOVERABLE +EOWNERDEAD +ERFKILL +EAUTH +EBADRPC +EDOOFUS +EFTYPE +ENEEDAUTH +ENOATTR +ENOTSUP +EPROCLIM +EPROCUNAVAIL +EPROGMISMATCH +EPROGUNAVAIL +ERPCMISMATCH +EIPSEC +EHWPOISON +ECAPMODE +ENOTCAPABLE diff --git a/jni/ruby/defs/lex.c.src b/jni/ruby/defs/lex.c.src new file mode 100644 index 0000000..1b5719a --- /dev/null +++ b/jni/ruby/defs/lex.c.src @@ -0,0 +1,53 @@ +%{ +struct kwtable {const char *name; int id[2]; enum lex_state_e state;}; +const struct kwtable *rb_reserved_word(const char *, unsigned int); +#ifndef RIPPER +static const struct kwtable *reserved_word(const char *, unsigned int); +#define rb_reserved_word(str, len) reserved_word(str, len) +%} + +struct kwtable; +%% +__ENCODING__, {keyword__ENCODING__, keyword__ENCODING__}, EXPR_END +__LINE__, {keyword__LINE__, keyword__LINE__}, EXPR_END +__FILE__, {keyword__FILE__, keyword__FILE__}, EXPR_END +BEGIN, {keyword_BEGIN, keyword_BEGIN}, EXPR_END +END, {keyword_END, keyword_END}, EXPR_END +alias, {keyword_alias, keyword_alias}, EXPR_FNAME +and, {keyword_and, keyword_and}, EXPR_VALUE +begin, {keyword_begin, keyword_begin}, EXPR_BEG +break, {keyword_break, keyword_break}, EXPR_MID +case, {keyword_case, keyword_case}, EXPR_VALUE +class, {keyword_class, keyword_class}, EXPR_CLASS +def, {keyword_def, keyword_def}, EXPR_FNAME +defined?, {keyword_defined, keyword_defined}, EXPR_ARG +do, {keyword_do, keyword_do}, EXPR_BEG +else, {keyword_else, keyword_else}, EXPR_BEG +elsif, {keyword_elsif, keyword_elsif}, EXPR_VALUE +end, {keyword_end, keyword_end}, EXPR_END +ensure, {keyword_ensure, keyword_ensure}, EXPR_BEG +false, {keyword_false, keyword_false}, EXPR_END +for, {keyword_for, keyword_for}, EXPR_VALUE +if, {keyword_if, modifier_if}, EXPR_VALUE +in, {keyword_in, keyword_in}, EXPR_VALUE +module, {keyword_module, keyword_module}, EXPR_VALUE +next, {keyword_next, keyword_next}, EXPR_MID +nil, {keyword_nil, keyword_nil}, EXPR_END +not, {keyword_not, keyword_not}, EXPR_ARG +or, {keyword_or, keyword_or}, EXPR_VALUE +redo, {keyword_redo, keyword_redo}, EXPR_END +rescue, {keyword_rescue, modifier_rescue}, EXPR_MID +retry, {keyword_retry, keyword_retry}, EXPR_END +return, {keyword_return, keyword_return}, EXPR_MID +self, {keyword_self, keyword_self}, EXPR_END +super, {keyword_super, keyword_super}, EXPR_ARG +then, {keyword_then, keyword_then}, EXPR_BEG +true, {keyword_true, keyword_true}, EXPR_END +undef, {keyword_undef, keyword_undef}, EXPR_FNAME +unless, {keyword_unless, modifier_unless}, EXPR_VALUE +until, {keyword_until, modifier_until}, EXPR_VALUE +when, {keyword_when, keyword_when}, EXPR_VALUE +while, {keyword_while, modifier_while}, EXPR_VALUE +yield, {keyword_yield, keyword_yield}, EXPR_ARG +%% +#endif diff --git a/jni/ruby/defs/opt_insn_unif.def b/jni/ruby/defs/opt_insn_unif.def new file mode 100644 index 0000000..1ac613d --- /dev/null +++ b/jni/ruby/defs/opt_insn_unif.def @@ -0,0 +1,29 @@ +# +# a definition of instruction unification +# +# + +__END__ + +putobject putobject +putobject putstring +putobject setlocal +putobject setdynamic + +putstring putstring +putstring putobject +putstring setlocal +putstring setdynamic + +# putnil end + +dup setlocal + +# from tarai +getlocal getlocal +# getlocal send + +# from tak, ackermann +getlocal putobject + + diff --git a/jni/ruby/defs/opt_operand.def b/jni/ruby/defs/opt_operand.def new file mode 100644 index 0000000..887e3da --- /dev/null +++ b/jni/ruby/defs/opt_operand.def @@ -0,0 +1,22 @@ +# +# configuration file for operand union optimization +# +# format: +# [insn name] op1, op2 ... +# +# wildcard: * +# + +getlocal *, 0 +getlocal *, 1 +setlocal *, 0 +setlocal *, 1 + +putobject INT2FIX(0) +putobject INT2FIX(1) + +__END__ + +putobject Qtrue +putobject Qfalse + |