Package railo.transformer.bytecode.statement.tag

Examples of railo.transformer.bytecode.statement.tag.Tag


    Body body=tag.getBody();
    if(body!=null) {
          List<Statement> list = body.getStatements();
          Statement[] stats = list.toArray(new Statement[list.size()]);
          PrintOut po;
          Tag t;
          for(int i=0;i<stats.length;i++) {
              if(stats[i] instanceof PrintOut) {
                po=(PrintOut) stats[i];
                if(po.getExpr() instanceof Literal) {
                  body.getStatements().remove(po);
                }
              }
              else if(recursive && stats[i] instanceof Tag) {
                t=(Tag) stats[i];
                if(t.getTagLibTag().isAllowRemovingLiteral()) {
                  removeLiterlChildren(t, recursive);
                }
              }
            }
        }
View Full Code Here


        adapter.returnValue();
        adapter.endMethod();
  
    // newInstance/initComponent/call
        if(isComponent()) {
          Tag component=getComponent();
             writeOutNewComponent(statConstr,constr,keys,cw,component);
          writeOutInitComponent(statConstr,constr,keys,cw,component);
        }
        else if(isInterface()) {
          Tag interf=getInterface();
             writeOutNewInterface(statConstr,constr,keys,cw,interf);
          writeOutInitInterface(statConstr,constr,keys,cw,interf);
        }
        else {
          writeOutCall(statConstr,constr,keys,cw);
View Full Code Here

  }

  private Tag getComponent() throws BytecodeException {
    Iterator it = getStatements().iterator();
    Statement s;
    Tag t;
        while(it.hasNext()) {
          s=(Statement)it.next();
          if(s instanceof Tag) {
            t=(Tag)s;
            if(t.getTagLibTag().getTagClassName().equals("railo.runtime.tag.Component"))return t;
          }
        }
    throw new BytecodeException("missing component",getStart());
  }
View Full Code Here

    throw new BytecodeException("missing component",getStart());
  }
  private Tag getInterface() throws BytecodeException {
    Iterator it = getStatements().iterator();
    Statement s;
    Tag t;
        while(it.hasNext()) {
          s=(Statement)it.next();
          if(s instanceof Tag) {
            t=(Tag)s;
            if(t.getTagLibTag().getTagClassName().equals("railo.runtime.tag.Interface"))return t;
          }
        }
    throw new BytecodeException("missing interface",getStart());
  }
View Full Code Here

       }
      appendix=StringUtil.removeStartingIgnoreCase(strNameNormal,tagLibTag.getName());
     }
   
    // CFXD Element
    Tag tag;
    try {
      tag = tagLibTag.getTag(line,data.cfml.getPosition());
    }
    catch (Exception e) {
      throw new TemplateException(data.cfml,e);
    }
    parent.addStatement(tag);
   
    // get tag from tag library
     if(appendix!=null)  {
      tag.setAppendix(appendix);
      tag.setFullname(tagLibTag.getFullName().concat(appendix));
     }
     else {
       tag.setFullname(tagLibTag.getFullName());    
     }
     if(tag.getFullname().equalsIgnoreCase("cfcomponent"))data.page.setIsComponent(true)// MUST to hardcoded, to better
     else if(tag.getFullname().equalsIgnoreCase("cfinterface"))data.page.setIsInterface(true)// MUST to hardcoded, to better
      
    tag.setTagLibTag(tagLibTag);
    comment(data.cfml,true);
   
    // Tag Translator Evaluator
    if(tagLibTag.hasTteClass())  {
      data.ep.add(tagLibTag,tag,data.flibs,data.cfml);
    }
   
    //get Attributes
    attributes(data,tagLibTag,tag);
   
    if(tagLibTag.hasAttributeEvaluator()) {
      try {
        tagLibTag=tagLibTag.getAttributeEvaluator().evaluate(tagLibTag,tag);
      } catch (AttributeEvaluatorException e) {
       
        throw new TemplateException(data.cfml, e);
      }
    }
   
   
   
    // End of begin Tag
//    TODO muss erlaubt sein
    if(data.cfml.forwardIfCurrent('>'))  {
      hasBody=tagLibTag.getHasBody();
    }
    else if(data.cfml.forwardIfCurrent('/','>')) {
      if(tagLibTag.getHasBody())tag.setBody(new BodyBase());
    }
    else {
      throw createTemplateException(data.cfml, "tag ["+tagLibTag.getFullName()+"] is not closed",tagLibTag);
    }
   

    // Body
    if(hasBody)  {

       
      // get Body
      if(tagLibTag.isTagDependent()) {
        // get TagDependentBodyTransformer
        TagDependentBodyTransformer tdbt=null;
        try {
          tdbt=tagLibTag.getBodyTransformer();
        } catch (TagLibException e) {
          throw new TemplateException(data.cfml,e);
        }
        if(tdbt==null) throw createTemplateException(data.cfml,"Tag dependent body Transformer is invalid for Tag ["+tagLibTag.getFullName()+"]",tagLibTag);
        tdbt.transform(data.page,this,data.ep,data.flibs,tag,tagLibTag,data.scriptTags,data.cfml,data.settings);
       
        //  get TagLib of end Tag
        if(!data.cfml.forwardIfCurrent("</")) {
          // MUST this is a patch, do a more proper implementation
          TemplateException te = new TemplateException(data.cfml,"invalid construct");
          if(tdbt instanceof CFMLScriptTransformer && ASMUtil.containsComponent(tag.getBody())) {
            throw new CFMLScriptTransformer.ComponentTemplateException(te);
          }
          throw te;
        }
       
        TagLib tagLibEnd=nameSpace(data);
        // same NameSpace
        if(!(tagLibEnd!=null && tagLibEnd.getNameSpaceAndSeparator().equals(tagLib.getNameSpaceAndSeparator())))
          throw new TemplateException(data.cfml,"invalid construct");
        // get end Tag
        String strNameEnd=identifier(data.cfml,true).toLowerCase();

        // not the same name Tag
        if(!strName.equals(strNameEnd)) {
          data.cfml.setPos(start);
          throw new TemplateException(data.cfml,"Start and End Tag has not the same Name ["+tagLib.getNameSpaceAndSeparator()+strName+"-"+tagLibEnd.getNameSpaceAndSeparator()+strNameEnd+"]");       
         }
         data.cfml.removeSpace();
         if(!data.cfml.forwardIfCurrent('>'))
           throw new TemplateException(data.cfml,"End Tag ["+tagLibEnd.getNameSpaceAndSeparator()+strNameEnd+"] not closed");
      }
      else {
        // get body of Tag
        BodyBase body=new BodyBase();
        body.setParent(tag);
        //tag.setBody(body);
          //parseExpression=(tagLibTag.getParseBody())?true:parseExpression;
        if(tagLibTag.getParseBody())parseExpression=true;
       
        while(true)  {
         
          // Load Expession Transformer from TagLib
          ExprTransformer transfomer=null;
          if(parseExpression) {
            try {
              transfomer = tagLibTag.getTagLib().getExprTransfomer();
            } catch (TagLibException e) {
              throw new TemplateException(data.cfml,e);
            }
          }
         

          // call body
         
            body(data,body,parseExpression,transfomer);
          
           
            // no End Tag
          if(data.cfml.isAfterLast()) {
             
            if(tagLibTag.isBodyReq()) {
                data.cfml.setPos(start);
              throw createTemplateException(data.cfml,"No matching end tag found for tag ["+tagLibTag.getFullName()+"]",tagLibTag);
            }
            body.moveStatmentsTo(parent);
            return executeEvaluator(data,tagLibTag, tag);
          }
         
          // Invalid Construct
          int posBeforeEndTag=data.cfml.getPos();
          if(!data.cfml.forwardIfCurrent('<','/'))
            throw createTemplateException(data.cfml,"Missing end tag for ["+tagLibTag.getFullName()+"]",tagLibTag);
         
          // get TagLib of end Tag
          int _start = data.cfml.getPos();
          TagLib tagLibEnd=nameSpace(data);
         
          // same NameSpace
          if(tagLibEnd!=null)  {
              String strNameEnd="";
              //railo.print.ln(data.cfml.getLine()+" - "+data.cfml.getColumn()+" - "+tagLibEnd.getNameSpaceAndSeperator()+".equals("+tagLib.getNameSpaceAndSeperator()+")");
              if(tagLibEnd.getNameSpaceAndSeparator().equals(tagLib.getNameSpaceAndSeparator())) {
                 
                // get end Tag
              strNameEnd=identifier(data.cfml,true).toLowerCase();
              // not the same name Tag
             
              // new part
              data.cfml.removeSpace();
              if(strName.equals(strNameEnd)) {
                  if(!data.cfml.forwardIfCurrent('>'))
                  throw new TemplateException(data.cfml,"End Tag ["+tagLibEnd.getNameSpaceAndSeparator()+strNameEnd+"] not closed");
                break;
              }
             
              }
              // new part
              if(tagLibTag.isBodyReq()) {
              TagLibTag endTag = tagLibEnd.getTag(strNameEnd);
              if(endTag!=null && !endTag.getHasBody())
                throw new TemplateException(data.cfml,
                    "End Tag ["+
                    tagLibEnd.getNameSpaceAndSeparator()+strNameEnd+"] is not allowed, for this tag only a Start Tag is allowed");
              data.cfml.setPos(start);
              if(tagLibEnd.getIgnoreUnknowTags() && (tagLibEnd.getTag(strNameEnd))==null){
                data.cfml.setPos(_start);
              }
              else throw new TemplateException(data.cfml,
                  "Start and End Tag has not the same Name ["+
                  tagLib.getNameSpaceAndSeparator()+strName+"-"+tagLibEnd.getNameSpaceAndSeparator()+strNameEnd+"]");
            }
              else {
              body.moveStatmentsTo(parent);
              data.cfml.setPos(posBeforeEndTag);
              return executeEvaluator(data,tagLibTag, tag);
              }
              /// new part 
          }
          body.addPrintOut("</",null,null);
         
        }
        tag.setBody(body);
       
      }
    }
    if(tag instanceof StatementBase)
      ((StatementBase)tag).setEnd(data.cfml.getPosition());
View Full Code Here

          throw new EvaluatorException("Attribute passby of the Tag Argument has an invalid value ["+passBy+"], valid values are [reference,value]");
      }
       
      // check if tag is direct inside function
      if(!ASMUtil.isParentTag(tag,functionName)) {
          Tag parent=ASMUtil.getParentTag(tag);
         
          String addText=(parent!=null)?
                  "but tag "+libTag.getFullName()+" is inside tag "+parent.getFullname()+"":
                  "but tag "+libTag.getFullName()+" has no parent";
         
        throw new EvaluatorException("Wrong Context, tag "+libTag.getFullName()
                +" must be direct inside a "+functionName+" tag, "+addText);
      }
View Full Code Here

        // count catch tag and other in body
        if(body!=null) {
          List stats = body.getStatements();
        Iterator it = stats.iterator();
          Statement stat;
          Tag t;
            String name;
            while(it.hasNext()) {
              stat=(Statement) it.next();
              if(stat instanceof Tag) {
                  t=(Tag) stat;
                  name=t.getTagLibTag().getName();
                  if(name.equals("finally")) {
                    finallyCount++;
                    noCatchCount++;
                  }
                  else if(name.equals("catch"))catchCount++;
View Full Code Here

TOP

Related Classes of railo.transformer.bytecode.statement.tag.Tag

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.