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
1bcf6d9f
Unverified
Commit
1bcf6d9f
authored
May 15, 2020
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create `MRB_OPSYM()` macro to refer symbols corresponding operators.
For example, `MRB_OPSYM(add)` refers a symbol for `+`.
parent
97e3c3a5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
1 deletion
+41
-1
Rakefile
Rakefile
+35
-0
include/mruby/presym.h
include/mruby/presym.h
+4
-1
src/symbol.c
src/symbol.c
+2
-0
No files found.
Rakefile
View file @
1bcf6d9f
...
...
@@ -146,11 +146,46 @@ file presym_inc => presym_file do
presyms
=
File
.
readlines
(
presym_file
,
chomp:
true
)
rm_f
presym_inc
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_OPSYM(op, sym, num) - symbol which is an operator id */
\n
"
f
.
print
"/* MRB_PRESYM_SYM(sym, num) - symbol which is not valid C id */
\n\n
"
presyms
.
each
.
with_index
do
|
sym
,
i
|
if
/\A\w+\Z/
=~
sym
f
.
print
"MRB_PRESYM_CSYM(
#{
sym
}
,
#{
i
+
1
}
)
\n
"
elsif
op_table
.
key?
(
sym
)
f
.
print
"MRB_PRESYM_OPSYM(
#{
sym
}
,
#{
op_table
[
sym
]
}
,
#{
i
+
1
}
)
\n
"
else
f
.
print
"MRB_PRESYM_SYM(
#{
sym
}
,
#{
i
+
1
}
)
\n
"
end
...
...
include/mruby/presym.h
View file @
1bcf6d9f
...
...
@@ -9,14 +9,17 @@
#undef MRB_PRESYM_MAX
#define MRB_PRESYM_CSYM(sym, num) MRB_PRESYM__##sym = (num<<1),
#define MRB_PRESYM_SYM(sym, num)
#define MRB_PRESYM_OPSYM(op, sym, num) MRB_PRESYM_op_##sym = (num<<1),
#define MRB_PRESYM_SYM(sym, num)
enum
mruby_presym
{
#include <../build/presym.inc>
};
#undef MRB_PRESYM_CSYM
#undef MRB_PRESYM_OPSYM
#undef MRB_PRESYM_SYM
#define MRB_SYM(sym) MRB_PRESYM__##sym
#define MRB_OPSYM(sym) MRB_PRESYM_op_##sym
#endif
/* MRUBY_PRESYM_H */
src/symbol.c
View file @
1bcf6d9f
...
...
@@ -14,8 +14,10 @@
#undef MRB_PRESYM_MAX
#undef MRB_PRESYM_CSYM
#undef MRB_PRESYM_OPSYM
#undef MRB_PRESYM_SYM
#define MRB_PRESYM_CSYM(sym, num) #sym,
#define MRB_PRESYM_OPSYM(op, sym, num) #op,
#define MRB_PRESYM_SYM(sym, num) #sym,
static
const
char
*
presym_table
[]
=
{
...
...
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