summaryrefslogtreecommitdiffhomepage
path: root/src/cdump.c
diff options
context:
space:
mode:
authorYukihiro Matz Matsumoto <[email protected]>2013-01-16 08:00:47 +0900
committerYukihiro Matz Matsumoto <[email protected]>2013-01-16 08:00:47 +0900
commit98d364e4a692b942d71cb976c034ccaaa6479afc (patch)
tree295803f3911a78e8a53373b6a3b8f9b7c57adfd8 /src/cdump.c
parent81e55d98057a4abab1716d1c401a538d0715c7a4 (diff)
parentd1656d4371e06259191045409701208ee00bdeb6 (diff)
downloadmruby-98d364e4a692b942d71cb976c034ccaaa6479afc.tar.gz
mruby-98d364e4a692b942d71cb976c034ccaaa6479afc.zip
Merge branch 'master' of github.com:mruby/mruby
Diffstat (limited to 'src/cdump.c')
-rw-r--r--src/cdump.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/cdump.c b/src/cdump.c
index 7cb159046..247511f5a 100644
--- a/src/cdump.c
+++ b/src/cdump.c
@@ -23,7 +23,7 @@ make_cdump_isec(mrb_state *mrb, int irep_no, FILE *f)
mrb_irep *irep = mrb->irep[irep_no];
if (irep == NULL)
- return -1;
+ return MRB_CDUMP_INVALID_IREP;
/* dump isec struct*/
if (irep->ilen > 0) {
@@ -34,7 +34,7 @@ make_cdump_isec(mrb_state *mrb, int irep_no, FILE *f)
SOURCE_CODE0 ("");
}
- return 0;
+ return MRB_CDUMP_OK;
}
static size_t
@@ -104,7 +104,7 @@ make_cdump_irep(mrb_state *mrb, int irep_no, FILE *f)
size_t buf_len, str_len;
if (irep == NULL)
- return -1;
+ return MRB_CDUMP_INVALID_IREP;
buf_len = MRB_CDUMP_LINE_LEN;
if ((buf = (char *)mrb_malloc(mrb, buf_len)) == NULL) {
@@ -176,9 +176,10 @@ int
mrb_cdump_irep(mrb_state *mrb, int n, FILE *f,const char *initname)
{
int irep_no;
+ int error;
if (mrb == NULL || n < 0 || n >= mrb->irep_len || f == NULL || initname == NULL)
- return -1;
+ return MRB_CDUMP_INVALID_ARGUMENT;
SOURCE_CODE0("#include \"mruby.h\"");
SOURCE_CODE0("#include \"mruby/irep.h\"");
@@ -187,8 +188,9 @@ mrb_cdump_irep(mrb_state *mrb, int n, FILE *f,const char *initname)
SOURCE_CODE0("");
for (irep_no=n; irep_no<mrb->irep_len; irep_no++) {
- if (make_cdump_isec(mrb, irep_no, f) != 0)
- return -1;
+ error = make_cdump_isec(mrb, irep_no, f);
+ if (error != MRB_CDUMP_OK)
+ return error;
}
SOURCE_CODE0("void");
@@ -200,12 +202,13 @@ mrb_cdump_irep(mrb_state *mrb, int n, FILE *f,const char *initname)
SOURCE_CODE0(" mrb_irep *irep;");
SOURCE_CODE0("");
for (irep_no=n; irep_no<mrb->irep_len; irep_no++) {
- if (make_cdump_irep(mrb, irep_no, f) != 0)
- return -1;
+ error = make_cdump_irep(mrb, irep_no, f);
+ if (error != MRB_CDUMP_OK)
+ return error;
}
SOURCE_CODE0(" mrb_run(mrb, mrb_proc_new(mrb, mrb->irep[n]), mrb_top_self(mrb));");
SOURCE_CODE0("}");
- return 0;
+ return MRB_CDUMP_OK;
}