Exemple #1
0
        public override int CompareTo(JavaScriptObject obj)
        {
            JavaScriptString str = (JavaScriptString)obj;

            return(value.CompareTo(str.value));
        }
Exemple #2
0
 public override JavaScriptBoolean Equals(JavaScriptObject obj, Scope scope, JavaScriptObject thisObject)
 {
     return(JavaScriptBoolean.ValueOf(this.CompareTo(obj) == 0));
 }
Exemple #3
0
 public override int CompareTo(JavaScriptObject o)
 {
     throw new NotImplementedException();
 }
Exemple #4
0
        /*
         * Evaluate the function.
         *
         * @param interpreter
         * @param pos Source position of function call
         * @return The result of evaluating the function.
         */
        public JavaScriptObject Execute(Scope parentscope, List <JavaScriptObject> arguments, SourcePosition pos, JavaScriptObject thisObject)
        {
            Scope             executionscope     = new Scope(parentscope);
            int               numberMissingArgs  = 0;
            int               numberRequiredArgs = 0;
            FunctionArguments argumentsVariable  = new FunctionArguments(arguments);

            for (int paramIndex = 0; paramIndex < this.ArgumentCount; paramIndex++)
            {
                String           argumentName = this.GetArgumentName(paramIndex);
                JavaScriptObject value        = this.GetDefaultValue(paramIndex);
                if (value == null)
                {
                    numberRequiredArgs++;
                }
                if (paramIndex < argumentsVariable.Count)
                {
                    // Value provided in function call overrides the default value
                    value = argumentsVariable[paramIndex];
                }
                if (value == null)
                {
                    numberMissingArgs++;
                }

                executionscope.SetLocalVariable(argumentName, value);
            }

            executionscope.SetLocalVariable("arguments", argumentsVariable);

            if (numberMissingArgs > 0)
            {
                throw new TooFewArgumentsException(this.Name, numberRequiredArgs, argumentsVariable.Count, pos);
            }

            return(this.Execute(pos, executionscope, thisObject));
        }
Exemple #5
0
 protected abstract JavaScriptObject Execute(SourcePosition pos, Scope scope, JavaScriptObject thisObject);
 public JavaScriptProperty(JavaScriptObject value)
 {
     this.value = value;
 }
 protected override JavaScriptObject Execute(SourcePosition pos, Scope scope, JavaScriptObject thisObject)
 {
     return(scope.GetVariable("string", pos).ToFloat());
 }
Exemple #8
0
 private Parameter(Parameter original)
 {
     this.name  = original.Name;
     this.value = original.value;
 }
Exemple #9
0
 public Parameter(String name, JavaScriptObject value)
 {
     this.name  = name;
     this.value = value;
 }