/* public */
Clazz.superConstructor = function (objThis, clazzThis, funParams) {
Clazz.superCall (objThis, clazzThis, "construct", funParams);
/* If there are members which are initialized out of the constructor */
if (clazzThis.con$truct != null) {
clazzThis.con$truct.apply (objThis, []);
}
};
/**
* Call this constructor of the class.
* The same effect as Java's expression:
* <code> this (*) </code>
*
* @param objThis host object
* @param clazzThis class of declaring method scope.
* @param funParams Array of method parameters
*/
/* public */
Clazz.thisConstructor = function (objThis, clazzThis, funParams) {
var funName = "construct";
var fx = null;
var i = -1;
var clazzFun = objThis[funName];
if (clazzFun != null) {
if (clazzFun.claxxOwner != null) {
// claxxOwner is a mark for methods that is single.
if (clazzFun.claxxOwner !== clazzThis) {
// This is a single method, call directly!
fx = clazzFun;
}
} else if (clazzFun.stacks == null && !(clazzFun.lastClaxxRef != null
&& clazzFun.lastClaxxRef.prototype[funName] != null
&& clazzFun.lastClaxxRef.prototype[funName].stacks != null)) { // super.toString
fx = clazzFun;
} else { // normal wrapped method
var stacks = clazzFun.stacks;
if (stacks == null) {
stacks = clazzFun.lastClaxxRef.prototype[funName].stacks;
}
var length = stacks.length;
for (i = length - 1; i >= 0; i--) {
/*
* Once super call is computed precisely, there are no need
* to calculate the inherited level but just an equals
* comparision
*/
//var level = Clazz.getInheritedLevel (clazzThis, stacks[i]);
if (clazzThis === stacks[i]) { // level == 0
fx = stacks[i].prototype[funName];
break;
}
} // end of for loop
} // end of normal wrapped method
} // end of clazzFun != null
if (fx != null) {
/* there are members which are initialized out of the constructor */
if (i == 0) {
var ss = clazzFun.stacks;
if (ss != null && ss[0].superClazz == null
&& ss[0].con$truct != null) {
ss[0].con$truct.apply (objThis, []);
}
}
/*# {$no.debug.support} >>x #*/
if (Clazz.tracingCalling) {
var caller = arguments.callee.caller;
if (caller === Clazz.thisConstructor) {
caller = caller.arguments.callee.caller;
}
Clazz.pu$hCalling (new Clazz.callingStack (caller, clazzThis));
var ret = fx.apply (objThis, (funParams == null) ? [] : funParams);
Clazz.p0pCalling ();
return ret;
}
/*# x<< #*/
return fx.apply (objThis, (funParams == null) ? [] : funParams);
} else {
/* there are members which are initialized out of the constructor */
/*
if (i == -1) {
// should be ignore as there are codes calling con$truct in
// #superConstructor
} else {
// unreachable
//var ss = clazzFun.stacks;
//if (ss != null && ss[0].superClazz == null
// && ss[0].con$truct != null) {
// ss[0].con$truct.apply (objThis, []);
//}
}
*/
/* No this constructor! */
return ;
}
throw new Clazz.MethodNotFoundException (objThis, clazzThis, funName,
Clazz.getParamsType (funParams).typeString);
};
public boolean visit(ConstructorInvocation node) { IMethodBinding constructorBinding = node.resolveConstructorBinding(); if (constructorBinding == null) { return false; } buffer.append("Clazz.thisConstructor (this, "); buffer.append(assureQualifiedName(shortenQualifiedName(getFullClassName()))); IMethodBinding methodDeclaration = null; if (constructorBinding != null) { methodDeclaration = constructorBinding.getMethodDeclaration(); } visitMethodParameterList(node.arguments(), methodDeclaration, true, ", [", "]"); buffer.append(");\r\n"); /* buffer.append("this.construct ("); IMethodBinding methodDeclaration = null; IMethodBinding constructorBinding = node.resolveConstructorBinding(); if (constructorBinding != null) { methodDeclaration = constructorBinding.getMethodDeclaration(); } visitMethodParameterList(node.arguments(), methodDeclaration, true, null, null); buffer.append(");\r\n"); // */ return false; }
--
You received this message because you are subscribed to the Google Groups "Java2Script" group.
To unsubscribe from this group and stop receiving emails from it, send an email to java2script...@googlegroups.com.
To post to this group, send email to java2...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/java2script/25d9d7b1-4e52-46dc-997c-a146478b6f47%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.