src/functiontable.c
// Add a variable to a function's parameter list
Add a variable to a function's parameter list
Add a variable to a function ' s parameter list
void AddParameter(function_table* table, char* fname, identifier_type type)
{
	int i;
	function* f = LookupFunction(table, fname);
	if (f == NULL)
		return;
	if (f->numParams >= f->maxParams)
	{
		f->maxParams *= 2;
		identifier_type* tmp = (identifier_type*) malloc(sizeof(identifier_type) * f->maxParams);
		for (i = 0; i < f->numParams; i++)
			tmp[i] = f->params[i];
		free(f->params);
		f->params = tmp;
	}
	switch (type)
	{
		case IT_BYTE:
		case IT_BOOL:
		case IT_WORD:
			f->paramSize += 2;
			break;
		case IT_BYTEP:
		case IT_WORDP:
			f->paramSize += 4;
			break;
		default:
			printf("error - invalid parameter\n");
	}
	f->params[f->numParams++] = type;
}
void AddParameter ( function_table * table , char * fname , identifier_type type ) { int i ; function * f = LookupFunction ( table , fname ) ; if ( f == NULL ) return ; if ( f -> numParams >= f -> maxParams ) { f -> maxParams *= 2 ; identifier_type * tmp = ( identifier_type * ) malloc ( sizeof ( identifier_type ) * f -> maxParams ) ; for ( i = 0 ; i < f -> numParams ; i ++ ) tmp [ i ] = f -> params [ i ] ; free ( f -> params ) ; f -> params = tmp ; } switch ( type ) { case IT_BYTE : case IT_BOOL : case IT_WORD : f -> paramSize += 2 ; break ; case IT_BYTEP : case IT_WORDP : f -> paramSize += 4 ; break ; default : printf ( " \n " ) ; } f -> params [ f -> numParams ++ ] = type ; }
Add a variable to a function's parameter list
Add a variable to a function ' s parameter list
// Expand array // Update parameter stack size