Order of build

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Order of build

Cauê W.
Hey guys!

I'm running into a problem when using my 'partials' implementation. It depends on Compiler.include() and needed only to be able to resume building the class after Compiler.include() had included all clases. The matter is that, it seems that sometimes when you reference the class that is currently being built on another class included by Compiler.include, it won't build the included instantly, but will wait for the current build class to finish. I understand that this must have been made like this to avoid circular dependencies on build classes, and I don't think it's a bad thing. I just wanted to know if there is any way I could be able to guarantee that a builded class will only execute after e.g. all classes from Compiler.include have finished building?


To make this a little more clear, here's a concrete example:

@:partial("some.other.pack")
class PartialParent implements PartialClass //<- PartialClass is an autobuild which will execute buildPartial
{

}

package some.other.pack;
class PartialChild implements PartialImplementation<PartialParent> //<- PartialImplementation is an autobuild which will execute buildImplementation
{

public var circularReference:PartialParent;

}


buildImplementation will cache all PartialChild build fields

buildPartial will get those fields and add them to its own fields. In order to do this, it will calll Compiler.include("some.other.pack"), which presumably would call buildImplementation on PartialChild. This works on cases where there's no back-reference to PartialParent, but fails otherwise. Is there a way to ensure the needed build order?

Thanks!
Cauê

--
haXe - an open source web programming language
http://haxe.org