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
58e94427
Commit
58e94427
authored
4 years ago
by
dearblue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unified `target_class` and `env` of `mrb_callinfo`
If there is `env`, `env->c` means `target_class`.
parent
b210cfa3
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
116 additions
and
55 deletions
+116
-55
include/mruby.h
include/mruby.h
+4
-2
include/mruby/proc.h
include/mruby/proc.h
+61
-0
lib/mruby/gem.rb
lib/mruby/gem.rb
+2
-2
mrbgems/mruby-bin-mirb/tools/mirb/mirb.c
mrbgems/mruby-bin-mirb/tools/mirb/mirb.c
+4
-4
mrbgems/mruby-bin-mruby/tools/mruby/mruby.c
mrbgems/mruby-bin-mruby/tools/mruby/mruby.c
+2
-2
mrbgems/mruby-class-ext/src/class.c
mrbgems/mruby-class-ext/src/class.c
+2
-1
mrbgems/mruby-compiler/core/parse.y
mrbgems/mruby-compiler/core/parse.y
+1
-1
mrbgems/mruby-compiler/core/y.tab.c
mrbgems/mruby-compiler/core/y.tab.c
+1
-1
mrbgems/mruby-eval/src/eval.c
mrbgems/mruby-eval/src/eval.c
+5
-5
mrbgems/mruby-fiber/src/fiber.c
mrbgems/mruby-fiber/src/fiber.c
+2
-2
mrbgems/mruby-object-ext/src/object.c
mrbgems/mruby-object-ext/src/object.c
+1
-1
src/gc.c
src/gc.c
+2
-3
src/kernel.c
src/kernel.c
+1
-2
src/proc.c
src/proc.c
+5
-5
src/vm.c
src/vm.c
+23
-24
No files found.
include/mruby.h
View file @
58e94427
...
...
@@ -152,12 +152,14 @@ typedef struct {
mrb_sym
mid
;
const
struct
RProc
*
proc
;
mrb_value
*
stackent
;
struct
REnv
*
env
;
const
mrb_code
*
pc
;
/* return address */
const
mrb_code
*
err
;
/* error position */
int16_t
argc
;
int16_t
acc
;
struct
RClass
*
target_class
;
union
{
struct
REnv
*
env
;
struct
RClass
*
target_class
;
}
u
;
}
mrb_callinfo
;
enum
mrb_fiber_state
{
...
...
This diff is collapsed.
Click to expand it.
include/mruby/proc.h
View file @
58e94427
...
...
@@ -136,6 +136,67 @@ MRB_API mrb_value mrb_proc_cfunc_env_get(mrb_state *mrb, mrb_int idx);
MRB_API
mrb_value
mrb_load_proc
(
mrb_state
*
mrb
,
const
struct
RProc
*
proc
);
static
inline
struct
RClass
*
mrb_vm_ci_target_class
(
const
mrb_callinfo
*
ci
)
{
if
(
ci
->
u
.
env
&&
ci
->
u
.
env
->
tt
==
MRB_TT_ENV
)
{
return
ci
->
u
.
env
->
c
;
}
else
{
return
ci
->
u
.
target_class
;
}
}
static
inline
void
mrb_vm_ci_target_class_set
(
mrb_callinfo
*
ci
,
struct
RClass
*
tc
)
{
struct
REnv
*
e
=
ci
->
u
.
env
;
if
(
e
)
{
if
(
e
->
tt
==
MRB_TT_ENV
)
{
e
->
c
=
tc
;
}
else
{
ci
->
u
.
target_class
=
tc
;
}
}
}
static
inline
struct
REnv
*
mrb_vm_ci_env
(
const
mrb_callinfo
*
ci
)
{
if
(
ci
->
u
.
env
&&
ci
->
u
.
env
->
tt
==
MRB_TT_ENV
)
{
return
ci
->
u
.
env
;
}
else
{
return
NULL
;
}
}
static
inline
void
mrb_vm_ci_env_set
(
mrb_callinfo
*
ci
,
struct
REnv
*
e
)
{
if
(
ci
->
u
.
env
)
{
if
(
ci
->
u
.
env
->
tt
==
MRB_TT_ENV
)
{
if
(
e
)
{
e
->
c
=
ci
->
u
.
env
->
c
;
ci
->
u
.
env
=
e
;
}
else
{
ci
->
u
.
target_class
=
ci
->
u
.
env
->
c
;
}
}
else
{
if
(
e
)
{
e
->
c
=
ci
->
u
.
target_class
;
ci
->
u
.
env
=
e
;
}
}
}
else
{
ci
->
u
.
env
=
e
;
}
}
MRB_END_DECL
#endif
/* MRUBY_PROC_H */
This diff is collapsed.
Click to expand it.
lib/mruby/gem.rb
View file @
58e94427
...
...
@@ -218,8 +218,8 @@ module MRuby
f
.
puts
%Q[ mrb_close(mrb);]
f
.
puts
%Q[ exit(EXIT_FAILURE);]
f
.
puts
%Q[ }]
f
.
puts
%Q[ struct REnv *e = mrb
->c->cibase->env
;]
f
.
puts
%Q[ mrb
->c->cibase->env = NULL
;]
f
.
puts
%Q[ struct REnv *e = mrb
_vm_ci_env(mrb->c->cibase)
;]
f
.
puts
%Q[ mrb
_vm_ci_env_set(mrb->c->cibase, NULL)
;]
f
.
puts
%Q[ mrb_env_unshare(mrb, e);]
end
f
.
puts
%Q[ mrb_gc_arena_restore(mrb, ai);]
...
...
This diff is collapsed.
Click to expand it.
mrbgems/mruby-bin-mirb/tools/mirb/mirb.c
View file @
58e94427
...
...
@@ -516,8 +516,8 @@ main(int argc, char **argv)
}
mrb_load_file_cxt
(
mrb
,
lfp
,
cxt
);
fclose
(
lfp
);
e
=
mrb
->
c
->
cibase
->
env
;
mrb
->
c
->
cibase
->
env
=
NULL
;
e
=
mrb
_vm_ci_env
(
mrb
->
c
->
cibase
)
;
mrb
_vm_ci_env_set
(
mrb
->
c
->
cibase
,
NULL
)
;
mrb_env_unshare
(
mrb
,
e
);
mrbc_cleanup_local_variables
(
mrb
,
cxt
);
}
...
...
@@ -658,8 +658,8 @@ main(int argc, char **argv)
mrb_codedump_all
(
mrb
,
proc
);
}
/* adjust stack length of toplevel environment */
if
(
mrb
->
c
->
cibase
->
env
)
{
struct
REnv
*
e
=
mrb
->
c
->
cibase
->
env
;
if
(
mrb
->
c
->
cibase
->
u
.
env
)
{
struct
REnv
*
e
=
mrb
_vm_ci_env
(
mrb
->
c
->
cibase
)
;
if
(
e
&&
MRB_ENV_LEN
(
e
)
<
proc
->
body
.
irep
->
nlocals
)
{
MRB_ENV_SET_LEN
(
e
,
proc
->
body
.
irep
->
nlocals
);
}
...
...
This diff is collapsed.
Click to expand it.
mrbgems/mruby-bin-mruby/tools/mruby/mruby.c
View file @
58e94427
...
...
@@ -333,8 +333,8 @@ main(int argc, char **argv)
v
=
mrb_load_detect_file_cxt
(
mrb
,
lfp
,
c
);
}
fclose
(
lfp
);
e
=
mrb
->
c
->
cibase
->
env
;
mrb
->
c
->
cibase
->
env
=
NULL
;
e
=
mrb
_vm_ci_env
(
mrb
->
c
->
cibase
)
;
mrb
_vm_ci_env_set
(
mrb
->
c
->
cibase
,
NULL
)
;
mrb_env_unshare
(
mrb
,
e
);
mrbc_cleanup_local_variables
(
mrb
,
c
);
}
...
...
This diff is collapsed.
Click to expand it.
mrbgems/mruby-class-ext/src/class.c
View file @
58e94427
#include "mruby.h"
#include "mruby/class.h"
#include "mruby/string.h"
#include "mruby/proc.h"
static
mrb_value
mrb_mod_name
(
mrb_state
*
mrb
,
mrb_value
self
)
...
...
@@ -51,7 +52,7 @@ mrb_mod_module_exec(mrb_state *mrb, mrb_value self)
if
(
mrb
->
c
->
ci
->
acc
<
0
)
{
return
mrb_yield_with_class
(
mrb
,
blk
,
argc
,
argv
,
self
,
c
);
}
mrb
->
c
->
ci
->
target_class
=
c
;
mrb
_vm_ci_target_class_set
(
mrb
->
c
->
ci
,
c
)
;
return
mrb_yield_cont
(
mrb
,
blk
,
self
,
argc
,
argv
);
}
...
...
This diff is collapsed.
Click to expand it.
mrbgems/mruby-compiler/core/parse.y
View file @
58e94427
...
...
@@ -6783,7 +6783,7 @@ mrb_load_exec(mrb_state *mrb, struct mrb_parser_state *p, mrbc_context *c)
}
MRB_PROC_SET_TARGET_CLASS(proc, target);
if (mrb->c->ci) {
mrb
->c->ci->target_class = target
;
mrb
_vm_ci_target_class_set(mrb->c->ci, target)
;
}
v = mrb_top_run(mrb, proc, mrb_top_self(mrb), keep);
if (mrb->exc) return mrb_nil_value();
...
...
This diff is collapsed.
Click to expand it.
mrbgems/mruby-compiler/core/y.tab.c
View file @
58e94427
...
...
@@ -12784,7 +12784,7 @@ mrb_load_exec(mrb_state *mrb, struct mrb_parser_state *p, mrbc_context *c)
}
MRB_PROC_SET_TARGET_CLASS
(
proc
,
target
);
if
(
mrb
->
c
->
ci
)
{
mrb
->c->ci->target_class = target
;
mrb
_vm_ci_target_class_set
(
mrb
->
c
->
ci
,
target
)
;
}
v
=
mrb_top_run
(
mrb
,
proc
,
mrb_top_self
(
mrb
),
keep
);
if
(
mrb
->
exc
)
return
mrb_nil_value
();
...
...
This diff is collapsed.
Click to expand it.
mrbgems/mruby-eval/src/eval.c
View file @
58e94427
...
...
@@ -79,19 +79,19 @@ create_proc_from_string(mrb_state *mrb, const char *s, mrb_int len, mrb_value bi
target_class
=
MRB_PROC_TARGET_CLASS
(
ci
->
proc
);
}
if
(
ci
->
proc
&&
!
MRB_PROC_CFUNC_P
(
ci
->
proc
))
{
if
(
ci
->
env
)
{
e
=
ci
->
env
;
if
(
(
e
=
mrb_vm_ci_env
(
ci
))
!=
NULL
)
{
/* do nothing, because e is assigned already */
}
else
{
e
=
mrb_env_new
(
mrb
,
mrb
->
c
,
ci
,
ci
->
proc
->
body
.
irep
->
nlocals
,
ci
[
1
].
stackent
,
target_class
);
ci
->
env
=
e
;
ci
->
u
.
env
=
e
;
}
proc
->
e
.
env
=
e
;
proc
->
flags
|=
MRB_PROC_ENVSET
;
mrb_field_write_barrier
(
mrb
,
(
struct
RBasic
*
)
proc
,
(
struct
RBasic
*
)
e
);
}
proc
->
upper
=
ci
->
proc
;
mrb
->
c
->
ci
->
target_class
=
target_class
;
mrb
_vm_ci_target_class_set
(
mrb
->
c
->
ci
,
target_class
)
;
/* mrb_codedump_all(mrb, proc); */
mrb_parser_free
(
p
);
...
...
@@ -157,7 +157,7 @@ f_instance_eval(mrb_state *mrb, mrb_value self)
proc
=
create_proc_from_string
(
mrb
,
s
,
len
,
mrb_nil_value
(),
file
,
line
);
MRB_PROC_SET_TARGET_CLASS
(
proc
,
mrb_class_ptr
(
cv
));
mrb_assert
(
!
MRB_PROC_CFUNC_P
(
proc
));
mrb
->
c
->
ci
->
target_class
=
mrb_class_ptr
(
cv
);
mrb
_vm_ci_target_class_set
(
mrb
->
c
->
ci
,
mrb_class_ptr
(
cv
)
);
return
exec_irep
(
mrb
,
self
,
proc
);
}
else
{
...
...
This diff is collapsed.
Click to expand it.
mrbgems/mruby-fiber/src/fiber.c
View file @
58e94427
...
...
@@ -120,7 +120,7 @@ fiber_init(mrb_state *mrb, mrb_value self)
/* adjust return callinfo */
ci
=
c
->
ci
;
ci
->
target_class
=
MRB_PROC_TARGET_CLASS
(
p
);
mrb_vm_ci_target_class_set
(
ci
,
MRB_PROC_TARGET_CLASS
(
p
)
);
ci
->
proc
=
p
;
mrb_field_write_barrier
(
mrb
,
(
struct
RBasic
*
)
mrb_obj_ptr
(
self
),
(
struct
RBasic
*
)
p
);
ci
->
pc
=
p
->
body
.
irep
->
iseq
;
...
...
@@ -154,7 +154,7 @@ fiber_result(mrb_state *mrb, const mrb_value *a, mrb_int len)
}
/* mark return from context modifying method */
#define MARK_CONTEXT_MODIFY(c) (c)->ci->target_class = NULL
#define MARK_CONTEXT_MODIFY(c) (c)->ci->
u.
target_class = NULL
static
void
fiber_check_cfunc
(
mrb_state
*
mrb
,
struct
mrb_context
*
c
)
...
...
This diff is collapsed.
Click to expand it.
mrbgems/mruby-object-ext/src/object.c
View file @
58e94427
...
...
@@ -105,7 +105,7 @@ mrb_obj_instance_exec(mrb_state *mrb, mrb_value self)
if
(
mrb
->
c
->
ci
->
acc
<
0
)
{
return
mrb_yield_with_class
(
mrb
,
blk
,
argc
,
argv
,
self
,
c
);
}
mrb
->
c
->
ci
->
target_class
=
c
;
mrb
_vm_ci_target_class_set
(
mrb
->
c
->
ci
,
c
)
;
return
mrb_yield_cont
(
mrb
,
blk
,
self
,
argc
,
argv
);
}
...
...
This diff is collapsed.
Click to expand it.
src/gc.c
View file @
58e94427
...
...
@@ -660,9 +660,8 @@ mark_context(mrb_state *mrb, struct mrb_context *c)
/* mark call stack */
if
(
c
->
cibase
)
{
for
(
ci
=
c
->
cibase
;
ci
<=
c
->
ci
;
ci
++
)
{
mrb_gc_mark
(
mrb
,
(
struct
RBasic
*
)
ci
->
env
);
mrb_gc_mark
(
mrb
,
(
struct
RBasic
*
)
ci
->
proc
);
mrb_gc_mark
(
mrb
,
(
struct
RBasic
*
)
ci
->
target_class
);
mrb_gc_mark
(
mrb
,
(
struct
RBasic
*
)
ci
->
u
.
target_class
);
}
}
/* mark fibers */
...
...
@@ -840,7 +839,7 @@ obj_free(mrb_state *mrb, struct RBasic *obj, int end)
mrb_callinfo
*
ce
=
c
->
cibase
;
while
(
ce
<=
ci
)
{
struct
REnv
*
e
=
ci
->
env
;
struct
REnv
*
e
=
ci
->
u
.
env
;
if
(
e
&&
!
mrb_object_dead_p
(
mrb
,
(
struct
RBasic
*
)
e
)
&&
e
->
tt
==
MRB_TT_ENV
&&
MRB_ENV_ONSTACK_P
(
e
))
{
mrb_env_unshare
(
mrb
,
e
);
...
...
This diff is collapsed.
Click to expand it.
src/kernel.c
View file @
58e94427
...
...
@@ -176,8 +176,7 @@ mrb_f_block_given_p_m(mrb_state *mrb, mrb_value self)
if
(
bidx
<
0
)
return
mrb_false_value
();
bp
=
&
e
->
stack
[
bidx
];
}
else
if
(
ci
->
env
)
{
e
=
ci
->
env
;
else
if
((
e
=
mrb_vm_ci_env
(
ci
))
!=
NULL
)
{
/* top-level does not have block slot (always false) */
if
(
e
->
stack
==
mrb
->
c
->
stbase
)
return
mrb_false_value
();
bidx
=
env_bidx
(
e
);
...
...
This diff is collapsed.
Click to expand it.
src/proc.c
View file @
58e94427
...
...
@@ -46,7 +46,7 @@ mrb_proc_new(mrb_state *mrb, const mrb_irep *irep)
tc
=
MRB_PROC_TARGET_CLASS
(
ci
->
proc
);
}
if
(
tc
==
NULL
)
{
tc
=
ci
->
target_class
;
tc
=
mrb_vm_ci_target_class
(
ci
)
;
}
p
->
upper
=
ci
->
proc
;
p
->
e
.
target_class
=
tc
;
...
...
@@ -83,14 +83,14 @@ closure_setup(mrb_state *mrb, struct RProc *p)
const
struct
RProc
*
up
=
p
->
upper
;
struct
REnv
*
e
=
NULL
;
if
(
ci
&&
ci
->
env
)
{
e
=
ci
->
env
;
if
(
ci
&&
(
e
=
mrb_vm_ci_env
(
ci
))
!=
NULL
)
{
/* do nothing, because e is assigned already */
}
else
if
(
up
)
{
struct
RClass
*
tc
=
MRB_PROC_TARGET_CLASS
(
p
);
e
=
mrb_env_new
(
mrb
,
mrb
->
c
,
ci
,
up
->
body
.
irep
->
nlocals
,
mrb
->
c
->
stack
,
tc
);
ci
->
env
=
e
;
ci
->
u
.
env
=
e
;
if
(
MRB_PROC_ENV_P
(
up
)
&&
MRB_PROC_ENV
(
up
)
->
cxt
==
NULL
)
{
e
->
mid
=
MRB_PROC_ENV
(
up
)
->
mid
;
}
...
...
@@ -211,7 +211,7 @@ mrb_proc_s_new(mrb_state *mrb, mrb_value proc_class)
proc
=
mrb_obj_value
(
p
);
mrb_funcall_with_block
(
mrb
,
proc
,
MRB_SYM
(
initialize
),
0
,
NULL
,
proc
);
if
(
!
MRB_PROC_STRICT_P
(
p
)
&&
mrb
->
c
->
ci
>
mrb
->
c
->
cibase
&&
MRB_PROC_ENV
(
p
)
==
mrb
->
c
->
ci
[
-
1
].
env
)
{
mrb
->
c
->
ci
>
mrb
->
c
->
cibase
&&
MRB_PROC_ENV
(
p
)
==
mrb
->
c
->
ci
[
-
1
].
u
.
env
)
{
p
->
flags
|=
MRB_PROC_ORPHAN
;
}
return
proc
;
...
...
This diff is collapsed.
Click to expand it.
src/vm.c
View file @
58e94427
...
...
@@ -133,7 +133,7 @@ stack_init(mrb_state *mrb)
c
->
cibase
=
(
mrb_callinfo
*
)
mrb_calloc
(
mrb
,
CALLINFO_INIT_SIZE
,
sizeof
(
mrb_callinfo
));
c
->
ciend
=
c
->
cibase
+
CALLINFO_INIT_SIZE
;
c
->
ci
=
c
->
cibase
;
c
->
ci
->
target_class
=
mrb
->
object_class
;
c
->
ci
->
u
.
target_class
=
mrb
->
object_class
;
c
->
ci
->
stackent
=
c
->
stack
;
}
...
...
@@ -144,7 +144,7 @@ envadjust(mrb_state *mrb, mrb_value *oldbase, mrb_value *newbase, size_t oldsize
if
(
newbase
==
oldbase
)
return
;
while
(
ci
<=
mrb
->
c
->
ci
)
{
struct
REnv
*
e
=
ci
->
env
;
struct
REnv
*
e
=
mrb_vm_ci_env
(
ci
)
;
mrb_value
*
st
;
if
(
e
&&
MRB_ENV_ONSTACK_P
(
e
)
&&
...
...
@@ -154,7 +154,7 @@ envadjust(mrb_state *mrb, mrb_value *oldbase, mrb_value *newbase, size_t oldsize
e
->
stack
=
newbase
+
off
;
}
if
(
ci
->
proc
&&
MRB_PROC_ENV_P
(
ci
->
proc
)
&&
ci
->
env
!=
MRB_PROC_ENV
(
ci
->
proc
))
{
if
(
ci
->
proc
&&
MRB_PROC_ENV_P
(
ci
->
proc
)
&&
e
!=
MRB_PROC_ENV
(
ci
->
proc
))
{
e
=
MRB_PROC_ENV
(
ci
->
proc
);
if
(
e
&&
MRB_ENV_ONSTACK_P
(
e
)
&&
...
...
@@ -240,7 +240,7 @@ uvenv(mrb_state *mrb, mrb_int up)
while
(
cb
<=
ci
)
{
if
(
ci
->
proc
==
proc
)
{
return
ci
->
env
;
return
mrb_vm_ci_env
(
ci
)
;
}
ci
--
;
}
...
...
@@ -284,9 +284,8 @@ cipush(mrb_state *mrb, const mrb_code *pc, mrb_int push_stacks, mrb_int acc,
ci
->
pc
=
pc
;
ci
->
argc
=
argc
;
ci
->
acc
=
acc
;
ci
->
target_class
=
target_class
;
ci
->
u
.
target_class
=
target_class
;
ci
->
err
=
0
;
ci
->
env
=
0
;
c
->
stack
+=
push_stacks
;
return
ci
;
...
...
@@ -302,7 +301,7 @@ mrb_env_unshare(mrb_state *mrb, struct REnv *e)
if
(
!
MRB_ENV_ONSTACK_P
(
e
))
return
;
if
(
e
->
cxt
!=
mrb
->
c
)
return
;
if
(
e
==
mrb
->
c
->
cibase
->
env
)
return
;
/* for mirb */
if
(
e
==
mrb
_vm_ci_env
(
mrb
->
c
->
cibase
)
)
return
;
/* for mirb */
p
=
(
mrb_value
*
)
mrb_malloc
(
mrb
,
sizeof
(
mrb_value
)
*
len
);
if
(
len
>
0
)
{
stack_copy
(
p
,
e
->
stack
,
len
);
...
...
@@ -317,7 +316,7 @@ static inline mrb_callinfo*
cipop
(
mrb_state
*
mrb
)
{
struct
mrb_context
*
c
=
mrb
->
c
;
struct
REnv
*
env
=
c
->
ci
->
env
;
struct
REnv
*
env
=
mrb_vm_ci_env
(
c
->
ci
)
;
mrb
->
c
->
stack
=
c
->
ci
->
stackent
;
c
->
ci
--
;
...
...
@@ -573,7 +572,7 @@ mrb_f_send(mrb_state *mrb, mrb_value self)
}
ci
->
mid
=
name
;
ci
->
target_class
=
c
;
ci
->
u
.
target_class
=
c
;
regs
=
mrb
->
c
->
stack
+
1
;
/* remove first symbol from arguments */
if
(
ci
->
argc
>=
0
)
{
...
...
@@ -609,7 +608,7 @@ eval_under(mrb_state *mrb, mrb_value self, mrb_value blk, struct RClass *c)
if
(
ci
->
acc
==
CI_ACC_DIRECT
)
{
return
mrb_yield_with_class
(
mrb
,
blk
,
1
,
&
self
,
self
,
c
);
}
ci
->
target_class
=
c
;
ci
->
u
.
target_class
=
c
;
p
=
mrb_proc_ptr
(
blk
);
ci
->
proc
=
p
;
ci
->
argc
=
1
;
...
...
@@ -1005,7 +1004,7 @@ mrb_vm_run(mrb_state *mrb, const struct RProc *proc, mrb_value self, mrb_int sta
static
mrb_bool
check_target_class
(
mrb_state
*
mrb
)
{
if
(
!
mrb
->
c
->
ci
->
target_class
)
{
if
(
!
mrb
_vm_ci_target_class
(
mrb
->
c
->
ci
)
)
{
mrb_value
exc
=
mrb_exc_new_lit
(
mrb
,
E_TYPE_ERROR
,
"no target class or module"
);
mrb_exc_set
(
mrb
,
exc
);
return
FALSE
;
...
...
@@ -1476,11 +1475,11 @@ RETRY_TRY_BLOCK:
ci
=
mrb
->
c
->
ci
;
if
(
mrb_proc_p
(
blk
))
{
struct
RProc
*
p
=
mrb_proc_ptr
(
blk
);
if
(
p
&&
!
MRB_PROC_STRICT_P
(
p
)
&&
MRB_PROC_ENV
(
p
)
==
ci
[
-
1
].
env
)
{
if
(
p
&&
!
MRB_PROC_STRICT_P
(
p
)
&&
MRB_PROC_ENV
(
p
)
==
mrb_vm_ci_env
(
&
ci
[
-
1
])
)
{
p
->
flags
|=
MRB_PROC_ORPHAN
;
}
}
if
(
!
ci
->
target_class
)
{
/* return from context modifying method (resume/yield) */
if
(
!
ci
->
u
.
target_class
)
{
/* return from context modifying method (resume/yield) */
if
(
ci
->
acc
==
CI_ACC_RESUMED
)
{
mrb
->
jmp
=
prev_jmp
;
return
recv
;
...
...
@@ -1518,7 +1517,7 @@ RETRY_TRY_BLOCK:
/* replace callinfo */
ci
=
mrb
->
c
->
ci
;
ci
->
target_class
=
MRB_PROC_TARGET_CLASS
(
m
);
ci
->
u
.
target_class
=
MRB_PROC_TARGET_CLASS
(
m
);
ci
->
proc
=
m
;
if
(
MRB_PROC_ENV_P
(
m
))
{
ci
->
mid
=
MRB_PROC_ENV
(
m
)
->
mid
;
...
...
@@ -1591,10 +1590,10 @@ RETRY_TRY_BLOCK:
goto
L_RAISE
;
}
if
(
target_class
->
flags
&
MRB_FL_CLASS_IS_PREPENDED
)
{
target_class
=
ci
->
target_class
;
target_class
=
mrb_vm_ci_target_class
(
ci
)
;
}
else
if
(
target_class
->
tt
==
MRB_TT_MODULE
)
{
target_class
=
ci
->
target_class
;
target_class
=
mrb_vm_ci_target_class
(
ci
)
;
if
(
target_class
->
tt
!=
MRB_TT_ICLASS
)
{
mrb_value
exc
=
mrb_exc_new_lit
(
mrb
,
E_RUNTIME_ERROR
,
"superclass info lost [mruby limitations]"
);
mrb_exc_set
(
mrb
,
exc
);
...
...
@@ -1659,7 +1658,7 @@ RETRY_TRY_BLOCK:
if
(
mrb
->
exc
)
goto
L_RAISE
;
ci
=
mrb
->
c
->
ci
;
mrb_assert
(
!
mrb_break_p
(
v
));
if
(
!
ci
->
target_class
)
{
/* return from context modifying method (resume/yield) */
if
(
!
mrb_vm_ci_target_class
(
ci
)
)
{
/* return from context modifying method (resume/yield) */
if
(
ci
->
acc
==
CI_ACC_RESUMED
)
{
mrb
->
jmp
=
prev_jmp
;
return
v
;
...
...
@@ -1700,7 +1699,7 @@ RETRY_TRY_BLOCK:
mrb_int
lv
=
(
b
>>
0
)
&
0xf
;
mrb_value
*
stack
;
if
(
mrb
->
c
->
ci
->
mid
==
0
||
mrb
->
c
->
ci
->
target_class
==
NULL
)
{
if
(
mrb
->
c
->
ci
->
mid
==
0
||
mrb
_vm_ci_target_class
(
mrb
->
c
->
ci
)
==
NULL
)
{
mrb_value
exc
;
L_NOSUPER:
...
...
@@ -1951,7 +1950,7 @@ RETRY_TRY_BLOCK:
struct
RProc
*
p
=
mrb_proc_ptr
(
blk
);
if
(
!
MRB_PROC_STRICT_P
(
p
)
&&
ci
>
mrb
->
c
->
cibase
&&
MRB_PROC_ENV
(
p
)
==
ci
[
-
1
].
env
)
{
ci
>
mrb
->
c
->
cibase
&&
MRB_PROC_ENV
(
p
)
==
mrb_vm_ci_env
(
&
ci
[
-
1
])
)
{
p
->
flags
|=
MRB_PROC_ORPHAN
;
}
}
...
...
@@ -2203,7 +2202,7 @@ RETRY_TRY_BLOCK:
mrb_assert
(
ci
==
mrb
->
c
->
ci
);
mrb_assert
(
mrb
->
exc
==
NULL
);
if
(
mrb
->
c
->
vmexec
&&
!
ci
->
target_class
)
{
if
(
mrb
->
c
->
vmexec
&&
!
mrb_vm_ci_target_class
(
ci
)
)
{
mrb_gc_arena_restore
(
mrb
,
ai
);
mrb
->
c
->
vmexec
=
FALSE
;
mrb
->
jmp
=
prev_jmp
;
...
...
@@ -2780,7 +2779,7 @@ RETRY_TRY_BLOCK:
CASE
(
OP_TCLASS
,
B
)
{
if
(
!
check_target_class
(
mrb
))
goto
L_RAISE
;
regs
[
a
]
=
mrb_obj_value
(
mrb
->
c
->
ci
->
target_class
);
regs
[
a
]
=
mrb_obj_value
(
mrb
_vm_ci_target_class
(
mrb
->
c
->
ci
)
);
NEXT
;
}
...
...
@@ -2788,7 +2787,7 @@ RETRY_TRY_BLOCK:
struct
RClass
*
target
;
if
(
!
check_target_class
(
mrb
))
goto
L_RAISE
;
target
=
mrb
->
c
->
ci
->
target_class
;
target
=
mrb
_vm_ci_target_class
(
mrb
->
c
->
ci
)
;
mrb_alias_method
(
mrb
,
target
,
syms
[
a
],
syms
[
b
]);
NEXT
;
}
...
...
@@ -2796,7 +2795,7 @@ RETRY_TRY_BLOCK:
struct
RClass
*
target
;
if
(
!
check_target_class
(
mrb
))
goto
L_RAISE
;
target
=
mrb
->
c
->
ci
->
target_class
;
target
=
mrb
_vm_ci_target_class
(
mrb
->
c
->
ci
)
;
mrb_undef_method_id
(
mrb
,
target
,
syms
[
a
]);
NEXT
;
}
...
...
@@ -2884,7 +2883,7 @@ mrb_top_run(mrb_state *mrb, const struct RProc *proc, mrb_value self, mrb_int st
return
mrb_vm_run
(
mrb
,
proc
,
self
,
stack_keep
);
}
if
(
mrb
->
c
->
ci
==
mrb
->
c
->
cibase
)
{
mrb
->
c
->
ci
->
env
=
NULL
;
mrb
_vm_ci_env_set
(
mrb
->
c
->
ci
,
NULL
)
;
return
mrb_vm_run
(
mrb
,
proc
,
self
,
stack_keep
);
}
cipush
(
mrb
,
NULL
,
0
,
CI_ACC_SKIP
,
mrb
->
object_class
,
NULL
,
0
,
0
);
...
...
This diff is collapsed.
Click to expand it.
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