summaryrefslogtreecommitdiffhomepage
path: root/Rakefile
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2020-05-15 19:17:29 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2020-10-12 16:20:53 +0900
commite2063fc267c384a73fc6e432cfee04d8ada2cc97 (patch)
tree74edc8fc98bcab484c2a20be4497162101d6d62b /Rakefile
parent68f8d73308fce7acca3605858fa2755185844b76 (diff)
downloadmruby-e2063fc267c384a73fc6e432cfee04d8ada2cc97.tar.gz
mruby-e2063fc267c384a73fc6e432cfee04d8ada2cc97.zip
Add operators to `presym` from `Rakefile`.
Diffstat (limited to 'Rakefile')
-rw-r--r--Rakefile78
1 files changed, 42 insertions, 36 deletions
diff --git a/Rakefile b/Rakefile
index 9de12fb57..c5dc31f19 100644
--- a/Rakefile
+++ b/Rakefile
@@ -112,8 +112,39 @@ rbfiles = (Dir.glob("#{MRUBY_ROOT}/mrblib/*.rb")+
Dir.glob("#{MRUBY_ROOT}/mrbgems/*/mrblib/*.rb")+
Dir.glob("#{MRUBY_ROOT}/build/*/mrbgems/**/mrblib/*.rb")).uniq
presym_file="#{MRUBY_ROOT}/build/presym"
+op_table = {
+ "!" => "not",
+ "!=" => "neq",
+ "!~" => "nmatch",
+ "%" => "mod",
+ "&" => "and",
+ "&&" => "andand",
+ "*" => "mul",
+ "**" => "pow",
+ "+" => "add",
+ "+@" => "plus",
+ "-" => "sub",
+ "-@" => "minus",
+ "/" => "div",
+ "<" => "lt",
+ "<=" => "le",
+ "<<" => "lshift",
+ "<=>" => "cmp",
+ "==" => "eq",
+ "===" => "eqq",
+ "=~" => "match",
+ ">" => "gt",
+ ">=" => "ge",
+ ">>" => "rshift",
+ "[]" => "aref",
+ "[]=" => "aset",
+ "^" => "xor",
+ "`" => "tick",
+ "|" => "or",
+ "||" => "oror",
+ "~" => "neg",
+}
-desc "preallocated symbols"
file presym_file => cfiles+rbfiles do
csymbols = cfiles.map do |f|
src = File.read(f)
@@ -121,7 +152,10 @@ file presym_file => cfiles+rbfiles do
src.scan(/mrb_define_method\([^\n"]*"([^\n"]*)"/),
src.scan(/mrb_define_class\([^\n"]*"([^\n"]*)"/),
src.scan(/mrb_define_module\([^\n"]*"([^\n"]*)"/),
- src.scan(/MRB_SYM\((\w+)\)/)]
+ src.scan(/MRB_SYM\((\w+)\)/),
+ src.scan(/MRB_QSYM\((\w+)\)/).map{|x,|
+ x.sub!(/_p$/, "?") || x.sub!(/_b$/, "!") || x.sub!(/_e$/, "=") || x.sub!(/^a_/, "@") || x.sub!(/^d_/, "$")
+ }.compact]
end
rbsymbols = rbfiles.map do |f|
src = File.read(f)
@@ -129,7 +163,7 @@ file presym_file => cfiles+rbfiles do
src.scan(/\bmodule +([A-Z]\w*)/),
src.scan(/\bdef +(\w+)/)]
end
- symbols = (csymbols+rbsymbols).flatten.uniq.sort
+ symbols = (csymbols+rbsymbols+op_table.keys).flatten.compact.uniq.sort
presyms = File.readlines(presym_file, chomp: true) rescue []
if presyms != symbols
File.write(presym_file, symbols.join("\n"))
@@ -140,38 +174,6 @@ presym_inc=presym_file+".inc"
file presym_inc => presym_file do
presyms = File.readlines(presym_file, chomp: true)
File.open(presym_inc, "w") do |f|
- op_table = {
- "!" => "not",
- "!=" => "neq",
- "!~" => "nmatch",
- "%" => "mod",
- "&" => "and",
- "&&" => "andand",
- "*" => "mul",
- "**" => "pow",
- "+" => "add",
- "+@" => "plus",
- "-" => "sub",
- "-@" => "minus",
- "/" => "div",
- "<" => "lt",
- "<=" => "le",
- "<<" => "lshift",
- "<=>" => "cmp",
- "==" => "eq",
- "===" => "eqq",
- "=~" => "match",
- ">" => "gt",
- ">=" => "ge",
- ">>" => "rshift",
- "[]" => "aref",
- "[]=" => "aset",
- "^" => "xor",
- "`" => "tick",
- "|" => "or",
- "||" => "oror",
- "~" => "neg",
- }
f.print "/* MRB_PRESYM_CSYM(sym, num) - symbol which is valid C id name */\n"
f.print "/* MRB_PRESYM_QSYM(sym, name, num) - symbol with alias name */\n"
f.print "/* MRB_PRESYM_SYM(sym, num) - symbol which is not valid C id */\n\n"
@@ -186,6 +188,9 @@ file presym_inc => presym_file do
elsif /\!\Z/ =~ sym
s = sym.dup; s[-1] = "_b"
f.print "MRB_PRESYM_QSYM(#{sym}, #{s}, #{i+1})\n"
+ elsif /\=\Z/ =~ sym
+ s = sym.dup; s[-1] = "_e"
+ f.print "MRB_PRESYM_QSYM(#{sym}, #{s}, #{i+1})\n"
elsif /\A@/ =~ sym
s = sym.dup; s[0] = "a_"
f.print "MRB_PRESYM_QSYM(#{sym}, #{s}, #{i+1})\n"
@@ -200,8 +205,9 @@ file presym_inc => presym_file do
end
end
+desc "preallocated symbols"
task :gensym => presym_inc
-depfiles.unshift "gensym"
+#task :all => :gensym
depfiles += MRuby.targets.map { |n, t|
t.libraries