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
0be572df
Commit
0be572df
authored
Nov 02, 2013
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change return value from mrb_generate_code()
parent
d2451dfb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
18 deletions
+17
-18
include/mruby/compile.h
include/mruby/compile.h
+1
-1
mrbgems/mruby-bin-mirb/tools/mirb/mirb.c
mrbgems/mruby-bin-mirb/tools/mirb/mirb.c
+2
-3
src/codegen.c
src/codegen.c
+8
-7
src/parse.y
src/parse.y
+6
-7
No files found.
include/mruby/compile.h
View file @
0be572df
...
@@ -164,7 +164,7 @@ struct mrb_parser_state* mrb_parse_file(mrb_state*,FILE*,mrbc_context*);
...
@@ -164,7 +164,7 @@ struct mrb_parser_state* mrb_parse_file(mrb_state*,FILE*,mrbc_context*);
#endif
#endif
struct
mrb_parser_state
*
mrb_parse_string
(
mrb_state
*
,
const
char
*
,
mrbc_context
*
);
struct
mrb_parser_state
*
mrb_parse_string
(
mrb_state
*
,
const
char
*
,
mrbc_context
*
);
struct
mrb_parser_state
*
mrb_parse_nstring
(
mrb_state
*
,
const
char
*
,
int
,
mrbc_context
*
);
struct
mrb_parser_state
*
mrb_parse_nstring
(
mrb_state
*
,
const
char
*
,
int
,
mrbc_context
*
);
int
mrb_generate_code
(
mrb_state
*
,
struct
mrb_parser_state
*
);
struct
RProc
*
mrb_generate_code
(
mrb_state
*
,
struct
mrb_parser_state
*
);
/* program load functions */
/* program load functions */
#ifdef ENABLE_STDIO
#ifdef ENABLE_STDIO
...
...
mrbgems/mruby-bin-mirb/tools/mirb/mirb.c
View file @
0be572df
...
@@ -361,13 +361,12 @@ main(int argc, char **argv)
...
@@ -361,13 +361,12 @@ main(int argc, char **argv)
}
}
else
{
else
{
/* generate bytecode */
/* generate bytecode */
n
=
mrb_generate_code
(
mrb
,
parser
);
struct
RProc
*
proc
=
mrb_generate_code
(
mrb
,
parser
);
/* evaluate the bytecode */
/* evaluate the bytecode */
result
=
mrb_run
(
mrb
,
result
=
mrb_run
(
mrb
,
/* pass a proc for evaulation */
/* pass a proc for evaulation */
mrb_proc_new
(
mrb
,
mrb
->
irep
[
n
]),
proc
,
mrb_top_self
(
mrb
));
mrb_top_self
(
mrb
));
/* did an exception occur? */
/* did an exception occur? */
if
(
mrb
->
exc
)
{
if
(
mrb
->
exc
)
{
p
(
mrb
,
mrb_obj_value
(
mrb
->
exc
),
0
);
p
(
mrb
,
mrb_obj_value
(
mrb
->
exc
),
0
);
...
...
src/codegen.c
View file @
0be572df
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
#include <string.h>
#include <string.h>
#include "mruby.h"
#include "mruby.h"
#include "mruby/compile.h"
#include "mruby/compile.h"
#include "mruby/
irep
.h"
#include "mruby/
proc
.h"
#include "mruby/numeric.h"
#include "mruby/numeric.h"
#include "mruby/string.h"
#include "mruby/string.h"
#include "mruby/debug.h"
#include "mruby/debug.h"
...
@@ -2829,14 +2829,16 @@ codedump(mrb_state *mrb, int n)
...
@@ -2829,14 +2829,16 @@ codedump(mrb_state *mrb, int n)
}
}
void
void
codedump_all
(
mrb_state
*
mrb
,
int
start
)
codedump_all
(
mrb_state
*
mrb
,
struct
RProc
*
proc
)
{
{
size_t
i
;
size_t
i
;
mrb_irep
*
irep
=
proc
->
body
.
irep
;
for
(
i
=
start
;
i
<
mrb
->
irep_len
;
i
++
)
{
for
(
i
=
irep
->
idx
;
i
<
mrb
->
irep_len
;
i
++
)
{
codedump
(
mrb
,
i
);
codedump
(
mrb
,
i
);
}
}
}
}
static
int
static
int
codegen_start
(
mrb_state
*
mrb
,
parser_state
*
p
)
codegen_start
(
mrb_state
*
mrb
,
parser_state
*
p
)
{
{
...
@@ -2860,14 +2862,13 @@ codegen_start(mrb_state *mrb, parser_state *p)
...
@@ -2860,14 +2862,13 @@ codegen_start(mrb_state *mrb, parser_state *p)
}
}
}
}
int
struct
RProc
*
mrb_generate_code
(
mrb_state
*
mrb
,
parser_state
*
p
)
mrb_generate_code
(
mrb_state
*
mrb
,
parser_state
*
p
)
{
{
int
start
=
mrb
->
irep_len
;
int
start
=
mrb
->
irep_len
;
int
n
;
int
n
;
n
=
codegen_start
(
mrb
,
p
);
n
=
codegen_start
(
mrb
,
p
);
if
(
n
<
0
)
return
n
;
if
(
n
<
0
)
return
NULL
;
return
mrb_proc_new
(
mrb
,
mrb
->
irep
[
start
]);
return
start
;
}
}
src/parse.y
View file @
0be572df
...
@@ -5155,7 +5155,7 @@ parser_update_cxt(parser_state *p, mrbc_context *cxt)
...
@@ -5155,7 +5155,7 @@ parser_update_cxt(parser_state *p, mrbc_context *cxt)
}
}
}
}
void codedump_all(mrb_state*,
int
);
void codedump_all(mrb_state*,
struct RProc*
);
void parser_dump(mrb_state *mrb, node *tree, int offset);
void parser_dump(mrb_state *mrb, node *tree, int offset);
void
void
...
@@ -5346,7 +5346,6 @@ load_exec(mrb_state *mrb, parser_state *p, mrbc_context *c)
...
@@ -5346,7 +5346,6 @@ load_exec(mrb_state *mrb, parser_state *p, mrbc_context *c)
{
{
struct RClass *target = mrb->object_class;
struct RClass *target = mrb->object_class;
struct RProc *proc;
struct RProc *proc;
int n;
mrb_value v;
mrb_value v;
if (!p) {
if (!p) {
...
@@ -5355,6 +5354,7 @@ load_exec(mrb_state *mrb, parser_state *p, mrbc_context *c)
...
@@ -5355,6 +5354,7 @@ load_exec(mrb_state *mrb, parser_state *p, mrbc_context *c)
if (!p->tree || p->nerr) {
if (!p->tree || p->nerr) {
if (p->capture_errors) {
if (p->capture_errors) {
char buf[256];
char buf[256];
int n;
n = snprintf(buf, sizeof(buf), "line %d: %s\n",
n = snprintf(buf, sizeof(buf), "line %d: %s\n",
p->error_buffer[0].lineno, p->error_buffer[0].message);
p->error_buffer[0].lineno, p->error_buffer[0].message);
...
@@ -5369,21 +5369,20 @@ load_exec(mrb_state *mrb, parser_state *p, mrbc_context *c)
...
@@ -5369,21 +5369,20 @@ load_exec(mrb_state *mrb, parser_state *p, mrbc_context *c)
return mrb_undef_value();
return mrb_undef_value();
}
}
}
}
n
= mrb_generate_code(mrb, p);
proc
= mrb_generate_code(mrb, p);
mrb_parser_free(p);
mrb_parser_free(p);
if (
n < 0
) {
if (
proc == NULL
) {
static const char msg[] = "codegen error";
static const char msg[] = "codegen error";
mrb->exc = mrb_obj_ptr(mrb_exc_new(mrb, E_SCRIPT_ERROR, msg, sizeof(msg) - 1));
mrb->exc = mrb_obj_ptr(mrb_exc_new(mrb, E_SCRIPT_ERROR, msg, sizeof(msg) - 1));
return mrb_nil_value();
return mrb_nil_value();
}
}
if (c) {
if (c) {
if (c->dump_result) codedump_all(mrb,
n
);
if (c->dump_result) codedump_all(mrb,
proc
);
if (c->no_exec) return mrb_fixnum_value(
n
);
if (c->no_exec) return mrb_fixnum_value(
0
);
if (c->target_class) {
if (c->target_class) {
target = c->target_class;
target = c->target_class;
}
}
}
}
proc = mrb_proc_new(mrb, mrb->irep[n]);
proc->target_class = target;
proc->target_class = target;
if (mrb->c->ci) {
if (mrb->c->ci) {
mrb->c->ci->target_class = target;
mrb->c->ci->target_class = target;
...
...
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