Re: Record Types and Arrays

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3 March 2011 20:30, Ian Lance Taylor <iant@xxxxxxxxxx> wrote:
> Philip Herron <redbrain@xxxxxxxxxxx> writes:
>
>>   tree callable_var_decl = build_decl (BUILTINS_LOCATION,VAR_DECL,
>>                                      get_identifier("__gpy_module_main_callables"),
>>                                      array_type);
>>
>>  DECL_ARTIFICIAL (callable_var_decl) = 1;
>>   TREE_STATIC (callable_var_decl) = 1;
>>   TREE_PUBLIC (callable_var_decl) = 1;
>>   TREE_USED (callable_var_decl) = 1;
>>
>> I get gimple dump output (although you dont see toplevel decls in
>> gimple for some reason) but no assembler output. I am not quite sure
>> what i am doing wrong with this.
>
> Did you call rest_of_decl_compilation, or pass this in the array you
> pass to wrapup_global_declarations and friends?  Everything else looks
> OK as far as I can see.
>


Hey

Thanks yeah i found my problem now, it wasnt to do with the var_decl
or anything but the data i was trying to put in:

tree array_type = build_array_type (gpy_callable_type,
				      build_index_type (build_int_cst
							(integer_type_node,
							 VEC_length(tree,gpy_function_decls))) );

  tree callable_var_decl = build_decl (BUILTINS_LOCATION,VAR_DECL,
				       get_identifier("__gpy_module_main_callables"),
				       array_type);

  DECL_ARTIFICIAL (callable_var_decl) = 1;
  TREE_STATIC (callable_var_decl) = 1;
  TREE_PUBLIC (callable_var_decl) = 1;
  TREE_USED (callable_var_decl) = 1;

  VEC(constructor_elt,gc) *array_data = NULL;

  int iax = 0;
  for (idx = 0; VEC_iterate (tree,gpy_function_decls,idx,itx); ++idx)
    {
      tree id = DECL_NAME (itx);
      gcc_assert (TREE_CODE(id) == IDENTIFIER_NODE);
      error("function <%q+E>!\n", itx);


      tree elt = gpy_init_callable_record (DECL_NAME(itx), 0, itx);
      CONSTRUCTOR_APPEND_ELT (array_data, build_index_type (build_int_cst
							    (integer_type_node,
							     iax)),
			      elt);
      iax++;
      debug_tree (elt);
    }

  tree array = build_constructor (array_type, array_data);
  DECL_INITIAL (callable_var_decl) = array;

  rest_of_decl_compilation (callable_var_decl,1,0);
  VEC_safe_push (tree,gc,global_decls,callable_var_decl);

The bit i comment out was causing the problem i am just not sure how i
go about doing

struct foo = { 1, 2, 3 }

i thought i could use that constructor_elt but maybe this is not the
way to go about doing that. And then again i need struct foo[] = {
{1,2,3}, {....} }
Hopefully some of this makes sense and sorry for the late reply had
patchy Internet this last 2 days.

--Phil



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux