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
b8e5a570
Commit
b8e5a570
authored
Dec 05, 2012
by
Yukihiro Matz Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename mrb_load_irep etc. for naming consistency
parent
c7a2af38
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
8 deletions
+39
-8
include/mruby/dump.h
include/mruby/dump.h
+3
-2
src/load.c
src/load.c
+34
-2
test/init_mrbtest.c
test/init_mrbtest.c
+1
-3
tools/mruby/mruby.c
tools/mruby/mruby.c
+1
-1
No files found.
include/mruby/dump.h
View file @
b8e5a570
...
@@ -16,9 +16,10 @@ extern "C" {
...
@@ -16,9 +16,10 @@ extern "C" {
#include <stdint.h>
#include <stdint.h>
int
mrb_dump_irep
(
mrb_state
*
,
int
,
FILE
*
);
int
mrb_dump_irep
(
mrb_state
*
,
int
,
FILE
*
);
int
mrb_load_irep
(
mrb_state
*
,
FILE
*
);
int
mrb_load_irep_offset
(
mrb_state
*
,
FILE
*
,
long
);
int
mrb_read_irep
(
mrb_state
*
,
const
char
*
);
int
mrb_read_irep
(
mrb_state
*
,
const
char
*
);
int
mrb_read_irep_file
(
mrb_state
*
,
FILE
*
);
mrb_value
mrb_load_irep
(
mrb_state
*
,
const
char
*
);
mrb_value
mrb_load_irep_file
(
mrb_state
*
,
FILE
*
);
int
mrb_bdump_irep
(
mrb_state
*
mrb
,
int
n
,
FILE
*
f
,
const
char
*
initname
);
int
mrb_bdump_irep
(
mrb_state
*
mrb
,
int
n
,
FILE
*
f
,
const
char
*
initname
);
...
...
src/load.c
View file @
b8e5a570
...
@@ -11,6 +11,7 @@
...
@@ -11,6 +11,7 @@
#ifdef ENABLE_REGEXP
#ifdef ENABLE_REGEXP
#include "re.h"
#include "re.h"
#endif
#endif
#include "mruby/proc.h"
#include "mruby/irep.h"
#include "mruby/irep.h"
typedef
struct
_RiteFILE
typedef
struct
_RiteFILE
...
@@ -28,7 +29,7 @@ const char hex2bin[256] = {
...
@@ -28,7 +29,7 @@ const char hex2bin[256] = {
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
0
,
0
,
0
,
0
,
0
,
0
,
//30-3f
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
0
,
0
,
0
,
0
,
0
,
0
,
//30-3f
0
,
10
,
11
,
12
,
13
,
14
,
15
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
//40-4f
0
,
10
,
11
,
12
,
13
,
14
,
15
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
//40-4f
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
//50-5f
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
//50-5f
0
,
10
,
11
,
12
,
13
,
14
,
15
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
//60-6f
0
,
10
,
11
,
12
,
13
,
14
,
15
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
//60-6f
//70-ff
//70-ff
};
};
...
@@ -241,7 +242,7 @@ error_exit:
...
@@ -241,7 +242,7 @@ error_exit:
}
}
int
int
mrb_
load_irep
(
mrb_state
*
mrb
,
FILE
*
fp
)
mrb_
read_irep_file
(
mrb_state
*
mrb
,
FILE
*
fp
)
{
{
int
ret
,
i
;
int
ret
,
i
;
uint32_t
len
,
rlen
=
0
;
uint32_t
len
,
rlen
=
0
;
...
@@ -659,3 +660,34 @@ hex_to_str(char *hex, char *str, uint16_t *str_len)
...
@@ -659,3 +660,34 @@ hex_to_str(char *hex, char *str, uint16_t *str_len)
}
}
return
str
;
return
str
;
}
}
static
void
irep_error
(
mrb_state
*
mrb
,
int
n
)
{
static
const
char
msg
[]
=
"irep load error"
;
mrb
->
exc
=
(
struct
RObject
*
)
mrb_object
(
mrb_exc_new
(
mrb
,
E_SCRIPT_ERROR
,
msg
,
sizeof
(
msg
)
-
1
));
}
mrb_value
mrb_load_irep_file
(
mrb_state
*
mrb
,
FILE
*
fp
)
{
int
n
=
mrb_read_irep_file
(
mrb
,
fp
);
if
(
n
<
0
)
{
irep_error
(
mrb
,
n
);
return
mrb_nil_value
();
}
return
mrb_run
(
mrb
,
mrb_proc_new
(
mrb
,
mrb
->
irep
[
n
]),
mrb_top_self
(
mrb
));
}
mrb_value
mrb_load_irep
(
mrb_state
*
mrb
,
const
char
*
bin
)
{
int
n
=
mrb_read_irep
(
mrb
,
bin
);
if
(
n
<
0
)
{
irep_error
(
mrb
,
n
);
return
mrb_nil_value
();
}
return
mrb_run
(
mrb
,
mrb_proc_new
(
mrb
,
mrb
->
irep
[
n
]),
mrb_top_self
(
mrb
));
}
test/init_mrbtest.c
View file @
b8e5a570
...
@@ -9,9 +9,7 @@ extern const char mrbtest_irep[];
...
@@ -9,9 +9,7 @@ extern const char mrbtest_irep[];
void
void
mrb_init_mrbtest
(
mrb_state
*
mrb
)
mrb_init_mrbtest
(
mrb_state
*
mrb
)
{
{
int
n
=
mrb_read_irep
(
mrb
,
mrbtest_irep
);
mrb_load_irep
(
mrb
,
mrbtest_irep
);
mrb_run
(
mrb
,
mrb_proc_new
(
mrb
,
mrb
->
irep
[
n
]),
mrb_top_self
(
mrb
));
if
(
mrb
->
exc
)
{
if
(
mrb
->
exc
)
{
mrb_p
(
mrb
,
mrb_obj_value
(
mrb
->
exc
));
mrb_p
(
mrb
,
mrb_obj_value
(
mrb
->
exc
));
exit
(
0
);
exit
(
0
);
...
...
tools/mruby/mruby.c
View file @
b8e5a570
...
@@ -238,7 +238,7 @@ main(int argc, char **argv)
...
@@ -238,7 +238,7 @@ main(int argc, char **argv)
mrb_define_global_const
(
mrb
,
"ARGV"
,
ARGV
);
mrb_define_global_const
(
mrb
,
"ARGV"
,
ARGV
);
if
(
args
.
mrbfile
)
{
if
(
args
.
mrbfile
)
{
n
=
mrb_
load_irep
(
mrb
,
args
.
rfp
);
n
=
mrb_
read_irep_file
(
mrb
,
args
.
rfp
);
if
(
n
<
0
)
{
if
(
n
<
0
)
{
fprintf
(
stderr
,
"failed to load mrb file: %s
\n
"
,
args
.
cmdline
);
fprintf
(
stderr
,
"failed to load mrb file: %s
\n
"
,
args
.
cmdline
);
}
}
...
...
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