예제 #1
0
파일: 1.c 프로젝트: tyru/libdatastruct
int main(void)
{
	cassoclist_t *cassoclist;
	unsigned int errcode;
	size_t counter = 0;
	void *pointer;
	cassoclist = cassoclist_initialize(sizeof(void *),free_object);
	if(!cassoclist){
		return -1;
	}
	while(counter != 1024){
		pointer = malloc(1);
		errcode = cassoclist_add(cassoclist,integer_to_string(counter),&pointer);
		if(errcode){
			fputs("Error!\n",stderr);
			return -1;
		}
		fprintf(stdout,"add : %s,%d\n",integer_to_string(counter),pointer);
		counter++;
	}
	counter = 0;
	while(counter != 1024){
		errcode = cassoclist_lookup(cassoclist
		    ,integer_to_string(counter),&pointer);
		if(errcode){
			fputs("Error!\n",stderr);
		}
		fprintf(stdout,"find : %s,%d\n",integer_to_string(counter),pointer);
		counter++;
	}
	cassoclist_release(cassoclist);
	return 0;
}
예제 #2
0
파일: 2.c 프로젝트: tyru/libdatastruct
int main(void)
{
	cassoclist_t *cassoclist;
	unsigned int errcode;
	size_t counter = 0;
	size_t temp;
	clock_t time;
	cassoclist = cassoclist_initialize(sizeof(size_t),NULL);
	if(!cassoclist){
		fputs("Error!\n",stderr);
		return -1;
	}
	time = clock();
	while(counter != (1<<22)){
		errcode = cassoclist_add(cassoclist,integer_to_string(counter),&counter);
		if(errcode){
			fputs("Error!\n",stderr);
			return -1;
		}
		counter++;
	}
	fprintf(stdout,"insert : %fs\n",(double)(clock()-time)/CLOCKS_PER_SEC);
	counter = 0;
	time = clock();
	while(counter != (1<<22)){
		errcode = cassoclist_lookup(cassoclist,integer_to_string(counter),&temp);
		if(errcode){
			fputs("Error!\n",stderr);
		}
	counter++;
	}
	fprintf(stdout,"find   : %fs\n",(double)(clock()-time)/CLOCKS_PER_SEC);
	cassoclist_release(cassoclist);
	return 0;
}
예제 #3
0
파일: main.cpp 프로젝트: 2eesh/asio_samples
std::string to_string(const ma::limited_int<Integer>& limited_value)
{
  if (limited_value.overflowed())
  {
    return ">" + integer_to_string(limited_value.value());
  }
  else
  {
    return integer_to_string(limited_value.value());
  }
}
예제 #4
0
// Serialize HttpMessage object to a string (very useful if you want to send a request :D )
std::string HttpMessage :: serialize(){
	std::stringstream stream;
	
	// code == 0 means that this is a HTTP request.
	if( code == 0 ){
		stream << method << " " << path << " " << version << "\r\n";
		}
	else {
		stream << version << " " << code << " " << code_string << "\r\n";
		}
		
	// If content-length header field is not provided, compute it
	if( header.find( "Content-Length") == header.end() && method != "GET" && method != "HEAD" ){
		header["Content-Length"] = integer_to_string( body.size() );
		}
	
	// Serialize all header fields into the stream, the order of the fields
	// STL implementation spesific and depends on the comparation function used in std::map
	for( std::map<std::string, std::string>::iterator it = header.begin(); it != header.end(); it++ ){
		stream << (*it).first << ": " << (*it).second << "\r\n";
		}
	stream << "\r\n";
	stream << body;
	
	
	return stream.str();
	}
예제 #5
0
bookmark_menu_item::bookmark_menu_item(Gtk::RadioButtonGroup& _group, int _line, std::string _filename)
: Gtk::RadioMenuItem(_group),filename(_filename)
{
    line = _line;
    set_label(filename+" "+ integer_to_string(line));
    set_active(false);
    }
예제 #6
0
IrrealContext :: IrrealContext(){
	
	pthread_mutex_lock( &global_contexts_lock );
	
	context_id = next_context_id;
	prefix = integer_to_string( context_id ) + std::string( "::" );
	
	global_contexts[ context_id ] = this;

	++next_context_id;
	
	pthread_mutex_lock( &global_stacks_lock );
	global_stacks[ prefix + std::string( "CURRENT" ) ] = IrrealStack(); 
	global_stacks[ prefix + std::string( "PARAMS" ) ] = IrrealStack(); 
	global_stacks[ prefix + std::string( "CODE" ) ] = IrrealStack(); 
	global_stacks[ prefix + std::string( "OUT" ) ] = IrrealStack(); 
	pthread_mutex_unlock( &global_stacks_lock );
	
	scope.push_back( prefix );
	
	state = STATE_OK;
	
	
	return_value = NULL;
	
	//context_lock = PTHREAD_MUTEX_INITIALIZER;
	
	pthread_mutex_init( &context_lock, NULL );
	
	marks = 0;
	
	pthread_mutex_unlock( &global_contexts_lock );
	
	}
예제 #7
0
std::string IrrealContext :: spawnNewAnonymousStack(){
	
	pthread_mutex_lock( &global_stacks_lock );
	
	std::string name = std::string( "_anon_" ) + integer_to_string( next_anon_stack_id );
	++next_anon_stack_id;
	global_stacks[ prefix + name ] = IrrealStack();
	
	pthread_mutex_unlock( &global_stacks_lock );
	
	spawned_stacks.push_back( name );
	
	return name;
	}
예제 #8
0
inline ss_size_t format_thousands(  C           *dest
                                ,   ss_size_t   cchDest
                                ,   C const     *picture
                                ,   I const     &number
                                ,   C           fmtSep
                                ,   C           outputSep
                                )
{
    C       szRawNumber[21];    // 21 is large enough for any 64-bit number (signed or unsigned)
    C const* rawNumber  =   integer_to_string(szRawNumber, STLSOFT_NUM_ELEMENTS(szRawNumber), static_cast<unsigned int>(number));

    STLSOFT_STATIC_ASSERT(sizeof(C) <= 8);

    return translate_thousands(dest, cchDest, picture, rawNumber, fmtSep, outputSep);
}
예제 #9
0
int problem263()
{
  integer testnum = string_to_integer("5");
  integer testnum_helper = string_to_integer("5");
  integer two = string_to_integer("2");
  integer total_src = string_to_integer("0");
  integer total_tar = string_to_integer("0");
  integer target_dif = string_to_integer("6");
  integer dif = string_to_integer("0");

  int found = 0;
  integer lastprime = string_to_integer("5");
  //int sexy_count = 0;
  printf("text here\n");
  while (found < 4) {
    //printf("gets 1\n");
    if (miller_rabin(testnum) == PRIME) {
      subtract_integer(testnum, lastprime, dif);
      if (compare_integers(dif, target_dif) == 0) {
        printf("difference between %s and %s is six\n", 
                integer_to_string(testnum), integer_to_string(lastprime));
        found++;
      }else {
        found = 1;
      }
      copy_integer(testnum, lastprime);
      add_integer(total_src, testnum, total_tar);
      copy_integer(total_tar, total_src);
      printf("Total is %s\n", integer_to_string(total_tar));
    }
    add_integer(testnum_helper, two, testnum);
    copy_integer(testnum, testnum_helper);
    printf("Tested %s\n", integer_to_string(testnum));
  }
  return 0;
}
예제 #10
0
int main()
{
	int mysockfd = socket(AF_INET, SOCK_STREAM, 0), clientfd,no_of_words;
	struct sockaddr_in servaddr;
	char receive_data[MAXLINE],send_data[MAXLINE];
	int n,temp,i,j;
	if(mysockfd<0)
	{
		printf("socket failed\n");
		return -1;
	}
	memset(&servaddr, 0, sizeof(servaddr));
	servaddr.sin_family = AF_INET;
	servaddr.sin_port = htons(5000);
	// inet_pton(AF_INET, "227.0.0.1", &servaddr.sin_addr);
	temp = bind(mysockfd, (struct sockaddr *)&servaddr, sizeof(servaddr));
	if(temp<0)
	{
		printf("bind failed\n");
		return -1;
	}
	else
	{
		printf("bind successful\n");
	}
	temp = listen(mysockfd, 1);
	if(temp<0)
	{
		printf("listen failed\n");
		return -1;
	}
	else
	{
		printf("listen successful\n");
	}
	struct sockaddr_in client;
	unsigned int clilen=sizeof(client);
	clientfd = accept(mysockfd, (struct sockaddr *)&client, &clilen);
	if(clientfd<0)
	{
		printf("accept failed\n");
		return -1;
	}
	else
	{
		printf("accept successful\n");
	}
	while(1)
	{
		if((n=read(clientfd,receive_data,MAXLINE-1))==0)
			break;
		if(n>0)
		{
			receive_data[n]='\0';
			no_of_words=0;
			for(i=0;receive_data[i]!='\0';i++)
			{
				if(receive_data[i]==' ')
					no_of_words++;
			}
			no_of_words++;
			printf("%s %d\n",receive_data,no_of_words);
			integer_to_string(no_of_words,send_data);
			write(clientfd,send_data,strlen(send_data));
		}
	}
	printf("end\n");
	return 0;
}
예제 #11
0
void IrrealVM :: execute( uint64_t thread_id ){
	
	//if( global_vm_queue.size() < 1 ){ return; }
	
	pthread_mutex_lock( &global_vm_queue_lock );
	
	if( global_vm_queue.size() < 1 ){
		pthread_mutex_unlock( &global_vm_queue_lock );
		return; 
		}
	
	uint64_t ctx_id = global_vm_queue.front();
	global_vm_queue.pop_front();
	
	IrrealContext *ctx = global_contexts[ ctx_id ];
	
	pthread_mutex_unlock( &global_vm_queue_lock );
	
	test_for_error( ctx == NULL, "Invalid context!" );
	
	ctx->lock_context();
	
	global_running_threads_vm[ thread_id ] = ctx_id;
	
	//printf( "Executing vm #%lu\n", ctx_id );
	//_debug_running_threads();
	
	
	IrrealStack *current, *code;
	
	current = ctx->getCurrentStack();
	code = ctx->getCodeStack();
	
	test_for_error( current == NULL, "Invalid current stack!" );
	test_for_error( code == NULL, "Invalid code stack!" );
	
	uint8_t state = ctx->getState();
	
	switch( state ){
		case STATE_JOINING:
			if( !current->isJoined() ){
				
				pthread_mutex_lock( &global_vm_queue_lock );
				global_vm_queue.push_back( ctx_id ); 
				pthread_mutex_unlock( &global_vm_queue_lock );
	
				ctx->mark();
	
				ctx->unlock_context();
				return;
				}
		break;
		case STATE_SYNCING:
			
			test_for_error( current->peek() == NULL, "Not enough values to perform 'sync'!" );
			
			//printf( "syncing... ('%s')\n", current->peek()->getValue().c_str() );
			if( current->peek()->getState() == STATE_NOT_YET ){
				
				pthread_mutex_lock( &global_vm_queue_lock );
				global_vm_queue.push_back( ctx_id ); 
				pthread_mutex_unlock( &global_vm_queue_lock );
				
				ctx->mark();
				
				ctx->unlock_context();
				return;
				}
			//printf( "Data synced, now continuing... \n" );
		break;
		}
	
	std::string anon_name;
	bool anon_state = false;
	uint64_t begin_end_counter = 0;
	bool done = false;
	IrrealStack *anon_stack = NULL;
	
	long int debug_value;
	
	IrrealStack *debug_stack;
	
	debug_value = ctx->getStack("PARAMS")->size();
	debug_stack = ctx->getStack("PARAMS");
	while( !done ){
		ctx->mark();
		//printf( "\n\n" ); 
		IrrealValue *q = code->pop();
		//printf( "current: " ); current->_debug_print();
		//printf( "params: " ); ctx->getStack("PARAMS")->_debug_print();
		//printf( "out: " ); ctx->getStack("OUT")->_debug_print();
		if( q == NULL ){
			//printf( "q == NULL\n" );
			done = true; 
			if( ctx->getReturnValue() != NULL ){
				//printf( "Returning value! ('%s')\n", ctx->getReturnValue()->getValue().c_str() );
				ctx->getStack( ctx->getReturnValue()->getValue() )->merge( ctx->getStack( "OUT" ), false ); 
				
				ctx->getReturnValue()->setType( TYPE_SYMBOL );
				ctx->getReturnValue()->setState( STATE_OK );
				}
			
			pthread_mutex_lock( &global_running_vms_lock );
				--global_running_vms;
			pthread_mutex_unlock( &global_running_vms_lock );
			
			continue; 
			}
		if( q->getType() & TYPE_OPERATOR ){
			printf( "q = {'%s', %s} \n", q->getValue().c_str(), debug_cmd_names[ q->getType() & (~0x80 ) ].c_str() );
			}
		else{
			printf( "q = {'%s', %i} \n", q->getValue().c_str(), q->getType() );
			}
		if( anon_state ){
			if( q->getType() & TYPE_OPERATOR ){
				switch( q->getType() ){
					case CMD_BEGIN:
						++begin_end_counter;
					break;
					case CMD_END:
						--begin_end_counter;
					break;
					}
				anon_stack->push( q );
				if( begin_end_counter == 0 ){
					 test_for_error( anon_stack == NULL, "Stack error when parsing block!" );
					 anon_stack->pop();
					 
					 anon_state = false;
					 IrrealValue* value = new IrrealValue();
					 value->setType( TYPE_SYMBOL );
					 value->setValue( anon_name );
					 current->push( value );
					 //printf( "pushing to stack: '%s' \n", current->peek()->getValue().c_str() );
					 continue;
					 }
				}
			else{
				test_for_error( anon_stack == NULL, "Stack error when parsing block!" );
				anon_stack->push( q );
				}
			}
		else{
			
			if( q->getType() & TYPE_OPERATOR ){
				//printf( "Executing command: %s \n", debug_cmd_names[ q->getType() & (~0x80) ].c_str() );
				switch( q->getType() ){
					
					case CMD_BEGIN:
					{
						anon_name = ctx->spawnNewAnonymousStack();
						anon_stack = ctx->getStack( anon_name );
						test_for_error( anon_stack == NULL, "Unable to spawn new anonymous stack!" );
						
						begin_end_counter = 1;
						anon_state = true;
						
					}
					break;
					
					case CMD_PUSH:
					{
						IrrealValue *target_stack_name;
						IrrealValue *value;
						IrrealStack *target_stack;
						
						target_stack_name = current->pop();
						
						value = current->pop();
						
						test_for_error( target_stack_name == NULL, "Not enough values to perform 'push'!" );
						test_for_error( value == NULL, "Not enough values to perform 'push'!" );
						
						
						target_stack = ctx->getStack( target_stack_name->getValue() );
						
						test_for_error( target_stack == NULL, "PUSH: Stack not found!" );
						
						target_stack->push( value );
					}
					break;
					
					case CMD_POP:
					{	
						IrrealValue *target_stack_name;
						IrrealStack *target_stack, *testing;
						IrrealValue *value;
						
						target_stack_name = current->pop();
						
						test_for_error( target_stack_name == NULL, "Not enough values to perform 'pop'!" );
						
						target_stack = ctx->getStack( target_stack_name->getValue() );
						testing = ctx->getStack( target_stack_name->getValue() );
							
						test_for_error( target_stack == NULL, "POP: Stack not found!" );
						
						value = target_stack->pop();
						
						
						if( value == NULL ){
							printf( "\n\n**** Debug info***\n\n" );
							printf( "In PARAMS stack there were %li entries in the beginning...\n", debug_value ); 
							printf( "target_stack_name = '%s' \n", target_stack_name->getValue().c_str() );
							printf( "Context mark count: %lu \n", ctx->read_marks() );
							printf( "target_stack pop_counter = %lu \n", target_stack->_debug_get_counter() );
							printf( "target_stack = %p, target_stack->id = %lu \n", target_stack, target_stack->get_id() );
							printf( "debug_stack = %p, debug_stack->id = %lu \n", debug_stack, debug_stack->get_id() );
							printf( "testing: %p, testing->id = %lu\n", testing, testing->get_id() );
							printf( "debug_stack->size = %lu, target_stack->size = %lu, testing->size = %lu \n", debug_stack->size(), target_stack->size(), testing->size() );
							value = testing->pop();
							printf( "testing->pop = %p, value->getValue = %s\n", value, value->getValue().c_str() ); 
							printf( "\n" );
							fflush( stdout );
							value = NULL;
							}
						test_for_error( value == NULL, "POP: Target stack empty!" );
						
						current->push( value );
					}
					break;
					
					case CMD_DEF:
					{	
						IrrealValue *target_name;
						IrrealValue *value;
						
						target_name = current->pop();
						value = current->pop();
						
						test_for_error( target_name == NULL, "Not enough values to perform 'def'!" );
						test_for_error( value == NULL, "No enough values to perform 'def'!" );
						
						ctx->spawnNewStack( target_name->getValue() );
						
						switch( value->getType() ){
							case TYPE_SYMBOL:
							{
								IrrealStack *target_stack = ctx->getStack( target_name->getValue() );
								IrrealStack *source_stack = ctx->getStack( value->getValue() );
								
								test_for_error( target_stack == NULL, "DEF: Target stack not found!" );
								test_for_error( source_stack == NULL, "DEF: Source stack not found!" );
								
								
								IrrealValue *tmp = source_stack->pop();
								
								
								while( tmp != NULL ){
									target_stack->push( tmp );
									tmp = source_stack->pop();
									}
							}
							break;
							default:
							{
								IrrealStack *target_stack = ctx->getStack( target_name->getValue() );
								test_for_error( target_stack == NULL, "DEF: Target stack not found!" );
								target_stack->push( value );
							}	
							break;
							}
					}	
					break;
					
					case CMD_MERGE:
					{
						IrrealValue *target_name;
						IrrealStack *target_stack;
						
						target_name = current->pop();
						test_for_error( target_name == NULL, "Not enough values to perform 'merge'!" );
						
						target_stack = ctx->getStack( target_name->getValue() );
						
						test_for_error( target_stack == NULL, "MERGE: Stack not found!" );
						
						current->merge( target_stack, false );
					}	
					break;
					
					case CMD_CALL:
					{
						IrrealValue *func, *nparams, *return_value;
						
						nparams = current->pop();
						func = current->pop();
						
						test_for_error( nparams == NULL, "Not enough values to perform 'call'!" );
						test_for_error( func == NULL, "Not enough values to perform 'call'!" );
						
						
						IrrealContext *new_ctx = new IrrealContext();
						
						new_ctx->lock_context();
						
						return_value = new IrrealValue();
						return_value->setType( TYPE_SENTINEL );
						return_value->setState( STATE_NOT_YET );
						return_value->setValue( ctx->spawnNewAnonymousStack() );
						
						//printf( "current->peek() = '%s' \n", current->peek()->getValue().c_str() );
						
						new_ctx->setReturnValue( return_value );
						
						IrrealStack *func_stack = ctx->getStack( func->getValue() );
						
						test_for_error( func_stack == NULL, "CALL: Function not found!" );
						
						new_ctx->getCodeStack()->nondestructive_merge( func_stack, true );
						
						size_t N = string_to_integer( nparams->getValue() );
						
						//printf( "nparams: %lu \n", N );
						
						IrrealStack *params = new_ctx->getStack( "PARAMS" );
						for( size_t i = 0 ; i < N ; ++i ){
							IrrealValue *p = current->pop();
							test_for_error( p == NULL, "Not enough values to perform 'call'!" );
							if( p->getType() == TYPE_SYMBOL ){
								std::string stack_name = ctx->spawnNewAnonymousStack();
								IrrealStack *pstack = ctx->getStack( stack_name );
								IrrealStack *target_stack = ctx->getStack( p->getValue() );
								
								test_for_error( pstack == NULL, "CALL: Unable to spawn new anonymous stack!" );
								test_for_error( target_stack == NULL, "CALL: Undefined symbol!" );
								
								pstack->nondestructive_merge( target_stack, false );
								params->push( new IrrealValue( TYPE_SYMBOL, STATE_OK, stack_name ) );
								}
							else{
								params->push( p );
								}
								
							}
						//printf( "Calling with params: "); params->_debug_print();
						
						//printf( "Merging scope...\n" );
						
						new_ctx->mergeScope( ctx->getScope() );
						
						new_ctx->unlock_context();
						
						pthread_mutex_lock( &global_vm_queue_lock );
						global_vm_queue.push_front( new_ctx->get_id() );
						pthread_mutex_unlock( &global_vm_queue_lock );
						
						pthread_mutex_lock( &global_running_vms_lock );
							++global_running_vms;
						pthread_mutex_unlock( &global_running_vms_lock );
						
						
						current->push( return_value );
						//printf( "current->peek() = '%s' \n", current->peek()->getValue().c_str() );
						
					}
					break;
					
					case CMD_JOIN:
						ctx->setState( STATE_JOINING );
						done = true;
						pthread_mutex_lock( &global_vm_queue_lock );
						global_vm_queue.push_back( ctx->get_id() );
						pthread_mutex_unlock( &global_vm_queue_lock );
						
					break;
					
					case CMD_ADD:
					{
						IrrealValue *first, *second, *value;
						first = current->pop();
						second = current->pop();
						
						test_for_error( first == NULL, "Not enough values to perform 'add'!" );
						test_for_error( second == NULL, "Not enough values to perform 'add'!" );
						
						
						value = new IrrealValue();
						value->setType( TYPE_INTEGER );
						value->setValue( integer_to_string( string_to_integer( first->getValue() ) + string_to_integer( second->getValue() ) ) );
						
						current->push( value );
					}
					break;
					
					case CMD_PRINT:
					{
						IrrealValue *value;
						value = current->pop();
						test_for_error( value == NULL, "Not enough values to perform 'print'!" );
						printf( "print: type = %i, state = %i, value = '%s' \n", value->getType(), value->getState(), value->getValue().c_str() );
						
					}
					break;
					
					case CMD_SYNC:
						ctx->setState( STATE_SYNCING );
						done = true;
						pthread_mutex_lock( &global_vm_queue_lock );
						global_vm_queue.push_back( ctx->get_id() );
						pthread_mutex_unlock( &global_vm_queue_lock );
					break;
					
					case CMD_DUP:
					{
						IrrealValue *value, *new_value;
						value = current->pop();
						test_for_error( value == NULL, "Not enough values to perform 'dup'!" );
						new_value = new IrrealValue( value->getType(), value->getState(), value->getValue() );
					
						current->push( value );
						current->push( new_value );
					}
					break;

					case CMD_WHILE:
					{
						IrrealValue *test, *body;
						
						
/*
{...} {some tests} while

some tests
{ ... 
* {...} {some tests} while 
} {} if

*/
						test = current->pop();
						body = current->pop();
						
						test_for_error( test == NULL, "Not enough values to perform 'while'!" );
						test_for_error( body == NULL, "Not enough values to perform 'while'!" );
						
						
						IrrealStack *new_code = new IrrealStack();
						IrrealStack *test_stack = ctx->getStack( test->getValue() );
						IrrealStack *body_stack = ctx->getStack( body->getValue() );
						
						test_for_error( test_stack == NULL, "Invalid test stack for 'while'!" );
						test_for_error( body_stack == NULL, "Invalid body stack for 'while'!" );
						
						new_code->nondestructive_merge( test_stack, true );
						 						
						new_code->push( new IrrealValue( CMD_BEGIN, STATE_OK, "" ) );
						new_code->nondestructive_merge( body_stack, true );
						new_code->push( body );
						new_code->push( test );
						new_code->push( new IrrealValue( CMD_WHILE, STATE_OK, "" ) );
						new_code->push( new IrrealValue( CMD_END, STATE_OK, "" ) );
						new_code->push( new IrrealValue( CMD_BEGIN, STATE_OK, "" ) );
						new_code->push( new IrrealValue( CMD_END, STATE_OK, "" ) );
						new_code->push( new IrrealValue( CMD_IF, STATE_OK, "" ) );
						
						
						
						//printf( "while: new_code: " ); new_code->_debug_print();
						
						code->merge( new_code, false );
						
						delete new_code;
					}
					break;
					
					case CMD_IF:
					{
						IrrealValue *test, *block_true, *block_false;
							
						block_false = current->pop();
						block_true = current->pop();
						test = current->pop();
						
						test_for_error( block_false ==  NULL, "Not enough values to perform 'if'!" );
						test_for_error( block_true ==  NULL, "Not enough values to perform 'if'!" );
						test_for_error( test ==  NULL, "Not enough values to perform 'if'!" );
						
						
						IrrealStack *stack_true, *stack_false;
						
						stack_true = ctx->getStack( block_true->getValue() );
						stack_false = ctx->getStack( block_false->getValue() );
						
						test_for_error( stack_true == NULL, "IF: Stack (true) not found!" );
						test_for_error( stack_false == NULL, "IF: Stack (false) not found!" );
						
						
						//printf( "if: stack_true: " ); stack_true->_debug_print();
						//printf( "if: stack_false: " ); stack_false->_debug_print();
						
						//if( test == NULL ){ printf( "if: test: null!\n" ); } 
						//printf( "if: test value: %li \n", string_to_integer( test->getValue() ) );
						
						if( string_to_integer( test->getValue() ) ){
							
							code->nondestructive_merge( stack_true, false );
							}
						else{
							code->nondestructive_merge( stack_false, false );
							}
						
					}
					break;
					
					case CMD_SUB:
					{
						IrrealValue *first, *second, *value;
						second = current->pop();
						first = current->pop();
						
						test_for_error( first == NULL, "Not enough values to perform 'sub'!" );
						test_for_error( second == NULL, "Not enough values to perform 'sub'!" );
						
						
						value = new IrrealValue();
						value->setType( TYPE_INTEGER );
						value->setValue( integer_to_string( string_to_integer( first->getValue() ) - string_to_integer( second->getValue() ) ) );
						
						current->push( value );
					}
					break;

					case CMD_MUL:
					{
						IrrealValue *first, *second, *value;
						first = current->pop();
						second = current->pop();
						
						test_for_error( first == NULL, "Not enough values to perform 'mul'!" );
						test_for_error( second == NULL, "Not enough values to perform 'mul'!" );
						
						
						value = new IrrealValue();
						value->setType( TYPE_INTEGER );
						value->setValue( integer_to_string( string_to_integer( first->getValue() ) * string_to_integer( second->getValue() ) ) );
						
						current->push( value );
					}
					break;

					case CMD_DIV:
					{
						IrrealValue *first, *second, *value;
						second = current->pop();
						first = current->pop();
						
						test_for_error( first == NULL, "Not enough values to perform 'div'!" );
						test_for_error( second == NULL, "Not enough values to perform 'div'!" );
						
						
						value = new IrrealValue();
						value->setType( TYPE_INTEGER );
						value->setValue( integer_to_string( string_to_integer( first->getValue() ) / string_to_integer( second->getValue() ) ) );
						
						current->push( value );
					}
					break;

					case CMD_MOD:
					{
						IrrealValue *first, *second, *value;
						second = current->pop();
						first = current->pop();
						
						test_for_error( first == NULL, "Not enough values to perform 'mod'!" );
						test_for_error( second == NULL, "Not enough values to perform 'mod'!" );
						
						value = new IrrealValue();
						value->setType( TYPE_INTEGER );
						value->setValue( integer_to_string( string_to_integer( first->getValue() ) % string_to_integer( second->getValue() ) ) );
						
						current->push( value );
					}
					break;

					case CMD_LENGTH:
					{
						IrrealValue *value;
						value = current->pop();
						
						test_for_error( value == NULL, "Not enough values to perform 'length'!" );
						
						current->push( new IrrealValue( TYPE_INTEGER, STATE_OK, integer_to_string( ctx->getStack( value->getValue() )->size() ) ) );
					
					}
					break;
					
					case CMD_MACRO:
					{
						IrrealValue *value;
						value = current->pop();
						
						test_for_error( value == NULL, "Not enough values to perform 'macro'!" );
						
						//printf( "MACRO: debug: stack name = '%s'\n", value->getValue().c_str() );
						
						IrrealStack *source_stack = ctx->getStack( value->getValue() );
						
						test_for_error( source_stack == NULL, "MACRO: Invalid source stack!" );
						
						code->nondestructive_merge( source_stack, true );
						
					}
					break;
					
					case CMD_SWAP:
					{
						IrrealValue *stack_name, *value0, *value1;
						IrrealStack *target_stack;
						
						stack_name = current->pop();
						
						test_for_error( stack_name == NULL, "Not enough values to perform 'swap'!" );
						
						target_stack = ctx->getStack( stack_name->getValue() );
						
						test_for_error( target_stack == NULL, "SWAP: Invalid stack!" );
						
						value0 = target_stack->pop();
						value1 = target_stack->pop();
						
						test_for_error( value0 == NULL, "SWAP: Not enough values in target stack!" );
						test_for_error( value1 == NULL, "SWAP: Not enough values in target stack!" );
						
						target_stack->push( value0 );
						target_stack->push( value1 );
						
					
					}
					break;
					
					case CMD_ROTR:
					{
						
					
					}
					break;
					
					default:
					break;
					}
				}
			else{
				current->push( q );
				}
			}
		
		}
	
	
	ctx->unlock_context();
	}