Java Reference
In-Depth Information
CLEmitterpartial=newCLEmitter();
//Addtheclassheadertothepartialclass
StringqualifiedName=
JAST.compilationUnit.packageName()==""?name:
JAST.compilationUnit.packageName()+"/"+name;
partial.addClass(mods,qualifiedName,superType.jvmName(),
null,false);
//Pre-analyzethemembersandaddthemtothepartialclass
for(JMembermember:classBlock){
member.preAnalyze(this.context,partial);
if(memberinstanceofJConstructorDeclaration&&
((JConstructorDeclaration)member).
params.size()==0){
hasExplicitConstructor=true;
}
}
//Addtheimplicitemptyconstructor?
if(!hasExplicitConstructor){
codegenPartialImplicitConstructor(partial);
}
//GettheClassrepforthe(partial)classandmakeitthe
//representationforthistype
Typeid=this.context.lookupType(name);
if(id!=null&&
!JAST.compilationUnit.errorHasOccurred()){
id.setClassRep(partial.toClass());
}
}
4.4.4 JMethodDeclaration.preAnalyze()
Here is the code for preAnalyze() in JMethodDeclaration :
publicvoidpreAnalyze(Contextcontext,CLEmitterpartial){
//Resolvetypesoftheformalparameters
for(JFormalParameterparam:params){
param.setType(param.type().resolve(context));
}
//Resolvereturntype
returnType=returnType.resolve(context);
//Checkproperlocaluseofabstract
if(isAbstract&&body!=null){
JAST.compilationUnit.reportSemanticError(line(),
"abstractmethodcannothaveabody");
}
elseif(body==null&&!isAbstract){
JAST.compilationUnit.reportSemanticError(line(),
"Methodwithnullbodymustbeabstract");
}
elseif(isAbstract&&isPrivate){
JAST.compilationUnit.reportSemanticError(line(),
"privatemethodcannotbedeclaredabstract");
}
elseif(isAbstract&&isStatic){
JAST.compilationUnit.reportSemanticError(line(),
"staticmethodcannotbedeclaredabstract");
 
Search WWH ::




Custom Search