Examples of NumberConstant


Examples of macromedia.asc.util.NumberConstant

    }
       
       
   public NumberConstant getValueOfNumberLiteral(String str, TypeValue[] ppType, NumberUsage numberUsage)
    {
        NumberConstant result;
       
        if (!cx.statics.es4_numerics) {
          // do things the old way
          return getDoubleValueOrInt(str, false, ppType);
        }

        TypeValue ftype = null// force type of literal to this if integral
        TypeValue floating_ftype; // use this if floating
       
        boolean forceType;

        if (numberUsage == null) {
          // can happen when processing imports
          floating_ftype = cx.doubleType();
          forceType = false;
        }
        else {
            if (numberUsage.get_floating_usage() == NumberUsage.use_decimal)
                floating_ftype = cx.decimalType();
            else
                floating_ftype = cx.doubleType();
            forceType = true; // until proven otherwise
            switch (numberUsage.get_usage()) {
            case NumberUsage.use_int:
                ftype = cx.intType();
                break;
            case NumberUsage.use_double:
                ftype = cx.doubleType();
                break;
            case NumberUsage.use_uint:
                ftype = cx.uintType();
                break;
            case NumberUsage.use_decimal:
                ftype = cx.decimalType();
                break;
            case NumberUsage.use_Number:
            default:
                forceType = false;
            }
         
        }

        int len = str.length();
        // See if there is a suffix to force the type of the literal
    testlastchar:
        while (true) { // dummy loop executed only once
            switch(str.charAt(len-1)) {
            case 'i': // from scanner, can only be on integer literals (i.e., no dot or "e")
                ftype = cx.intType();
                break;
            case 'u': // from scanner, can only be on integer literals (i.e., no dot or "e")
                ftype = cx.uintType();
                break;
            case 'm':
                ftype = floating_ftype = cx.decimalType();
                break;
            case 'd':
              if ((str.indexOf('x') != -1) || (str.indexOf('X') != -1)) {
                // hex numbers can't have terminal d's
                break testlastchar;
              }
                ftype = floating_ftype = cx.doubleType();
                break;
            default:
                break testlastchar;
            }
            forceType = true;
            str = str.substring(0, len-1);
            break;
        } // dummy loop labelled testlastchar
           
        if (forceType) {
            if (ftype == cx.doubleType()) {
                return getDoubleValueOrInt(str, true, ppType);
            }
            else if (ftype == cx.decimalType()) {
                return getDecimalValueOrInt(str, true, ppType);
            }
        }
        // either not forceType or force to int or uint 
        if (floating_ftype == cx.decimalType())
            result = getDecimalValueOrInt(str, false, ppType);
        else
            result = getDoubleValueOrInt(str, false, ppType);
           
        if (forceType) {
            ppType[0] = ftype; // either int or uint at this point
            if (ftype == cx.intType()) {
                if (!(result instanceof IntNumberConstant))
                    result = new IntNumberConstant(result.intValue());
            }
            else { // ftype == cx.uintType()
                if (!(result instanceof UintNumberConstant))
                    result = new UintNumberConstant(result.uintValue());
            }
        }
        return result;
    }
View Full Code Here

Examples of macromedia.asc.util.NumberConstant

        ret = obj.getValue();
      }
      else if( isNumericType(cx, tv) )
      {
                TypeValue[] type = new TypeValue[1];
                NumberConstant v = cx.getEmitter().getValueOfNumberLiteral( obj.getValue(), type, obj.getNumberUsage());
                ret = v.toString();
      }
    }
    return ret;
  }
View Full Code Here

Examples of macromedia.asc.util.NumberConstant

    }
       
       
   public NumberConstant getValueOfNumberLiteral(String str, TypeValue[] ppType, NumberUsage numberUsage)
    {
        NumberConstant result;
       
        if (!cx.statics.es4_numerics) {
          // do things the old way
          return getDoubleValueOrInt(str, false, ppType);
        }

        TypeValue ftype = null// force type of literal to this if integral
        TypeValue floating_ftype; // use this if floating
       
        boolean forceType;

        if (numberUsage == null) {
          // can happen when processing imports
          floating_ftype = cx.doubleType();
          forceType = false;
        }
        else {
            if (numberUsage.get_floating_usage() == NumberUsage.use_decimal)
                floating_ftype = cx.decimalType();
            else
                floating_ftype = cx.doubleType();
            forceType = true; // until proven otherwise
            switch (numberUsage.get_usage()) {
            case NumberUsage.use_int:
                ftype = cx.intType();
                break;
            case NumberUsage.use_double:
                ftype = cx.doubleType();
                break;
            case NumberUsage.use_uint:
                ftype = cx.uintType();
                break;
            case NumberUsage.use_decimal:
                ftype = cx.decimalType();
                break;
            case NumberUsage.use_Number:
            default:
                forceType = false;
            }
         
        }

        int len = str.length();
        // See if there is a suffix to force the type of the literal
    testlastchar:
        while (true) { // dummy loop executed only once
            switch(str.charAt(len-1)) {
            case 'i': // from scanner, can only be on integer literals (i.e., no dot or "e")
                ftype = cx.intType();
                break;
            case 'u': // from scanner, can only be on integer literals (i.e., no dot or "e")
                ftype = cx.uintType();
                break;
            case 'm':
                ftype = floating_ftype = cx.decimalType();
                break;
            case 'd':
              if ((str.indexOf('x') != -1) || (str.indexOf('X') != -1)) {
                // hex numbers can't have terminal d's
                break testlastchar;
              }
                ftype = floating_ftype = cx.doubleType();
                break;
            default:
                break testlastchar;
            }
            forceType = true;
            str = str.substring(0, len-1);
            break;
        } // dummy loop labelled testlastchar
           
        if (forceType) {
            if (ftype == cx.doubleType()) {
                return getDoubleValueOrInt(str, true, ppType);
            }
            else if (ftype == cx.decimalType()) {
                return getDecimalValueOrInt(str, true, ppType);
            }
        }
        // either not forceType or force to int or uint 
        if (floating_ftype == cx.decimalType())
            result = getDecimalValueOrInt(str, false, ppType);
        else
            result = getDoubleValueOrInt(str, false, ppType);
           
        if (forceType) {
            ppType[0] = ftype; // either int or uint at this point
            if (ftype == cx.intType()) {
                if (!(result instanceof IntNumberConstant))
                    result = new IntNumberConstant(result.intValue());
            }
            else { // ftype == cx.uintType()
                if (!(result instanceof UintNumberConstant))
                    result = new UintNumberConstant(result.uintValue());
            }
        }
        return result;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.