예제 #1
0
파일: Break.java 프로젝트: junekee/railo
 static String variableToString(Tag tag, Attribute attrLabel, String defaultValue) {
   Expression value = attrLabel.getValue();
   while (value instanceof Cast) value = ((Cast) value).getExpr();
   if (value instanceof Variable) {
     Variable var = (Variable) value;
     try {
       return VariableString.variableToString(var, true);
     } catch (Throwable t) {
     }
   }
   return defaultValue;
 }
예제 #2
0
  /**
   * @param type
   * @param name
   * @param b
   * @param line
   * @throws BytecodeException
   */
  public void addCatch(Expression type, Expression name, Body b, Position line)
      throws BytecodeException {

    // type
    if (type == null || type instanceof ExprString) ;
    else if (type instanceof Variable) {
      type = VariableString.toExprString(type);
    } else throw new BytecodeException("type from catch statement is invalid", type.getStart());

    // name
    if (name instanceof LitString) {
      Variable v = new Variable(Scope.SCOPE_UNDEFINED, name.getStart(), name.getEnd());
      v.addMember(new DataMember(name));
      name = new VariableRef(v);
    } else if (name instanceof Variable) name = new VariableRef((Variable) name);
    else throw new BytecodeException("name from catch statement is invalid", name.getStart());

    addCatch((ExprString) type, (VariableRef) name, b, line);
  }