mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Rename MRB_OPSYM() to MRB_QSYM().
Where `QSYM` means quoted symbols, which cannot be represented C symbols, so specify aliases instead. - operators: name of the operation, e.g. add for `+` - predicates: add `_p` suffix instead of `?` - bang methods: add `_b` suffix instead of `!` - instance variables: add `a_` prefix instead of `@` - global variables: add `d_` prefix instead of `@` - class variables: unsupported; don't use them
This commit is contained in:
@@ -173,13 +173,25 @@ file presym_inc => presym_file do
|
||||
"~" => "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_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"
|
||||
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"
|
||||
f.print "MRB_PRESYM_QSYM(#{sym}, #{op_table[sym]}, #{i+1})\n"
|
||||
elsif /\?\Z/ =~ sym
|
||||
s = sym.dup; s[-1] = "_p"
|
||||
f.print "MRB_PRESYM_QSYM(#{sym}, #{s}, #{i+1})\n"
|
||||
elsif /\!\Z/ =~ sym
|
||||
s = sym.dup; s[-1] = "_b"
|
||||
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"
|
||||
elsif /\A$/ =~ sym
|
||||
s = sym.dup; s[0] = "d_"
|
||||
f.print "MRB_PRESYM_QSYM(#{sym}, #{s}, #{i+1})\n"
|
||||
else
|
||||
f.print "MRB_PRESYM_SYM(#{sym}, #{i+1})\n"
|
||||
end
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#undef MRB_PRESYM_MAX
|
||||
#define MRB_PRESYM_CSYM(sym, num) MRB_PRESYM__##sym = (num<<1),
|
||||
#define MRB_PRESYM_OPSYM(op, sym, num) MRB_PRESYM_op_##sym = (num<<1),
|
||||
#define MRB_PRESYM_QSYM(src, sym, num) MRB_PRESYM_q_##sym = (num<<1),
|
||||
#define MRB_PRESYM_SYM(sym, num)
|
||||
|
||||
enum mruby_presym {
|
||||
@@ -17,9 +17,9 @@ enum mruby_presym {
|
||||
};
|
||||
|
||||
#undef MRB_PRESYM_CSYM
|
||||
#undef MRB_PRESYM_OPSYM
|
||||
#undef MRB_PRESYM_QSYM
|
||||
#undef MRB_PRESYM_SYM
|
||||
|
||||
#define MRB_SYM(sym) MRB_PRESYM__##sym
|
||||
#define MRB_OPSYM(sym) MRB_PRESYM_op_##sym
|
||||
#define MRB_QSYM(sym) MRB_PRESYM_q_##sym
|
||||
#endif /* MRUBY_PRESYM_H */
|
||||
|
||||
+1
-1
@@ -766,7 +766,7 @@ mrb_obj_ceqq(mrb_state *mrb, mrb_value self)
|
||||
{
|
||||
mrb_value v = mrb_get_arg1(mrb);
|
||||
mrb_int i, len;
|
||||
mrb_sym eqq = MRB_OPSYM(eqq);
|
||||
mrb_sym eqq = MRB_QSYM(eqq);
|
||||
mrb_value ary;
|
||||
|
||||
if (mrb_array_p(self)) {
|
||||
|
||||
+2
-2
@@ -14,10 +14,10 @@
|
||||
|
||||
#undef MRB_PRESYM_MAX
|
||||
#undef MRB_PRESYM_CSYM
|
||||
#undef MRB_PRESYM_OPSYM
|
||||
#undef MRB_PRESYM_QSYM
|
||||
#undef MRB_PRESYM_SYM
|
||||
#define MRB_PRESYM_CSYM(sym, num) #sym,
|
||||
#define MRB_PRESYM_OPSYM(op, sym, num) #op,
|
||||
#define MRB_PRESYM_QSYM(sym, name, num) #sym,
|
||||
#define MRB_PRESYM_SYM(sym, num) #sym,
|
||||
|
||||
static const char *presym_table[] = {
|
||||
|
||||
Reference in New Issue
Block a user