コード例 #1
0
ファイル: execution.c プロジェクト: tomsik68/brainfuck.c
void execute(bf_instruction_t* program, bf_env_t* environment) {
	printf("\n------------------Execution start.---------------------\n");
	bf_instruction_t* currentInstruction = program;
	while(currentInstruction != NULL){
		switch(currentInstruction->type){
			case INC_PTR:
				inc_ptr(environment, currentInstruction->parameters);
				break;
			case DEC_PTR:
				dec_ptr(environment, currentInstruction->parameters);
				break;
			case READ:
				read(environment, currentInstruction->parameters);
				break;
			case PRINT:
				print(environment, currentInstruction->parameters);
				break;
			case PTR_LEFT:
				ptr_left(environment, currentInstruction->parameters);
				break;
			case PTR_RIGHT:
				ptr_right(environment, currentInstruction->parameters);
				break;
			case WHILE:
				/* do nothing */
				if(!(environment->memory[environment->ptr])){
					currentInstruction = currentInstruction->parameters;
				}
				break;
			case ENDWHILE:
				if(environment->memory[environment->ptr]) {
					/* jump back to associated while */
					currentInstruction = currentInstruction->parameters;
				} else {
					/* do nothing, we're continuing in the program */
				}
				break;
		}
		currentInstruction = currentInstruction->next;
	}
	printf("\n------------------Execution end.---------------------\n");
}
コード例 #2
0
ファイル: atomic.hpp プロジェクト: netroby/jdk9-dev
inline void Atomic::dec(volatile size_t* dest) {
    dec_ptr((volatile intptr_t*) dest);
}