Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
e2063fc2
Unverified
Commit
e2063fc2
authored
May 15, 2020
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add operators to `presym` from `Rakefile`.
parent
68f8d733
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
36 deletions
+42
-36
Rakefile
Rakefile
+42
-36
No files found.
Rakefile
View file @
e2063fc2
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment