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
432e8e9e
Commit
432e8e9e
authored
Aug 08, 2014
by
Satoshi Odawara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed evaluation context of eval(string) and instance_eval(string)
parent
569c7dec
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
0 deletions
+16
-0
mrbgems/mruby-eval/src/eval.c
mrbgems/mruby-eval/src/eval.c
+3
-0
mrbgems/mruby-eval/test/eval.rb
mrbgems/mruby-eval/test/eval.rb
+13
-0
No files found.
mrbgems/mruby-eval/src/eval.c
View file @
432e8e9e
...
@@ -132,6 +132,9 @@ create_proc_from_string(mrb_state *mrb, char *s, int len, mrb_value binding, cha
...
@@ -132,6 +132,9 @@ create_proc_from_string(mrb_state *mrb, char *s, int len, mrb_value binding, cha
}
}
proc
=
mrb_generate_code
(
mrb
,
p
);
proc
=
mrb_generate_code
(
mrb
,
p
);
if
(
mrb
->
c
->
ci
[
-
1
].
proc
->
target_class
)
{
proc
->
target_class
=
mrb
->
c
->
ci
[
-
1
].
proc
->
target_class
;
}
e
=
(
struct
REnv
*
)
mrb_obj_alloc
(
mrb
,
MRB_TT_ENV
,
(
struct
RClass
*
)
mrb
->
c
->
ci
[
-
1
].
proc
->
env
);
e
=
(
struct
REnv
*
)
mrb_obj_alloc
(
mrb
,
MRB_TT_ENV
,
(
struct
RClass
*
)
mrb
->
c
->
ci
[
-
1
].
proc
->
env
);
e
->
mid
=
mrb
->
c
->
ci
[
-
1
].
mid
;
e
->
mid
=
mrb
->
c
->
ci
[
-
1
].
mid
;
e
->
cioff
=
mrb
->
c
->
ci
-
mrb
->
c
->
cibase
-
1
;
e
->
cioff
=
mrb
->
c
->
ci
-
mrb
->
c
->
cibase
-
1
;
...
...
mrbgems/mruby-eval/test/eval.rb
View file @
432e8e9e
...
@@ -60,3 +60,16 @@ assert('String instance_eval') do
...
@@ -60,3 +60,16 @@ assert('String instance_eval') do
assert_equal
(
'test'
)
{
obj
.
instance_eval
(
'@test'
)
}
assert_equal
(
'test'
)
{
obj
.
instance_eval
(
'@test'
)
}
assert_equal
(
'test'
)
{
obj
.
instance_eval
{
@test
}
}
assert_equal
(
'test'
)
{
obj
.
instance_eval
{
@test
}
}
end
end
assert
(
'Kernel.#eval(string) context'
)
do
class
TestEvalConstScope
EVAL_CONST_CLASS
=
'class'
def
const_string
eval
'EVAL_CONST_CLASS'
end
end
obj
=
TestEvalConstScope
.
new
assert_raise
(
NameError
)
{
eval
'EVAL_CONST_CLASS'
}
assert_equal
(
'class'
)
{
obj
.
const_string
}
end
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