Package railo.transformer.bytecode.statement.tag

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


     * @param attrName
     * @return attribute value
     * @throws EvaluatorException
     */
  public static Literal getAttributeLiteral(Tag tag,String attrName, Literal defaultValue) {
    Attribute attr = tag.getAttribute(attrName);
    if(attr!=null && attr.getValue() instanceof Literal) return ((Literal)attr.getValue());
        return defaultValue;
    }
View Full Code Here


     
    int comp=adapter.newLocal(Types.COMPONENT_IMPL);
    adapter.newInstance(Types.COMPONENT_IMPL);
    adapter.dup();
   
    Attribute attr;
    // ComponentPage
    adapter.visitVarInsn(Opcodes.ALOAD, 0);
    adapter.checkCast(Types.COMPONENT_PAGE);

    // !!! also check CFMLScriptTransformer.addMetaData if you do any change here !!!
   
    // Output
    attr = component.removeAttribute("output");
    if(attr!=null) {
      ExpressionUtil.writeOutSilent(attr.getValue(),bc, Expression.MODE_REF);
    }
    else ASMConstants.NULL(adapter);

    // synchronized
    attr = component.removeAttribute("synchronized");
    if(attr!=null) ExpressionUtil.writeOutSilent(attr.getValue(),bc, Expression.MODE_VALUE);
    else adapter.push(false);

    // extends
    attr = component.removeAttribute("extends");
    if(attr!=null) ExpressionUtil.writeOutSilent(attr.getValue(),bc, Expression.MODE_REF);
    else adapter.push("");
    // implements
    attr = component.removeAttribute("implements");
    if(attr!=null) ExpressionUtil.writeOutSilent(attr.getValue(),bc, Expression.MODE_REF);
    else adapter.push("");
   
    // hint
    attr = component.removeAttribute("hint");
    if(attr!=null) {
      Expression value = attr.getValue();
      if(!(value instanceof Literal)){
        value=LitString.toExprString("[runtime expression]");
      }
      ExpressionUtil.writeOutSilent(value,bc, Expression.MODE_REF);
    }
    else adapter.push("");
   
    // dspName
    attr = component.removeAttribute("displayname");
    if(attr==null) attr=component.getAttribute("display");
    if(attr!=null) ExpressionUtil.writeOutSilent(attr.getValue(),bc, Expression.MODE_REF);
    else adapter.push("");
       
    // callpath
    adapter.visitVarInsn(Opcodes.ALOAD, 2);
    // realpath
    adapter.visitVarInsn(Opcodes.ILOAD, 3);
   

    // style
    attr = component.removeAttribute("style");
    if(attr!=null) ExpressionUtil.writeOutSilent(attr.getValue(),bc, Expression.MODE_REF);
    else adapter.push("");

    // persistent
    attr = component.removeAttribute("persistent");
    boolean persistent=false;
View Full Code Here

   
    adapter.newInstance(Types.INTERFACE_IMPL);
    adapter.dup();
   
   
    Attribute attr;
    // Interface Page
    adapter.visitVarInsn(Opcodes.ALOAD, 0);
    adapter.checkCast(Types.INTERFACE_PAGE);

    // extened
    attr = interf.removeAttribute("extends");
    if(attr!=null) ExpressionUtil.writeOutSilent(attr.getValue(),bc, Expression.MODE_REF);
    else adapter.push("");
   
    // hint
    attr = interf.removeAttribute("hint");
    if(attr!=null) ExpressionUtil.writeOutSilent(attr.getValue(),bc, Expression.MODE_REF);
    else adapter.push("");
   
    // dspName
    attr = interf.removeAttribute("displayname");
    if(attr==null) attr=interf.getAttribute("display");
    if(attr!=null) ExpressionUtil.writeOutSilent(attr.getValue(),bc, Expression.MODE_REF);
    else adapter.push("");
   
   
    // callpath
    adapter.visitVarInsn(Opcodes.ALOAD, 1);
View Full Code Here

   
    adapter.loadLocal(sct);
  }

  private static void _createMetaDataStruct(BytecodeContext bc, GeneratorAdapter adapter, int sct, Map attrs) throws BytecodeException {
    Attribute attr;
    Iterator it = attrs.entrySet().iterator();
    Entry entry;
    while(it.hasNext()){
      entry = (Map.Entry)it.next();
      attr=(Attribute) entry.getValue();
      adapter.loadLocal(sct);
      adapter.push(attr.getName());
      if(attr.getValue() instanceof Literal)
        ExpressionUtil.writeOutSilent(attr.getValue(),bc,Expression.MODE_REF);
      else
        adapter.push("[runtime expression]");
     
      adapter.invokeVirtual(STRUCT_IMPL, SET_EL);
      adapter.pop();
View Full Code Here

     
        while(it.hasNext())  {
          TagLibTagAttr att=hash.get(it.next());
          if(!parent.containsAttribute(att.getName()) && att.hasDefaultValue())  {
             
            Attribute attr=new Attribute(tag.getAttributeType()==TagLibTag.ATTRIBUTE_TYPE_DYNAMIC,
                  att.getName(),
                  CastOther.toExpression(LitString.toExprString(Caster.toString(att.getDefaultValue(),null)),att.getType()),att.getType()
              );
              parent.addAttribute(attr);
          }
View Full Code Here

      strName=attr.getName();
      strType=attr.getType()
      pe=attr.getRtexpr();
    }
    //LitString.toExprString("",-1);
    Attribute att=new Attribute(false,strName,attributeValue(data,tag,strType,pe,true,NullExpression.NULL_EXPRESSION),strType);
    parent.addAttribute(att);
  }
View Full Code Here

          value=CastOther.toExpression(value, sbType.toString());
        }
      }   
      comment(data.cfml,true);
     
      return new Attribute(dynamic.toBooleanValue(),name,value,sbType.toString());
    }
View Full Code Here

    boolean isCFC=true;
        try {
      isCFC = ASMUtil.getAncestorPage(tag).isComponent();
    } catch (BytecodeException e) {}

    Attribute attrName = tag.getAttribute("name");
    if(attrName!=null) {
      Expression expr = attrName.getValue();
      if(expr instanceof LitString && !isCFC){
        checkFunctionName(((LitString)expr).getString(),flibs);
      }
       
    }
    // attribute modifier
    Attribute attrModifier = tag.getAttribute("modifier");
    if(attrModifier!=null) {
      ExprString expr = CastString.toExprString(attrModifier.getValue());
      if(!(expr instanceof Literal))
        throw new EvaluatorException("Attribute modifier of the Tag Function, must be one of the following literal string values: [abstract] or [final]");
      String modifier=StringUtil.emptyIfNull(((Literal)expr).getString()).trim();
      if(!StringUtil.isEmpty(modifier) && !"abstract".equalsIgnoreCase(modifier) && !"final".equalsIgnoreCase(modifier))
        throw new EvaluatorException("Attribute modifier of the Tag Function, must be one of the following literal string values: [abstract] or [final]");
     
     
      boolean abstr = "abstract".equalsIgnoreCase(modifier);
      if(abstr)throwIfNotEmpty(tag);
    }
   
    // cachedWithin
    Attribute attrCachedWithin = tag.getAttribute("cachedwithin");
    if(attrCachedWithin!=null) {
      Expression val = attrCachedWithin.getValue();
      tag.addAttribute(new Attribute(attrCachedWithin.isDynamicType(), attrCachedWithin.getName(), LitLong.toExpr(ASMUtil.timeSpanToLong(val), null, null), "numeric"));
    }
   
    // Attribute localMode
    Attribute attrLocalMode = tag.getAttribute("localmode");
    if(attrLocalMode!=null) {
      Expression expr = attrLocalMode.getValue();
      String str = ASMUtil.toString(expr,null);
      if(!StringUtil.isEmpty(str) && AppListenerUtil.toLocalMode(str, -1)==-1)
        throw new EvaluatorException("Attribute localMode of the Tag Function, must be a literal value (modern, classic, true or false)");
      //boolean output = ((LitBoolean)expr).getBooleanValue();
      //if(!output) ASMUtil.removeLiterlChildren(tag, true);
    }
   
   
    // Attribute Output
    // "output=true" wird in "railo.transformer.cfml.attributes.impl.Function" geh�ndelt
    Attribute attrOutput = tag.getAttribute("output");
    if(attrOutput!=null) {
      Expression expr = CastBoolean.toExprBoolean(attrOutput.getValue());
      if(!(expr instanceof LitBoolean))
        throw new EvaluatorException("Attribute output of the Tag Function, must be a literal boolean value (true or false, yes or no)");
      //boolean output = ((LitBoolean)expr).getBooleanValue();
      //if(!output) ASMUtil.removeLiterlChildren(tag, true);
    }
   
    Attribute attrBufferOutput = tag.getAttribute("bufferoutput");
    if(attrBufferOutput!=null) {
      Expression expr = CastBoolean.toExprBoolean(attrBufferOutput.getValue());
      if(!(expr instanceof LitBoolean))
        throw new EvaluatorException("Attribute bufferOutput of the Tag Function, must be a literal boolean value (true or false, yes or no)");
      //boolean output = ((LitBoolean)expr).getBooleanValue();
      //if(!output) ASMUtil.removeLiterlChildren(tag, true);
    }
   
   
        //if(ASMUtil.isRoot(pp)) {
          Map attrs = tag.getAttributes();
          Iterator it = attrs.keySet().iterator();
          Attribute attr;
          while(it.hasNext()) {
            attr=(Attribute) attrs.get(it.next());
            checkAttributeValue(tag,attr);
          }
        //}
View Full Code Here

      try {
        ConfigImpl config=(ConfigImpl) ThreadLocalPageContext.getConfig();
        transformer = tagLib.getExprTransfomer();
        Expression expr=transformer.transform(ASMUtil.getAncestorPage(tag),null,flibs,config.getCoreTagLib().getScriptTags(),new CFMLString(text,"UTF-8"),TransfomerSettings.toSetting(ThreadLocalPageContext.getConfig(),null));
        tag.addAttribute(new Attribute(false,"condition",CastBoolean.toExprBoolean(expr),"boolean"));
      }
      catch (Exception e) {
        throw new EvaluatorException(e.getMessage());
      }
      loop.setType(TagLoop.TYPE_CONDITION);
View Full Code Here

  /**
   * @see railo.transformer.cfml.evaluator.EvaluatorSupport#evaluate(org.w3c.dom.Element, railo.transformer.library.tag.TagLibTag)
   */
  public void evaluate(Tag tag) throws EvaluatorException {
    tag.addAttribute(
        new Attribute(
            false,
            "_id",
            LitString.toExprString(Caster.toString((int)(Math.random()*100000))),
            "string"
        ));
 
View Full Code Here

TOP

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

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.