Package railo.transformer.bytecode.statement.tag

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


    TagLibTagScript script = tlt.getScript();
    //TagLibTag tlt = CFMLTransformer.getTLT(data.cfml,type);
    if(script.getContext()==CTX_CFC)data.isCFC=true;
    else if(script.getContext()==CTX_INTERFACE)data.isInterface=true;
    //Tag tag=new TagComponent(line);
    Tag tag=getTag(data,parent,tlt, line,null);
    tag.setTagLibTag(tlt);
    tag.setScriptBase(true);
   
    // add component meta data
    if(data.isCFC) {
      addMetaData(data,tag,IGNORE_LIST_COMPONENT);
    }
    if(data.isInterface) {
      addMetaData(data,tag,IGNORE_LIST_INTERFACE);
    }
    //EvaluatorPool.getPool();
    comments(data);
   
    // attributes
    //attributes(func,data);
    Attribute[] attrs = attributes(tag,tlt,data,SEMI_BLOCK,LitString.EMPTY,script.getRtexpr()?Boolean.TRUE:Boolean.FALSE,null,false);
   
    for(int i=0;i<attrs.length;i++){
      tag.addAttribute(attrs[i]);
    }
   
    comments(data);
 
    // body
    if(tlt.getHasBody()){
      Body body=new BodyBase();
      boolean wasSemiColon=statement(data,body,script.getContext());
      if(!wasSemiColon || !tlt.isBodyFree() || body.hasStatements())
        tag.setBody(body);
     
     
     
    }
    else checkSemiColonLineFeed(data,true,true);
   
    tag.setEnd(data.cfml.getPosition());
    eval(tlt,data,tag);
    return tag;
  }
View Full Code Here


    if(data.context!=CTX_CFC || !data.cfml.forwardIfCurrent("property "))
      return null;
    Position line = data.cfml.getPosition();
   
    TagLibTag tlt = CFMLTransformer.getTLT(data.cfml,"property");
    Tag property=new TagOther(line,null);
    addMetaData(data, property,IGNORE_LIST_PROPERTY);
   

    boolean hasName=false,hasType=false;

    // TODO allow the following pattern property "a.b.C" d;
    //Expression t = string(data);
    // print.o("name:"+t.getClass().getName());
   
    int pos = data.cfml.getPos();
    String tmp=variableDec(data, true);
    if(!StringUtil.isEmpty(tmp)) {
      if(tmp.indexOf('.')!=-1) {
        property.addAttribute(new Attribute(false,"type",LitString.toExprString(tmp),"string"));
        hasType=true;
      }
      else {
        data.cfml.setPos(pos);
      }
    }
    else data.cfml.setPos(pos);
   
   
   
    // folgend wird tlt extra nicht uebergeben, sonst findet pruefung statt
    Attribute[] attrs = attributes(property,tlt,data,SEMI,  NULL,Boolean.FALSE,"name",true);
   
    checkSemiColonLineFeed(data,true,true);

    property.setTagLibTag(tlt);
    property.setScriptBase(true);
   
   
    Attribute attr;
   
    // first fill all regular attribute -> name="value"
    for(int i=attrs.length-1;i>=0;i--){
      attr=attrs[i];
      if(!attr.getValue().equals(NULL)){
        if(attr.getName().equalsIgnoreCase("name")){
          hasName=true;
          //attr=new Attribute(attr.isDynamicType(),attr.getName(),CastString.toExprString(attr.getValue()),"string");
        }
        else if(attr.getName().equalsIgnoreCase("type")){
          hasType=true;
          //attr=new Attribute(attr.isDynamicType(),attr.getName(),CastString.toExprString(attr.getValue()),"string");
        }
        property.addAttribute(attr);
      }
    }
   
    // now fill name named attributes -> attr1 attr2
   
    String first=null,second=null;
    for(int i=0;i<attrs.length;i++){
      attr=attrs[i];
     
      if(attr.getValue().equals(NULL)){
        // type
        if(first==null && (!hasName || !hasType)){
          first=attr.getName();
          //type=new Attribute(false,"type",LitString.toExprString(attr.getName()),"string");
          //property.addAttribute(type);
        }
        // name
        else if(second==null && !hasName && !hasType){
          second=attr.getName();
          //name=new Attribute(false,"name",LitString.toExprString(attr.getName()),"string");
          //property.addAttribute(name);
        }
        // attr with no value
        else {
          attr=new Attribute(true,attr.getName(),LitString.EMPTY,"string");
          property.addAttribute(attr);
        }
      }
    }

   
   
    if(first!=null) {
        hasName=true;
      if(second!=null){
        hasType=true;
        property.addAttribute(new Attribute(false,"name",LitString.toExprString(second),"string"));
        property.addAttribute(new Attribute(false,"type",LitString.toExprString(first),"string"));
      }
      else {
        property.addAttribute(new Attribute(false,"name",LitString.toExprString(first),"string"));
      }
    }
   
    if(!hasType)
      property.addAttribute(ANY);
   
    if(!hasName)
      throw new TemplateException(data.cfml,"missing name declaration for property");

    /*Tag property=new TagBase(line);
    property.setTagLibTag(tlt);
    property.addAttribute(new Attribute(false,"name",LitString.toExprString(name),"string"));
    property.addAttribute(new Attribute(false,"type",LitString.toExprString(type),"string"));
    */
    property.setEnd(data.cfml.getPosition());
   
    return property;
  }
View Full Code Here

   
    int pos=data.cfml.getPos()-tagName.length();
    Position line = data.cfml.getPosition();
    //TagLibTag tlt = CFMLTransformer.getTLT(data.cfml,tagName.equals("pageencoding")?"processingdirective":tagName);
   
    Tag tag=getTag(data,parent,tlt,line,null);
    tag.setScriptBase(true);
    tag.setTagLibTag(tlt);
   
    comments(data);
   
    // attribute
    TagLibTagAttr attr = tlt.getScript().getSingleAttr();
    String attrName=null;
    Expression attrValue=null;
    short attrType=ATTR_TYPE_NONE;
    if(attr!=null){
      attrType = attr.getScriptSupport();
      char c = data.cfml.getCurrent();
      if(ATTR_TYPE_REQUIRED==attrType || (!data.cfml.isCurrent(';') && ATTR_TYPE_OPTIONAL==attrType)) {
        attrValue =attributeValue(data, tlt.getScript().getRtexpr());
        if(attrValue!=null && isOperator(c)) {
          data.cfml.setPos(pos);
          return null;
        }
      }
    }
   
    if(attrValue!=null){
      attrName=attr.getName();
      TagLibTagAttr tlta = tlt.getAttribute(attr.getName());
      tag.addAttribute(new Attribute(false,attrName,CastOther.toExpression(attrValue,tlta.getType()),tlta.getType()));
    }
    else if(ATTR_TYPE_REQUIRED==attrType){
      data.cfml.setPos(pos);
      return null;
    }
   
    checkSemiColonLineFeed(data,true,true);
    if(!StringUtil.isEmpty(tlt.getTteClassName()))data.ep.add(tlt, tag, data.flibs, data.cfml);
   
    if(!StringUtil.isEmpty(attrName))validateAttributeName(attrName, data.cfml, new ArrayList<String>(), tlt, new RefBooleanImpl(false), new StringBuffer(), allowTwiceAttr);
    tag.setEnd(data.cfml.getPosition());
    eval(tlt,data,tag);
    return tag;
  }
View Full Code Here

    }
  }

  private final Tag getTag(ExprData data,Body parent, TagLibTag tlt, Position start,Position end) throws TemplateException {
    try {
      Tag tag = tlt.getTag(start, end);
      tag.setParent(parent);
      return tag;
    } catch (TagLibException e) {
      throw new TemplateException(data.cfml,e);
    }
    /*if(StringUtil.isEmpty(tlt.getTttClassName()))tag= new TagBase(line);
View Full Code Here

   
    // 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 
View Full Code Here

  public TagLibTag evaluate(TagLibTag tagLibTag, Tag tag) throws AttributeEvaluatorException {
    Attribute action = tag.getAttribute("action");
   
    if(action!=null){
      Tag parent = ASMUtil.getAncestorTag(tag, tag.getFullname());
      if(parent!=null) {
        tagLibTag=tagLibTag.duplicate(false);
        tagLibTag.setBodyContent("empty");
      }
    }
View Full Code Here

    super.evaluate(tag,libTag);
    Body body = tag.getBody();
    List statments = body.getStatements();
    Statement stat;
    Iterator it = statments.iterator();
    Tag t;
    while(it.hasNext()) {
      stat=(Statement) it.next();
     
      if(stat instanceof PrintOut) {
        //body.remove(stat);
      }
      else if(stat instanceof Tag) {
        t=(Tag) stat;
        if(stat instanceof TagImport) {
          // ignore
        }
        else if(stat instanceof TagFunction) {
         
          Function.throwIfNotEmpty(t);
          Attribute attr = t.getAttribute("access");
         
          if(attr!=null) {
            ExprString expr = CastString.toExprString(attr.getValue());
           
            if(!(expr instanceof LitString))
              throw new EvaluatorException(
            "the attribute access of the Tag function inside an interface must contain a constant value");
            String access = ((LitString)expr).getString().trim();
            if(!"public".equalsIgnoreCase(access))
              throw new EvaluatorException(
            "the attribute access of the tag function inside an interface definition can only have the value [public] not ["+access+"]");
          }
          else t.addAttribute(new Attribute(false,"access",LitString.toExprString("public"),"string"));
         
        }
        else throw new EvaluatorException("tag "+libTag.getFullName()+" can only contain function definitions.");
      }
    }
View Full Code Here

      throw new EvaluatorException("Wrong Context, tag "+libTag.getFullName()+" must be inside a "+name+" tag");
  }
 
  public static Statement getAncestorCatch(TagLib tagLib, Statement stat) {
    String name=tagLib.getNameSpaceAndSeparator()+"catch";
    Tag tag;
    Statement parent=stat;
    while(true)  {
      parent=parent.getParent();
      if(parent==null)return null;
      if(parent instanceof Tag)  {
        tag=(Tag) parent;
        if(tag.getFullname().equalsIgnoreCase(name))
          return tag;
      }
      else if(parent instanceof TryCatchFinally)
        return parent;
    }
View Full Code Here

    if(p instanceof Tag) return (Tag) p;
    return null;
  }

  public static boolean isParentTag(Tag tag,String fullName)  {
    Tag p = getParentTag(tag);
    if(p==null) return false;
    return p.getFullname().equalsIgnoreCase(fullName);
   
  }
View Full Code Here

    if(p==null) return false;
    return p.getFullname().equalsIgnoreCase(fullName);
   
  }
  public static boolean isParentTag(Tag tag,Class clazz)  {
    Tag p = getParentTag(tag);
    if(p==null) return false;
    return p.getClass()==clazz;
   
  }
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.