summaryrefslogtreecommitdiff
path: root/ecomp-c/ec.c
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-c/ec.c')
-rw-r--r--ecomp-c/ec.c52
1 files changed, 19 insertions, 33 deletions
diff --git a/ecomp-c/ec.c b/ecomp-c/ec.c
index 8a2fd4a..2e5b288 100644
--- a/ecomp-c/ec.c
+++ b/ecomp-c/ec.c
@@ -1592,43 +1592,22 @@ static void parseWhileStatement( Scope *scope )
static void parseParameterList( Scope *scope, ExpressionNodeList *list )
{
ExpressionNode *node;
-/*
-function insertBeginning(List list, Node newNode)
- if list.firstNode == null
- list.firstNode := newNode
- list.lastNode := newNode
- newNode.prev := null
- newNode.next := null
- else
- newNode.next := list.firstNode
- if list.firstNode.prev == null
- newNode.prev := null -- (not always necessary)
- list.firstNode := newNode
- else
- newNode.prev := list.firstNode.prev
- list.firstNode.prev.next := newNode
- list.firstNode.prev := newNode
-
-*/
Expect( S_lparen );
list->head = NULL;
list->tail = NULL;
do {
node = parseExpression( scope );
- if( list->head == NULL && list->tail == NULL ) {
- list->head = node;
+
+ if( list->head == NULL ) {
list->tail = node;
} else {
- node->next = list->head;
- if( list->head->prev == NULL ) {
- list->head = node;
- } else {
- node->prev = list->head->prev;
- list->head->prev->next = node;
- }
list->head->prev = node;
- }
+ }
+
+ node->next = list->head;
+ list->head = node;
+
if( sym == S_comma ) {
sym = getSym( );
}
@@ -1671,14 +1650,14 @@ static void parseProcedureCall( Scope *scope )
/* check types */
if( nof_expected_params > 0 ) {
- node = list.tail;
+ node = list.head;
param = symbol->param;
while( param != NULL ) {
if( !is_compatible_type( node->actual_type, param->type ) ) {
Abort( "Incompatible parameter type for parameter '%s' in procedure '%s', expecting type '%s', got '%s'",
param->name, symbol->name, param->type->name, node->actual_type->name );
}
- node = node->prev;
+ node = node->next;
param = param->next;
}
}
@@ -2217,7 +2196,7 @@ static void parseProcedureDeclaration( Scope *scope )
size_params = 0;
} else if( sym == S_lparen ) {
- Symbol *param, *copy, *defparam;
+ Symbol *param, *defparam;
int offset;
parseParameterDeclarationList( symbol->scope );
@@ -2272,13 +2251,20 @@ static void parseProcedureDeclaration( Scope *scope )
* of the definition of the procedure and not the one of the forward
* declaration */
if( symbol->param == NULL ) {
+ Symbol *copy, *last = NULL;
param = symbol->scope->symbol;
while( param != NULL ) {
if( param->class == SYMBOL_CLASS_VARIABLE ) {
copy = copy_symbol( param );
+ copy->next = NULL;
copy->scope = NULL;
- copy->next = symbol->param;
- symbol->param = copy;
+ if( last == NULL ) {
+ symbol->param = copy;
+ last = symbol->param;
+ } else {
+ last->next = copy;
+ last = copy;
+ }
}
param = param->next;
}