コード例 #1
0
ファイル: chor.c プロジェクト: choreos/ChoreographySimulator
int service_cordel(int argc,char *argv[]){
    chor_method_data list_methods[12];
    int list_methods_len = 0;
    char mailbox[50];
    strcpy(mailbox,argv[1]);
    XBT_INFO("created service %s",mailbox);
    int count_arg = 2;
    while(count_arg < argc){
	//add method
	if(strcmp(argv[count_arg],"method") == 0){
	    count_arg++;
	    make_chor_method(&list_methods[list_methods_len],argv[count_arg],argv[count_arg+1],argv[count_arg+2]);

	    XBT_INFO("method: %s",argv[count_arg]);
	    count_arg = count_arg+3;
	    //add instructions
	    int number_of_instruction = 0;
	    while(strcmp(argv[count_arg],"method") != 0){
		if(strcmp(argv[count_arg],"invoke") == 0){
		    make_instruction(&list_methods[list_methods_len].instructions[number_of_instruction],INVOKE,argv[count_arg+1],argv[count_arg+2],atof(argv[count_arg+3]));
		    count_arg = count_arg+4;
		}else if(strcmp(argv[count_arg],"invoke_a") == 0){
		    make_instruction(&list_methods[list_methods_len].instructions[number_of_instruction],INVOKE_A,argv[count_arg+1],argv[count_arg+2],atof(argv[count_arg+3]));
		    count_arg = count_arg+4;
		}else if(strcmp(argv[count_arg],"exec") == 0){
			list_methods[list_methods_len].instructions[number_of_instruction].type = EXEC;
			count_arg++;
		}else if(strcmp(argv[count_arg],"wait") == 0){
			list_methods[list_methods_len].instructions[number_of_instruction].type = WAIT;
			count_arg++;
		}else if(strcmp(argv[count_arg],"return") == 0){
			list_methods[list_methods_len].instructions[number_of_instruction].type = RETURN;
			count_arg++;
		    }else{
			XBT_WARN("parser arguments error");
			return 1;}
		number_of_instruction++;
		if(count_arg >= argc){
		    break;
		}
	    }
	    list_methods[list_methods_len].instructions_len = number_of_instruction;
	    list_methods_len++;
	}
    }
    
    run_service_cordel(list_methods_len,list_methods,mailbox);
}
コード例 #2
0
instruction* str_to_instrction(char *str1) {

	char* pch;
	char** all_tokens;
	char** all_tokens_tmp;

	printf("%s\n",str1);

	pch = strtok(str1, separatorns);

	if (pch != NULL ) {
		all_tokens = (char**) malloc(sizeof(char**));
		all_tokens_tmp = all_tokens;
	} else {
		return NULL ;
	}

	while (pch != NULL ) {

		*all_tokens_tmp = pch;
		all_tokens_tmp++;

		pch = strtok(NULL, separatorns);
	}

	*all_tokens_tmp = NULL;
	// debug


	all_tokens_tmp = NULL;
	instruction* inst = make_instruction(all_tokens);

	return inst;

}
コード例 #3
0
ファイル: crx-dis.c プロジェクト: cooljeanius/apple-gdb-1824
/* Prints the instruction by calling print_arguments after proper matching: */
int
print_insn_crx(bfd_vma memaddr, struct disassemble_info *info)
{
  int is_decoded;     /* Nonzero means instruction has a match.  */

  /* Initialize global variables: */
  cst4flag = 0;
  size_changed = 0;

  /* Retrieve the encoding from current memory location: */
  get_words_at_PC(memaddr, info);
  /* Find a matching opcode in table: */
  is_decoded = match_opcode();
  /* If found, print the instruction's mnemonic and arguments: */
  if ((is_decoded > 0) && (((words[0] << 16) != 0) || (words[1] != 0)))
    {
      info->fprintf_func(info->stream, "%s", instruction->mnemonic);
      if ((currInsn.nargs = get_number_of_operands()) != 0)
	info->fprintf_func(info->stream, "\t");
      make_instruction();
      print_arguments(&currInsn, memaddr, info);
      return currInsn.size;
    }

  /* No match found: */
  info->fprintf_func(info->stream, "%s ", ILLEGAL);
  return 2;
}
コード例 #4
0
ファイル: FloatInstructions.cpp プロジェクト: vsekhar/push
void initFloat() {
    Type binaryFloat = floatType + floatType;

    make_instruction(plus<double>,"FLOAT.+", binaryFloat, floatType);
    make_instruction(minus<double>,"FLOAT.-", binaryFloat, floatType);
    make_instruction(multiplies<double>, "FLOAT.*", binaryFloat, floatType);
    make_instruction(divides<double>, "FLOAT./", binaryFloat, floatType);
    make_instruction(bool2float, "FLOAT.FROMBOOLEAN", boolType, floatType);
    make_instruction(int2float, "FLOAT.FROMINTEGER", integerType, floatType);
    make_instruction(_fmod,"FLOAT.%", binaryFloat, floatType);
    make_instruction(smaller<double>,"FLOAT.<", binaryFloat, boolType);
    make_instruction(greater<double>, "FLOAT.>", binaryFloat, boolType);
    make_instruction(_max<double>, "FLOAT.MAX", binaryFloat, floatType);
    make_instruction(_min<double>, "FLOAT.MIN", binaryFloat, floatType);
    make_instruction(_cos, "FLOAT.COS", floatType, floatType);
    make_instruction(_sin, "FLOAT.SIN", floatType, floatType);
    make_instruction(_tan, "FLOAT.TAN", floatType, floatType);
    make_instruction(rand_float, "FLOAT.RAND", nullType, floatType);
    make_instruction(rand_float, "FLOAT.ERC", nullType, floatType);
}
コード例 #5
0
ファイル: CodeInstructions.cpp プロジェクト: vsekhar/push
void initCode() {
    static bool initialized = false;
    if (initialized) return;
    initialized = true;

    /* CODE */
    Type binaryCode = codeType + codeType;

    make_instruction(_cons, "CODE.CONS", binaryCode, codeType);
    make_instruction(_list, "CODE.LIST", binaryCode, codeType);
    make_instruction(_do, "CODE.DO", codeType, execType);
    make_instruction(_do_star, "CODE.DO*", codeType, execType);
    make_instruction(_quote, "CODE.QUOTE", execType, codeType);
    make_instruction(_if, "CODE.IF", boolType + binaryCode, execType);
    make_instruction(_length, "CODE.LENGTH", codeType, integerType);
    make_instruction(_size, "CODE.SIZE", codeType, integerType);

    make_instruction(_from_T<int>, "CODE.FROMINTEGER", integerType, codeType);
    make_instruction(_from_T<double>, "CODE.FROMFLOAT", floatType, codeType);
    make_instruction(_from_T<bool>, "CODE.FROMBOOLEAN", boolType, codeType);
    make_instruction(_from_T<name_t>, "CODE.FROMNAME", nameType, codeType);

    make_instruction(_instructions, "CODE.INSTRUCTIONS", nullType, codeType);
    make_instruction(_append, "CODE.APPEND", binaryCode, codeType);
    make_instruction(_atom, "CODE.ATOM", codeType, boolType);
    make_instruction(_car, "CODE.CAR", codeType, codeType);
    make_instruction(_cdr, "CODE.CDR", codeType, codeType);
    make_instruction(_container, "CODE.CONTAINER", binaryCode, codeType);
    make_instruction(_extract, "CODE.EXTRACT", codeType+integerType, codeType);
    make_instruction(_insert, "CODE.INSERT", binaryCode+integerType, codeType);
    make_instruction(_member, "CODE.MEMBER", binaryCode, boolType);
    make_instruction(_noop, "CODE.NOOP", nullType, nullType);
    make_instruction(_nth, "CODE.NTH", integerType + codeType, codeType);
    make_instruction(_nthcdr, "CODE.NTHCDR", integerType + codeType, codeType);
    make_instruction(_null, "CODE.NULL", codeType, boolType);
    make_instruction(_position, "CODE.POSITION", binaryCode, integerType);

    make_instruction(rand_code, "CODE.RAND", nullType, codeType);
    make_instruction(rand_code, "CODE.ERC", nullType, codeType);
    
    make_instruction(code_do_range, "CODE.DO*RANGE", integerType+integerType+codeType, execType+execType, false);
    make_instruction(do_count, "CODE.DO*COUNT", integerType+codeType, execType, false);
    make_instruction(do_times, "CODE.DO*TIMES", integerType+codeType, execType, false);
}