Exemplo n.º 1
0
  /** Initialize the properties on this object */
  public void initializeProperties() {
    Environment environment = this.owningEnvironment;
    int attributes = Property.DONT_DELETE | Property.DONT_ENUM;
    int fileIndex = FileContextManager.BUILT_IN_FILE_INDEX;
    int offset = Range.Empty.getStartingOffset();

    // add properties to Number
    this.putPropertyValue(
        "length",
        environment.createNumber(fileIndex, Range.Empty),
        fileIndex,
        attributes); //$NON-NLS-1$
    this.putPropertyValue(
        "MAX_VALUE",
        environment.createNumber(fileIndex, Range.Empty),
        fileIndex,
        attributes); //$NON-NLS-1$
    this.putPropertyValue(
        "MIN_VALUE",
        environment.createNumber(fileIndex, Range.Empty),
        fileIndex,
        attributes); //$NON-NLS-1$
    this.putPropertyValue(
        "NaN",
        environment.createNumber(fileIndex, Range.Empty),
        fileIndex,
        attributes); //$NON-NLS-1$
    this.putPropertyValue(
        "NEGATIVE_INFINITY",
        environment.createNumber(fileIndex, Range.Empty),
        fileIndex,
        attributes); //$NON-NLS-1$
    this.putPropertyValue(
        "POSITIVE_INFINITY",
        environment.createNumber(fileIndex, Range.Empty),
        fileIndex,
        attributes); //$NON-NLS-1$

    // add properties to Number.prototype
    IObject prototype = this.getPropertyValue("prototype", fileIndex, offset); // $NON-NLS-1$

    prototype.putPropertyValue("constructor", this, fileIndex, attributes); // $NON-NLS-1$
    prototype.putPropertyValue(
        "toString",
        environment.createFunction(fileIndex, Range.Empty),
        fileIndex,
        attributes); //$NON-NLS-1$
    prototype.putPropertyValue(
        "toLocaleString",
        environment.createFunction(fileIndex, Range.Empty),
        fileIndex,
        attributes); //$NON-NLS-1$
    prototype.putPropertyValue(
        "valueOf",
        environment.createFunction(fileIndex, Range.Empty),
        fileIndex,
        attributes); //$NON-NLS-1$
    prototype.putPropertyValue(
        "toFixed",
        environment.createFunction(fileIndex, Range.Empty),
        fileIndex,
        attributes); //$NON-NLS-1$
    prototype.putPropertyValue(
        "toExponential",
        environment.createFunction(fileIndex, Range.Empty),
        fileIndex,
        attributes); //$NON-NLS-1$
    prototype.putPropertyValue(
        "toPrecision",
        environment.createFunction(fileIndex, Range.Empty),
        fileIndex,
        attributes); //$NON-NLS-1$
  }
Exemplo n.º 2
0
 /**
  * @see
  *     com.aptana.ide.editor.js.runtime.FunctionBase#invoke(com.aptana.ide.editor.js.runtime.Environment,
  *     com.aptana.ide.editor.js.runtime.IObject[], int, IRange)
  */
 public IObject invoke(
     Environment environment, IObject[] arguments, int fileIndex, IRange sourceRegion) {
   return environment.createNumber(fileIndex, sourceRegion);
 }