improved log message handling
This commit is contained in:
parent
0c4ce4eb04
commit
eeb2fdebbd
@ -31,6 +31,22 @@
|
||||
{
|
||||
#dcl(#class) Q R.
|
||||
#dcl(#classinst) a1 a2.
|
||||
|
||||
#method test999
|
||||
{
|
||||
^self.Q
|
||||
}
|
||||
}
|
||||
|
||||
#class B.TestObject(Object)
|
||||
{
|
||||
#dcl(#class) Q R.
|
||||
#dcl(#classinst) a1 a2.
|
||||
|
||||
#method test000
|
||||
{
|
||||
^self.Q
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -43,7 +43,8 @@ libstix_la_SOURCES = \
|
||||
decode.c \
|
||||
dic.c \
|
||||
exec.c \
|
||||
fmt.c \
|
||||
logfmtv.h \
|
||||
logfmt.c \
|
||||
gc.c \
|
||||
heap.c \
|
||||
ignite.c \
|
||||
|
@ -153,7 +153,7 @@ am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
|
||||
libstix_la_DEPENDENCIES = $(am__DEPENDENCIES_2)
|
||||
am_libstix_la_OBJECTS = libstix_la-bigint.lo libstix_la-comp.lo \
|
||||
libstix_la-debug.lo libstix_la-decode.lo libstix_la-dic.lo \
|
||||
libstix_la-exec.lo libstix_la-fmt.lo libstix_la-gc.lo \
|
||||
libstix_la-exec.lo libstix_la-logfmt.lo libstix_la-gc.lo \
|
||||
libstix_la-heap.lo libstix_la-ignite.lo libstix_la-obj.lo \
|
||||
libstix_la-proc.lo libstix_la-rbt.lo libstix_la-stix.lo \
|
||||
libstix_la-sym.lo libstix_la-utf8.lo libstix_la-utl.lo
|
||||
@ -425,7 +425,8 @@ libstix_la_SOURCES = \
|
||||
decode.c \
|
||||
dic.c \
|
||||
exec.c \
|
||||
fmt.c \
|
||||
logfmtv.h \
|
||||
logfmt.c \
|
||||
gc.c \
|
||||
heap.c \
|
||||
ignite.c \
|
||||
@ -656,10 +657,10 @@ distclean-compile:
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstix_la-decode.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstix_la-dic.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstix_la-exec.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstix_la-fmt.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstix_la-gc.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstix_la-heap.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstix_la-ignite.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstix_la-logfmt.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstix_la-obj.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstix_la-proc.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstix_la-rbt.Plo@am__quote@
|
||||
@ -743,12 +744,12 @@ libstix_la-exec.lo: exec.c
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libstix_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libstix_la-exec.lo `test -f 'exec.c' || echo '$(srcdir)/'`exec.c
|
||||
|
||||
libstix_la-fmt.lo: fmt.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libstix_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libstix_la-fmt.lo -MD -MP -MF $(DEPDIR)/libstix_la-fmt.Tpo -c -o libstix_la-fmt.lo `test -f 'fmt.c' || echo '$(srcdir)/'`fmt.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libstix_la-fmt.Tpo $(DEPDIR)/libstix_la-fmt.Plo
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fmt.c' object='libstix_la-fmt.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
libstix_la-logfmt.lo: logfmt.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libstix_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libstix_la-logfmt.lo -MD -MP -MF $(DEPDIR)/libstix_la-logfmt.Tpo -c -o libstix_la-logfmt.lo `test -f 'logfmt.c' || echo '$(srcdir)/'`logfmt.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libstix_la-logfmt.Tpo $(DEPDIR)/libstix_la-logfmt.Plo
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='logfmt.c' object='libstix_la-logfmt.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libstix_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libstix_la-fmt.lo `test -f 'fmt.c' || echo '$(srcdir)/'`fmt.c
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libstix_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libstix_la-logfmt.lo `test -f 'logfmt.c' || echo '$(srcdir)/'`logfmt.c
|
||||
|
||||
libstix_la-gc.lo: gc.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libstix_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libstix_la-gc.lo -MD -MP -MF $(DEPDIR)/libstix_la-gc.Tpo -c -o libstix_la-gc.lo `test -f 'gc.c' || echo '$(srcdir)/'`gc.c
|
||||
|
101
stix/lib/comp.c
101
stix/lib/comp.c
@ -147,18 +147,6 @@ enum voca_id_t
|
||||
};
|
||||
typedef enum voca_id_t voca_id_t;
|
||||
|
||||
#if defined(STIX_DEBUG_COMP_001)
|
||||
# define DBGOUT_COMP_0(fmt) printf(fmt "\n")
|
||||
# define DBGOUT_COMP_1(fmt,a1) printf(fmt "\n",a1)
|
||||
# define DBGOUT_COMP_2(fmt,a1,a2) printf(fmt "\n", a1, a2)
|
||||
# define DBGOUT_COMP_3(fmt,a1,a2,a3) printf(fmt "\n", a1, a2, a3)
|
||||
#else
|
||||
# define DBGOUT_COMP_0(fmt)
|
||||
# define DBGOUT_COMP_1(fmt,a1)
|
||||
# define DBGOUT_COMP_2(fmt,a1,a2)
|
||||
# define DBGOUT_COMP_3(fmt,a1,a2,a3)
|
||||
#endif
|
||||
|
||||
static int compile_block_statement (stix_t* stix);
|
||||
static int compile_method_statement (stix_t* stix);
|
||||
static int compile_method_expression (stix_t* stix, int pop);
|
||||
@ -1502,11 +1490,7 @@ retry:
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
printf ("TOKEN: [");
|
||||
print_oocs (&stix->c->tok.name);
|
||||
printf ("]\n");
|
||||
*/
|
||||
/*stix_logbfmt (stix, STIX_FMTOUT_COMPILER | STIX_FMTOUT_DEBUG, "TOKEN: [%.*S]\n", stix->c->tok.name.len, stix->c->tok.name.ptr);*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1793,36 +1777,29 @@ static int emit_push_smint_literal (stix_t* stix, stix_ooi_t i)
|
||||
switch (i)
|
||||
{
|
||||
case -1:
|
||||
DBGOUT_COMP_0("\tpush negone");
|
||||
return emit_byte_instruction (stix, BCODE_PUSH_NEGONE);
|
||||
|
||||
case 0:
|
||||
DBGOUT_COMP_0("\tpush zero");
|
||||
return emit_byte_instruction (stix, BCODE_PUSH_ZERO);
|
||||
|
||||
case 1:
|
||||
DBGOUT_COMP_0("\tpush one");
|
||||
return emit_byte_instruction (stix, BCODE_PUSH_ONE);
|
||||
|
||||
case 2:
|
||||
DBGOUT_COMP_0("\tpush two");
|
||||
return emit_byte_instruction (stix, BCODE_PUSH_TWO);
|
||||
}
|
||||
|
||||
if (i >= 0 && i <= MAX_CODE_PARAM)
|
||||
{
|
||||
DBGOUT_COMP_1("\tpush intlit %d", (int)i);
|
||||
return emit_single_param_instruction(stix, BCODE_PUSH_INTLIT, i);
|
||||
}
|
||||
else if (i < 0 && i >= -(stix_ooi_t)MAX_CODE_PARAM)
|
||||
{
|
||||
DBGOUT_COMP_1("\tpush negintlit %d", (int)i);
|
||||
return emit_single_param_instruction(stix, BCODE_PUSH_NEGINTLIT, -i);
|
||||
}
|
||||
|
||||
if (add_literal(stix, STIX_SMOOI_TO_OOP(i), &index) <= -1 ||
|
||||
emit_single_param_instruction(stix, BCODE_PUSH_LITERAL_0, index) <= -1) return -1;
|
||||
DBGOUT_COMP_1("\tpush litral_0 %d", (int)index);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -2755,9 +2732,6 @@ static int get_variable_info (stix_t* stix, const stix_oocs_t* name, const stix_
|
||||
|
||||
if (preprocess_dotted_name (stix, 1, 1, name, name_loc, &last, &ns_oop) <= -1) return -1;
|
||||
|
||||
printf ("checking variable ");
|
||||
print_oocs (&last);
|
||||
printf ("\n");
|
||||
ass = stix_lookupdic (stix, ns_oop, &last);
|
||||
if (ass)
|
||||
{
|
||||
@ -3050,20 +3024,14 @@ static int compile_block_expression (stix_t* stix)
|
||||
if (store_tmpr_count_for_block (stix, stix->c->mth.tmpr_count) <= -1) return -1;
|
||||
|
||||
#if defined(STIX_USE_MAKE_BLOCK)
|
||||
DBGOUT_COMP_2 ("\tmake_block nargs %d ntmprs %d", (int)block_arg_count, (int)stix->c->mth.tmpr_count /*block_tmpr_count*/);
|
||||
if (emit_double_param_instruction(stix, BCODE_MAKE_BLOCK, block_arg_count, stix->c->mth.tmpr_count/*block_tmpr_count*/) <= -1) return -1;
|
||||
#else
|
||||
DBGOUT_COMP_0("\tpush_context");
|
||||
DBGOUT_COMP_1("\tpush smint nargs=%d", (int)block_arg_count);
|
||||
DBGOUT_COMP_1("\tpush smint ntmprs=%d", (int)stix->c->mth.tmpr_count /*block_tmpr_count*/);
|
||||
DBGOUT_COMP_0("\tsend_block_copy");
|
||||
if (emit_byte_instruction(stix, BCODE_PUSH_CONTEXT) <= -1 ||
|
||||
emit_push_smint_literal(stix, block_arg_count) <= -1 ||
|
||||
emit_push_smint_literal(stix, stix->c->mth.tmpr_count/*block_tmpr_count*/) <= -1 ||
|
||||
emit_byte_instruction(stix, BCODE_SEND_BLOCK_COPY) <= -1) return -1;
|
||||
#endif
|
||||
|
||||
DBGOUT_COMP_0 ("\tjump_forward_0");
|
||||
/* insert dummy instructions before replacing them with a jump instruction */
|
||||
jump_inst_pos = stix->c->mth.code.len;
|
||||
/* specifying MAX_CODE_JUMP causes emit_single_param_instruction() to
|
||||
@ -3074,7 +3042,6 @@ static int compile_block_expression (stix_t* stix)
|
||||
if (stix->c->tok.type == STIX_IOTOK_RBRACK)
|
||||
{
|
||||
/* the block is empty */
|
||||
DBGOUT_COMP_0("\tpush_nil");
|
||||
if (emit_byte_instruction (stix, BCODE_PUSH_NIL) <= -1) return -1;
|
||||
}
|
||||
else
|
||||
@ -3088,7 +3055,6 @@ static int compile_block_expression (stix_t* stix)
|
||||
{
|
||||
GET_TOKEN (stix);
|
||||
if (stix->c->tok.type == STIX_IOTOK_RBRACK) break;
|
||||
DBGOUT_COMP_0("\tpop_stacktop");
|
||||
if (emit_byte_instruction(stix, BCODE_POP_STACKTOP) <= -1) return -1;
|
||||
}
|
||||
else
|
||||
@ -3099,7 +3065,6 @@ static int compile_block_expression (stix_t* stix)
|
||||
}
|
||||
}
|
||||
|
||||
DBGOUT_COMP_0("\treturn_from_block");
|
||||
if (emit_byte_instruction(stix, BCODE_RETURN_FROM_BLOCK) <= -1) return -1;
|
||||
|
||||
|
||||
@ -3115,7 +3080,6 @@ static int compile_block_expression (stix_t* stix)
|
||||
|
||||
if (block_code_size > MAX_CODE_JUMP)
|
||||
{
|
||||
DBGOUT_COMP_0("\tfixed jump_forward to jump2_forward");
|
||||
stix->c->mth.code.ptr[jump_inst_pos] = BCODE_JUMP2_FORWARD;
|
||||
jump_offset = block_code_size - MAX_CODE_JUMP;
|
||||
}
|
||||
@ -3124,8 +3088,6 @@ static int compile_block_expression (stix_t* stix)
|
||||
jump_offset = block_code_size;
|
||||
}
|
||||
|
||||
DBGOUT_COMP_1("\tfixed jump offset to %u", (unsigned int)jump_offset);
|
||||
|
||||
#if (STIX_BCODE_LONG_PARAM_SIZE == 2)
|
||||
stix->c->mth.code.ptr[jump_inst_pos + 1] = jump_offset >> 8;
|
||||
stix->c->mth.code.ptr[jump_inst_pos + 2] = jump_offset & 0xFF;
|
||||
@ -3349,7 +3311,6 @@ static int compile_byte_array_literal (stix_t* stix)
|
||||
if (read_byte_array_literal(stix, &lit) <= -1 ||
|
||||
add_literal(stix, lit, &index) <= -1 ||
|
||||
emit_single_param_instruction(stix, BCODE_PUSH_LITERAL_0, index) <= -1) return -1;
|
||||
DBGOUT_COMP_0("\tpush_literal byte_array");
|
||||
|
||||
GET_TOKEN (stix);
|
||||
return 0;
|
||||
@ -3385,7 +3346,6 @@ static int compile_array_literal (stix_t* stix)
|
||||
if (read_array_literal(stix, &lit) <= -1 ||
|
||||
add_literal(stix, lit, &index) <= -1 ||
|
||||
emit_single_param_instruction(stix, BCODE_PUSH_LITERAL_0, index) <= -1) return -1;
|
||||
DBGOUT_COMP_0("\tpush_literal array");
|
||||
|
||||
GET_TOKEN (stix);
|
||||
return 0;
|
||||
@ -3426,7 +3386,6 @@ static int compile_expression_primary (stix_t* stix, const stix_oocs_t* ident, c
|
||||
{
|
||||
if (var.pos >= stix->c->mth.blk_tmprcnt[i - 1])
|
||||
{
|
||||
DBGOUT_COMP_2("\tpush ctxtempvar %d %d", (int)(stix->c->mth.blk_depth - i), (int)(var.pos - stix->c->mth.blk_tmprcnt[i - 1]));
|
||||
if (emit_double_param_instruction(stix, BCODE_PUSH_CTXTEMPVAR_0, stix->c->mth.blk_depth - i, var.pos - stix->c->mth.blk_tmprcnt[i - 1]) <= -1) return -1;
|
||||
goto temporary_done;
|
||||
}
|
||||
@ -3435,7 +3394,6 @@ static int compile_expression_primary (stix_t* stix, const stix_oocs_t* ident, c
|
||||
#endif
|
||||
|
||||
if (emit_single_param_instruction(stix, BCODE_PUSH_TEMPVAR_0, var.pos) <= -1) return -1;
|
||||
DBGOUT_COMP_1("\tpush tempvar %d", (int)var.pos);
|
||||
temporary_done:
|
||||
break;
|
||||
}
|
||||
@ -3443,13 +3401,11 @@ static int compile_expression_primary (stix_t* stix, const stix_oocs_t* ident, c
|
||||
case VAR_INSTANCE:
|
||||
case VAR_CLASSINST:
|
||||
if (emit_single_param_instruction(stix, BCODE_PUSH_INSTVAR_0, var.pos) <= -1) return -1;
|
||||
DBGOUT_COMP_1("\tpush instvar %d", (int)var.pos);
|
||||
break;
|
||||
|
||||
case VAR_CLASS:
|
||||
if (add_literal(stix, (stix_oop_t)var.cls, &index) <= -1 ||
|
||||
emit_double_param_instruction(stix, BCODE_PUSH_OBJVAR_0, var.pos, index) <= -1) return -1;
|
||||
DBGOUT_COMP_2("\tpush objvar %d %d", (int)var.pos, (int)index);
|
||||
break;
|
||||
|
||||
case VAR_GLOBAL:
|
||||
@ -3464,7 +3420,6 @@ static int compile_expression_primary (stix_t* stix, const stix_oocs_t* ident, c
|
||||
*/
|
||||
if (add_literal(stix, (stix_oop_t)var.gbl, &index) <= -1 ||
|
||||
emit_single_param_instruction(stix, BCODE_PUSH_OBJECT_0, index) <= -1) return -1;
|
||||
DBGOUT_COMP_1("\tpush object %d", (int)index);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -3487,38 +3442,32 @@ static int compile_expression_primary (stix_t* stix, const stix_oocs_t* ident, c
|
||||
goto handle_ident;
|
||||
|
||||
case STIX_IOTOK_SELF:
|
||||
DBGOUT_COMP_0("\tpush receiver");
|
||||
if (emit_byte_instruction(stix, BCODE_PUSH_RECEIVER) <= -1) return -1;
|
||||
GET_TOKEN (stix);
|
||||
break;
|
||||
|
||||
case STIX_IOTOK_SUPER:
|
||||
DBGOUT_COMP_0("\tpush receiver(super)");
|
||||
if (emit_byte_instruction(stix, BCODE_PUSH_RECEIVER) <= -1) return -1;
|
||||
GET_TOKEN (stix);
|
||||
*to_super = 1;
|
||||
break;
|
||||
|
||||
case STIX_IOTOK_NIL:
|
||||
DBGOUT_COMP_0("\tpush nil");
|
||||
if (emit_byte_instruction(stix, BCODE_PUSH_NIL) <= -1) return -1;
|
||||
GET_TOKEN (stix);
|
||||
break;
|
||||
|
||||
case STIX_IOTOK_TRUE:
|
||||
DBGOUT_COMP_0("\tpush true");
|
||||
if (emit_byte_instruction(stix, BCODE_PUSH_TRUE) <= -1) return -1;
|
||||
GET_TOKEN (stix);
|
||||
break;
|
||||
|
||||
case STIX_IOTOK_FALSE:
|
||||
DBGOUT_COMP_0("\tpush false");
|
||||
if (emit_byte_instruction(stix, BCODE_PUSH_FALSE) <= -1) return -1;
|
||||
GET_TOKEN (stix);
|
||||
break;
|
||||
|
||||
case STIX_IOTOK_THIS_CONTEXT:
|
||||
DBGOUT_COMP_0("\tpush context");
|
||||
if (emit_byte_instruction(stix, BCODE_PUSH_CONTEXT) <= -1) return -1;
|
||||
GET_TOKEN (stix);
|
||||
break;
|
||||
@ -3527,21 +3476,18 @@ static int compile_expression_primary (stix_t* stix, const stix_oocs_t* ident, c
|
||||
STIX_ASSERT (stix->c->tok.name.len == 1);
|
||||
if (add_character_literal(stix, stix->c->tok.name.ptr[0], &index) <= -1 ||
|
||||
emit_single_param_instruction(stix, BCODE_PUSH_LITERAL_0, index) <= -1) return -1;
|
||||
DBGOUT_COMP_1("\tpush character literal %d", (int)index);
|
||||
GET_TOKEN (stix);
|
||||
break;
|
||||
|
||||
case STIX_IOTOK_STRLIT:
|
||||
if (add_string_literal(stix, &stix->c->tok.name, &index) <= -1 ||
|
||||
emit_single_param_instruction(stix, BCODE_PUSH_LITERAL_0, index) <= -1) return -1;
|
||||
DBGOUT_COMP_1("\tpush string literal %d", (int)index);
|
||||
GET_TOKEN (stix);
|
||||
break;
|
||||
|
||||
case STIX_IOTOK_SYMLIT:
|
||||
if (add_symbol_literal(stix, &stix->c->tok.name, &index) <= -1 ||
|
||||
emit_single_param_instruction(stix, BCODE_PUSH_LITERAL_0, index) <= -1) return -1;
|
||||
DBGOUT_COMP_1("\tpush symbol literal %d", (int)index);
|
||||
GET_TOKEN (stix);
|
||||
break;
|
||||
|
||||
@ -3563,7 +3509,6 @@ static int compile_expression_primary (stix_t* stix, const stix_oocs_t* ident, c
|
||||
{
|
||||
if (add_literal(stix, tmp, &index) <= -1 ||
|
||||
emit_single_param_instruction(stix, BCODE_PUSH_LITERAL_0, index) <= -1) return -1;
|
||||
DBGOUT_COMP_1("\tpush_literal_0 %d", (int)index);
|
||||
}
|
||||
|
||||
GET_TOKEN (stix);
|
||||
@ -3637,10 +3582,6 @@ static int compile_unary_message (stix_t* stix, int to_super)
|
||||
{
|
||||
if (add_symbol_literal(stix, &stix->c->tok.name, &index) <= -1 ||
|
||||
emit_double_param_instruction(stix, send_message_cmd[to_super], 0, index) <= -1) return -1;
|
||||
printf ("\tsend unary message %d [", (int)index);
|
||||
print_oocs (&stix->c->tok.name);
|
||||
printf ("] with 0 arguments %s\n", (to_super? " to super": ""));
|
||||
|
||||
GET_TOKEN (stix);
|
||||
}
|
||||
while (stix->c->tok.type == STIX_IOTOK_IDENT);
|
||||
@ -3680,9 +3621,6 @@ static int compile_binary_message (stix_t* stix, int to_super)
|
||||
binsel.ptr = &stix->c->mth.binsels.ptr[binsel_offset];
|
||||
if (add_symbol_literal(stix, &binsel, &index) <= -1 ||
|
||||
emit_double_param_instruction(stix, send_message_cmd[to_super], 1, index) <= -1) goto oops;
|
||||
printf ("\tsend binary message %d [", (int)index);
|
||||
print_oocs (&binsel);
|
||||
printf ("] with 1 arguments %s\n", (to_super? " to super": ""));
|
||||
|
||||
stix->c->mth.binsels.len = saved_binsels_len;
|
||||
}
|
||||
@ -3746,9 +3684,6 @@ static int compile_keyword_message (stix_t* stix, int to_super)
|
||||
if (add_symbol_literal(stix, &kwsel, &index) <= -1 ||
|
||||
emit_double_param_instruction(stix, send_message_cmd[to_super], nargs, index) <= -1) goto oops;
|
||||
|
||||
printf ("\tsend keyword message %d [", (int)index);
|
||||
print_oocs (&kwsel);
|
||||
printf ("] with %d arguments to %s\n", (int)nargs, (to_super? "super": "self"));
|
||||
stix->c->mth.kwsels.len = saved_kwsel_len;
|
||||
return 0;
|
||||
|
||||
@ -3841,7 +3776,6 @@ static int compile_message_expression (stix_t* stix, int to_super)
|
||||
|
||||
if (stix->c->tok.type == STIX_IOTOK_SEMICOLON)
|
||||
{
|
||||
DBGOUT_COMP_0("\tdup_stacktop for cascading");
|
||||
stix->c->mth.code.ptr[noop_pos] = BCODE_DUP_STACKTOP;
|
||||
if (emit_byte_instruction(stix, BCODE_POP_STACKTOP) <= -1) return -1;
|
||||
GET_TOKEN(stix);
|
||||
@ -3928,11 +3862,6 @@ static int compile_method_expression (stix_t* stix, int pop)
|
||||
|
||||
GET_TOKEN (stix);
|
||||
|
||||
printf ("ASSIGNING TO ....");
|
||||
assignee.ptr = &stix->c->mth.assignees.ptr[assignee_offset];
|
||||
print_oocs (&assignee);
|
||||
printf ("\n");
|
||||
|
||||
if (compile_method_expression(stix, 0) <= -1) goto oops;
|
||||
|
||||
/* compile_method_expression() is called after clone_assignee().
|
||||
@ -3965,7 +3894,6 @@ printf ("\n");
|
||||
{
|
||||
if (var.pos >= stix->c->mth.blk_tmprcnt[i - 1])
|
||||
{
|
||||
DBGOUT_COMP_3("\t%s_into_ctxtempvar %d %d", (pop? "pop":"store"), (int)(stix->c->mth.blk_depth - i), (int)(var.pos - stix->c->mth.blk_tmprcnt[i - 1]));
|
||||
if (emit_double_param_instruction(stix, (pop? BCODE_POP_INTO_CTXTEMPVAR_0: BCODE_STORE_INTO_CTXTEMPVAR_0), stix->c->mth.blk_depth - i, var.pos - stix->c->mth.blk_tmprcnt[i - 1]) <= -1) return -1;
|
||||
goto temporary_done;
|
||||
}
|
||||
@ -3973,7 +3901,6 @@ printf ("\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
DBGOUT_COMP_2("\t%s_into_tempvar %d", (pop? "pop":"store"), (int)var.pos);
|
||||
if (emit_single_param_instruction (stix, (pop? BCODE_POP_INTO_TEMPVAR_0: BCODE_STORE_INTO_TEMPVAR_0), var.pos) <= -1) goto oops;
|
||||
|
||||
temporary_done:
|
||||
@ -3983,7 +3910,6 @@ printf ("\n");
|
||||
|
||||
case VAR_INSTANCE:
|
||||
case VAR_CLASSINST:
|
||||
DBGOUT_COMP_2("\t%s_into_instvar %d", (pop? "pop":"store"), (int)var.pos);
|
||||
if (emit_single_param_instruction (stix, (pop? BCODE_POP_INTO_INSTVAR_0: BCODE_STORE_INTO_INSTVAR_0), var.pos) <= -1) goto oops;
|
||||
ret = pop;
|
||||
break;
|
||||
@ -3991,14 +3917,12 @@ printf ("\n");
|
||||
case VAR_CLASS:
|
||||
if (add_literal (stix, (stix_oop_t)var.cls, &index) <= -1 ||
|
||||
emit_double_param_instruction (stix, (pop? BCODE_POP_INTO_OBJVAR_0: BCODE_STORE_INTO_OBJVAR_0), var.pos, index) <= -1) goto oops;
|
||||
DBGOUT_COMP_3("\t%s_into_objvar %d %d", (pop? "pop":"store"), (int)var.pos, (int)index);
|
||||
ret = pop;
|
||||
break;
|
||||
|
||||
case VAR_GLOBAL:
|
||||
if (add_literal(stix, (stix_oop_t)var.gbl, &index) <= -1 ||
|
||||
emit_single_param_instruction(stix, (pop? BCODE_POP_INTO_OBJECT_0: BCODE_STORE_INTO_OBJECT_0), index) <= -1) return -1;
|
||||
DBGOUT_COMP_2("\t%s_into_object %d", (pop? "pop":"store"), (int)index);
|
||||
ret = pop;
|
||||
break;
|
||||
|
||||
@ -4040,7 +3964,6 @@ static int compile_block_statement (stix_t* stix)
|
||||
/* handle the return statement */
|
||||
GET_TOKEN (stix);
|
||||
if (compile_method_expression(stix, 0) <= -1) return -1;
|
||||
DBGOUT_COMP_0("\treturn_stacktop");
|
||||
return emit_byte_instruction (stix, BCODE_RETURN_STACKTOP);
|
||||
}
|
||||
else
|
||||
@ -4061,7 +3984,6 @@ static int compile_method_statement (stix_t* stix)
|
||||
/* handle the return statement */
|
||||
GET_TOKEN (stix);
|
||||
if (compile_method_expression(stix, 0) <= -1) return -1;
|
||||
DBGOUT_COMP_0("\treturn_stacktop");
|
||||
return emit_byte_instruction (stix, BCODE_RETURN_STACKTOP);
|
||||
}
|
||||
else
|
||||
@ -4080,7 +4002,6 @@ static int compile_method_statement (stix_t* stix)
|
||||
/* if n is 1, no stack popping is required */
|
||||
if (n == 0)
|
||||
{
|
||||
DBGOUT_COMP_0("\tpop_stacktop");
|
||||
return emit_byte_instruction (stix, BCODE_POP_STACKTOP);
|
||||
}
|
||||
|
||||
@ -4124,7 +4045,6 @@ static int compile_method_statements (stix_t* stix)
|
||||
|
||||
/* arrange to return the receiver if execution reached
|
||||
* the end of the method without explicit return */
|
||||
printf ("\treturn_receiver\n");
|
||||
return emit_byte_instruction (stix, BCODE_RETURN_RECEIVER);
|
||||
}
|
||||
|
||||
@ -4311,9 +4231,7 @@ need to write code to collect string.
|
||||
*/
|
||||
|
||||
/* TODO: call stix_decode only if decoding is enabled... */
|
||||
printf (">>>> BYTE CODE.....\n");
|
||||
stix_decode (stix, mth);
|
||||
|
||||
stix_decode (stix, &stix->c->cls.fqn, mth);
|
||||
|
||||
stix_poptmps (stix, tmp_count); tmp_count = 0;
|
||||
|
||||
@ -4371,10 +4289,6 @@ static int compile_method_definition (stix_t* stix)
|
||||
|
||||
if (compile_method_name(stix) <= -1) return -1;
|
||||
|
||||
printf (">>METHOD ");
|
||||
print_oocs (&stix->c->mth.name);
|
||||
printf ("\n");
|
||||
|
||||
if (stix->c->tok.type != STIX_IOTOK_LBRACE)
|
||||
{
|
||||
/* { expected */
|
||||
@ -4417,11 +4331,6 @@ static int make_defined_class (stix_t* stix)
|
||||
self_spec = STIX_CLASS_SELFSPEC_MAKE (stix->c->cls.var_count[VAR_CLASS],
|
||||
stix->c->cls.var_count[VAR_CLASSINST]);
|
||||
|
||||
#if 0
|
||||
printf ("MAKING ... ");
|
||||
print_oocs (&stix->c->cls.name);
|
||||
printf (" instvars %d classvars %d classinstvars %d\n", (int)stix->c->cls.var_count[VAR_INSTANCE], (int)stix->c->cls.var_count[VAR_CLASS], (int)stix->c->cls.var_count[VAR_CLASSINST]);
|
||||
#endif
|
||||
if (stix->c->cls.self_oop)
|
||||
{
|
||||
/* this is an internally created class object being defined. */
|
||||
@ -4433,12 +4342,6 @@ printf (" instvars %d classvars %d classinstvars %d\n", (int)stix->c->cls.var_co
|
||||
self_spec != STIX_OOP_TO_SMOOI(stix->c->cls.self_oop->selfspec))
|
||||
{
|
||||
/* it conflicts with internal definition */
|
||||
#if 0
|
||||
printf (" CONFLICTING CLASS DEFINITION %lu %lu %lu %lu\n",
|
||||
(unsigned long)spec, (unsigned long)self_spec,
|
||||
(unsigned long)STIX_OOP_TO_SMOOI(stix->c->cls.self_oop->spec), (unsigned long)STIX_OOP_TO_SMOOI(stix->c->cls.self_oop->selfspec)
|
||||
);
|
||||
#endif
|
||||
set_syntax_error (stix, STIX_SYNERR_CLASSCONTRA, &stix->c->cls.fqn_loc, &stix->c->cls.name);
|
||||
return -1;
|
||||
}
|
||||
|
184
stix/lib/debug.c
184
stix/lib/debug.c
@ -38,7 +38,7 @@ void dump_symbol_table (stix_t* stix)
|
||||
for (i = 0; i < STIX_OBJ_GET_SIZE(stix->symtab->bucket); i++)
|
||||
{
|
||||
symbol = (stix_oop_char_t)stix->symtab->bucket->slot[i];
|
||||
if ((stix_oop_t)symbol != stix->_nil)
|
||||
if ((stix_oop_t)symbol != stix->_nil)
|
||||
{
|
||||
printf (" %lu [", (unsigned long int)i);
|
||||
for (j = 0; j < STIX_OBJ_GET_SIZE(symbol); j++)
|
||||
@ -83,27 +83,27 @@ void print_oocs (const stix_oocs_t* name)
|
||||
}
|
||||
|
||||
|
||||
void print_object (stix_t* stix, stix_oop_t oop)
|
||||
void print_object (stix_t* stix, unsigned int mask, stix_oop_t oop)
|
||||
{
|
||||
if (oop == stix->_nil)
|
||||
{
|
||||
stix_bfmtout (stix, "nil");
|
||||
stix_logbfmt (stix, mask, "nil");
|
||||
}
|
||||
else if (oop == stix->_true)
|
||||
{
|
||||
stix_bfmtout (stix, "true");
|
||||
stix_logbfmt (stix, mask, "true");
|
||||
}
|
||||
else if (oop == stix->_false)
|
||||
{
|
||||
stix_bfmtout (stix, "false");
|
||||
stix_logbfmt (stix, mask, "false");
|
||||
}
|
||||
else if (STIX_OOP_IS_SMOOI(oop))
|
||||
{
|
||||
stix_bfmtout (stix, "%zd", STIX_OOP_TO_SMOOI(oop));
|
||||
stix_logbfmt (stix, mask, "%zd", STIX_OOP_TO_SMOOI(oop));
|
||||
}
|
||||
else if (STIX_OOP_IS_CHAR(oop))
|
||||
{
|
||||
stix_bfmtout (stix, "$%.1C", STIX_OOP_TO_CHAR(oop));
|
||||
stix_logbfmt (stix, mask, "$%.1C", STIX_OOP_TO_CHAR(oop));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -116,199 +116,75 @@ void print_object (stix_t* stix, stix_oop_t oop)
|
||||
if ((stix_oop_t)c == stix->_large_negative_integer)
|
||||
{
|
||||
stix_oow_t i;
|
||||
stix_bfmtout (stix, "-16r");
|
||||
stix_logbfmt (stix, mask, "-16r");
|
||||
for (i = STIX_OBJ_GET_SIZE(oop); i > 0;)
|
||||
{
|
||||
stix_bfmtout (stix, "%0*lX", (int)(STIX_SIZEOF(stix_liw_t) * 2), (unsigned long)((stix_oop_liword_t)oop)->slot[--i]);
|
||||
stix_logbfmt (stix, mask, "%0*lX", (int)(STIX_SIZEOF(stix_liw_t) * 2), (unsigned long)((stix_oop_liword_t)oop)->slot[--i]);
|
||||
}
|
||||
}
|
||||
else if ((stix_oop_t)c == stix->_large_positive_integer)
|
||||
{
|
||||
stix_oow_t i;
|
||||
stix_bfmtout (stix, "16r");
|
||||
stix_logbfmt (stix, mask, "16r");
|
||||
for (i = STIX_OBJ_GET_SIZE(oop); i > 0;)
|
||||
{
|
||||
stix_bfmtout (stix, "%0*lX", (int)(STIX_SIZEOF(stix_liw_t) * 2), (unsigned long)((stix_oop_liword_t)oop)->slot[--i]);
|
||||
stix_logbfmt (stix, mask, "%0*lX", (int)(STIX_SIZEOF(stix_liw_t) * 2), (unsigned long)((stix_oop_liword_t)oop)->slot[--i]);
|
||||
}
|
||||
}
|
||||
else if (STIX_OBJ_GET_FLAGS_TYPE(oop) == STIX_OBJ_TYPE_CHAR)
|
||||
{
|
||||
if ((stix_oop_t)c == stix->_symbol) stix_bfmtout (stix, "#");
|
||||
else if ((stix_oop_t)c == stix->_string) stix_bfmtout (stix, "'");
|
||||
if ((stix_oop_t)c == stix->_symbol) stix_logbfmt (stix, mask, "#");
|
||||
else if ((stix_oop_t)c == stix->_string) stix_logbfmt (stix, mask, "'");
|
||||
|
||||
stix_bfmtout (stix, "%.*S", STIX_OBJ_GET_SIZE(oop), ((stix_oop_char_t)oop)->slot);
|
||||
if ((stix_oop_t)c == stix->_string) stix_bfmtout (stix, "'");
|
||||
stix_logbfmt (stix, mask, "%.*S", STIX_OBJ_GET_SIZE(oop), ((stix_oop_char_t)oop)->slot);
|
||||
if ((stix_oop_t)c == stix->_string) stix_logbfmt (stix, mask, "'");
|
||||
}
|
||||
else if (STIX_OBJ_GET_FLAGS_TYPE(oop) == STIX_OBJ_TYPE_BYTE)
|
||||
{
|
||||
stix_bfmtout (stix, "#[");
|
||||
stix_logbfmt (stix, mask, "#[");
|
||||
for (i = 0; i < STIX_OBJ_GET_SIZE(oop); i++)
|
||||
{
|
||||
stix_bfmtout (stix, " %d", ((stix_oop_byte_t)oop)->slot[i]);
|
||||
stix_logbfmt (stix, mask, " %d", ((stix_oop_byte_t)oop)->slot[i]);
|
||||
}
|
||||
stix_bfmtout (stix, "]");
|
||||
stix_logbfmt (stix, mask, "]");
|
||||
}
|
||||
|
||||
else if (STIX_OBJ_GET_FLAGS_TYPE(oop) == STIX_OBJ_TYPE_HALFWORD)
|
||||
{
|
||||
stix_bfmtout (stix, "#[["); /* TODO: fix this symbol */
|
||||
stix_logbfmt (stix, mask, "#[["); /* TODO: fix this symbol/notation */
|
||||
for (i = 0; i < STIX_OBJ_GET_SIZE(oop); i++)
|
||||
{
|
||||
stix_bfmtout (stix, " %zX", (stix_oow_t)((stix_oop_halfword_t)oop)->slot[i]);
|
||||
stix_logbfmt (stix, mask, " %zX", (stix_oow_t)((stix_oop_halfword_t)oop)->slot[i]);
|
||||
}
|
||||
stix_bfmtout (stix, "]]");
|
||||
stix_logbfmt (stix, mask, "]]");
|
||||
}
|
||||
else if (STIX_OBJ_GET_FLAGS_TYPE(oop) == STIX_OBJ_TYPE_WORD)
|
||||
{
|
||||
stix_bfmtout (stix, "#[[["); /* TODO: fix this symbol */
|
||||
stix_logbfmt (stix, mask, "#[[["); /* TODO: fix this symbol/notation */
|
||||
for (i = 0; i < STIX_OBJ_GET_SIZE(oop); i++)
|
||||
{
|
||||
stix_bfmtout (stix, " %zX", ((stix_oop_word_t)oop)->slot[i]);
|
||||
stix_logbfmt (stix, mask, " %zX", ((stix_oop_word_t)oop)->slot[i]);
|
||||
}
|
||||
stix_bfmtout (stix, "]]]");
|
||||
stix_logbfmt (stix, mask, "]]]");
|
||||
}
|
||||
else if ((stix_oop_t)c == stix->_array)
|
||||
{
|
||||
stix_bfmtout (stix, "#(");
|
||||
stix_logbfmt (stix, mask, "#(");
|
||||
for (i = 0; i < STIX_OBJ_GET_SIZE(oop); i++)
|
||||
{
|
||||
stix_bfmtout (stix, " ");
|
||||
print_object (stix, ((stix_oop_oop_t)oop)->slot[i]);
|
||||
stix_logbfmt (stix, mask, " ");
|
||||
print_object (stix, mask, ((stix_oop_oop_t)oop)->slot[i]);
|
||||
}
|
||||
stix_bfmtout (stix, ")");
|
||||
stix_logbfmt (stix, mask, ")");
|
||||
}
|
||||
else if ((stix_oop_t)c == stix->_class)
|
||||
{
|
||||
/* print the class name */
|
||||
stix_bfmtout (stix, "%.*S", STIX_OBJ_GET_SIZE(((stix_oop_class_t)oop)->name), ((stix_oop_class_t)oop)->name->slot);
|
||||
stix_logbfmt (stix, mask, "%.*S", STIX_OBJ_GET_SIZE(((stix_oop_class_t)oop)->name), ((stix_oop_class_t)oop)->name->slot);
|
||||
}
|
||||
else
|
||||
{
|
||||
stix_bfmtout (stix, "instance of %.*S - (%p)", STIX_OBJ_GET_SIZE(c->name), ((stix_oop_char_t)c->name)->slot, oop);
|
||||
stix_logbfmt (stix, mask, "instance of %.*S - (%p)", STIX_OBJ_GET_SIZE(c->name), ((stix_oop_char_t)c->name)->slot, oop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void __dump_object (stix_t* stix, stix_oop_t oop, int depth)
|
||||
{
|
||||
stix_oop_class_t c;
|
||||
stix_oocs_t s;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < depth; i++) printf ("\t");
|
||||
printf ("%p instance of ", oop);
|
||||
|
||||
c = (stix_oop_class_t)STIX_CLASSOF(stix, oop);
|
||||
s.ptr = ((stix_oop_char_t)c->name)->slot;
|
||||
s.len = STIX_OBJ_GET_SIZE(c->name);
|
||||
print_oocs (&s);
|
||||
|
||||
if (oop == stix->_nil)
|
||||
{
|
||||
printf (" nil");
|
||||
}
|
||||
else if (oop == stix->_true)
|
||||
{
|
||||
printf (" true");
|
||||
}
|
||||
else if (oop == stix->_false)
|
||||
{
|
||||
printf (" false");
|
||||
}
|
||||
else if (STIX_OOP_IS_SMOOI(oop))
|
||||
{
|
||||
printf (" %ld", (long int)STIX_OOP_TO_SMOOI(oop));
|
||||
}
|
||||
else if (STIX_OOP_IS_CHAR(oop))
|
||||
{
|
||||
stix_bch_t bcs[32];
|
||||
stix_uch_t uch;
|
||||
stix_oow_t ucslen, bcslen;
|
||||
|
||||
uch = STIX_OOP_TO_CHAR(oop);
|
||||
bcslen = STIX_COUNTOF(bcs);
|
||||
ucslen = 1;
|
||||
if (stix_ucstoutf8 (&uch, &ucslen, bcs, &bcslen) >= 0)
|
||||
{
|
||||
printf (" $%.*s", (int)bcslen, bcs);
|
||||
}
|
||||
}
|
||||
else if (STIX_OOP_IS_POINTER(oop))
|
||||
{
|
||||
if (STIX_OBJ_GET_FLAGS_TYPE(oop) == STIX_OBJ_TYPE_OOP)
|
||||
{
|
||||
/* TODO: print _Array specially using #( */
|
||||
printf ("\n");
|
||||
for (i = 0; i < STIX_OBJ_GET_SIZE(oop); i++)
|
||||
{
|
||||
__dump_object (stix, ((stix_oop_oop_t)oop)->slot[i], depth + 1);
|
||||
}
|
||||
}
|
||||
else if (STIX_OBJ_GET_FLAGS_TYPE(oop) == STIX_OBJ_TYPE_CHAR)
|
||||
{
|
||||
if (STIX_CLASSOF(stix,oop) == stix->_symbol)
|
||||
{
|
||||
printf (" #'");
|
||||
}
|
||||
else if (STIX_CLASSOF(stix,oop) == stix->_string)
|
||||
{
|
||||
printf (" '");
|
||||
}
|
||||
|
||||
for (i = 0; i < STIX_OBJ_GET_SIZE(oop); i++)
|
||||
{
|
||||
stix_bch_t bcs[32];
|
||||
stix_uch_t uch;
|
||||
stix_oow_t ucslen, bcslen;
|
||||
uch = ((stix_oop_char_t)oop)->slot[i];
|
||||
if (uch == '\'') printf ("''");
|
||||
else
|
||||
{
|
||||
bcslen = STIX_COUNTOF(bcs);
|
||||
ucslen = 1;
|
||||
if (stix_ucstoutf8 (&uch, &ucslen, bcs, &bcslen) >= 0)
|
||||
{
|
||||
printf ("%.*s", (int)bcslen, bcs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
printf ("'");
|
||||
}
|
||||
else if (STIX_OBJ_GET_FLAGS_TYPE(oop) == STIX_OBJ_TYPE_BYTE)
|
||||
{
|
||||
printf (" #[");
|
||||
for (i = 0; i < STIX_OBJ_GET_SIZE(oop); i++)
|
||||
{
|
||||
printf (" %d", ((stix_oop_byte_t)oop)->slot[i]);
|
||||
}
|
||||
printf ("]");
|
||||
}
|
||||
else if (STIX_OBJ_GET_FLAGS_TYPE(oop) == STIX_OBJ_TYPE_HALFWORD)
|
||||
{
|
||||
printf (" #["); /* TODO: different symbol for word array ?? */
|
||||
for (i = 0; i < STIX_OBJ_GET_SIZE(oop); i++)
|
||||
{
|
||||
printf (" %ld", (long int)((stix_oop_halfword_t)oop)->slot[i]);
|
||||
}
|
||||
printf ("]");
|
||||
}
|
||||
else if (STIX_OBJ_GET_FLAGS_TYPE(oop) == STIX_OBJ_TYPE_WORD)
|
||||
{
|
||||
printf (" #["); /* TODO: different symbol for word array ?? */
|
||||
for (i = 0; i < STIX_OBJ_GET_SIZE(oop); i++)
|
||||
{
|
||||
printf (" %ld", (long int)((stix_oop_word_t)oop)->slot[i]);
|
||||
}
|
||||
printf ("]");
|
||||
}
|
||||
}
|
||||
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
void dump_object (stix_t* stix, stix_oop_t oop, const char* title)
|
||||
{
|
||||
printf ("[%s]\n", title);
|
||||
__dump_object (stix, oop, 0);
|
||||
}
|
||||
|
@ -26,12 +26,13 @@
|
||||
|
||||
#include "stix-prv.h"
|
||||
|
||||
# define DECODE_OUT_0(stix,fmt) stix_bfmtout(stix, "\t" fmt "\n")
|
||||
# define DECODE_OUT_1(stix,fmt,a1) stix_bfmtout(stix, "\t" fmt "\n",a1)
|
||||
# define DECODE_OUT_2(stix,fmt,a1,a2) stix_bfmtout(stix, "\t" fmt "\n", a1, a2)
|
||||
# define DECODE_OUT_3(stix,fmt,a1,a2,a3) stix_bfmtout(stix, "\t" fmt "\n", a1, a2, a3)
|
||||
|
||||
#define LOG_MASK_INST (STIX_LOG_COMPILER | STIX_LOG_INFO)
|
||||
|
||||
#define LOG_INST_0(stix,fmt) if (STIX_LOG_ENABLED(stix,LOG_MASK_INST)) stix_logbfmt(stix, LOG_MASK_INST, "\t" fmt "\n")
|
||||
#define LOG_INST_1(stix,fmt,a1) if (STIX_LOG_ENABLED(stix,LOG_MASK_INST)) stix_logbfmt(stix, LOG_MASK_INST, "\t" fmt "\n",a1)
|
||||
#define LOG_INST_2(stix,fmt,a1,a2) if (STIX_LOG_ENABLED(stix,LOG_MASK_INST)) stix_logbfmt(stix, LOG_MASK_INST, "\t" fmt "\n", a1, a2)
|
||||
#define LOG_INST_3(stix,fmt,a1,a2,a3) if (STIX_LOG_ENABLED(stix,LOG_MASK_INST)) stix_logbfmt(stix, LOG_MASK_INST, "\t" fmt "\n", a1, a2, a3)
|
||||
|
||||
#define FETCH_BYTE_CODE(stix) (cdptr[ip++])
|
||||
#define FETCH_BYTE_CODE_TO(stix,v_ooi) (v_ooi = FETCH_BYTE_CODE(stix))
|
||||
@ -45,11 +46,8 @@
|
||||
# define FETCH_PARAM_CODE_TO(stix,v_ooi) (v_ooi = FETCH_BYTE_CODE(stix))
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
/* TODO: check if ip shoots beyond the maximum length in fetching code and parameters */
|
||||
int stix_decode (stix_t* stix, stix_oop_method_t mth)
|
||||
int stix_decode (stix_t* stix, const stix_oocs_t* classfqn, stix_oop_method_t mth)
|
||||
{
|
||||
stix_oob_t bcode, * cdptr;
|
||||
stix_oow_t ip = 0, cdlen;
|
||||
@ -58,6 +56,9 @@ int stix_decode (stix_t* stix, stix_oop_method_t mth)
|
||||
cdptr = STIX_METHOD_GET_CODE_BYTE(mth);
|
||||
cdlen = STIX_METHOD_GET_CODE_SIZE(mth);
|
||||
|
||||
if (STIX_LOG_ENABLED(stix, LOG_MASK_INST))
|
||||
stix_logbfmt (stix, LOG_MASK_INST, "%.*S>>%O\n", classfqn->len, classfqn->ptr, mth->name);
|
||||
|
||||
/* TODO: check if ip increases beyon bcode when fetching parameters too */
|
||||
while (ip < cdlen)
|
||||
{
|
||||
@ -78,7 +79,7 @@ int stix_decode (stix_t* stix, stix_oop_method_t mth)
|
||||
case BCODE_PUSH_INSTVAR_7:
|
||||
b1 = bcode & 0x7; /* low 3 bits */
|
||||
push_instvar:
|
||||
DECODE_OUT_1 (stix, "push_instvar %zd", b1);
|
||||
LOG_INST_1 (stix, "push_instvar %zd", b1);
|
||||
break;
|
||||
|
||||
/* ------------------------------------------------- */
|
||||
@ -96,7 +97,7 @@ int stix_decode (stix_t* stix, stix_oop_method_t mth)
|
||||
case BCODE_STORE_INTO_INSTVAR_7:
|
||||
b1 = bcode & 0x7; /* low 3 bits */
|
||||
store_instvar:
|
||||
DECODE_OUT_1 (stix, "store_into_instvar %zd", b1);
|
||||
LOG_INST_1 (stix, "store_into_instvar %zd", b1);
|
||||
break;
|
||||
|
||||
case BCODE_POP_INTO_INSTVAR_X:
|
||||
@ -112,7 +113,7 @@ int stix_decode (stix_t* stix, stix_oop_method_t mth)
|
||||
case BCODE_POP_INTO_INSTVAR_7:
|
||||
b1 = bcode & 0x7; /* low 3 bits */
|
||||
pop_into_instvar:
|
||||
DECODE_OUT_1 (stix, "pop_into_instvar %zd", b1);
|
||||
LOG_INST_1 (stix, "pop_into_instvar %zd", b1);
|
||||
break;
|
||||
|
||||
/* ------------------------------------------------- */
|
||||
@ -152,7 +153,7 @@ int stix_decode (stix_t* stix, stix_oop_method_t mth)
|
||||
if ((bcode >> 4) & 1)
|
||||
{
|
||||
/* push - bit 4 on */
|
||||
DECODE_OUT_1 (stix, "push_tempvar %zd", b1);
|
||||
LOG_INST_1 (stix, "push_tempvar %zd", b1);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -160,11 +161,11 @@ int stix_decode (stix_t* stix, stix_oop_method_t mth)
|
||||
if ((bcode >> 3) & 1)
|
||||
{
|
||||
/* pop - bit 3 on */
|
||||
DECODE_OUT_1 (stix, "pop_into_tempvar %zd", b1);
|
||||
LOG_INST_1 (stix, "pop_into_tempvar %zd", b1);
|
||||
}
|
||||
else
|
||||
{
|
||||
DECODE_OUT_1 (stix, "store_into_tempvar %zd", b1);
|
||||
LOG_INST_1 (stix, "store_into_tempvar %zd", b1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -184,7 +185,7 @@ int stix_decode (stix_t* stix, stix_oop_method_t mth)
|
||||
case BCODE_PUSH_LITERAL_7:
|
||||
b1 = bcode & 0x7; /* low 3 bits */
|
||||
push_literal:
|
||||
DECODE_OUT_1 (stix, "push_literal %zd", b1);
|
||||
LOG_INST_1 (stix, "push_literal %zd", b1);
|
||||
break;
|
||||
|
||||
/* ------------------------------------------------- */
|
||||
@ -212,16 +213,16 @@ int stix_decode (stix_t* stix, stix_oop_method_t mth)
|
||||
{
|
||||
if ((bcode >> 2) & 1)
|
||||
{
|
||||
DECODE_OUT_1 (stix, "pop_into_object %zd", b1);
|
||||
LOG_INST_1 (stix, "pop_into_object %zd", b1);
|
||||
}
|
||||
else
|
||||
{
|
||||
DECODE_OUT_1 (stix, "store_into_object %zd", b1);
|
||||
LOG_INST_1 (stix, "store_into_object %zd", b1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DECODE_OUT_1 (stix, "push_object %zd", b1);
|
||||
LOG_INST_1 (stix, "push_object %zd", b1);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -229,19 +230,19 @@ int stix_decode (stix_t* stix, stix_oop_method_t mth)
|
||||
|
||||
case BCODE_JUMP_FORWARD_X:
|
||||
FETCH_PARAM_CODE_TO (stix, b1);
|
||||
DECODE_OUT_1 (stix, "jump_forward %zd", b1);
|
||||
LOG_INST_1 (stix, "jump_forward %zd", b1);
|
||||
break;
|
||||
|
||||
case BCODE_JUMP_FORWARD_0:
|
||||
case BCODE_JUMP_FORWARD_1:
|
||||
case BCODE_JUMP_FORWARD_2:
|
||||
case BCODE_JUMP_FORWARD_3:
|
||||
DECODE_OUT_1 (stix, "jump_forward %zd", (bcode & 0x3)); /* low 2 bits */
|
||||
LOG_INST_1 (stix, "jump_forward %zd", (bcode & 0x3)); /* low 2 bits */
|
||||
break;
|
||||
|
||||
case BCODE_JUMP_BACKWARD_X:
|
||||
FETCH_PARAM_CODE_TO (stix, b1);
|
||||
DECODE_OUT_1 (stix, "jump_backward %zd", b1);
|
||||
LOG_INST_1 (stix, "jump_backward %zd", b1);
|
||||
stix->ip += b1;
|
||||
break;
|
||||
|
||||
@ -249,7 +250,7 @@ int stix_decode (stix_t* stix, stix_oop_method_t mth)
|
||||
case BCODE_JUMP_BACKWARD_1:
|
||||
case BCODE_JUMP_BACKWARD_2:
|
||||
case BCODE_JUMP_BACKWARD_3:
|
||||
DECODE_OUT_1 (stix, "jump_backward %zd", (bcode & 0x3)); /* low 2 bits */
|
||||
LOG_INST_1 (stix, "jump_backward %zd", (bcode & 0x3)); /* low 2 bits */
|
||||
break;
|
||||
|
||||
case BCODE_JUMP_IF_TRUE_X:
|
||||
@ -262,18 +263,18 @@ int stix_decode (stix_t* stix, stix_oop_method_t mth)
|
||||
case BCODE_JUMP_IF_FALSE_1:
|
||||
case BCODE_JUMP_IF_FALSE_2:
|
||||
case BCODE_JUMP_IF_FALSE_3:
|
||||
DECODE_OUT_0 (stix, "<<<<<<<<<<<<<< JUMP NOT IMPLEMENTED YET >>>>>>>>>>>>");
|
||||
LOG_INST_0 (stix, "<<<<<<<<<<<<<< JUMP NOT IMPLEMENTED YET >>>>>>>>>>>>");
|
||||
stix->errnum = STIX_ENOIMPL;
|
||||
return -1;
|
||||
|
||||
case BCODE_JUMP2_FORWARD:
|
||||
FETCH_PARAM_CODE_TO (stix, b1);
|
||||
DECODE_OUT_1 (stix, "jump2_forward %zd", b1);
|
||||
LOG_INST_1 (stix, "jump2_forward %zd", b1);
|
||||
break;
|
||||
|
||||
case BCODE_JUMP2_BACKWARD:
|
||||
FETCH_PARAM_CODE_TO (stix, b1);
|
||||
DECODE_OUT_1 (stix, "jump2_backward %zd", b1);
|
||||
LOG_INST_1 (stix, "jump2_backward %zd", b1);
|
||||
break;
|
||||
|
||||
/* -------------------------------------------------------- */
|
||||
@ -306,17 +307,17 @@ return -1;
|
||||
|
||||
if ((bcode >> 2) & 1)
|
||||
{
|
||||
DECODE_OUT_2 (stix, "pop_into_ctxtempvar %zd %zd", b1, b2);
|
||||
LOG_INST_2 (stix, "pop_into_ctxtempvar %zd %zd", b1, b2);
|
||||
}
|
||||
else
|
||||
{
|
||||
DECODE_OUT_2 (stix, "store_into_ctxtempvar %zd %zd", b1, b2);
|
||||
LOG_INST_2 (stix, "store_into_ctxtempvar %zd %zd", b1, b2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* push */
|
||||
DECODE_OUT_2 (stix, "push_ctxtempvar %zd %zd", b1, b2);
|
||||
LOG_INST_2 (stix, "push_ctxtempvar %zd %zd", b1, b2);
|
||||
}
|
||||
|
||||
break;
|
||||
@ -352,16 +353,16 @@ return -1;
|
||||
/* store or pop */
|
||||
if ((bcode >> 2) & 1)
|
||||
{
|
||||
DECODE_OUT_2 (stix, "pop_into_objvar %zd %zd", b1, b2);
|
||||
LOG_INST_2 (stix, "pop_into_objvar %zd %zd", b1, b2);
|
||||
}
|
||||
else
|
||||
{
|
||||
DECODE_OUT_2 (stix, "store_into_objvar %zd %zd", b1, b2);
|
||||
LOG_INST_2 (stix, "store_into_objvar %zd %zd", b1, b2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DECODE_OUT_2 (stix, "push_objvar %zd %zd", b1, b2);
|
||||
LOG_INST_2 (stix, "push_objvar %zd %zd", b1, b2);
|
||||
}
|
||||
|
||||
break;
|
||||
@ -387,77 +388,77 @@ return -1;
|
||||
FETCH_BYTE_CODE_TO (stix, b2);
|
||||
|
||||
handle_send_message:
|
||||
DECODE_OUT_3 (stix, "send_message%hs %zd @%zd", (((bcode >> 2) & 1)? "_to_super": ""), b1, b2);
|
||||
LOG_INST_3 (stix, "send_message%hs %zd @%zd", (((bcode >> 2) & 1)? "_to_super": ""), b1, b2);
|
||||
break;
|
||||
|
||||
/* -------------------------------------------------------- */
|
||||
|
||||
case BCODE_PUSH_RECEIVER:
|
||||
DECODE_OUT_0 (stix, "push_receiver");
|
||||
LOG_INST_0 (stix, "push_receiver");
|
||||
break;
|
||||
|
||||
case BCODE_PUSH_NIL:
|
||||
DECODE_OUT_0 (stix, "push_nil");
|
||||
LOG_INST_0 (stix, "push_nil");
|
||||
break;
|
||||
|
||||
case BCODE_PUSH_TRUE:
|
||||
DECODE_OUT_0 (stix, "push_true");
|
||||
LOG_INST_0 (stix, "push_true");
|
||||
break;
|
||||
|
||||
case BCODE_PUSH_FALSE:
|
||||
DECODE_OUT_0 (stix, "push_false");
|
||||
LOG_INST_0 (stix, "push_false");
|
||||
break;
|
||||
|
||||
case BCODE_PUSH_CONTEXT:
|
||||
DECODE_OUT_0 (stix, "push_context");
|
||||
LOG_INST_0 (stix, "push_context");
|
||||
break;
|
||||
|
||||
case BCODE_PUSH_NEGONE:
|
||||
DECODE_OUT_0 (stix, "push_negone");
|
||||
LOG_INST_0 (stix, "push_negone");
|
||||
break;
|
||||
|
||||
case BCODE_PUSH_ZERO:
|
||||
DECODE_OUT_0 (stix, "push_zero");
|
||||
LOG_INST_0 (stix, "push_zero");
|
||||
break;
|
||||
|
||||
case BCODE_PUSH_ONE:
|
||||
DECODE_OUT_0 (stix, "push_one");
|
||||
LOG_INST_0 (stix, "push_one");
|
||||
break;
|
||||
|
||||
case BCODE_PUSH_TWO:
|
||||
DECODE_OUT_0 (stix, "push_two");
|
||||
LOG_INST_0 (stix, "push_two");
|
||||
break;
|
||||
|
||||
case BCODE_PUSH_INTLIT:
|
||||
FETCH_PARAM_CODE_TO (stix, b1);
|
||||
DECODE_OUT_1 (stix, "push_intlit %zd", b1);
|
||||
LOG_INST_1 (stix, "push_intlit %zd", b1);
|
||||
break;
|
||||
|
||||
case BCODE_PUSH_NEGINTLIT:
|
||||
FETCH_PARAM_CODE_TO (stix, b1);
|
||||
DECODE_OUT_1 (stix, "push_negintlit %zd", -b1);
|
||||
LOG_INST_1 (stix, "push_negintlit %zd", -b1);
|
||||
break;
|
||||
|
||||
/* -------------------------------------------------------- */
|
||||
|
||||
case BCODE_DUP_STACKTOP:
|
||||
DECODE_OUT_0 (stix, "dup_stacktop");
|
||||
LOG_INST_0 (stix, "dup_stacktop");
|
||||
break;
|
||||
|
||||
case BCODE_POP_STACKTOP:
|
||||
DECODE_OUT_0 (stix, "pop_stacktop");
|
||||
LOG_INST_0 (stix, "pop_stacktop");
|
||||
break;
|
||||
|
||||
case BCODE_RETURN_STACKTOP:
|
||||
DECODE_OUT_0 (stix, "return_stacktop");
|
||||
LOG_INST_0 (stix, "return_stacktop");
|
||||
break;
|
||||
|
||||
case BCODE_RETURN_RECEIVER:
|
||||
DECODE_OUT_0 (stix, "return_receiver");
|
||||
LOG_INST_0 (stix, "return_receiver");
|
||||
break;
|
||||
|
||||
case BCODE_RETURN_FROM_BLOCK:
|
||||
DECODE_OUT_0 (stix, "return_from_block");
|
||||
LOG_INST_0 (stix, "return_from_block");
|
||||
break;
|
||||
|
||||
case BCODE_MAKE_BLOCK:
|
||||
@ -466,7 +467,7 @@ return -1;
|
||||
FETCH_PARAM_CODE_TO (stix, b1);
|
||||
FETCH_PARAM_CODE_TO (stix, b2);
|
||||
|
||||
DECODE_OUT_2 (stix, "make_block %zd %zd", b1, b2);
|
||||
LOG_INST_2 (stix, "make_block %zd %zd", b1, b2);
|
||||
|
||||
STIX_ASSERT (b1 >= 0);
|
||||
STIX_ASSERT (b2 >= b1);
|
||||
@ -474,16 +475,16 @@ return -1;
|
||||
|
||||
|
||||
case BCODE_SEND_BLOCK_COPY:
|
||||
DECODE_OUT_0 (stix, "send_block_copy");
|
||||
LOG_INST_0 (stix, "send_block_copy");
|
||||
break;
|
||||
|
||||
case BCODE_NOOP:
|
||||
/* do nothing */
|
||||
DECODE_OUT_0 (stix, "noop");
|
||||
LOG_INST_0 (stix, "noop");
|
||||
break;
|
||||
|
||||
default:
|
||||
DECODE_OUT_1 (stix, "UNKNOWN BYTE CODE ENCOUNTERED %x", (int)bcode);
|
||||
LOG_INST_1 (stix, "UNKNOWN BYTE CODE ENCOUNTERED %x", (int)bcode);
|
||||
stix->errnum = STIX_EINTERN;
|
||||
break;
|
||||
|
||||
@ -493,7 +494,7 @@ return -1;
|
||||
/* print literal frame contents */
|
||||
for (ip = 0; ip < STIX_OBJ_GET_SIZE(mth) - STIX_METHOD_NAMED_INSTVARS; ip++)
|
||||
{
|
||||
DECODE_OUT_2 (stix, " @%-3lu %O", (unsigned long int)ip, mth->slot[ip]);
|
||||
LOG_INST_2 (stix, " @%-3lu %O", (unsigned long int)ip, mth->slot[ip]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1037,7 +1037,7 @@ static stix_oop_method_t find_method (stix_t* stix, stix_oop_t receiver, const s
|
||||
|
||||
#if defined(STIX_DEBUG_EXEC_002)
|
||||
printf ("==== FINDING METHOD FOR %p [", receiver);
|
||||
print_object (stix, receiver);
|
||||
print_object (stix, 0, receiver);
|
||||
printf ("] - [");
|
||||
print_oocs (message);
|
||||
printf ("] in ");
|
||||
@ -1051,7 +1051,7 @@ printf ("] in ");
|
||||
dic_no = STIX_CLASS_MTHDIC_CLASS;
|
||||
#if defined(STIX_DEBUG_EXEC_002)
|
||||
printf ("class method dictioanry of ");
|
||||
print_object(stix, (stix_oop_t)((stix_oop_class_t)c)->name);
|
||||
print_object(stix, 0, (stix_oop_t)((stix_oop_class_t)c)->name);
|
||||
printf ("\n");
|
||||
#endif
|
||||
}
|
||||
@ -1061,7 +1061,7 @@ printf ("\n");
|
||||
dic_no = STIX_CLASS_MTHDIC_INSTANCE;
|
||||
#if defined(STIX_DEBUG_EXEC_002)
|
||||
printf ("instance method dictioanry of ");
|
||||
print_object(stix, (stix_oop_t)((stix_oop_class_t)c)->name);
|
||||
print_object(stix, 0, (stix_oop_t)((stix_oop_class_t)c)->name);
|
||||
printf ("\n");
|
||||
#endif
|
||||
}
|
||||
@ -1213,15 +1213,11 @@ static int prim_dump (stix_t* stix, stix_ooi_t nargs)
|
||||
|
||||
STIX_ASSERT (nargs >= 0);
|
||||
|
||||
stix_bfmtout (stix, "RECEIVER: ");
|
||||
print_object (stix, STIX_STACK_GET(stix, stix->sp - nargs));
|
||||
stix_bfmtout (stix, "\n");
|
||||
stix_logbfmt (stix, 0, "RECEIVER: %O\n", STIX_STACK_GET(stix, stix->sp - nargs));
|
||||
for (i = nargs; i > 0; )
|
||||
{
|
||||
--i;
|
||||
stix_bfmtout (stix, "ARGUMENT: ");
|
||||
print_object (stix, STIX_STACK_GET(stix, stix->sp - i));
|
||||
stix_bfmtout (stix, "\n");
|
||||
stix_logbfmt (stix, 0, "ARGUMENT %zd: %O\n", i, STIX_STACK_GET(stix, stix->sp - i));
|
||||
}
|
||||
|
||||
STIX_STACK_POPS (stix, nargs);
|
||||
@ -2907,7 +2903,7 @@ static int send_message (stix_t* stix, stix_oop_char_t selector, int to_super, s
|
||||
|
||||
#if defined(STIX_DEBUG_EXEC_001)
|
||||
printf (" RECEIVER = ");
|
||||
print_object(stix, receiver);
|
||||
print_object(stix, 0, receiver);
|
||||
printf ("\n");
|
||||
#endif
|
||||
|
||||
@ -2933,9 +2929,9 @@ printf ("\n");
|
||||
/* TODO: remove this print-out.... or have it gracefully returned to the caller side */
|
||||
c = STIX_CLASSOF(stix,receiver);
|
||||
printf ("HARD FAILURE ERROR [IMAGE PROBLEM] - receiver [");
|
||||
print_object (stix, receiver);
|
||||
print_object (stix, 0, receiver);
|
||||
printf ("] class ");
|
||||
print_object (stix, c);
|
||||
print_object (stix, 0, c);
|
||||
printf (" doesNotUnderstand: [");
|
||||
print_oocs (&mthname);
|
||||
printf ("]\n");
|
||||
@ -3408,7 +3404,7 @@ printf ("BCODE = %x\n", bcode);
|
||||
}
|
||||
}
|
||||
/*
|
||||
print_object (stix, ctx->slot[bx]);
|
||||
print_object (stix, 0, ctx->slot[bx]);
|
||||
printf ("\n");
|
||||
*/
|
||||
break;
|
||||
@ -3431,7 +3427,7 @@ printf ("BCODE = %x\n", bcode);
|
||||
push_literal:
|
||||
DBGOUT_EXEC_1 ("PUSH_LITERAL %d", (int)b1);
|
||||
/*
|
||||
print_object (stix, stix->active_method->slot[b1]);
|
||||
print_object (stix, 0, stix->active_method->slot[b1]);
|
||||
printf ("\n");
|
||||
*/
|
||||
STIX_STACK_PUSH (stix, stix->active_method->slot[b1]);
|
||||
@ -3703,7 +3699,7 @@ printf ("\n");
|
||||
|
||||
#if defined(STIX_DEBUG_EXEC_001)
|
||||
printf ("SEND_MESSAGE%s TO RECEIVER AT STACKPOS=%d NARGS=%d SELECTOR=", (((bcode >> 2) & 1)? "_TO_SUPER": ""), (int)(stix->sp - b1), (int)b1);
|
||||
print_object (stix, (stix_oop_t)selector);
|
||||
print_object (stix, 0, (stix_oop_t)selector);
|
||||
fflush (stdout);
|
||||
#endif
|
||||
if (send_message (stix, selector, ((bcode >> 2) & 1), b1) <= -1) goto oops;
|
||||
|
@ -129,17 +129,27 @@ static const stix_bch_t hex2ascii_upper[] =
|
||||
static stix_ooch_t ooch_nullstr[] = { '(','n','u','l','l', ')','\0' };
|
||||
static stix_bch_t bch_nullstr[] = { '(','n','u','l','l', ')','\0' };
|
||||
|
||||
typedef int (*stix_fmtout_put_t) (
|
||||
typedef int (*stix_fmtout_putch_t) (
|
||||
stix_t* stix,
|
||||
stix_ooch_t c
|
||||
int mask,
|
||||
stix_ooch_t c,
|
||||
stix_oow_t len
|
||||
);
|
||||
|
||||
typedef int (*stix_fmtout_putcs_t) (
|
||||
stix_t* stix,
|
||||
int mask,
|
||||
const stix_ooch_t* ptr,
|
||||
stix_oow_t len
|
||||
);
|
||||
|
||||
typedef struct stix_fmtout_t stix_fmtout_t;
|
||||
struct stix_fmtout_t
|
||||
{
|
||||
stix_oow_t count; /* out */
|
||||
stix_oow_t limit; /* in */
|
||||
stix_fmtout_put_t put;
|
||||
stix_oow_t count; /* out */
|
||||
int mask; /* in */
|
||||
stix_fmtout_putch_t putch; /* in */
|
||||
stix_fmtout_putcs_t putcs; /* in */
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -175,16 +185,30 @@ static stix_bch_t* sprintn_upper (stix_bch_t* nbuf, stix_uintmax_t num, int base
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static int put_ooch (stix_t* stix, stix_ooch_t ch)
|
||||
static int put_ooch (stix_t* stix, unsigned int mask, stix_ooch_t ch, stix_oow_t len)
|
||||
{
|
||||
if (len <= 0) return 1;
|
||||
|
||||
if (stix->log.len >= stix->log.capa)
|
||||
if (stix->log.len > 0 && stix->log.last_mask != mask)
|
||||
{
|
||||
/* the mask has changed. commit the buffered text */
|
||||
stix->vmprim.log_write (stix, stix->log.last_mask, stix->log.ptr, stix->log.len);
|
||||
stix->log.len = 0;
|
||||
}
|
||||
|
||||
if (len > stix->log.capa - stix->log.len)
|
||||
{
|
||||
stix_oow_t newcapa;
|
||||
stix_ooch_t* tmp;
|
||||
|
||||
newcapa = stix->log.capa + 512; /* TODO: adjust this capacity */
|
||||
if (len > STIX_TYPE_MAX(stix_oow_t) - stix->log.len)
|
||||
{
|
||||
/* data too big */
|
||||
stix->errnum = STIX_ETOOBIG;
|
||||
return -1;
|
||||
}
|
||||
|
||||
newcapa = STIX_ALIGN(stix->log.len + len, 512); /* TODO: adjust this capacity */
|
||||
tmp = stix_reallocmem (stix, stix->log.ptr, newcapa * STIX_SIZEOF(*tmp));
|
||||
if (!tmp) return -1;
|
||||
|
||||
@ -192,61 +216,111 @@ static int put_ooch (stix_t* stix, stix_ooch_t ch)
|
||||
stix->log.capa = newcapa;
|
||||
}
|
||||
|
||||
stix->log.ptr[stix->log.len++] = ch;
|
||||
if (ch == '\n')
|
||||
while (len > 0)
|
||||
{
|
||||
stix->vmprim.log_write (stix, 0, stix->log.ptr, stix->log.len);
|
||||
/* TODO: error handling */
|
||||
stix->log.ptr[stix->log.len++] = ch;
|
||||
len--;
|
||||
}
|
||||
|
||||
stix->log.last_mask = mask;
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
static int put_oocs (stix_t* stix, unsigned int mask, const stix_ooch_t* ptr, stix_oow_t len)
|
||||
{
|
||||
if (len <= 0) return 1;
|
||||
|
||||
if (stix->log.len > 0 && stix->log.last_mask != mask)
|
||||
{
|
||||
/* the mask has changed. commit the buffered text */
|
||||
stix->vmprim.log_write (stix, stix->log.last_mask, stix->log.ptr, stix->log.len);
|
||||
stix->log.len = 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
if (len > stix->log.capa - stix->log.len)
|
||||
{
|
||||
stix_oow_t newcapa;
|
||||
stix_ooch_t* tmp;
|
||||
|
||||
if (len > STIX_TYPE_MAX(stix_oow_t) - stix->log.len)
|
||||
{
|
||||
/* data too big */
|
||||
stix->errnum = STIX_ETOOBIG;
|
||||
return -1;
|
||||
}
|
||||
|
||||
newcapa = STIX_ALIGN(stix->log.len + len, 512); /* TODO: adjust this capacity */
|
||||
tmp = stix_reallocmem (stix, stix->log.ptr, newcapa * STIX_SIZEOF(*tmp));
|
||||
if (!tmp) return -1;
|
||||
|
||||
stix->log.ptr = tmp;
|
||||
stix->log.capa = newcapa;
|
||||
}
|
||||
|
||||
STIX_MEMCPY (&stix->log.ptr[stix->log.len], ptr, len * STIX_SIZEOF(*ptr));
|
||||
stix->log.len += len;
|
||||
|
||||
stix->log.last_mask = mask;
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
#undef fmtchar_t
|
||||
#undef fmtoutv
|
||||
#undef logfmtv
|
||||
#define fmtchar_t stix_bch_t
|
||||
#define fmtoutv stix_bfmtoutv
|
||||
#include "fmtoutv.h"
|
||||
#define FMTCHAR_IS_BCH
|
||||
#define logfmtv stix_logbfmtv
|
||||
#include "logfmtv.h"
|
||||
|
||||
#undef fmtchar_t
|
||||
#undef fmtoutv
|
||||
#undef logfmtv
|
||||
#define fmtchar_t stix_ooch_t
|
||||
#define fmtoutv stix_oofmtoutv
|
||||
#include "fmtoutv.h"
|
||||
#define logfmtv stix_logoofmtv
|
||||
#define FMTCHAR_IS_OOCH
|
||||
#include "logfmtv.h"
|
||||
|
||||
stix_ooi_t stix_bfmtout (stix_t* stix, const stix_bch_t* fmt, ...)
|
||||
stix_ooi_t stix_logbfmt (stix_t* stix, unsigned int mask, const stix_bch_t* fmt, ...)
|
||||
{
|
||||
stix_ooi_t x;
|
||||
int x;
|
||||
va_list ap;
|
||||
stix_fmtout_t fo;
|
||||
|
||||
fo.count = 0;
|
||||
fo.limit = STIX_TYPE_MAX(stix_ooi_t);
|
||||
fo.put = put_ooch;
|
||||
fo.mask = mask;
|
||||
fo.putch = put_ooch;
|
||||
fo.putcs = put_oocs;
|
||||
|
||||
va_start (ap, fmt);
|
||||
x = stix_bfmtoutv (stix, fmt, &fo, ap);
|
||||
x = stix_logbfmtv (stix, fmt, &fo, ap);
|
||||
va_end (ap);
|
||||
|
||||
if (stix->log.len > 0 && stix->log.ptr[stix->log.len - 1] == '\n')
|
||||
{
|
||||
stix->vmprim.log_write (stix, stix->log.last_mask, stix->log.ptr, stix->log.len);
|
||||
stix->log.len = 0;
|
||||
}
|
||||
return (x <= -1)? -1: fo.count;
|
||||
}
|
||||
|
||||
stix_ooi_t stix_oofmtout (stix_t* stix, const stix_ooch_t* fmt, ...)
|
||||
stix_ooi_t stix_logoofmt (stix_t* stix, unsigned int mask, const stix_ooch_t* fmt, ...)
|
||||
{
|
||||
stix_ooi_t x;
|
||||
int x;
|
||||
va_list ap;
|
||||
stix_fmtout_t fo;
|
||||
|
||||
fo.count = 0;
|
||||
fo.limit = STIX_TYPE_MAX(stix_ooi_t);
|
||||
fo.put = put_ooch;
|
||||
fo.mask = mask;
|
||||
fo.putch = put_ooch;
|
||||
fo.putcs = put_oocs;
|
||||
|
||||
va_start (ap, fmt);
|
||||
x = stix_oofmtoutv (stix, fmt, &fo, ap);
|
||||
x = stix_logoofmtv (stix, fmt, &fo, ap);
|
||||
va_end (ap);
|
||||
|
||||
if (stix->log.len > 0 && stix->log.ptr[stix->log.len - 1] == '\n')
|
||||
{
|
||||
stix->vmprim.log_write (stix, stix->log.last_mask, stix->log.ptr, stix->log.len);
|
||||
stix->log.len = 0;
|
||||
}
|
||||
|
||||
return (x <= -1)? -1: fo.count;
|
||||
}
|
@ -68,19 +68,29 @@
|
||||
/* NOTE: data output is aborted if the data limit is reached or
|
||||
* I/O error occurs */
|
||||
|
||||
#undef PUT_CHAR
|
||||
#undef PUT_OOCH
|
||||
#undef PUT_OOCS
|
||||
|
||||
#define PUT_CHAR(stix,c) do { \
|
||||
#define PUT_OOCH(c,n) do { \
|
||||
int xx; \
|
||||
if (data->count >= data->limit) goto done; \
|
||||
if ((xx = data->put (stix, c)) <= -1) goto oops; \
|
||||
if ((xx = data->putch (stix, data->mask, c, n)) <= -1) goto oops; \
|
||||
if (xx == 0) goto done; \
|
||||
data->count++; \
|
||||
data->count += n; \
|
||||
} while (0)
|
||||
|
||||
int fmtoutv (stix_t* stix, const fmtchar_t* fmt, stix_fmtout_t* data, va_list ap)
|
||||
#define PUT_OOCS(ptr,len) do { \
|
||||
int xx; \
|
||||
if ((xx = data->putcs (stix, data->mask, ptr, len)) <= -1) goto oops; \
|
||||
if (xx == 0) goto done; \
|
||||
data->count += len; \
|
||||
} while (0)
|
||||
|
||||
int logfmtv (stix_t* stix, const fmtchar_t* fmt, stix_fmtout_t* data, va_list ap)
|
||||
{
|
||||
const fmtchar_t* percent;
|
||||
#if defined(FMTCHAR_IS_OOCH)
|
||||
const fmtchar_t* checkpoint;
|
||||
#endif
|
||||
stix_bch_t nbuf[MAXNBUF], bch;
|
||||
const stix_bch_t* nbufp;
|
||||
int n, base, neg, sign;
|
||||
@ -111,11 +121,24 @@ int fmtoutv (stix_t* stix, const fmtchar_t* fmt, stix_fmtout_t* data, va_list ap
|
||||
|
||||
while (1)
|
||||
{
|
||||
#if defined(FMTCHAR_IS_OOCH)
|
||||
checkpoint = fmt;
|
||||
while ((ch = *fmt++) != '%' || stop)
|
||||
{
|
||||
if (ch == '\0')
|
||||
{
|
||||
PUT_OOCS (checkpoint, fmt - checkpoint - 1);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
PUT_OOCS (checkpoint, fmt - checkpoint - 1);
|
||||
#else
|
||||
while ((ch = *fmt++) != '%' || stop)
|
||||
{
|
||||
if (ch == '\0') goto done;
|
||||
PUT_CHAR (stix, ch);
|
||||
PUT_OOCH (ch, 1);
|
||||
}
|
||||
#endif
|
||||
percent = fmt - 1;
|
||||
|
||||
padc = ' ';
|
||||
@ -363,15 +386,9 @@ reswitch:
|
||||
print_lowercase_c:
|
||||
/* precision 0 doesn't kill the letter */
|
||||
width--;
|
||||
if (!(flagc & FLAGC_LEFTADJ) && width > 0)
|
||||
{
|
||||
while (width--) PUT_CHAR (stix, padc);
|
||||
}
|
||||
PUT_CHAR (stix, bch);
|
||||
if ((flagc & FLAGC_LEFTADJ) && width > 0)
|
||||
{
|
||||
while (width--) PUT_CHAR (stix, padc);
|
||||
}
|
||||
if (!(flagc & FLAGC_LEFTADJ) && width > 0) PUT_OOCH (padc, width);
|
||||
PUT_OOCH (bch, 1);
|
||||
if ((flagc & FLAGC_LEFTADJ) && width > 0) PUT_OOCH (padc, width);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -387,17 +404,9 @@ reswitch:
|
||||
|
||||
/* precision 0 doesn't kill the letter */
|
||||
width--;
|
||||
if (!(flagc & FLAGC_LEFTADJ) && width > 0)
|
||||
{
|
||||
while (width--) PUT_CHAR (stix, padc);
|
||||
}
|
||||
|
||||
PUT_CHAR (stix, ooch);
|
||||
|
||||
if ((flagc & FLAGC_LEFTADJ) && width > 0)
|
||||
{
|
||||
while (width--) PUT_CHAR (stix, padc);
|
||||
}
|
||||
if (!(flagc & FLAGC_LEFTADJ) && width > 0) PUT_OOCH (padc, width);
|
||||
PUT_OOCH (ooch, 1);
|
||||
if ((flagc & FLAGC_LEFTADJ) && width > 0) PUT_OOCH (padc, width);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -408,7 +417,7 @@ reswitch:
|
||||
|
||||
/* zeropad must not take effect for 'S' */
|
||||
if (flagc & FLAGC_ZEROPAD) padc = ' ';
|
||||
if (lm_flag & LF_H) goto lowercase_s;
|
||||
if (lm_flag & LF_L) goto uppercase_s;
|
||||
lowercase_s:
|
||||
|
||||
bsp = va_arg (ap, stix_bch_t*);
|
||||
@ -429,14 +438,11 @@ reswitch:
|
||||
if ((flagc & FLAGC_DOT) && precision < slen) n = precision;
|
||||
width -= n;
|
||||
|
||||
if (!(flagc & FLAGC_LEFTADJ) && width > 0)
|
||||
{
|
||||
while (width--) PUT_CHAR (stix, padc);
|
||||
}
|
||||
if (!(flagc & FLAGC_LEFTADJ) && width > 0) PUT_OOCH (padc, width);
|
||||
|
||||
{
|
||||
stix_ooch_t conv_buf[32];
|
||||
stix_oow_t i, conv_len, src_len, tot_len = 0;
|
||||
stix_oow_t conv_len, src_len, tot_len = 0;
|
||||
while (n > 0)
|
||||
{
|
||||
STIX_ASSERT (bslen > tot_len);
|
||||
@ -449,19 +455,13 @@ reswitch:
|
||||
tot_len += src_len;
|
||||
|
||||
if (conv_len > n) conv_len = n;
|
||||
for (i = 0; i < conv_len; i++)
|
||||
{
|
||||
PUT_CHAR (stix, conv_buf[i]);
|
||||
}
|
||||
PUT_OOCS (conv_buf, conv_len);
|
||||
|
||||
n -= conv_len;
|
||||
}
|
||||
}
|
||||
|
||||
if ((flagc & FLAGC_LEFTADJ) && width > 0)
|
||||
{
|
||||
while (width--) PUT_CHAR (stix, padc);
|
||||
}
|
||||
if ((flagc & FLAGC_LEFTADJ) && width > 0) PUT_OOCH (padc, width);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -471,7 +471,7 @@ reswitch:
|
||||
|
||||
/* zeropad must not take effect for 's' */
|
||||
if (flagc & FLAGC_ZEROPAD) padc = ' ';
|
||||
if (lm_flag & LF_L) goto uppercase_s;
|
||||
if (lm_flag & LF_H) goto lowercase_s;
|
||||
uppercase_s:
|
||||
sp = va_arg (ap, stix_ooch_t*);
|
||||
if (sp == STIX_NULL) sp = ooch_nullstr;
|
||||
@ -487,20 +487,14 @@ reswitch:
|
||||
|
||||
width -= n;
|
||||
|
||||
if (!(flagc & FLAGC_LEFTADJ) && width > 0)
|
||||
{
|
||||
while (width--) PUT_CHAR (stix, padc);
|
||||
}
|
||||
while (n--) PUT_CHAR (stix, *sp++);
|
||||
if ((flagc & FLAGC_LEFTADJ) && width > 0)
|
||||
{
|
||||
while (width--) PUT_CHAR (stix, padc);
|
||||
}
|
||||
if (!(flagc & FLAGC_LEFTADJ) && width > 0) PUT_OOCH (padc, width);
|
||||
PUT_OOCS (sp, n);
|
||||
if ((flagc & FLAGC_LEFTADJ) && width > 0) PUT_OOCH (padc, width);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'O': /* object - ignore precision, width, adjustment */
|
||||
print_object (stix, va_arg (ap, stix_oop_t));
|
||||
print_object (stix, data->mask, va_arg (ap, stix_oop_t));
|
||||
break;
|
||||
|
||||
#if 0
|
||||
@ -825,61 +819,66 @@ number:
|
||||
numlen = nbufp - nbuf;
|
||||
if ((flagc & FLAGC_DOT) && precision > numlen)
|
||||
{
|
||||
/* extra zeros fro precision specified */
|
||||
/* extra zeros for precision specified */
|
||||
tmp += (precision - numlen);
|
||||
}
|
||||
|
||||
if (!(flagc & FLAGC_LEFTADJ) && !(flagc & FLAGC_ZEROPAD) && width > 0 && (width -= tmp) > 0)
|
||||
{
|
||||
while (width--) PUT_CHAR (stix, padc);
|
||||
PUT_OOCH (padc, width);
|
||||
width = 0;
|
||||
}
|
||||
|
||||
if (neg) PUT_CHAR (stix, '-');
|
||||
else if (flagc & FLAGC_SIGN) PUT_CHAR (stix, '+');
|
||||
else if (flagc & FLAGC_SPACE) PUT_CHAR (stix, ' ');
|
||||
if (neg) PUT_OOCH ('-', 1);
|
||||
else if (flagc & FLAGC_SIGN) PUT_OOCH ('+', 1);
|
||||
else if (flagc & FLAGC_SPACE) PUT_OOCH (' ', 1);
|
||||
|
||||
if ((flagc & FLAGC_SHARP) && num != 0)
|
||||
{
|
||||
if (base == 8)
|
||||
{
|
||||
PUT_CHAR (stix, '0');
|
||||
PUT_OOCH ('0', 1);
|
||||
}
|
||||
else if (base == 16)
|
||||
{
|
||||
PUT_CHAR (stix, '0');
|
||||
PUT_CHAR (stix, 'x');
|
||||
PUT_OOCH ('0', 1);
|
||||
PUT_OOCH ('x', 1);
|
||||
}
|
||||
}
|
||||
|
||||
if ((flagc & FLAGC_DOT) && precision > numlen)
|
||||
{
|
||||
/* extra zeros for precision specified */
|
||||
while (numlen < precision)
|
||||
{
|
||||
PUT_CHAR (stix, '0');
|
||||
numlen++;
|
||||
}
|
||||
PUT_OOCH ('0', precision - numlen);
|
||||
}
|
||||
|
||||
if (!(flagc & FLAGC_LEFTADJ) && width > 0 && (width -= tmp) > 0)
|
||||
{
|
||||
while (width-- > 0) PUT_CHAR (stix, padc);
|
||||
PUT_OOCH (padc, width);
|
||||
}
|
||||
|
||||
while (*nbufp) PUT_CHAR (stix, *nbufp--); /* output actual digits */
|
||||
while (*nbufp) PUT_OOCH (*nbufp--, 1); /* output actual digits */
|
||||
|
||||
if ((flagc & FLAGC_LEFTADJ) && width > 0 && (width -= tmp) > 0)
|
||||
{
|
||||
while (width-- > 0) PUT_CHAR (stix, padc);
|
||||
PUT_OOCH (padc, width);
|
||||
}
|
||||
break;
|
||||
|
||||
invalid_format:
|
||||
while (percent < fmt) PUT_CHAR (stix, *percent++);
|
||||
#if defined(FMTCHAR_IS_OOCH)
|
||||
PUT_OOCS (percent, fmt - percent);
|
||||
#else
|
||||
while (percent < fmt) PUT_OOCH (*percent++, 1);
|
||||
#endif
|
||||
break;
|
||||
|
||||
default:
|
||||
while (percent < fmt) PUT_CHAR (stix, *percent++);
|
||||
#if defined(FMTCHAR_IS_OOCH)
|
||||
PUT_OOCS (percent, fmt - percent);
|
||||
#else
|
||||
while (percent < fmt) PUT_OOCH (*percent++, 1);
|
||||
#endif
|
||||
/*
|
||||
* Since we ignore an formatting argument it is no
|
||||
* longer safe to obey the remaining formatting
|
||||
@ -895,6 +894,6 @@ done:
|
||||
return 0;
|
||||
|
||||
oops:
|
||||
return (stix_ooi_t)-1;
|
||||
return -1;
|
||||
}
|
||||
#undef PUT_CHAR
|
||||
#undef PUT_OOCH
|
@ -330,7 +330,7 @@ printf ("MOD_GETSYM [%s]\n", &buf[0]);
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
static void log_write (stix_t* stix, int mask, const stix_ooch_t* msg, stix_oow_t len)
|
||||
static void log_write (stix_t* stix, unsigned int mask, const stix_ooch_t* msg, stix_oow_t len)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
# error NOT IMPLEMENTED
|
||||
|
@ -48,8 +48,6 @@
|
||||
/*#define STIX_DEBUG_PROCESSOR*/
|
||||
/*#define STIX_DEBUG_GC_001*/
|
||||
/*#define STIX_DEBUG_GC_002*/
|
||||
#define STIX_DEBUG_COMP_001
|
||||
/*#define STIX_DEBUG_COMP_002*/
|
||||
/*#define STIX_DEBUG_EXEC_001*/
|
||||
/*#define STIX_DEBUG_EXEC_002*/
|
||||
#define STIX_PROFILE_EXEC
|
||||
@ -1306,7 +1304,7 @@ stix_oop_t stix_inttostr (
|
||||
/* comp.c */
|
||||
/* ========================================================================= */
|
||||
STIX_EXPORT int stix_compile (
|
||||
stix_t* stix,
|
||||
stix_t* stix,
|
||||
stix_ioimpl_t io
|
||||
);
|
||||
|
||||
@ -1323,21 +1321,6 @@ int stix_getprimno (
|
||||
const stix_oocs_t* name
|
||||
);
|
||||
|
||||
/* ========================================================================= */
|
||||
/* fmt.c */
|
||||
/* ========================================================================= */
|
||||
stix_ooi_t stix_bfmtout (
|
||||
stix_t* stix,
|
||||
const stix_bch_t* fmt,
|
||||
...
|
||||
);
|
||||
|
||||
|
||||
stix_ooi_t stix_oofmtout (
|
||||
stix_t* stix,
|
||||
const stix_ooch_t* fmt,
|
||||
...
|
||||
);
|
||||
/* TODO: remove debugging functions */
|
||||
/* ========================================================================= */
|
||||
/* debug.c */
|
||||
@ -1345,8 +1328,7 @@ stix_ooi_t stix_oofmtout (
|
||||
void dump_symbol_table (stix_t* stix);
|
||||
void dump_dictionary (stix_t* stix, stix_oop_set_t dic, const char* title);
|
||||
void print_oocs (const stix_oocs_t* name);
|
||||
void print_object (stix_t* stix, stix_oop_t oop);
|
||||
void dump_object (stix_t* stix, stix_oop_t oop, const char* title);
|
||||
void print_object (stix_t* stix, unsigned int mask, stix_oop_t oop);
|
||||
|
||||
|
||||
|
||||
|
@ -89,6 +89,7 @@ int stix_init (stix_t* stix, stix_mmgr_t* mmgr, stix_oow_t heapsz, const stix_vm
|
||||
stix->mmgr = mmgr;
|
||||
stix->vmprim = *vmprim;
|
||||
|
||||
stix->option.log_mask = ~0u;
|
||||
stix->option.dfl_symtab_size = STIX_DFL_SYMTAB_SIZE;
|
||||
stix->option.dfl_sysdic_size = STIX_DFL_SYSDIC_SIZE;
|
||||
stix->option.dfl_procstk_size = STIX_DFL_PROCSTK_SIZE;
|
||||
@ -195,7 +196,11 @@ int stix_setoption (stix_t* stix, stix_option_t id, const void* value)
|
||||
switch (id)
|
||||
{
|
||||
case STIX_TRAIT:
|
||||
stix->option.trait = *(const int*)value;
|
||||
stix->option.trait = *(const unsigned int*)value;
|
||||
return 0;
|
||||
|
||||
case STIX_LOG_MASK:
|
||||
stix->option.log_mask = *(const unsigned int*)value;
|
||||
return 0;
|
||||
|
||||
case STIX_SYMTAB_SIZE:
|
||||
@ -242,7 +247,11 @@ int stix_getoption (stix_t* stix, stix_option_t id, void* value)
|
||||
switch (id)
|
||||
{
|
||||
case STIX_TRAIT:
|
||||
*(int*)value = stix->option.trait;
|
||||
*(unsigned int*)value = stix->option.trait;
|
||||
return 0;
|
||||
|
||||
case STIX_LOG_MASK:
|
||||
*(unsigned int*)value = stix->option.log_mask;
|
||||
return 0;
|
||||
|
||||
case STIX_SYMTAB_SIZE:
|
||||
|
@ -55,6 +55,7 @@ enum stix_errnum_t
|
||||
STIX_ESYSMEM, /**< insufficient system memory */
|
||||
STIX_EOOMEM, /**< insufficient object memory */
|
||||
STIX_EINVAL, /**< invalid parameter or data */
|
||||
STIX_ETOOBIG, /**< data too large */
|
||||
STIX_EMSGSND, /**< message sending error. even doesNotUnderstand: is not found */
|
||||
STIX_ERANGE, /**< range error. overflow and underflow */
|
||||
STIX_ENOENT, /**< no matching entry */
|
||||
@ -75,6 +76,7 @@ typedef enum stix_errnum_t stix_errnum_t;
|
||||
enum stix_option_t
|
||||
{
|
||||
STIX_TRAIT,
|
||||
STIX_LOG_MASK,
|
||||
STIX_SYMTAB_SIZE, /* default system table size */
|
||||
STIX_SYSDIC_SIZE, /* default system dictionary size */
|
||||
STIX_PROCSTK_SIZE /* default process stack size */
|
||||
@ -661,7 +663,7 @@ typedef void* (*stix_mod_open_t) (stix_t* stix, const stix_ooch_t* name);
|
||||
typedef void (*stix_mod_close_t) (stix_t* stix, void* handle);
|
||||
typedef void* (*stix_mod_getsym_t) (stix_t* stix, void* handle, const stix_ooch_t* name);
|
||||
|
||||
typedef void (*stix_log_write_t) (stix_t* stix, int mask, const stix_ooch_t* msg, stix_oow_t len);
|
||||
typedef void (*stix_log_write_t) (stix_t* stix, unsigned int mask, const stix_ooch_t* msg, stix_oow_t len);
|
||||
|
||||
struct stix_vmprim_t
|
||||
{
|
||||
@ -748,7 +750,8 @@ struct stix_t
|
||||
|
||||
struct
|
||||
{
|
||||
int trait;
|
||||
unsigned int trait;
|
||||
unsigned int log_mask;
|
||||
stix_oow_t dfl_symtab_size;
|
||||
stix_oow_t dfl_sysdic_size;
|
||||
stix_oow_t dfl_procstk_size;
|
||||
@ -764,6 +767,7 @@ struct stix_t
|
||||
stix_ooch_t* ptr;
|
||||
stix_oow_t len;
|
||||
stix_oow_t capa;
|
||||
int last_mask;
|
||||
} log;
|
||||
|
||||
/* ========================= */
|
||||
@ -883,6 +887,28 @@ struct stix_t
|
||||
#define STIX_STACK_POPS(stix,count) ((stix)->sp = (stix)->sp - (count))
|
||||
#define STIX_STACK_ISEMPTY(stix) ((stix)->sp <= -1)
|
||||
|
||||
|
||||
/* =========================================================================
|
||||
* STIX VM LOGGING
|
||||
* ========================================================================= */
|
||||
|
||||
enum stix_log_mask_t
|
||||
{
|
||||
/* for general messages */
|
||||
STIX_LOG_DEBUG = (1 << 0),
|
||||
STIX_LOG_INFO = (1 << 1),
|
||||
STIX_LOG_ERROR = (1 << 2),
|
||||
|
||||
/* for special messages */
|
||||
STIX_LOG_COMPILER = (1 << 8),
|
||||
STIX_LOG_EXECUTOR = (1 << 9),
|
||||
STIX_LOG_DECODER = (1 << 10)
|
||||
};
|
||||
typedef enum stix_log_mask_t stix_log_mask_t;
|
||||
|
||||
#define STIX_LOG_ENABLED(stix,mask) ((stix)->option.log_mask & mask)
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -1042,7 +1068,8 @@ STIX_EXPORT void stix_poptmps (
|
||||
|
||||
STIX_EXPORT int stix_decode (
|
||||
stix_t* stix,
|
||||
stix_oop_method_t mth
|
||||
const stix_oocs_t* classfqn,
|
||||
stix_oop_method_t mth
|
||||
);
|
||||
|
||||
/* Memory allocation/deallocation functions using stix's MMGR */
|
||||
@ -1068,6 +1095,21 @@ STIX_EXPORT void stix_freemem (
|
||||
void* ptr
|
||||
);
|
||||
|
||||
|
||||
STIX_EXPORT stix_ooi_t stix_logbfmt (
|
||||
stix_t* stix,
|
||||
unsigned int mask,
|
||||
const stix_bch_t* fmt,
|
||||
...
|
||||
);
|
||||
|
||||
STIX_EXPORT stix_ooi_t stix_logoofmt (
|
||||
stix_t* stix,
|
||||
unsigned int mask,
|
||||
const stix_ooch_t* fmt,
|
||||
...
|
||||
);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user