Example #1
0
struct memorycontainer* createArrayExpression(struct stack_t* arrayVals, struct memorycontainer* repetitionExpr) {
	int lenOfArray=getStackSize(arrayVals);
	struct memorycontainer* expressionContainer=NULL;
	int i;
	for (i=0;i<lenOfArray;i++) {
		if (expressionContainer == NULL) {
			expressionContainer=getExpressionAt(arrayVals, i);
		} else {
			expressionContainer=concatenateMemory(expressionContainer, getExpressionAt(arrayVals, i));
		}
	}

	struct memorycontainer* memoryContainer = (struct memorycontainer*) malloc(sizeof(struct memorycontainer));
	memoryContainer->length=sizeof(unsigned char)*2 + sizeof(int);
	memoryContainer->data=(char*) malloc(memoryContainer->length);
	memoryContainer->lineDefns=NULL;

	int location=appendStatement(memoryContainer, ARRAY_TOKEN, 0);
	memcpy(&memoryContainer->data[location], &lenOfArray, sizeof(int));
    location+=sizeof(int);
	unsigned char hasRepetitionExpr=repetitionExpr == NULL ? 0 : 1;
	memcpy(&memoryContainer->data[location], &hasRepetitionExpr, sizeof(unsigned char));
	if (repetitionExpr != NULL) memoryContainer=concatenateMemory(memoryContainer, repetitionExpr);
	return concatenateMemory(memoryContainer, expressionContainer);
}
Example #2
0
/* BEGIN HIDDEN */
int getRankOf(int size) {
	int rank;
	for (rank=0;rank<getStackSize();rank++)
		if (getPancakeRadius(rank) == size)
			return rank;
	return -99; // Well, be robust to border cases
}
Example #3
0
bool GLWorld::pickup(unsigned int count)
{
    if(!World::pickup(count))
        return false;

    unsigned int here = map[steve.first][steve.second].stack_size;
    bend_pos_y = static_cast<float>(getStackSize()) * 0.5 - 2.0;

    int diff = getStackSize() - here;

    //Play flying animation if the height difference is > 3 bricks
    if(diff > 3)
        setAnimation(ANIM_DEPOSIT_FLY);
    else
        setAnimation(ANIM_BEND);

    fbo_dirty = true;

    emit changed();

    return true;
}
Example #4
0
int blockLength() {
	int pos = 0;
	int radius = getPancakeRadius(pos);
	int o = getPancakeRadius(pos+1) - radius;

	if (o != -1 && o != 1) {
		printf("Asked to compute the block length, but the step o is %d instead of +1 or -1. The length is then 1, but you are violating a precondition somehow\n",o);
		return 1;
	}

	while (pos < getStackSize()-1 && getPancakeRadius(pos+1) == radius + o) {
		pos++;
		radius += o;
	}
	return pos+1;
}
Example #5
0
int isLast(int pos) {
	if (pos == -99)
		return 0;
	int radius = getPancakeRadius(pos);
	if (pos<getStackSize()-1) {
		int nextRadius = getPancakeRadius(pos+1);
		if (nextRadius == radius-1 || nextRadius == radius+1)
			return 0;
	}
	if (pos>0) {
		int nextRadius = getPancakeRadius(pos-1);
		if (nextRadius == radius-1 || nextRadius == radius+1)
			return 1;
	}
	return 0;
}
void SlidingStackComponent::refreshLayout ()
{
	for (int i=0; i<getStackSize (); i++)
	{
		Component* panel = getContentComponentAtIndex (i);
		if (i == getStackFocusIndex())
		{
			panel->setVisible (true);
			panel->setBounds (0,0,getWidth(),getHeight());
		}
		else
		{
			panel->setVisible (false);
		}
	}
}
void StackComponent::refreshLayout ()
{
    int focusIndex = getStackFocusIndex ();

    for (int i = 0; i<getStackSize(); i++)
    {
        Component* c = getContentComponentAtIndex(i);
        if (i == focusIndex)
        {
            c->setBounds (0,0,getWidth(),getHeight());
            c->setVisible(true);
        }
        else
        {
            c->setVisible(false);
            c->setBounds (0,0,getWidth(),getHeight());
        }
    }
}
/* 
    Print proc prologue, body, and epilogue
*/
void print_proc(Proc proc) {
    // Print proc label
    printf("proc_%s:", proc->header->id);
    int stack_count = getStackSize(proc->header->id);
    printf("\n");

    // Print prologue comment in output
    printf("#prologue\n");

    if (proc->decls || proc->header->params) {
        // Get the number of declarations.
        printf("push_stack_frame %d", stack_count);
        printf("\n");

        // Print proc parameters
        if(proc->header->params)
            print_params(proc->header->params,proc->header->id);

        // Declare int and real constants
        printf("int_const r0, 0\n");
        printf("real_const r1, 0.0\n");
        printf("\n");
        
        // Print proc declarations
        if(proc->decls)
            print_decls(proc->decls, proc->header->id);
    }

    printf("\n");

    // Print proc body
    if (proc->body) {
        print_stmts(proc->body, proc->header->id);
    }

    // Print epilogue
    printf("#epilogue\n");
    if (stack_count != 0) 
        printf("pop_stack_frame %d\n", stack_count);

    printf("return\n");
}
Example #9
0
/**
 * Creates an expression wrapping an identifier array access
 */
struct memorycontainer* createIdentifierArrayAccessExpression(char* identifier, struct stack_t* index_expressions) {
    int lenOfIndexes=getStackSize(index_expressions);

	struct memorycontainer* memoryContainer = (struct memorycontainer*) malloc(sizeof(struct memorycontainer));
	memoryContainer->length=sizeof(unsigned short)+(sizeof(unsigned char)*2);
	memoryContainer->data=(char*) malloc(memoryContainer->length);
	memoryContainer->lineDefns=NULL;

	unsigned int position=0;

	position=appendStatement(memoryContainer, ARRAYACCESS_TOKEN, position);
	position=appendVariable(memoryContainer, getVariableId(identifier, 1), position);
	unsigned char packageNumDims=(unsigned char) lenOfIndexes;
    memcpy(&memoryContainer->data[position], &packageNumDims, sizeof(unsigned char));
    position+=sizeof(unsigned char);

    int i;
	for (i=0;i<lenOfIndexes;i++) {
        memoryContainer=concatenateMemory(memoryContainer, getExpressionAt(index_expressions, i));
	}
	return memoryContainer;
}
Example #10
0
/**
 * Appends and returns the setting of an array element (assignment) statement
 */
struct memorycontainer* appendArraySetStatement( char* identifier, struct stack_t* indexContainer,
		struct memorycontainer* expressionContainer) {
	struct memorycontainer* memoryContainer = (struct memorycontainer*) malloc(sizeof(struct memorycontainer));
	memoryContainer->length=(sizeof(unsigned char)*2)+sizeof(unsigned short);
	memoryContainer->data=(char*) malloc(memoryContainer->length);
	memoryContainer->lineDefns=NULL;

	unsigned int position=0;

	position=appendStatement(memoryContainer, ARRAYSET_TOKEN, position);
	position=appendVariable(memoryContainer, getVariableId(identifier, 1), position);

	unsigned char numIndexes=(unsigned char) getStackSize(indexContainer);
	memcpy(&memoryContainer->data[position], &numIndexes, sizeof(unsigned char));
    position+=sizeof(unsigned char);
	int i;
	for (i=0;i<numIndexes;i++) {
        memoryContainer=concatenateMemory(memoryContainer, getExpressionAt(indexContainer, i));
	}
    memoryContainer=concatenateMemory(memoryContainer, expressionContainer);
	return memoryContainer;
}
Example #11
0
int main(){
	char c;
	int p, pushed=0, k=-2, error=1, charNum=1;
	double pop1, pop2, fo, num;
	c = getchar();

	while ((c!='\n') && (c!=-1)){
		//If number
		if(isdigit(c)){
			c = c - '0';
			// k=-1 if the previous input was an int
			if(k!=-1){
				num = c;
			} else {
				pop();
				num *= 10;
				num+=c;
			}

			pushed = push(num);
			if (pushed==-1){
				printf("Stack full error\n");
				error = -1;
				break;
			}
			k=-1;
		} 
		//If operator
		else if(c=='+' || c=='-' || c=='*' || c=='/'){

			if(getStackSize() < 2){
				printf("Input error at character %d (%c); too few arguments on stack.\n", charNum, c);
				error=-1;
				break;
			}
			else{
				pop1 = pop();
				pop2 = pop();
				
				if(c=='+'){
					fo = pop1 + pop2;
				} else if (c=='-'){
					fo = pop2 - pop1;
				} else if (c=='*'){
					fo = pop1*pop2;
				} else if (c=='/'){
					fo = pop2/pop1;
				}
				push(fo);
			}
			k=-2;
		}
		else {
			k=-2;
		}

		c = getchar();
		charNum++;
	}

	if(getStackSize()!=1){
		error = -1;
		printf("There are too few operators in the expression.\n");
	}
	if(error!=-1){
		printf("Result %.2f\n", fo);
	}
}
Example #12
0
/* BEGIN TEMPLATE */
void solve() {
	/* BEGIN SOLUTION */
	/* cruft to search for an instance exercising all transformations */
	int doneA=0;
	int doneB=0;
	int doneC=0;
	int doneD=0;
	int doneE=0;
	int doneF=0;
	int doneG=0;
	int doneH=0;
	int* origSizes = (int*)malloc(sizeof(int)*getStackSize());
	int i;
	for (i=0;i<getStackSize();i++)
		origSizes[i] = getPancakeRadius(i);
	/* end of this cruft */

	int stackSize = getStackSize();

	if (debug>0) {
		printf("{\n");
		int rank;
		for (rank=0; rank < stackSize; rank++){
			printf("%d\n",getPancakeRadius(rank));
		}
		printf("}\n");
	}

	while (1) {
		int tRadius = getPancakeRadius(0);
		int posTPlus  = getRankOf(tRadius+1); // returns -99 if non-existent, that is then ignored
		int posTMinus = getRankOf(tRadius-1);
		int posT = 0;

		if (debug>1) {
			printf("t Radius: %d\n",tRadius);
			int rank;
			for (rank=0; rank < stackSize; rank++) {
				printf("[%d]=%d; ",rank,getPancakeRadius(rank));

				if (isFree(rank))
					printf("free;");
				else
					printf("NON-free;");

				if (isFirst(rank))
					printf("first; ");
				else
					printf("NON-first; ");

				if (isLast(rank))
					printf("last; ");
				else
					printf("NON-last; ");


				if (rank == posTPlus)
					printf("t+1; ");
				if (rank == posTMinus)
					printf("t-1; ");
				if (rank == posT)
					printf("t;" );

				printf("\n");
			}
		}

		if (isFree(posT)) {
			if (isFree(posTPlus)) { /* CASE A: t and t+o free */
				if (debug>0)
					printf("Case A+\n");
				flip(posTPlus);
				doneA = 1;
			} else if (isFree(posTMinus)) { /* CASE A: t and t-o free */
				if (debug>0)
					printf("Case A-\n");
				flip(posTMinus);
				doneA = 1;

			} else if (isFirst(posTPlus)) { /* CASE B: t free, t+o first element */
				if (debug>0)
					printf("Case B+\n");
				flip(posTPlus);
				doneB = 1;
			} else if (isFirst(posTMinus)) { /* CASE B: t free, t-o first element */
				if (debug>0)
					printf("Case B-\n");
				flip(posTMinus);
				doneB = 1;

			} else if (min(posTPlus,posTMinus) != -99) { /* CASE C: t free, but both t+o and t-o are last elements */
				if (debug>0)
					printf("Case C\n");
				flip(min(posTPlus,posTMinus) );
				flip(min(posTPlus,posTMinus) - 1);
				flip(max(posTPlus,posTMinus) + 1);
				flip(min(posTPlus,posTMinus) - 1);
				doneC = 1;

			} else {
				if (debug>0)
					printf("Case Cbis\n");
				flip(max(posTPlus,posTMinus) + 1);
				flip(max(posTPlus,posTMinus) );
				doneC = 1;
			}

		} else { // t is in a block
			if (blockLength() == stackSize) { // Done!
				if (tRadius != 1) // all reverse
					flip(stackSize);
				if (doneA && doneB && doneC && doneD && doneE && doneF && doneG && doneH && wasRandom()) {
					printf("BINGO! This instance is VERY interesting as it experiences every cases of the algorithm.\nPLEASE REPORT IT. PLEASE DONT LOSE IT.\n");
					printf("{\n");
					int rank;
					for (rank=0; rank < stackSize; rank++)
						printf("%d, ",origSizes[rank]);
					printf("}\n");
				}
				free(origSizes);
				return;
			}

			if (isFree(posTPlus)) {          /* CASE D: t in a block, t+1 free */
				if (debug>0)
					printf("Case D+\n");
				flip(posTPlus);
				doneD = 1;

			} else if (isFree(posTMinus)) {  /* CASE D: t in a block, t-1 free */
				if (debug>0)
					printf("Case D-\n");
				flip(posTMinus);
				doneD = 1;

			} else if (isFirst(posTPlus)) {  /* CASE E: t in a block, t+1 first element */
				if (debug>0)
					printf("Case E+\n");
				flip(posTPlus);
				doneE = 1;

			} else if (isFirst(posTMinus)) { /* CASE E: t in a block, t-1 first element */
				if (debug>0)
					printf("Case E-\n");
				flip(posTMinus);
				doneE = 1;

			} else if (isLast(posTPlus) && posTPlus != 1) { /* CASE F+: t in a block, t+1 last element */
				doneF = 1;
				if (debug>0)
					printf("Case F+\n");
				flip(blockLength());
				flip(posTPlus + 1);
				int newPos = getRankOf(tRadius);
				if (newPos>0)
					flip(newPos);

			} else if (isLast(posTMinus) && posTMinus != 1) { /* CASE F-: t in a block, t-1 last element */
				doneF = 1;
				if (debug>0)
					printf("Case F-\n");
				flip(blockLength());
				flip(posTMinus + 1);
				int newPos = getRankOf(tRadius);
				if (newPos>0)
					flip(newPos);
			} else {
				int k = blockLength()-1;
				int o = getPancakeRadius(1) - tRadius;
				int pos = getRankOf(tRadius+(k+1)*o);
				if (isFree(pos) || isFirst(pos)) {
					doneG = 1;
					if (debug>0)
						printf("Case G\n");
					flip(k+1);
					flip(pos);
				} else {
					doneH = 1;
					if (debug>0)
						printf("Case H\n");
					flip(pos+1);
					flip(getRankOf(tRadius+k*o));
				}
			}
		}
	}
	free(origSizes);
	/* END SOLUTION */
}
Example #13
0
int main ()
{
  int i;
  double result;

  if (getStackSize() ==0)
    printf ("Passed 1\n");
  else
    printf ("Failed 1\n");

  /* Make sure a pop of an empty stack returns NAN.*/
  result = pop();
  if (isnan(result))
    printf ("Passed 2\n");
  else
    printf ("Failed 2\n");

  
  /* Check if an empty stack returns a non-zero (true) value. */
  emptyStack();

  if (isStackEmpty())
    printf ("Passed 3\n");
  else
    printf ("Failed 3\n");

  /************************************************
  /* Push 15 values on the stack -- 
     Check result, isStackEmpty, and getStackSize */
  for (i=0; i<15; i++)
    result = push (i);

  if (result == 0)
    printf ("Passed 4\n");
  else
    printf ("Failed 4\n");
  
  if (getStackSize() == 15)
    printf ("Passed 5\n");
  else
    printf ("Failed 5\n");

  if (!isStackEmpty())
    printf ("Passed 6\n");
  else
    printf ("Failed 6\n");

  /************************************************
  /* Check two pops */
  /* Then make sure stack size is now 13.
   */
  if (pop() == 14)
    printf ("Passed 6\n");
  else
    printf ("Failed 6\n");

  if (pop() == 13)
    printf ("Passed 7\n");
  else
    printf ("Failed 7\n");

  if (getStackSize() == 13)
    printf ("Passed 8\n");
  else
    printf ("Failed 8\n");

  /************************************************
  * Push 100 values on the stack -- 
  * All should have a result of 0.
  * Then push a 101th value and make sure the result is -1.  
  */
  emptyStack();
  
  for (i=0; i<100; i++) {
    result = push (i);
    if (result != 0) {
      printf("Push 100 failed on %d\n", i);
      break;
    }
  }
    
  result = push(101);
  if (result == -1) 
    printf ("Passed 9\n");
  else
    printf ("Failed 9\n");
}  
Example #14
0
/**
 * Appends a new function statement to the function list which is held by the memory manager.
 * This also appends a return statement to the end of the function body and registers
 * the current goto point as the function name
 */
void appendNewFunctionStatement(char* functionName, struct stack_t * args, struct memorycontainer* functionContents) {
	struct functionDefinition * fn=(struct functionDefinition*) malloc(sizeof(struct functionDefinition));
	fn->name=(char*) malloc(strlen(functionName) + 1);
	strcpy(fn->name, functionName);
	fn->called=0;

	unsigned short numberArgs=(unsigned short) getStackSize(args);
	struct memorycontainer* numberArgsContainer = (struct memorycontainer*) malloc(sizeof(struct memorycontainer));
	numberArgsContainer->length=sizeof(unsigned short) * (numberArgs + 1);
	numberArgsContainer->data=(char*) malloc(sizeof(unsigned short) * (numberArgs + 1));
	numberArgsContainer->lineDefns=NULL;

	((unsigned short *) numberArgsContainer->data)[0]=numberArgs;

	struct memorycontainer* assignmentContainer=NULL;

	int i;
	for (i=0;i<numberArgs;i++) {
		if (getTypeAt(args, i) == 2) {
			((unsigned short *) numberArgsContainer->data)[i+1]=getVariableId(getIdentifierAt(args, i), 1);
		} else {
			struct identifier_exp * idexp=getExpressionIdentifierAt(args, i);
			if (assignmentContainer == NULL) {
				assignmentContainer=appendLetIfNoAliasStatement(idexp->identifier, idexp->exp);
			} else {
				assignmentContainer=concatenateMemory(assignmentContainer, appendLetIfNoAliasStatement(idexp->identifier, idexp->exp));
			}
			((unsigned short *) numberArgsContainer->data)[i+1]=getVariableId(idexp->identifier, 1);
		}
	}

	clearStack(args);

	if (assignmentContainer != NULL) numberArgsContainer=concatenateMemory(numberArgsContainer, assignmentContainer);

	struct memorycontainer* completedFunction=concatenateMemory(concatenateMemory(numberArgsContainer, functionContents),
			appendReturnStatement());

	struct lineDefinition * defn = (struct lineDefinition*) malloc(sizeof(struct lineDefinition));
	defn->next=completedFunction->lineDefns;
	defn->type=2;
	defn->currentpoint=0;
	defn->name=(char*) malloc(strlen(functionName) + 1);
	strcpy(defn->name, functionName);
	completedFunction->lineDefns=defn;

	fn->contents=completedFunction;
	fn->numberEntriesInSymbolTable=current_var_id - currentSymbolTableId;
	fn->recursive=isFnRecursive;
	fn->number_of_fn_calls=currentCall->number_of_calls;
	if (currentCall->number_of_calls == 0) {
		fn->functionCalls=NULL;
	} else {
		fn->functionCalls=(char**) malloc(sizeof(char*) * currentCall->number_of_calls);
		memcpy(fn->functionCalls, currentCall->calledFunctions, sizeof(char*) * currentCall->number_of_calls);
	}
	free(currentFunctionName);
	currentFunctionName=NULL;
	currentCall=NULL;
	addFunction(fn);
}
Example #15
0
/**
 * Appends and returns a call function, this is added as a placeholder and then resolved at the end to point to the absolute byte code location
 * which is needed as the function might appear at any point
 */
struct memorycontainer* appendCallFunctionStatement(char* functionName, struct stack_t* args) {
	char * last_dot=strrchr(functionName,'.');
	if (last_dot != NULL) functionName=last_dot+1;
	if (currentFunctionName != NULL && strcmp(currentFunctionName, functionName) == 0) isFnRecursive=1;

	struct memorycontainer* assignmentContainer=NULL;
	unsigned short numArgs=(unsigned short) getStackSize(args);
	char *isArgIdentifier=(char*) malloc(numArgs);
	unsigned short *varIds=(unsigned short*) malloc(sizeof(unsigned short) * numArgs);
	char * varname=(char*) malloc(strlen(functionName)+5);
	int i;
	for (i=0;i<numArgs;i++) {
		struct memorycontainer* expression=getExpressionAt(args, i);
		unsigned char command=((unsigned char*) expression->data)[0];
		if (command != IDENTIFIER_TOKEN) {
			isArgIdentifier[i]=0;
			sprintf(varname,"%s#%d", functionName, i);
			if (assignmentContainer == NULL) {
				assignmentContainer=appendLetStatement(varname, getExpressionAt(args, i));
			} else {
				assignmentContainer=concatenateMemory(assignmentContainer, appendLetStatement(varname, getExpressionAt(args, i)));
			}
		} else {
			isArgIdentifier[i]=1;
			varIds[i]=*((unsigned short*) (&((char*) expression->data)[1]));
			free(expression->data);
		}
	}
	struct memorycontainer* memoryContainer = (struct memorycontainer*) malloc(sizeof(struct memorycontainer));
	memoryContainer->length=sizeof(unsigned short)*(2+numArgs)+sizeof(unsigned char);
	memoryContainer->data=(char*) malloc(memoryContainer->length);
    unsigned int position=0;

	if (doesVariableExist(functionName)) {
        memoryContainer->lineDefns=NULL;
        position=appendStatement(memoryContainer, FNCALL_BY_VAR_TOKEN, position);
        position=appendVariable(memoryContainer, getVariableId(functionName, 0), position);
	} else {
        struct lineDefinition * defn = (struct lineDefinition*) malloc(sizeof(struct lineDefinition));
        defn->next=NULL;
        defn->type=3;
        defn->linenumber=line_num;
        defn->name=(char*) malloc(strlen(functionName)+1);
        strcpy(defn->name, functionName);
        defn->currentpoint=sizeof(unsigned char);

        memoryContainer->lineDefns=defn;

        position=appendStatement(memoryContainer, FNCALL_TOKEN, position);
        position+=sizeof(unsigned short);
	}
	position=appendVariable(memoryContainer, numArgs, position);

	for (i=0;i<numArgs;i++) {
		if (isArgIdentifier[i]) {
			position=appendVariable(memoryContainer, varIds[i], position);
		} else {
			sprintf(varname,"%s#%d", functionName, i);
			position=appendVariable(memoryContainer, getVariableId(varname, 0), position);
		}
	}
	clearStack(args);
	free(varname);
	free(isArgIdentifier);
	free(varIds);
	if (currentCall==NULL) {
		mainCodeCallTree.calledFunctions[mainCodeCallTree.number_of_calls]=(char*)malloc(strlen(functionName)+1);
		strcpy(mainCodeCallTree.calledFunctions[mainCodeCallTree.number_of_calls++], functionName);
	} else {
		currentCall->calledFunctions[currentCall->number_of_calls]=(char*)malloc(strlen(functionName)+1);
		strcpy(currentCall->calledFunctions[currentCall->number_of_calls++], functionName);
	}
	if (assignmentContainer != NULL) {
		return concatenateMemory(assignmentContainer, memoryContainer);
	} else {
		return memoryContainer;
	}

}
Example #16
0
struct memorycontainer* appendNativeCallFunctionStatement(char* functionName, struct stack_t* args, struct memorycontainer* singleArg) {
    struct memorycontainer* memoryContainer = (struct memorycontainer*) malloc(sizeof(struct memorycontainer));
	memoryContainer->length=(sizeof(unsigned char)*2) + sizeof(unsigned short);
	memoryContainer->data=(char*) malloc(memoryContainer->length);
	memoryContainer->lineDefns=NULL;

	unsigned int position=0;

	position=appendStatement(memoryContainer, NATIVE_TOKEN, position);
    if (strcmp(functionName, NATIVE_RTL_ISHOST_STR)==0) {
        position=appendStatement(memoryContainer, NATIVE_FN_RTL_ISHOST, position);
    } else if (strcmp(functionName, NATIVE_RTL_ISDEVICE_STR)==0) {
        position=appendStatement(memoryContainer, NATIVE_FN_RTL_ISDEVICE, position);
    } else if (strcmp(functionName, NATIVE_RTL_PRINT_STR)==0) {
        position=appendStatement(memoryContainer, NATIVE_FN_RTL_PRINT, position);
    } else if (strcmp(functionName, NATIVE_RTL_NUMDIMS_STR)==0) {
        position=appendStatement(memoryContainer, NATIVE_FN_RTL_NUMDIMS, position);
    } else if (strcmp(functionName, NATIVE_RTL_DSIZE_STR)==0) {
        position=appendStatement(memoryContainer, NATIVE_FN_RTL_DSIZE, position);
    } else if (strcmp(functionName, NATIVE_RTL_INPUT_STR)==0) {
        position=appendStatement(memoryContainer, NATIVE_FN_RTL_INPUT, position);
    } else if (strcmp(functionName, NATIVE_RTL_INPUTPRINT_STR)==0) {
        position=appendStatement(memoryContainer, NATIVE_FN_RTL_INPUTPRINT, position);
    } else if (strcmp(functionName, NATIVE_RTL_SYNC_STR)==0) {
        position=appendStatement(memoryContainer, NATIVE_FN_RTL_SYNC, position);
    } else if (strcmp(functionName, NATIVE_RTL_GC_STR)==0) {
        position=appendStatement(memoryContainer, NATIVE_FN_RTL_GC, position);
    } else if (strcmp(functionName, NATIVE_RTL_FREE_STR)==0) {
        position=appendStatement(memoryContainer, NATIVE_FN_RTL_FREE, position);
    } else if (strcmp(functionName, NATIVE_RTL_SEND_STR)==0) {
        position=appendStatement(memoryContainer, NATIVE_FN_RTL_SEND, position);
    } else if (strcmp(functionName, NATIVE_RTL_RECV_STR)==0) {
        position=appendStatement(memoryContainer, NATIVE_FN_RTL_RECV, position);
    } else if (strcmp(functionName, NATIVE_RTL_SENDRECV_STR)==0) {
        position=appendStatement(memoryContainer, NATIVE_FN_RTL_SENDRECV, position);
    } else if (strcmp(functionName, NATIVE_RTL_BCAST_STR)==0) {
        position=appendStatement(memoryContainer, NATIVE_FN_RTL_BCAST, position);
    } else if (strcmp(functionName, NATIVE_RTL_NUMCORES_STR)==0) {
        position=appendStatement(memoryContainer, NATIVE_FN_RTL_NUMCORES, position);
    } else if (strcmp(functionName, NATIVE_RTL_COREID_STR)==0) {
        position=appendStatement(memoryContainer, NATIVE_FN_RTL_COREID, position);
    } else if (strcmp(functionName, NATIVE_RTL_REDUCE_STR)==0) {
        position=appendStatement(memoryContainer, NATIVE_FN_RTL_REDUCE, position);
    } else if (strcmp(functionName, NATIVE_RTL_ALLOCATEARRAY_STR)==0) {
        position=appendStatement(memoryContainer, NATIVE_FN_RTL_ALLOCARRAY, position);
    } else if (strcmp(functionName, NATIVE_RTL_ALLOCATESHAREDARRAY_STR)==0) {
        position=appendStatement(memoryContainer, NATIVE_FN_RTL_ALLOCSHAREDARRAY, position);
    } else if (strcmp(functionName, NATIVE_RTL_MATH_STR)==0) {
        position=appendStatement(memoryContainer, NATIVE_FN_RTL_MATH, position);
    } else if (strcmp(functionName, NATIVE_RTL_PROBE_FOR_MESSAGE_STR)==0) {
        position=appendStatement(memoryContainer, NATIVE_FN_RTL_PROBE_FOR_MESSAGE, position);
    } else if (strcmp(functionName, NATIVE_RTL_TEST_FOR_SEND_STR)==0) {
        position=appendStatement(memoryContainer, NATIVE_FN_RTL_TEST_FOR_SEND, position);
    } else if (strcmp(functionName, NATIVE_RTL_WAIT_FOR_SEND_STR)==0) {
        position=appendStatement(memoryContainer, NATIVE_FN_RTL_WAIT_FOR_SEND, position);
    } else if (strcmp(functionName, NATIVE_RTL_SEND_NB_STR)==0) {
        position=appendStatement(memoryContainer, NATIVE_FN_RTL_SEND_NB, position);
    } else {
        fprintf(stderr, "Native function call of '%s' is not found\n", functionName);
        exit(EXIT_FAILURE);
    }
    unsigned short numArgs=args !=NULL ? (unsigned short) getStackSize(args) : singleArg != NULL ? 1 : 0;
    position=appendVariable(memoryContainer, numArgs, position);

    if (args != NULL) {
        int i;
        for (i=0;i<numArgs;i++) {
            struct memorycontainer* expression=getExpressionAt(args, i);
            memoryContainer=concatenateMemory(memoryContainer, expression);
        }
    }
    if (singleArg != NULL) memoryContainer=concatenateMemory(memoryContainer, singleArg);
	return memoryContainer;
}