mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
allow DISABLE/ENABLE_SATDIO
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
//#define DISABLE_MATH /* Math functions */
|
||||
//#define DISABLE_TIME /* Time class */
|
||||
//#define DISABLE_STRUCT /* Struct class */
|
||||
//#define DISABLE_STDIO /* use of stdio */
|
||||
|
||||
#undef HAVE_UNISTD_H /* WINDOWS */
|
||||
#define HAVE_UNISTD_H /* LINUX */
|
||||
@@ -50,6 +51,9 @@ typedef intptr_t mrb_sym;
|
||||
#ifndef DISABLE_STRUCT
|
||||
#define ENABLE_STRUCT
|
||||
#endif
|
||||
#ifndef DISABLE_STDIO
|
||||
#define ENABLE_STDIO
|
||||
#endif
|
||||
|
||||
#ifndef FALSE
|
||||
# define FALSE 0
|
||||
|
||||
@@ -94,7 +94,9 @@ codegen_error(codegen_scope *s, const char *message)
|
||||
s = s->prev;
|
||||
}
|
||||
mrb_pool_close(s->mpool);
|
||||
#ifdef ENABLE_STDIO
|
||||
fprintf(stderr, "codegen error: %s\n", message);
|
||||
#endif
|
||||
longjmp(s->jmp, 1);
|
||||
}
|
||||
|
||||
@@ -270,7 +272,9 @@ dispatch(codegen_scope *s, int pc)
|
||||
case OP_ONERR:
|
||||
break;
|
||||
default:
|
||||
#ifdef ENABLE_STDIO
|
||||
fprintf(stderr, "bug: dispatch on non JMP op\n");
|
||||
#endif
|
||||
scope_error(s);
|
||||
}
|
||||
s->iseq[pc] = MKOP_AsBx(c, GETARG_A(i), diff);
|
||||
@@ -739,7 +743,9 @@ gen_assignment(codegen_scope *s, node *node, int sp, int val)
|
||||
break;
|
||||
|
||||
default:
|
||||
#ifdef ENABLE_STDIO
|
||||
printf("unknown lhs %d\n", type);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
if (val) push();
|
||||
@@ -2047,6 +2053,7 @@ loop_pop(codegen_scope *s, int val)
|
||||
static void
|
||||
codedump(mrb_state *mrb, int n)
|
||||
{
|
||||
#ifdef ENABLE_STDIO
|
||||
mrb_irep *irep = mrb->irep[n];
|
||||
int i;
|
||||
mrb_code c;
|
||||
@@ -2342,6 +2349,7 @@ codedump(mrb_state *mrb, int n)
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
+2
-8
@@ -403,11 +403,6 @@ mrb_check_type(mrb_state *mrb, mrb_value x, enum mrb_vtype t)
|
||||
struct RString *s;
|
||||
int xt;
|
||||
|
||||
/*if (x == Qundef) {
|
||||
//mrb_bug("undef leaked to the Ruby space");
|
||||
printf ("undef leaked to the Ruby space\n");
|
||||
}*/
|
||||
|
||||
xt = mrb_type(x);
|
||||
if ((xt != t) || (xt == MRB_TT_DATA)) {
|
||||
while (type->type < MRB_TT_MAXDEFINE) {
|
||||
@@ -431,12 +426,11 @@ mrb_check_type(mrb_state *mrb, mrb_value x, enum mrb_vtype t)
|
||||
etype = mrb_obj_classname(mrb, x);
|
||||
}
|
||||
mrb_raise(mrb, E_TYPE_ERROR, "wrong argument type %s (expected %s)",
|
||||
etype, type->name);
|
||||
etype, type->name);
|
||||
}
|
||||
type++;
|
||||
}
|
||||
/*mrb_bug("unknown type 0x%x", t);*/
|
||||
printf ("unknown type 0x%x (0x%x given)", t, mrb_type(x));
|
||||
mrb_raise(mrb, E_TYPE_ERROR, "unknown type 0x%x (0x%x given)", t, mrb_type(x));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-1
@@ -2964,12 +2964,14 @@ yyerror(parser_state *p, const char *s)
|
||||
int n;
|
||||
|
||||
if (! p->capture_errors) {
|
||||
#ifdef ENABLE_STDIO
|
||||
if (p->filename) {
|
||||
fprintf(stderr, "%s:%d:%d: %s\n", p->filename, p->lineno, p->column, s);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "line %d:%d: %s\n", p->lineno, p->column, s);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if (p->nerr < sizeof(p->error_buffer) / sizeof(p->error_buffer[0])) {
|
||||
n = strlen(s);
|
||||
@@ -2998,12 +3000,14 @@ yywarn(parser_state *p, const char *s)
|
||||
int n;
|
||||
|
||||
if (! p->capture_errors) {
|
||||
#ifdef ENABLE_STDIO
|
||||
if (p->filename) {
|
||||
fprintf(stderr, "%s:%d:%d: %s\n", p->filename, p->lineno, p->column, s);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "line %d:%d: %s\n", p->lineno, p->column, s);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if (p->nerr < sizeof(p->warn_buffer) / sizeof(p->warn_buffer[0])) {
|
||||
n = strlen(s);
|
||||
@@ -4943,6 +4947,7 @@ dump_recur(mrb_state *mrb, node *tree, int offset)
|
||||
void
|
||||
parser_dump(mrb_state *mrb, node *tree, int offset)
|
||||
{
|
||||
#ifdef ENABLE_STDIO
|
||||
int n;
|
||||
|
||||
if (!tree) return;
|
||||
@@ -5631,7 +5636,7 @@ parser_dump(mrb_state *mrb, node *tree, int offset)
|
||||
printf("node type: %d (0x%x)\n", (int)n, (int)n);
|
||||
break;
|
||||
}
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef PARSER_TEST
|
||||
|
||||
Reference in New Issue
Block a user