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
c15af5d5
Commit
c15af5d5
authored
Feb 21, 2013
by
Yukihiro Matz Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
compile /a/ as ::Regexp.new("a")
parent
ffd7aeeb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
11 deletions
+20
-11
src/codegen.c
src/codegen.c
+20
-11
No files found.
src/codegen.c
View file @
c15af5d5
...
...
@@ -1914,18 +1914,27 @@ codegen(codegen_scope *s, node *tree, int val)
case
NODE_REGX
:
if
(
val
)
{
char
*
p1
=
(
char
*
)
tree
->
car
;
//
char *p2 = (char*)tree->cdr;
char
*
p2
=
(
char
*
)
tree
->
cdr
;
int
ai
=
mrb_gc_arena_save
(
s
->
mrb
);
struct
RClass
*
c
=
mrb_class_get
(
s
->
mrb
,
REGEXP_CLASS
);
mrb_value
args
[
2
];
int
off
;
args
[
0
]
=
mrb_str_new
(
s
->
mrb
,
p1
,
strlen
(
p1
));
// TODO: Some regexp implementation does not have second argument
//args[1] = mrb_str_new(s->mrb, p2, strlen(p2))
off
=
new_lit
(
s
,
mrb_class_new_instance
(
s
->
mrb
,
1
,
args
,
c
));
mrb_gc_arena_restore
(
s
->
mrb
,
ai
);
genop
(
s
,
MKOP_ABx
(
OP_LOADL
,
cursp
(),
off
));
int
sym
=
new_sym
(
s
,
mrb_intern
(
s
->
mrb
,
REGEXP_CLASS
));
int
off
=
new_lit
(
s
,
mrb_str_new
(
s
->
mrb
,
p1
,
strlen
(
p1
)));
int
n
=
1
;
genop
(
s
,
MKOP_A
(
OP_OCLASS
,
cursp
()));
genop
(
s
,
MKOP_ABx
(
OP_GETMCNST
,
cursp
(),
sym
));
push
();
genop
(
s
,
MKOP_ABx
(
OP_STRING
,
cursp
(),
off
));
if
(
p2
)
{
push
();
off
=
new_lit
(
s
,
mrb_str_new
(
s
->
mrb
,
p2
,
strlen
(
p2
)));
genop
(
s
,
MKOP_ABx
(
OP_STRING
,
cursp
(),
off
));
n
++
;
pop
();
}
pop
();
sym
=
new_sym
(
s
,
mrb_intern
(
s
->
mrb
,
"new"
));
genop
(
s
,
MKOP_ABC
(
OP_SEND
,
cursp
(),
sym
,
n
));
mrb_gc_arena_restore
(
s
->
mrb
,
ai
);
push
();
}
break
;
...
...
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