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
bbb7ba46
Commit
bbb7ba46
authored
Mar 11, 2014
by
take_cheeze
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
don't use of anonymous unions
parent
fee63977
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
30 additions
and
30 deletions
+30
-30
include/mruby/debug.h
include/mruby/debug.h
+4
-4
mrbgems/mruby-random/src/mt19937ar.c
mrbgems/mruby-random/src/mt19937ar.c
+3
-3
mrbgems/mruby-random/src/mt19937ar.h
mrbgems/mruby-random/src/mt19937ar.h
+3
-3
src/debug.c
src/debug.c
+12
-12
src/dump.c
src/dump.c
+3
-3
src/load.c
src/load.c
+5
-5
No files found.
include/mruby/debug.h
View file @
bbb7ba46
...
...
@@ -28,10 +28,10 @@ typedef struct mrb_irep_debug_info_file {
uint32_t
line_entry_count
;
mrb_debug_line_type
line_type
;
union
{
void
*
line_
ptr
;
mrb_irep_debug_info_line
*
line_
flat_map
;
uint16_t
*
line_
ary
;
};
void
*
ptr
;
mrb_irep_debug_info_line
*
flat_map
;
uint16_t
*
ary
;
}
lines
;
}
mrb_irep_debug_info_file
;
typedef
struct
mrb_irep_debug_info
{
...
...
mrbgems/mruby-random/src/mt19937ar.c
View file @
bbb7ba46
...
...
@@ -63,7 +63,7 @@ unsigned long mrb_random_genrand_int32(mt_state *t)
y
^=
(
y
<<
15
)
&
0xefc60000UL
;
y
^=
(
y
>>
18
);
t
->
gen
_int
=
y
;
t
->
gen
.
int_
=
y
;
return
y
;
}
...
...
@@ -71,8 +71,8 @@ unsigned long mrb_random_genrand_int32(mt_state *t)
double
mrb_random_genrand_real1
(
mt_state
*
t
)
{
mrb_random_genrand_int32
(
t
);
t
->
gen
_dbl
=
t
->
gen_int
*
(
1
.
0
/
4294967295
.
0
);
return
t
->
gen
_dbl
;
t
->
gen
.
double_
=
t
->
gen
.
int_
*
(
1
.
0
/
4294967295
.
0
);
return
t
->
gen
.
double_
;
/* divided by 2^32-1 */
}
...
...
mrbgems/mruby-random/src/mt19937ar.h
View file @
bbb7ba46
...
...
@@ -10,9 +10,9 @@ typedef struct {
unsigned
long
mt
[
N
];
int
mti
;
union
{
unsigned
long
gen_int
;
double
gen_dbl
;
};
unsigned
long
int_
;
double
double_
;
}
gen
;
mrb_int
seed
;
mrb_bool
has_seed
:
1
;
...
...
src/debug.c
View file @
bbb7ba46
...
...
@@ -74,11 +74,11 @@ mrb_debug_get_line(mrb_irep *irep, uint32_t pc)
switch
(
f
->
line_type
)
{
case
mrb_debug_line_ary
:
mrb_assert
(
f
->
start_pos
<=
pc
&&
pc
<
(
f
->
start_pos
+
f
->
line_entry_count
));
return
f
->
line
_
ary
[
pc
-
f
->
start_pos
];
return
f
->
line
s
.
ary
[
pc
-
f
->
start_pos
];
case
mrb_debug_line_flat_map
:
{
/* get upper bound */
mrb_irep_debug_info_line
*
ret
=
f
->
line
_
flat_map
;
mrb_irep_debug_info_line
*
ret
=
f
->
line
s
.
flat_map
;
uint32_t
count
=
f
->
line_entry_count
;
while
(
count
>
0
)
{
int32_t
step
=
count
/
2
;
...
...
@@ -92,10 +92,10 @@ mrb_debug_get_line(mrb_irep *irep, uint32_t pc)
--
ret
;
/* check line entry pointer range */
mrb_assert
(
f
->
line
_flat_map
<=
ret
&&
ret
<
(
f
->
line_
flat_map
+
f
->
line_entry_count
));
mrb_assert
(
f
->
line
s
.
flat_map
<=
ret
&&
ret
<
(
f
->
lines
.
flat_map
+
f
->
line_entry_count
));
/* check pc range */
mrb_assert
(
ret
->
start_pos
<=
pc
&&
pc
<
(((
ret
+
1
-
f
->
line
_
flat_map
)
<
f
->
line_entry_count
)
pc
<
(((
ret
+
1
-
f
->
line
s
.
flat_map
)
<
f
->
line_entry_count
)
?
(
ret
+
1
)
->
start_pos
:
irep
->
debug_info
->
pc_count
));
return
ret
->
line
;
...
...
@@ -160,31 +160,31 @@ mrb_debug_info_append_file(mrb_state *mrb, mrb_irep *irep,
ret
->
filename
=
mrb_sym2name_len
(
mrb
,
ret
->
filename_sym
,
&
len
);
ret
->
line_type
=
select_line_type
(
irep
->
lines
+
start_pos
,
end_pos
-
start_pos
);
ret
->
line
_
ptr
=
NULL
;
ret
->
line
s
.
ptr
=
NULL
;
switch
(
ret
->
line_type
)
{
case
mrb_debug_line_ary
:
ret
->
line_entry_count
=
file_pc_count
;
ret
->
line
_
ary
=
(
uint16_t
*
)
mrb_malloc
(
mrb
,
sizeof
(
uint16_t
)
*
file_pc_count
);
ret
->
line
s
.
ary
=
(
uint16_t
*
)
mrb_malloc
(
mrb
,
sizeof
(
uint16_t
)
*
file_pc_count
);
for
(
i
=
0
;
i
<
file_pc_count
;
++
i
)
{
ret
->
line
_
ary
[
i
]
=
irep
->
lines
[
start_pos
+
i
];
ret
->
line
s
.
ary
[
i
]
=
irep
->
lines
[
start_pos
+
i
];
}
break
;
case
mrb_debug_line_flat_map
:
{
uint16_t
prev_line
=
0
;
mrb_irep_debug_info_line
m
;
ret
->
line
_
flat_map
=
(
mrb_irep_debug_info_line
*
)
mrb_malloc
(
mrb
,
sizeof
(
mrb_irep_debug_info_line
)
*
1
);
ret
->
line
s
.
flat_map
=
(
mrb_irep_debug_info_line
*
)
mrb_malloc
(
mrb
,
sizeof
(
mrb_irep_debug_info_line
)
*
1
);
ret
->
line_entry_count
=
0
;
for
(
i
=
0
;
i
<
file_pc_count
;
++
i
)
{
if
(
irep
->
lines
[
start_pos
+
i
]
==
prev_line
)
{
continue
;
}
ret
->
line
_
flat_map
=
(
mrb_irep_debug_info_line
*
)
mrb_realloc
(
mrb
,
ret
->
line
_
flat_map
,
ret
->
line
s
.
flat_map
=
(
mrb_irep_debug_info_line
*
)
mrb_realloc
(
mrb
,
ret
->
line
s
.
flat_map
,
sizeof
(
mrb_irep_debug_info_line
)
*
(
ret
->
line_entry_count
+
1
));
m
.
start_pos
=
start_pos
+
i
;
m
.
line
=
irep
->
lines
[
start_pos
+
i
];
ret
->
line
_
flat_map
[
ret
->
line_entry_count
]
=
m
;
ret
->
line
s
.
flat_map
[
ret
->
line_entry_count
]
=
m
;
/* update */
++
ret
->
line_entry_count
;
...
...
@@ -207,7 +207,7 @@ mrb_debug_info_free(mrb_state *mrb, mrb_irep_debug_info *d)
for
(
i
=
0
;
i
<
d
->
flen
;
++
i
)
{
mrb_assert
(
d
->
files
[
i
]);
mrb_free
(
mrb
,
d
->
files
[
i
]
->
line
_
ptr
);
mrb_free
(
mrb
,
d
->
files
[
i
]
->
line
s
.
ptr
);
mrb_free
(
mrb
,
d
->
files
[
i
]);
}
mrb_free
(
mrb
,
d
->
files
);
...
...
src/dump.c
View file @
bbb7ba46
...
...
@@ -578,15 +578,15 @@ write_debug_record_1(mrb_state *mrb, mrb_irep *irep, uint8_t *bin, mrb_sym const
case
mrb_debug_line_ary
:
{
uint32_t
l
;
for
(
l
=
0
;
l
<
file
->
line_entry_count
;
++
l
)
{
cur
+=
uint16_to_bin
(
file
->
line
_
ary
[
l
],
cur
);
cur
+=
uint16_to_bin
(
file
->
line
s
.
ary
[
l
],
cur
);
}
}
break
;
case
mrb_debug_line_flat_map
:
{
uint32_t
line
;
for
(
line
=
0
;
line
<
file
->
line_entry_count
;
++
line
)
{
cur
+=
uint32_to_bin
(
file
->
line
_
flat_map
[
line
].
start_pos
,
cur
);
cur
+=
uint16_to_bin
(
file
->
line
_
flat_map
[
line
].
line
,
cur
);
cur
+=
uint32_to_bin
(
file
->
line
s
.
flat_map
[
line
].
start_pos
,
cur
);
cur
+=
uint16_to_bin
(
file
->
line
s
.
flat_map
[
line
].
line
,
cur
);
}
}
break
;
...
...
src/load.c
View file @
bbb7ba46
...
...
@@ -324,9 +324,9 @@ read_debug_record(mrb_state *mrb, const uint8_t *start, mrb_irep* irep, size_t *
case
mrb_debug_line_ary
:
{
uint32_t
l
;
file
->
line
_
ary
=
(
uint16_t
*
)
mrb_malloc
(
mrb
,
sizeof
(
uint16_t
)
*
(
size_t
)(
file
->
line_entry_count
));
file
->
line
s
.
ary
=
(
uint16_t
*
)
mrb_malloc
(
mrb
,
sizeof
(
uint16_t
)
*
(
size_t
)(
file
->
line_entry_count
));
for
(
l
=
0
;
l
<
file
->
line_entry_count
;
++
l
)
{
file
->
line
_
ary
[
l
]
=
bin_to_uint16
(
bin
);
file
->
line
s
.
ary
[
l
]
=
bin_to_uint16
(
bin
);
bin
+=
sizeof
(
uint16_t
);
}
}
break
;
...
...
@@ -334,12 +334,12 @@ read_debug_record(mrb_state *mrb, const uint8_t *start, mrb_irep* irep, size_t *
case
mrb_debug_line_flat_map
:
{
uint32_t
l
;
file
->
line
_
flat_map
=
(
mrb_irep_debug_info_line
*
)
mrb_malloc
(
file
->
line
s
.
flat_map
=
(
mrb_irep_debug_info_line
*
)
mrb_malloc
(
mrb
,
sizeof
(
mrb_irep_debug_info_line
)
*
(
size_t
)(
file
->
line_entry_count
));
for
(
l
=
0
;
l
<
file
->
line_entry_count
;
++
l
)
{
file
->
line
_
flat_map
[
l
].
start_pos
=
bin_to_uint32
(
bin
);
file
->
line
s
.
flat_map
[
l
].
start_pos
=
bin_to_uint32
(
bin
);
bin
+=
sizeof
(
uint32_t
);
file
->
line
_
flat_map
[
l
].
line
=
bin_to_uint16
(
bin
);
file
->
line
s
.
flat_map
[
l
].
line
=
bin_to_uint16
(
bin
);
bin
+=
sizeof
(
uint16_t
);
}
}
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