...
 
Commits (2)
This diff is collapsed.
......@@ -413,6 +413,7 @@ void CLASS_add_property(CLASS *class, TRANS_PROPERTY *decl)
prop->name = decl->index;
prop->line = decl->line;
prop->comment = decl->comment;
prop->use = decl->use;
for (i = 0; i < decl->nsynonymous; i++)
{
......@@ -884,13 +885,58 @@ static int check_one_property_func(CLASS *class, PROPERTY *prop, bool write)
int index;
JOB->line = prop->line;
JOB->current = NULL;
is_static = TYPE_is_static(prop->type);
name = STR_copy(TABLE_get_symbol_name_suffix(class->table, prop->name, write ? "_Write" : "_Read"));
if (!TABLE_find_symbol(class->table, name, strlen(name), &index))
THROW("&1 is not declared", name);
{
TRANS_FUNC decl;
if (prop->use == 0)
THROW("&1 is not declared", name);
CLEAR(&decl);
decl.index = index = CLASS_add_symbol(class, name);
if (write)
{
decl.nparam = 1;
decl.param[0].type = prop->type;
decl.param[0].index = NO_SYMBOL;
}
else
{
decl.type = prop->type;
TYPE_clear_flag(&decl.type, TF_PUBLIC);
}
decl.line = prop->line;
TYPE_set_kind(&decl.type, TK_FUNCTION);
CLASS_add_function(JOB->class, &decl);
JOB->nobreak = TRUE;
sym = CLASS_get_symbol(JOB->class, prop->use);
if (write)
{
sym->global_assigned = TRUE;
CODE_push_local(-1);
CODE_pop_global(sym->global.value, is_static);
CODE_return(2);
}
else
{
sym->global_used = TRUE;
CODE_push_global(sym->global.value, is_static, FALSE);
CODE_return(1);
}
FUNCTION_add_last_pos_line();
JOB->func->stack = CODE_stack_usage;
}
sym = (CLASS_SYMBOL *)TABLE_get_symbol(class->table, index);
......
......@@ -157,6 +157,7 @@ typedef
int line; // The line where the property is declared
int comment; // Property string description, added to datatype
int synonymous; // Synonymous property index (-1 if not a synonymous)
int use; // Associated global private variable
short read; // Read function
short write; // Write function
}
......
......@@ -668,7 +668,8 @@ void COMPILE_print(int type, int line, const char *msg, ...)
else if (JOB->step == JOB_STEP_CODE)
{
line = JOB->line;
col = COMPILE_get_column(JOB->current);
if (JOB->current)
col = COMPILE_get_column(JOB->current);
}
}
......
......@@ -340,7 +340,7 @@ static bool header_property(TRANS_PROPERTY *prop)
/* property name */
if (!PATTERN_is_identifier(*JOB->current))
THROW("Syntax error. Invalid identifier in property name");
THROW("Syntax error. Identifier expected for property name");
prop->index = PATTERN_index(*JOB->current);
JOB->current++;
......@@ -352,13 +352,13 @@ static bool header_property(TRANS_PROPERTY *prop)
if (prop->nsynonymous == 3)
THROW("Too many property synonymous");
if (!PATTERN_is_identifier(*JOB->current))
THROW("Syntax error. Invalid identifier in property name");
THROW("Syntax error. Identifier expected for property synonymous");
prop->synonymous[prop->nsynonymous++] = PATTERN_index(*JOB->current);
JOB->current++;
}
if (!TRANS_type(TT_NOTHING, &ptype))
THROW("Syntax error. Bad property type");
THROW("Syntax error. Invalid property type");
prop->type = ptype.type;
prop->line = JOB->line;
......@@ -368,6 +368,24 @@ static bool header_property(TRANS_PROPERTY *prop)
TYPE_set_flag(&prop->type, TF_STATIC);
TYPE_set_flag(&prop->type, TF_PUBLIC);
if (TRANS_is(RS_USE))
{
TRANS_DECL decl = ptype;
TYPE_set_kind(&decl.type, TK_VARIABLE);
if (is_static)
TYPE_set_flag(&decl.type, TF_STATIC);
if (!PATTERN_is_identifier(*JOB->current))
THROW("Syntax error. Identifier expected for property variable");
prop->use = PATTERN_index(*JOB->current);
JOB->current++;
decl.index = prop->use;
CLASS_add_declaration(JOB->class, &decl);
}
if (PATTERN_is_string(*JOB->current))
{
prop->comment = PATTERN_index(*JOB->current);
......
......@@ -808,19 +808,14 @@ static void output_param_local(void)
if (func->name != NO_SYMBOL)
{
/* Les param�res sont remis dans les variables locales !
for (j = 0; j < func->nparam; j++)
{
param = &func->param[j];
write_int(param->type);
write_type(param->type);
}
*/
for (j = 0; j < func->nlocal + func->nparam; j++)
for (j = 0; j < func->nlocal; j++)
{
param = &func->local[j];
/* type */
param = &func->local[j + func->nparam];
write_type(param->type);
}
}
......
......@@ -46,7 +46,7 @@ static CLASS_SYMBOL *add_local(int sym_index, TYPE type, int value, bool used)
PARAM *loc;
bool warnings = JOB->warnings;
if (ARRAY_count(_func->local) >= MAX_LOCAL_SYMBOL)
if (value > MAX_LOCAL_SYMBOL)
THROW("Too many local variables");
loc = ARRAY_add(&_func->local);
......
......@@ -88,8 +88,9 @@ EXTERN char *TYPE_name[];
#define TYPE_set_value(type, _value) ((type)->t.value = (_value))
#define TYPE_set_id(type, _id) ((type)->t.id = (_id))
#define TYPE_set_kind(type, _kind) ((type)->t.flag |= (_kind))
#define TYPE_set_kind(type, _kind) ((type)->t.flag &= ~0x7, (type)->t.flag |= (_kind))
#define TYPE_set_flag(type, _flag) ((type)->t.flag |= (_flag))
#define TYPE_clear_flag(type, _flag) ((type)->t.flag &= ~(_flag))
#define TYPE_clear(type) ((type)->l = 0)
#define TYPE_can_be_long(type) (TYPE_get_id(type) <= T_LONG)
......
......@@ -121,9 +121,9 @@ typedef
int line;
int comment;
int synonymous[3];
bool read;
unsigned char nsynonymous;
bool _reserved[2];
int use;
unsigned nsynonymous:3;
unsigned read:1;
}
PACKED
TRANS_PROPERTY;
......