Ejemplo n.º 1
0
void print_rows(TopItem *root, int nmemb, int mask_length)
{
	int i;
	void (*print_function)(TopItem *);
	
	if (mask_length == 32)
		print_function = print_row;
	else
		print_function = print_row_agg;
	
	print_function(0);
	for ( i = 0; i < nmemb; ++i, ++root ) {
		print_function(root);
	}
}
Ejemplo n.º 2
0
void print_object (STREAM stream, D instance, BOOL escape_p, int print_depth) {
  enum dylan_type_enum type = dylan_type(instance);
  switch (type) {
    case integer_type:
      print_integer(stream, instance, escape_p, print_depth); break;
    case character_type:
      print_character(stream, instance, escape_p, print_depth); break;
    case float_type:
      print_float (stream, instance, escape_p, print_depth); break;
    case dylan_boolean_type:
      print_boolean(stream, instance, escape_p, print_depth); break;
    case string_type:
      print_string (stream, instance, escape_p, print_depth); break;
    case vector_type:
      print_vector(stream, instance, escape_p, print_depth); break;
    case pair_type:
      print_pair(stream, instance, escape_p, print_depth); break;
    case empty_list_type:
      print_empty_list(stream, instance, escape_p, print_depth); break;
    case symbol_type:
      print_symbol(stream, instance, escape_p, print_depth); break;
    case simple_condition_type:
      print_simple_condition(stream, instance, escape_p, print_depth); break;
    case class_type:
      print_class(stream, instance, escape_p, print_depth); break;
    case function_type:
      print_function(stream, instance, escape_p, print_depth); break;
    case unknown_type:
      format(stream, "?%lx", instance); break;
    default:
      print_user_defined(stream, instance, escape_p, print_depth); break;
  }
}
Ejemplo n.º 3
0
void
xref_output()
{
     Symbol **symbols, *symp;
     size_t i, num;
     
     num = collect_symbols(&symbols, is_var, 0);
     qsort(symbols, num, sizeof(*symbols), compare);
     
     /* produce xref output */
     for (i = 0; i < num; i++) {
	  symp = symbols[i];
	  switch (symp->type) {
	  case SymIdentifier:
	       print_function(symp);
	       break;
	  case SymToken:
	       print_type(symp);
	       break;
	  case SymUndefined:
	       break;
	  }
     }
     free(symbols);
}
static void walk_functions(tree_set *visited, const struct cgraph_node *node)
{
	struct cgraph_edge *e;
	const_tree caller;

	if (!node)
		return;
	caller = NODE_DECL(node);

	if (pointer_set_insert(visited, caller))
		return;

	for (e = node->callees; e; e = e->next_callee) {
		const struct cgraph_node *next_node;
		tree callee = gimple_call_fndecl(e->call_stmt);

		if (DECL_BUILT_IN(callee))
			continue;

		print_function(caller, callee);

		next_node = cgraph_get_node(callee);
		walk_functions(visited, next_node);
	}
}
void print_data(char * filename, void print_function (FILE *, void *, int), double * data, int n, int p, int P)
{
    FILE * fp;
    int dummy = 0xcafe;
    MPI_Status status;

    if (p == 0)
    {
        //Create file
        fp = fopen(filename, "w");
    }
    else
    {
        MPI_Recv(&dummy, 1, MPI_INTEGER, p-1, 88, MPI_COMM_WORLD, &status);
        //Append file
        fp = fopen(filename, "a");
    }
 
    fprintf(fp, "On process P: %d\n", p);
    print_function(fp, data, n);

    fclose(fp);

    if (p != P-1)
    {
        MPI_Send(&dummy, 1, MPI_INTEGER, p+1, 88, MPI_COMM_WORLD);
    }
}
Ejemplo n.º 6
0
void ALL::order_function_big(const int string_length,const int& length_dis,const int ID_length,vector<int>& record_array,int string_score_remain,int flag){
	if(string_score_remain==0){	
		char advise_string[101];
		//cout<<"string_length="<<string_length<<endl;
		strncpy(advise_string,save_used_ID,ID_length);
		advise_string[string_length]='\0';
		//cout<<"advise_string="<<advise_string<<endl;
		int i;
		for(i=ID_length;i<string_length;i++){
			//cout<<"flag="<<flag<<" "<<endl;
			record_array.push_back(i);
		}
		print_function(record_array,advise_string,0);
		for(i;i>ID_length;i--){record_array.pop_back();}
		return;
	}
	if(flag>=string_length){return;}
	//===============================
	if(string_score_remain>=(ID_length-flag)){
		for(flag;flag<ID_length;flag++){
			record_array.push_back(flag);
			order_function_big(string_length,length_dis,ID_length,record_array,string_score_remain-(ID_length-flag),flag+1);
			record_array.pop_back();
		}
	}
	else{
		order_function_big(string_length,length_dis,ID_length,record_array,string_score_remain,flag+1);
	}
	//================================
	
	return;	
}
Ejemplo n.º 7
0
int main()
{
	std::ofstream out_file;
	out_file.open("cpp_mylang.cpp");
	out_file<<"\n#include<iostream>\n\nint main()\n{";
	
	std::ifstream in_file;
	in_file.open("hello-world.mylang");

	std::string line;
	int lno = 1;
	while(getline(in_file, line))
	{
		trim(line);
		if( not line.empty() )
		{
			bool is_semicolon = true;
			std::vector<std::string> tokens = tokenize(line, is_semicolon);

			if(!is_semicolon) {std::cout<<"hello-world.mylang : error "<<lno<<" expected ;\n"; break; } 
			if(not (print_function(tokens, out_file) or scan_function(tokens, out_file)) )
			{
				for(auto s : tokens)
					std::cout<<s;
				std::cout<<"hello-world.mylang :  error line : "<<lno<<"\n" ; 
				break;
			}
		}
		++lno;
	}
	out_file << "\n}";
}
Ejemplo n.º 8
0
int main(void)
{
    struct generic_tag var;

    var.type = CHARACTER;
    var.shared.c = '$';
    print_function( var );

    var.type = FLOAT;
    var.shared.f = (float) 12345.67890;
    print_function( var );

    var.type = 'x';
    var.shared.i = 111;
    print_function( var );
    return 0;
}
Ejemplo n.º 9
0
 void deep_print(const Value& obj,
                 int(*print_function)(json_printer*, int, const char *, uint32_t)) {
     switch (obj.type_) {
         case Type::Null: {
             print_function(&printer_, JSON_NULL, nullptr, 0);
             break;
         }
         case Type::Boolean: {
             print_function(&printer_, obj.value_.bool_val ? JSON_TRUE : JSON_FALSE, nullptr, 0);
             break;
         }
         case Type::Integer: {
             std::string str = detail::to_string(obj.value_.int_val);
             print_function(&printer_, JSON_INT, str.c_str(), static_cast<uint32_t>(str.size()));
             break;
         }
         case Type::Double:{
             std::string str = detail::to_string(obj.value_.dbl_val);
             print_function(&printer_, JSON_FLOAT, str.c_str(), static_cast<uint32_t>(str.size()));
             break;
         }
         case Type::String: {
             print_function(&printer_, JSON_STRING, obj.value_.str_val.c_str(), static_cast<uint32_t>(obj.value_.str_val.size()));
             break;
         }
         case Type::Array: {
             print_function(&printer_, JSON_ARRAY_BEGIN, nullptr, 0);
             Value::const_array_iterator it = obj.value_.arr_val.begin(), end = obj.value_.arr_val.end();
             for (; it != end; ++it) {
                 deep_print(*it, print_function);
             }
             print_function(&printer_, JSON_ARRAY_END, nullptr, 0);
             break;
         }
         case Type::Object: {
             print_function(&printer_, JSON_OBJECT_BEGIN, nullptr, 0);
             Value::const_iterator it = obj.value_.map_val.begin(), end = obj.value_.map_val.end();
             for (; it != end; ++it) {
                 print_function(&printer_, JSON_KEY, it->first.c_str(), static_cast<uint32_t>(it->first.length()));
                 deep_print(it->second, print_function);
             }
             print_function(&printer_, JSON_OBJECT_END, nullptr, 0);
             break;
         }
     }
 }
Ejemplo n.º 10
0
void print_list(List *l, void (*print_function)(void *))
{
	Node *tmp = l->head;
	while (tmp) {
		print_function(tmp->data);
		tmp = tmp->next;
	}
	printf("\n");
}
Ejemplo n.º 11
0
Archivo: print.cpp Proyecto: csll/llvm
void
print(Printer& p, Define_decl const* d)
{
  print_function(p, d, "define");
  print_space(p);
  print(p, '{');
  print_nested(p, d->blocks());
  print(p, '}');
}
Ejemplo n.º 12
0
void __cyg_profile_func_enter (void *func,  void *caller)
{
 	int n;
	depth++;
	for (n = 0; n < depth; n++) printf ("  ");
	printf ("|-> ");
	print_function(func);
	printf ("\n");
}
Ejemplo n.º 13
0
/*Prints s. Behaviour (how to print each element) is defined on print_function*/
void print_stack (stack s, void (*print_function) (void*elem)) {
	pnodos temp = s.first;

	while (temp != NULL) {
		print_function (temp->elem);
		temp = temp->next;
	}
	printf ("\n");

}
Ejemplo n.º 14
0
/*Prints s. Behaviour (how to print each element) is defined on print_function*/
void print_queue (queue s, void (*print_function) (void*elem)) {
	pqnodos temp = s.first;

	while (temp != NULL) {
		print_function (temp->elem);
		temp = temp->next;
	}
	printf ("\n");

}
Ejemplo n.º 15
0
void print_function_set(ADCL_fnctset_t *fnctset)
{
    int i;
    printf("\n");
    printf("Function Set Name: %s", fnctset->fs_name);
    for(i=0;i<(fnctset->fs_maxnum);i++) {
	printf("\n");
	print_function(fnctset->fs_fptrs[i]);
    }
    printf("\n");
}
Ejemplo n.º 16
0
int main()
{


    std::string aString("A simple string");
    std::cout << aString << std::endl;

    print_function(aString.c_str()); 

    return 0;
}
Ejemplo n.º 17
0
void ALL::print_function(vector<int>& record_array,char *advise_string,int flag){
	if(flag>=record_array.size()){return;}
	for(int i=0;i<=61;i++){
		advise_string[ record_array[flag] ]=antiTranslate(i);
		print_function(record_array,advise_string,flag+1);
		int now=translate(advise_string[0]);
		if( findTree(tree[now],advise_string,0,strlen(advise_string)-1)<0 ){
			char *tmp=new char[101];
			strcpy(tmp,advise_string);
			TEN.push_back(tmp);
		}
	}
	return;
}
Ejemplo n.º 18
0
static void
switch_on_type(struct mlist *mlp, struct tdesc *tdp, char *format, int level)
{
	boolean_t allocated = B_FALSE;

	if (format == NULL) {
		allocated = B_TRUE;
		format = uc(mlp->name);
	}

	switch (tdp->type) {
	case INTRINSIC:
		print_intrinsic(mlp, tdp, format, level);
		break;
	case POINTER:
		print_pointer(mlp, tdp, format, level);
		break;
	case ARRAY:
		print_array(mlp, tdp, format, level);
		break;
	case FUNCTION:
		print_function(mlp, tdp, format, level);
		break;
	case UNION:
		print_union(mlp, tdp, format, level);
		break;
	case ENUM:
		print_enum(mlp, tdp, format, level);
		break;
	case FORWARD:
		print_forward(mlp, tdp, format, level);
		break;
	case TYPEOF:
		print_typeof(mlp, tdp, format, level);
		break;
	case STRUCT:
		print_struct(mlp, tdp, format, level);
		break;
	case VOLATILE:
		print_volatile(mlp, tdp, format, level);
		break;
	default:
		fprintf(stderr, "Switch to Unknown type\n");
		error = B_TRUE;
		break;
	}
	if (allocated)
		free(format);
}
Ejemplo n.º 19
0
int	add_function(char *path, char *hpath)
{
  char	*raw;

  if ((raw = get_src(path)) == NULL)
    {
      free(path);
      path = NULL;
      return (-1);
    }
  print_function(raw);
  fprintf(stderr, "Writed %s%s%s'functions into %s%s%s\n", GREEN, path, WHITE, GREEN, hpath, WHITE);
  free(raw);
  free(path);
  path = NULL;
  return (0);
}
Ejemplo n.º 20
0
/*
 * helper functions to print instructions
 */
void print_fop(struct filter_op *fop, u_int32 eip)
{
      switch (fop->opcode) {
         case FOP_TEST:
            print_test(fop, eip);
            break;
            
         case FOP_ASSIGN:
            print_assign(fop, eip);
            break;
            
         case FOP_INC:
            print_inc(fop, eip);
            break;
            
         case FOP_DEC:
            print_dec(fop, eip);
            break;
            
         case FOP_FUNC:
            print_function(fop, eip);
            break;
            
         case FOP_JMP:
            fprintf(stdout, "%04lu: JUMP ALWAYS to %04d\n", (unsigned long)eip, fop->op.jmp);
            break;
            
         case FOP_JTRUE:
            fprintf(stdout, "%04lu: JUMP IF TRUE to %04d\n", (unsigned long)eip, fop->op.jmp);
            break;
            
         case FOP_JFALSE:
            fprintf(stdout, "%04lu: JUMP IF FALSE to %04d\n", (unsigned long)eip, fop->op.jmp);
            break;
            
         case FOP_EXIT:
            fprintf(stdout, "%04lu: EXIT\n", (unsigned long)eip);
            break;
            
         default:
            fprintf(stderr, "UNDEFINED OPCODE (%d) !!\n", fop->opcode);
            exit(-1);
            break;
      }
}
Ejemplo n.º 21
0
 void DisassemblerContext::run_term(const ValuePtr<>& term) {
   switch (term->term_type()) {
   case term_function: {
     ValuePtr<Function> function = value_cast<Function>(term);
     setup_term_name(function);
     setup_function(function);
     build_unique_names();
     print_definitions(m_global_definitions, "", true);
     print_function(function);
     break;
   }
   
   case term_block: {
     ValuePtr<Block> block = value_cast<Block>(term);
     m_in_function_mode = true;
     setup_term_name(block);
     setup_block(block);
     build_unique_names();
     print_block(block, m_global_definitions);
     break;
   }
   
   default:
     m_in_function_mode = true;
     setup_term_definition(term);
     build_unique_names();
     print_definitions(m_global_definitions);
     
     switch (term->term_type()) {
     case term_instruction:
     case term_phi:
     case term_function_parameter:
     case term_recursive:
       print_term_definition(term, true);
       break;
       
     default:
       break;
     }
     break;
   }
 }
Ejemplo n.º 22
0
void ALL::order_function(const int string_length,const int& length_dis,const int ID_length,vector<int>& record_array,int string_score_remain,int flag){
	if(string_score_remain==0){
		char advise_string[101];
		strncpy(advise_string,save_used_ID,string_length);
		advise_string[string_length]='\0';
		//cout<<"advise_string="<<advise_string<<endl;
		int now=translate(advise_string[0]);
		if(record_array.size()==0){
			if(findTree(tree[now],advise_string,0,strlen(advise_string)-1)<0&& strcmp(advise_string," ")!=0){
				char *tmp = new char [101];
				strcpy(tmp, advise_string);
				TEN.push_back(tmp);
			}
		}
		print_function(record_array,advise_string,0);
		return;
	}
	//cout<<"string_length= "<<string_length<<"   "<<"flag= "<<flag<<endl;
	//cout<<"string_score_remain="<<string_score_remain<<endl;
	if(flag>=string_length){return;}
	//===============================
	if(string_score_remain>=(string_length-flag)){
		//cout<<"enter if and  "<<"string_length= "<<string_length<<"   "<<"flag= "<<flag<<endl;
		for(flag;flag<string_length;flag++){
			/*cout<<"string_score_remain="<<string_score_remain<<"   ";
			cout<<"flag= "<<flag<<endl;
			cout<<"string_length-flag="<<string_length-flag<<endl;*/
			record_array.push_back(flag);
			order_function(string_length,length_dis,ID_length,record_array,string_score_remain-(string_length-flag),flag+1);
			record_array.pop_back();
		}
	}
	else{
		//cout<<"enter else"<<endl;
		order_function(string_length,length_dis,ID_length,record_array,string_score_remain,flag+1);
	}
	//================================
	return;
}
Ejemplo n.º 23
0
int print_actions (Action * actions)
{
    printf("\n\nACTION %s:\n", actions->name);
    print_var_list("Parameters", actions->param);
    print_function("Preconditions", actions->pre);
    print_function("Add effects", actions->add);
    print_function("Delete effects", actions->del);
    while (actions->next)
    {
        actions = actions->next;
        printf("\n\nACTION %s:\n", actions->name);
        print_var_list("Parameters", actions->param);
        print_function("Preconditions", actions->pre);
        print_function("Add effects", actions->add);
        print_function("Delete effects", actions->del);
    }
}
Ejemplo n.º 24
0
Archivo: ast.c Proyecto: MatzeB/fluffy
static void print_entity(const entity_t *entity)
{
	print_indent();

	switch (entity->kind) {
	case ENTITY_FUNCTION:
		print_function(&entity->function);
		break;
	case ENTITY_CONCEPT:
		print_concept(&entity->concept);
		break;
	case ENTITY_VARIABLE:
		print_variable(&entity->variable);
		break;
	case ENTITY_TYPEALIAS:
		print_typealias(&entity->typealias);
		break;
	case ENTITY_CONSTANT:
		print_constant(&entity->constant);
		break;
	case ENTITY_CONCEPT_FUNCTION:
	case ENTITY_FUNCTION_PARAMETER:
	case ENTITY_ERROR:
		// TODO
		fprintf(out, "some entity of type '%s'\n",
		        get_entity_kind_name(entity->kind));
		break;

	case ENTITY_TYPE_VARIABLE:
	case ENTITY_LABEL:
		break;

	case ENTITY_INVALID:
		fprintf(out, "invalid entity (%s)\n",
		        get_entity_kind_name(entity->kind));
		break;
	}
}
Ejemplo n.º 25
0
Archivo: print.cpp Proyecto: csll/llvm
void
print(Printer& p, Declare_decl const* d)
{
  print_function(p, d, "declare");
}
Ejemplo n.º 26
0
 void DisassemblerContext::print_term_definition(const ValuePtr<>& term, bool global) {
   *m_output << name(term) << " = ";
   
   switch (term->term_type()) {
   case term_functional: {
     if (global)
       *m_output << "define ";
     print_functional_term(value_cast<FunctionalValue>(term), false);
     *m_output << ";\n";
     break;
   }
   
   case term_function_type: {
     if (global)
       *m_output << "define ";
     print_function_type_term(value_cast<FunctionType>(term), false);
     *m_output << ";\n";
     break;
   }
   
   case term_instruction: {
     print_instruction_term(value_cast<Instruction>(term));
     break;
   }
   
   case term_phi: {
     print_phi_term(value_cast<Phi>(term));
     break;
   }
   
   case term_global_variable: {
     ValuePtr<GlobalVariable> gvar = value_cast<GlobalVariable>(term);
     *m_output << "global ";
     if (gvar->constant())
       *m_output << "const ";
     print_term(gvar->value_type(), true);
     if (gvar->value()) {
       *m_output << ' ';
       print_term(gvar->value(), true);
     }
     *m_output << ";\n";
     return;
   }
   
   case term_function: {
     print_function(value_cast<Function>(term));
     return;
   }
   
   case term_function_parameter: {
     ValuePtr<FunctionParameter> parameter = value_cast<FunctionParameter>(term);
     ValuePtr<Function> function = parameter->function();
     unsigned n = 0;
     for (Function::ParameterList::const_iterator ii = function->parameters().begin(), ie = function->parameters().end(); ii != ie; ++ii, ++n) {
       if (parameter == *ii) {
         *m_output << "[function parameter " << n << "]\n";
         return;
       }
     }
     *m_output << "[invalid function parameter]\n";
     return;
   }
   
   case term_apply: {
     if (global)
       *m_output << "define ";
     print_apply_term(value_cast<ApplyType>(term), false);
     *m_output << ";\n";
     return;
   }
   
   case term_exists: {
     if (global)
       *m_output << "define ";
     print_exists(value_cast<Exists>(term), false);
     *m_output << ";\n";
     return;
   }
   
   case term_recursive: {
     print_recursive(value_cast<RecursiveType>(term));
     return;
   }
   
   case term_recursive_parameter: *m_output << "[recursive parameter]\n"; return;
   case term_parameter_placeholder: *m_output << "[parameter placeholder]\n"; return;
   case term_upref_null: *m_output << "upref_null\n"; return;
     
   default:
     PSI_FAIL("unexpected term type - cannot print a definition");
   }
 }