1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2025-08-09 16:25:01 +00:00

Synchronize C PLASM compiler with PLASMA PLASM compiler

This commit is contained in:
David Schmenk
2014-11-19 22:24:05 -08:00
parent 766c856eed
commit f94755aaa4
3 changed files with 270 additions and 235 deletions

2
src/FIRE.PLA#040000 Executable file
View File

@@ -0,0 +1,2 @@
CONST FALSE = 0
CONST TRUE = NOT FALSE

View File

@@ -355,8 +355,8 @@ int parse_value(int rvalue)
} }
else else
(type & BPTR_TYPE) ? emit_lb() : emit_lw(); (type & BPTR_TYPE) ? emit_lb() : emit_lw();
emit_value = 1;
} }
emit_value = 1;
type &= ~(VAR_TYPE | ADDR_TYPE); type &= ~(VAR_TYPE | ADDR_TYPE);
type |= WORD_TYPE; type |= WORD_TYPE;
scantoken = scantoken == PTRB_TOKEN ? DOT_TOKEN : COLON_TOKEN; scantoken = scantoken == PTRB_TOKEN ? DOT_TOKEN : COLON_TOKEN;
@@ -387,6 +387,7 @@ int parse_value(int rvalue)
else // FUNC_TYPE else // FUNC_TYPE
{ {
emit_globaladdr(value, elem_offset, type); emit_globaladdr(value, elem_offset, type);
elem_offset = 0;
emit_value = 1; emit_value = 1;
} }
} }
@@ -416,9 +417,10 @@ int parse_value(int rvalue)
} }
else if (type & CONST_TYPE) else if (type & CONST_TYPE)
{ {
emit_const(value); emit_const(value + elem_offset);
} }
emit_value = 1; elem_offset = 0;
emit_value = 1;
} }
while (parse_expr()) while (parse_expr())
{ {
@@ -442,7 +444,7 @@ int parse_value(int rvalue)
parse_error("Invalid member offset"); parse_error("Invalid member offset");
return (0); return (0);
} }
type = elem_type; //(type & ~(ADDR_TYPE | CONST_TYPE)) | elem_type; type = elem_type;
break; break;
case OPEN_PAREN_TOKEN: case OPEN_PAREN_TOKEN:
/* /*
@@ -867,10 +869,16 @@ int parse_stmnt(void)
int i; int i;
for (i = 0; i < stack_loop; i++) for (i = 0; i < stack_loop; i++)
emit_drop(); emit_drop();
if (!parse_expr())
emit_const(0);
emit_leave();
}
else
{
if (!parse_expr())
emit_const(0);
emit_ret();
} }
if (!parse_expr())
emit_const(0);
emit_ret();
break; break;
case EOL_TOKEN: case EOL_TOKEN:
case COMMENT_TOKEN: case COMMENT_TOKEN:

File diff suppressed because it is too large Load Diff