Alien-LibJIT
view release on metacpan or search on metacpan
libjit/dpas/dpas-parser.y view on Meta::CPAN
jit_type_get_tagged_type(type) == 0 &&
jit_type_get_tagged_kind($3) == DPAS_TAG_NAME)
{
/* This is a defintion of a record type that was
previously encountered in a forward pointer
reference of the form "^name". We need to
back-patch the previous type with the type info */
jit_type_set_tagged_type
(type, jit_type_get_tagged_type($3), 1);
}
else
{
dpas_redeclared($1, item);
}
jit_free($1);
jit_type_free($3);
}
;
VariableDeclarationPart
: /* empty */
| K_VAR VariableDeclarationList
;
VariableDeclarationList
: VariableDeclaration
| VariableDeclarationList VariableDeclaration
;
VariableDeclaration
: IdentifierList ':' Type ';' {
/* Add each of the variables to the current scope */
int posn;
dpas_scope_item_t item;
for(posn = 0; posn < $1.len; ++posn)
{
item = dpas_scope_lookup(dpas_scope_current(),
$1.list[posn], 0);
if(item)
{
dpas_redeclared($1.list[posn], item);
}
else
{
if(!dpas_scope_is_module())
{
jit_value_t value;
value = jit_value_create
(dpas_current_function(), $3);
if(!value)
{
dpas_out_of_memory();
}
dpas_scope_add(dpas_scope_current(),
$1.list[posn], $3,
DPAS_ITEM_VARIABLE, value, 0,
dpas_filename, dpas_linenum);
}
else
{
/* Allocate some memory to hold the global data */
void *space = jit_calloc(1, jit_type_get_size($3));
if(!space)
{
dpas_out_of_memory();
}
dpas_scope_add(dpas_scope_current(),
$1.list[posn], $3,
DPAS_ITEM_GLOBAL_VARIABLE, space, 0,
dpas_filename, dpas_linenum);
}
}
}
/* Free the id list and type, which we don't need any more */
identifier_list_free($1.list, $1.len);
jit_type_free($3);
}
;
ProcedureAndFunctionDeclarationPart
: /* empty */
| ProcedureOrFunctionList
;
ProcedureOrFunctionList
: ProcedureOrFunctionDeclaration ';'
| ProcedureOrFunctionList ProcedureOrFunctionDeclaration ';'
;
StatementPart
: K_BEGIN StatementSequence OptSemi K_END
| K_BEGIN OptSemi K_END
| K_END
| K_BEGIN error K_END
;
OptSemi
: /* empty */
| ';'
;
/*
* Procedure and function declarations.
*/
ProcedureOrFunctionDeclaration
: ProcedureOrFunctionHeading ';' {
unsigned int num_params;
unsigned int param;
jit_type_t type;
const char *name;
dpas_scope_item_t item;
jit_function_t func;
/* Declare the procedure/function into the current scope */
item = dpas_scope_lookup(dpas_scope_current(), $1.name, 0);
if(item)
{
dpas_redeclared($1.name, item);
item = 0;
( run in 0.443 second using v1.01-cache-2.11-cpan-f0fbb3f571b )