Package railo.transformer.bytecode.statement.tag

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


    if(!data.cfml.forwardIfCurrent("param "))
      return null;
    Position line = data.cfml.getPosition();
   
    TagLibTag tlt = CFMLTransformer.getTLT(data.cfml,"param");
    TagParam param=new TagParam(line,null);
   
    // type
    boolean hasType=false;
    int pos = data.cfml.getPos();
    String tmp=variableDec(data, true);
    if(!StringUtil.isEmpty(tmp)) {
      if(tmp.indexOf('.')!=-1) {
        param.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(param,tlt,data,SEMI,  NULL,Boolean.TRUE,"name",true);
    checkSemiColonLineFeed(data,true,true);

    param.setTagLibTag(tlt);
    param.setScriptBase(true);
   
   
    Attribute attr;
   
    // first fill all regular attribute -> name="value"
    boolean hasDynamic=false;
    boolean hasName=false;
    for(int i=attrs.length-1;i>=0;i--){
      attr=attrs[i];
      if(!attr.getValue().equals(NULL)){
        if(attr.getName().equalsIgnoreCase("name")){
          hasName=true;
          param.addAttribute(attr);
        }
        else if(attr.getName().equalsIgnoreCase("type")){
          hasType=true;
          param.addAttribute(attr);
        }
        else if(attr.isDynamicType()){
          hasName=true;
          if(hasDynamic) throw attrNotSupported(data.cfml,tlt,attr.getName());
          hasDynamic=true;
          param.addAttribute(new Attribute(false,"name",LitString.toExprString(attr.getName()),"string"));
          param.addAttribute(new Attribute(false,"default",attr.getValue(),"any"));
        }
        else
          param.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();
        }
        // name
        else if(second==null && !hasName && !hasType){
          second=attr.getName();
        }
        // attr with no value
        else {
          attr=new Attribute(true,attr.getName(),LitString.EMPTY,"string");
          param.addAttribute(attr);
        }
      }
    }

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

    param.setEnd(data.cfml.getPosition());
    return param;
  }
View Full Code Here

TOP

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

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.