This info is gold. I have much clearer understanding now. Thanks, André
On Wed, Apr 12, 2017 at 2:45 PM, Richard Biener <richard.guent...@gmail.com> wrote: > On Wed, Apr 12, 2017 at 2:07 PM, Andre Groenewald > <adres.is.ge...@gmail.com> wrote: >> Thanks for the help. I just want to elaborate just a bit. >> >> So if I understand it correctly, only the function in my case are >> gimplified or the starting point. >> >> Lets say I initialised classVariable 10 outside a function. >> tree setVariable = build2(INIT_EXPR, void_type_node, >> classVariableDecl, build_int_cst_type(integer_type_node, 10)); >> assume setVariable ends up in the statement list of TestClass correctly. >> >> Does it means that gcc will follow the chain from testFunc to >> TestClass (DECL_CONTEXT(testFunc) = TestClass) and then follows the >> stament list of TestClass ending up initialising classVariable by only >> submitting testFunc to gimple? > > No. You have to add that to the function body. The only way to initialize > variables outside of function bodies is via DECL_INITIAL and that only > works for globals and constant initializers. > > Richard. > >> Regards, >> André >> >> On Wed, Apr 12, 2017 at 10:36 AM, Richard Biener >> <richard.guent...@gmail.com> wrote: >>> On April 12, 2017 10:24:31 AM GMT+02:00, Andre Groenewald >>> <adres.is.ge...@gmail.com> wrote: >>>>I am a bit stuck on global, file and local name spaces and scopes. >>>> >>>>Normally my expression bindings is associated with a function, which >>>>makes the function the scope of all the variables. >>>> >>>>my front end can parse something like this: >>>> >>>>int testfunc(int parmVar) >>>>{ >>>> int testfuncVar; >>>>} >>>> >>>>int testfunc2(int funcVar) >>>>{ >>>> int testfuncVar2; >>>>} >>>> >>>>Every function is individually gimplified and added and finalized. >>>>Everything is chained and bind correctly. >>>> >>>>parser->Fndecl = build_fn_decl(functionName, fnDeclType); >>>>.... >>>>gimplify_function_tree(parser->Fndecl); >>>>cgraph_node::finalize_function(parser->Fndecl, true); >>>> >>>>I want to expand my front end to something like this: >>>> >>>>module TestModule >>>>{ >>>> int moduleVariable; >>>> class TestClass >>>> { >>>> int classVariable; >>>> int testfunc(int parmVar) >>>> { >>>> int testfuncVar; >>>> } >>>> } >>>>} >>>> >>>>The question is what should TestModule be declared as, what tree type >>>>or declaration function, and also TestClass. How should TestModule be >>>>gimplified and then finalized. >>> >>> TestModule should be context of TestClass which should be context of >>> testFunc which is the only thing gimplified. >>> >>> For TestModule you have the choice of NAMESPACE_DECL and >>> TRANSLATION_UNIT_DECL. >>> >>> Richard. >>> >>>>Thank you >>>>André >>>