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
e73a0913
Commit
e73a0913
authored
Aug 20, 2014
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'cubicdaiya-issues/scope_new_error_handlings'
parents
c7fda223
05ede522
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
43 additions
and
8 deletions
+43
-8
src/class.c
src/class.c
+3
-3
src/codegen.c
src/codegen.c
+13
-1
src/load.c
src/load.c
+7
-0
src/parse.y
src/parse.y
+4
-4
src/pool.c
src/pool.c
+3
-0
src/state.c
src/state.c
+4
-0
tasks/mrbgem_spec.rake
tasks/mrbgem_spec.rake
+1
-0
tasks/mrbgems_test.rake
tasks/mrbgems_test.rake
+4
-0
test/init_mrbtest.c
test/init_mrbtest.c
+4
-0
No files found.
src/class.c
View file @
e73a0913
...
...
@@ -128,7 +128,7 @@ mrb_class_outer_module(mrb_state *mrb, struct RClass *c)
mrb_value
outer
;
outer
=
mrb_obj_iv_get
(
mrb
,
(
struct
RObject
*
)
c
,
mrb_intern_lit
(
mrb
,
"__outer__"
));
if
(
mrb_nil_p
(
outer
))
return
0
;
if
(
mrb_nil_p
(
outer
))
return
NULL
;
return
mrb_class_ptr
(
outer
);
}
...
...
@@ -1030,7 +1030,7 @@ mrb_method_search_vm(mrb_state *mrb, struct RClass **cp, mrb_sym mid)
}
c
=
c
->
super
;
}
return
0
;
/* no method */
return
NULL
;
/* no method */
}
MRB_API
struct
RProc
*
...
...
@@ -1295,7 +1295,7 @@ MRB_API struct RClass *
mrb_class_real
(
struct
RClass
*
cl
)
{
if
(
cl
==
0
)
return
0
;
return
NULL
;
while
((
cl
->
tt
==
MRB_TT_SCLASS
)
||
(
cl
->
tt
==
MRB_TT_ICLASS
))
{
cl
=
cl
->
super
;
}
...
...
src/codegen.c
View file @
e73a0913
...
...
@@ -85,6 +85,7 @@ static void gen_assignment(codegen_scope *s, node *node, int sp, int val);
static
void
gen_vmassignment
(
codegen_scope
*
s
,
node
*
tree
,
int
rhs
,
int
val
);
static
void
codegen
(
codegen_scope
*
s
,
node
*
tree
,
int
val
);
static
void
raise_error
(
codegen_scope
*
s
,
const
char
*
msg
);
static
void
codegen_error
(
codegen_scope
*
s
,
const
char
*
message
)
...
...
@@ -552,6 +553,10 @@ for_body(codegen_scope *s, node *tree)
codegen
(
s
,
tree
->
cdr
->
car
,
VAL
);
/* generate loop-block */
s
=
scope_new
(
s
->
mrb
,
s
,
NULL
);
if
(
s
==
NULL
)
{
raise_error
(
prev
,
"unexpected scope"
);
}
push
();
/* push for a block parameter */
lp
=
loop_push
(
s
,
LOOP_FOR
);
...
...
@@ -589,6 +594,10 @@ lambda_body(codegen_scope *s, node *tree, int blk)
mrb_code
c
;
codegen_scope
*
parent
=
s
;
s
=
scope_new
(
s
->
mrb
,
s
,
tree
->
car
);
if
(
s
==
NULL
)
{
raise_error
(
parent
,
"unexpected scope"
);
}
s
->
mscope
=
!
blk
;
if
(
blk
)
{
...
...
@@ -674,6 +683,9 @@ static int
scope_body
(
codegen_scope
*
s
,
node
*
tree
,
int
val
)
{
codegen_scope
*
scope
=
scope_new
(
s
->
mrb
,
s
,
tree
->
car
);
if
(
scope
==
NULL
)
{
raise_error
(
s
,
"unexpected scope"
);
}
codegen
(
scope
,
tree
->
cdr
,
VAL
);
if
(
!
s
->
iseq
)
{
...
...
@@ -2470,7 +2482,7 @@ scope_new(mrb_state *mrb, codegen_scope *prev, node *lv)
mrb_pool
*
pool
=
mrb_pool_open
(
mrb
);
codegen_scope
*
p
=
(
codegen_scope
*
)
mrb_pool_alloc
(
pool
,
sizeof
(
codegen_scope
));
if
(
!
p
)
return
0
;
if
(
!
p
)
return
NULL
;
*
p
=
codegen_scope_zero
;
p
->
mrb
=
mrb
;
p
->
mpool
=
pool
;
...
...
src/load.c
View file @
e73a0913
...
...
@@ -164,11 +164,18 @@ read_irep_record(mrb_state *mrb, const uint8_t *bin, size_t *len, mrb_bool alloc
mrb_irep
*
irep
=
read_irep_record_1
(
mrb
,
bin
,
len
,
alloc
);
size_t
i
;
if
(
irep
==
NULL
)
{
return
NULL
;
}
bin
+=
*
len
;
for
(
i
=
0
;
i
<
irep
->
rlen
;
i
++
)
{
size_t
rlen
;
irep
->
reps
[
i
]
=
read_irep_record
(
mrb
,
bin
,
&
rlen
,
alloc
);
if
(
irep
->
reps
[
i
]
==
NULL
)
{
return
NULL
;
}
bin
+=
rlen
;
*
len
+=
rlen
;
}
...
...
src/parse.y
View file @
e73a0913
...
...
@@ -5365,9 +5365,9 @@ mrb_parser_new(mrb_state *mrb)
static const parser_state parser_state_zero = { 0 };
pool = mrb_pool_open(mrb);
if (!pool) return
0
;
if (!pool) return
NULL
;
p = (parser_state *)mrb_pool_alloc(pool, sizeof(parser_state));
if (!p) return
0
;
if (!p) return
NULL
;
*p = parser_state_zero;
p->mrb = mrb;
...
...
@@ -5483,7 +5483,7 @@ mrb_parse_file(mrb_state *mrb, FILE *f, mrbc_context *c)
parser_state *p;
p = mrb_parser_new(mrb);
if (!p) return
0
;
if (!p) return
NULL
;
p->s = p->send = NULL;
p->f = f;
...
...
@@ -5498,7 +5498,7 @@ mrb_parse_nstring(mrb_state *mrb, const char *s, int len, mrbc_context *c)
parser_state *p;
p = mrb_parser_new(mrb);
if (!p) return
0
;
if (!p) return
NULL
;
p->s = s;
p->send = s + len;
...
...
src/pool.c
View file @
e73a0913
...
...
@@ -166,6 +166,9 @@ mrb_pool_realloc(mrb_pool *pool, void *p, size_t oldlen, size_t newlen)
page
=
page
->
next
;
}
np
=
mrb_pool_alloc
(
pool
,
newlen
);
if
(
np
==
NULL
)
{
return
NULL
;
}
memcpy
(
np
,
p
,
oldlen
);
return
np
;
}
...
...
src/state.c
View file @
e73a0913
...
...
@@ -110,6 +110,10 @@ mrb_open_allocf(mrb_allocf f, void *ud)
{
mrb_state
*
mrb
=
mrb_open_core
(
f
,
ud
);
if
(
mrb
==
NULL
)
{
return
NULL
;
}
#ifndef DISABLE_GEMS
mrb_init_mrbgems
(
mrb
);
mrb_gc_arena_restore
(
mrb
,
0
);
...
...
tasks/mrbgem_spec.rake
View file @
e73a0913
...
...
@@ -183,6 +183,7 @@ module MRuby
def
print_gem_test_header
(
f
)
print_gem_comment
(
f
)
f
.
puts
%Q[#include <stdio.h>]
f
.
puts
%Q[#include <stdlib.h>]
f
.
puts
%Q[#include "mruby.h"]
f
.
puts
%Q[#include "mruby/irep.h"]
...
...
tasks/mrbgems_test.rake
View file @
e73a0913
...
...
@@ -47,6 +47,10 @@ MRuby.each_target do
g
.
test_rbfiles
.
count
.
times
do
|
i
|
f
.
puts
%Q[ ai = mrb_gc_arena_save(mrb);]
f
.
puts
%Q[ mrb2 = mrb_open_core(mrb_default_allocf, NULL);]
f
.
puts
%Q[ if (mrb2 == NULL) {]
f
.
puts
%Q[ fprintf(stderr, "Invalid mrb_state, exiting
\%
s", __FUNCTION__);]
f
.
puts
%Q[ exit(EXIT_FAILURE);]
f
.
puts
%Q[ }]
dep_list
.
each
do
|
d
|
f
.
puts
%Q[ GENERATED_TMP_mrb_
#{
d
.
funcname
}
_gem_init(mrb2);]
f
.
puts
%Q[ mrb_state_atexit(mrb2, GENERATED_TMP_mrb_
#{
d
.
funcname
}
_gem_final);]
...
...
test/init_mrbtest.c
View file @
e73a0913
...
...
@@ -18,6 +18,10 @@ mrb_init_mrbtest(mrb_state *mrb)
mrb_load_irep
(
mrb
,
mrbtest_assert_irep
);
core_test
=
mrb_open_core
(
mrb_default_allocf
,
NULL
);
if
(
core_test
==
NULL
)
{
fprintf
(
stderr
,
"Invalid mrb_state, exiting %s"
,
__FUNCTION__
);
exit
(
EXIT_FAILURE
);
}
mrb_init_test_driver
(
core_test
,
mrb_test
(
mrb_gv_get
(
mrb
,
mrb_intern_lit
(
mrb
,
"$mrbtest_verbose"
))));
mrb_load_irep
(
core_test
,
mrbtest_assert_irep
);
mrb_load_irep
(
core_test
,
mrbtest_irep
);
...
...
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