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
5073d14e
Commit
5073d14e
authored
Apr 29, 2014
by
take_cheeze
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove `lv_len` and use `nlocals - 1` instead.
Check that `lv`'s length is always `nlocals - 1`.
parent
7ea82fed
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
12 additions
and
20 deletions
+12
-20
include/mruby/irep.h
include/mruby/irep.h
+1
-1
mrbgems/mruby-proc-ext/src/proc.c
mrbgems/mruby-proc-ext/src/proc.c
+2
-2
src/codegen.c
src/codegen.c
+2
-6
src/dump.c
src/dump.c
+5
-7
src/load.c
src/load.c
+2
-4
No files found.
include/mruby/irep.h
View file @
5073d14e
...
...
@@ -41,7 +41,7 @@ typedef struct mrb_irep {
uint16_t
*
lines
;
struct
mrb_irep_debug_info
*
debug_info
;
size_t
ilen
,
plen
,
slen
,
rlen
,
lv_len
,
refcnt
;
size_t
ilen
,
plen
,
slen
,
rlen
,
refcnt
;
}
mrb_irep
;
#define MRB_ISEQ_NO_FREE 1
...
...
mrbgems/mruby-proc-ext/src/proc.c
View file @
5073d14e
...
...
@@ -137,8 +137,8 @@ mrb_local_variables(mrb_state *mrb, mrb_value self)
}
irep
=
proc
->
body
.
irep
;
ret
=
mrb_ary_new_capa
(
mrb
,
irep
->
lv_len
);
for
(
i
=
0
;
i
<
irep
->
lv_len
;
++
i
)
{
ret
=
mrb_ary_new_capa
(
mrb
,
irep
->
nlocals
-
1
);
for
(
i
=
0
;
i
<
(
irep
->
nlocals
-
1
)
;
++
i
)
{
mrb_ary_push
(
mrb
,
ret
,
mrb_symbol_value
(
irep
->
lv
[
i
].
name
));
}
...
...
src/codegen.c
View file @
5073d14e
...
...
@@ -2496,20 +2496,16 @@ scope_new(mrb_state *mrb, codegen_scope *prev, node *lv)
p
->
lv
=
lv
;
p
->
sp
+=
node_len
(
lv
)
+
1
;
/* add self */
p
->
nlocals
=
p
->
sp
;
p
->
irep
->
lv_len
=
0
;
if
(
lv
)
{
node
*
n
=
lv
;
size_t
i
=
0
;
for
(
n
=
lv
;
n
;
n
=
n
->
cdr
)
{
p
->
irep
->
lv_len
++
;
}
p
->
irep
->
lv
=
(
struct
mrb_locals
*
)
mrb_malloc
(
mrb
,
sizeof
(
struct
mrb_locals
)
*
p
->
irep
->
lv_len
);
p
->
irep
->
lv
=
(
struct
mrb_locals
*
)
mrb_malloc
(
mrb
,
sizeof
(
struct
mrb_locals
)
*
(
p
->
nlocals
-
1
));
for
(
i
=
0
,
n
=
lv
;
n
;
i
++
,
n
=
n
->
cdr
)
{
p
->
irep
->
lv
[
i
].
name
=
lv_name
(
n
);
p
->
irep
->
lv
[
i
].
r
=
lv_idx
(
p
,
lv_name
(
n
));
}
mrb_assert
(
i
==
(
p
->
nlocals
-
1
));
}
p
->
ai
=
mrb_gc_arena_save
(
mrb
);
...
...
src/dump.c
View file @
5073d14e
...
...
@@ -693,7 +693,7 @@ write_section_debug(mrb_state *mrb, mrb_irep *irep, uint8_t *cur)
}
static
void
create_lv_sym_table
(
mrb_state
*
mrb
,
mrb_irep
*
irep
,
mrb_sym
**
syms
,
uint32_t
*
syms_len
)
create_lv_sym_table
(
mrb_state
*
mrb
,
const
mrb_irep
*
irep
,
mrb_sym
**
syms
,
uint32_t
*
syms_len
)
{
size_t
i
;
...
...
@@ -701,7 +701,7 @@ create_lv_sym_table(mrb_state *mrb, mrb_irep *irep, mrb_sym **syms, uint32_t *sy
*
syms
=
(
mrb_sym
*
)
mrb_malloc
(
mrb
,
sizeof
(
mrb_sym
)
*
1
);
}
for
(
i
=
0
;
i
<
irep
->
lv_len
;
++
i
)
{
for
(
i
=
0
;
i
<
(
irep
->
nlocals
-
1
)
;
++
i
)
{
mrb_sym
const
name
=
irep
->
lv
[
i
].
name
;
if
(
find_filename_index
(
*
syms
,
*
syms_len
,
name
)
!=
-
1
)
continue
;
...
...
@@ -738,13 +738,12 @@ write_lv_sym_table(mrb_state *mrb, uint8_t **start, mrb_sym const *syms, uint32_
}
static
int
write_lv_record
(
mrb_state
*
mrb
,
mrb_irep
*
irep
,
uint8_t
**
start
,
mrb_sym
const
*
syms
,
uint32_t
syms_len
)
write_lv_record
(
mrb_state
*
mrb
,
const
mrb_irep
*
irep
,
uint8_t
**
start
,
mrb_sym
const
*
syms
,
uint32_t
syms_len
)
{
uint8_t
*
cur
=
*
start
;
size_t
i
;
cur
+=
uint16_to_bin
(
irep
->
lv_len
,
cur
);
for
(
i
=
0
;
i
<
irep
->
lv_len
;
++
i
)
{
for
(
i
=
0
;
i
<
(
irep
->
nlocals
-
1
);
++
i
)
{
int
const
sym_idx
=
find_filename_index
(
syms
,
syms_len
,
irep
->
lv
[
i
].
name
);
mrb_assert
(
sym_idx
!=
-
1
);
/* local variable name must be in syms */
...
...
@@ -766,8 +765,7 @@ get_lv_record_size(mrb_state *mrb, mrb_irep *irep)
{
size_t
ret
=
0
,
i
;
ret
+=
sizeof
(
uint16_t
);
/* lv_len */
ret
+=
(
sizeof
(
uint16_t
)
+
sizeof
(
uint32_t
))
*
irep
->
lv_len
;
ret
+=
(
sizeof
(
uint16_t
)
+
sizeof
(
uint32_t
))
*
(
irep
->
nlocals
-
1
);
for
(
i
=
0
;
i
<
irep
->
rlen
;
++
i
)
{
ret
+=
get_lv_record_size
(
mrb
,
irep
->
reps
[
i
]);
...
...
src/load.c
View file @
5073d14e
...
...
@@ -408,11 +408,9 @@ read_lv_record(mrb_state *mrb, const uint8_t *start, mrb_irep *irep, size_t *rec
size_t
i
;
ptrdiff_t
diff
;
irep
->
lv_len
=
bin_to_uint16
(
bin
);
bin
+=
sizeof
(
uint16_t
);
irep
->
lv
=
(
struct
mrb_locals
*
)
mrb_malloc
(
mrb
,
sizeof
(
struct
mrb_locals
)
*
irep
->
lv_len
);
irep
->
lv
=
(
struct
mrb_locals
*
)
mrb_malloc
(
mrb
,
sizeof
(
struct
mrb_locals
)
*
(
irep
->
nlocals
-
1
));
for
(
i
=
0
;
i
<
irep
->
lv_len
;
++
i
)
{
for
(
i
=
0
;
i
<
(
irep
->
nlocals
-
1
)
;
++
i
)
{
uint16_t
const
sym_idx
=
bin_to_uint16
(
bin
);
bin
+=
sizeof
(
uint16_t
);
if
(
sym_idx
>=
syms_len
)
{
...
...
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