* @see railo.transformer.cfml.evaluator.EvaluatorSupport#evaluate(org.w3c.dom.Element, railo.transformer.library.tag.TagLibTag)
*/
public void evaluate(Tag tag,TagLibTag tlt) throws EvaluatorException {
Statement pPage = tag.getParent();
String className=tag.getTagLibTag().getTagClassName();
// is direct in document
if(!(pPage instanceof Page)){
// is script Component
Tag p = ASMUtil.getParentTag(tag);
if(p.getTagLibTag().getName().equals("script") && (pPage = p.getParent()) instanceof Page){
// move imports from script to component body
List children = p.getBody().getStatements();
Iterator it = children.iterator();
Statement stat;
Tag t;
while(it.hasNext()){
stat=(Statement) it.next();
if(!(stat instanceof Tag)) continue;
t=(Tag) stat;
if(t.getTagLibTag().getName().equals("import")){
tag.getBody().addStatement(t);
}
}
// replace script with component
ASMUtil.replace(p, tag, false);
}
else
throw new EvaluatorException("Wrong Context, tag "+tlt.getFullName()+" can't be inside other tags, tag is inside tag "+p.getFullname());
}
Page page=(Page) pPage;
// is inside a file named cfc
String src=page.getSource();
int pos=src.lastIndexOf(".");
if(!(pos!=-1 && pos<src.length() && src.substring(pos+1).equals("cfc")))
throw new EvaluatorException("Wrong Context, "+tlt.getFullName()+" tag must be inside a file with extension cfc");
// check if more than one component in document and remove any other data
List stats = page.getStatements();
Iterator it = stats.iterator();
Statement stat;
int count=0;
while(it.hasNext()) {
stat=(Statement) it.next();
if(stat instanceof Tag) {
tag=(Tag) stat;