Ejemplo n.º 1
0
 public FunctionDeclaration(Identifier identifier, FormalParameters formalParameters, FunctionStatementList functionBody, bool isStrictMode) : base(isStrictMode)
 {
     isAnonymous           = false;
     this.identifier       = identifier;
     this.formalParameters = formalParameters;
     this.functionBody     = functionBody;
 }
Ejemplo n.º 2
0
        private Object CreateMappedArgumentsObject(FormalParameters formalParameters, IReadOnlyList <IValue> arguments, EnvironmentRecord env)
        {
            var map            = Utils.ObjectCreate(null);
            var obj            = new MappedArguments(map);
            var parameterNames = formalParameters.BoundNames();
            int index;

            for (index = 0; index < arguments.Count; index++)
            {
                Utils.CreateDataProperty(obj, index.ToString(System.Globalization.CultureInfo.InvariantCulture), arguments[index]);
            }
            obj.DefinePropertyOrThrow("length", new PropertyDescriptor(new NumberValue(arguments.Count), true, false, true));
            var mappedNames = new List <string>();

            for (index = parameterNames.Count - 1; index >= 0; index--)
            {
                var name = parameterNames[index];
                if (!mappedNames.Contains(name))
                {
                    mappedNames.Add(name);
                    if (index < arguments.Count)
                    {
                        var g = MakeArgGetter(name, env);
                        var p = MakeArgSetter(name, env);
                        map.DefineOwnProperty(index.ToString(System.Globalization.CultureInfo.InvariantCulture), new PropertyDescriptor(p, g, false, true));
                    }
                }
            }
            DefinePropertyOrThrow("@@iterator", new PropertyDescriptor(Utils.CreateBuiltinFunction(ArrayPrototype.values), true, false, true));
            DefinePropertyOrThrow("callee", new PropertyDescriptor(this, true, false, true));
            return(obj);
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Constructor
        /// </summary>
        /// <param name="efsSystem"></param>
        public Override(EfsSystem efsSystem)
            : base(efsSystem, "Override")
        {
            DefaultFunction      = (Parameter)acceptor.getFactory().createParameter();
            DefaultFunction.Name = "Default";
            DefaultFunction.Type = EFSSystem.AnyType;
            DefaultFunction.setFather(this);
            FormalParameters.Add(DefaultFunction);

            OverrideFunction      = (Parameter)acceptor.getFactory().createParameter();
            OverrideFunction.Name = "Override";
            OverrideFunction.Type = EFSSystem.AnyType;
            OverrideFunction.setFather(this);
            FormalParameters.Add(OverrideFunction);

            Returns            = (Function)acceptor.getFactory().createFunction();
            Returns.Name       = "Override";
            Returns.ReturnType = EFSSystem.DoubleType;
            Returns.setFather(this);

            Parameter distanceParam = (Parameter)acceptor.getFactory().createParameter();

            distanceParam.Name = "Distance";
            distanceParam.Type = EFSSystem.DoubleType;
            distanceParam.setFather(Returns);
            Returns.appendParameters(distanceParam);

            Parameter speedParameter = (Parameter)acceptor.getFactory().createParameter();

            speedParameter.Name = "Speed";
            speedParameter.Type = EFSSystem.DoubleType;
            speedParameter.setFather(Returns);
            Returns.appendParameters(speedParameter);
        }
Ejemplo n.º 4
0
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="efsSystem"></param>
 public CheckNumber(EfsSystem efsSystem)
     : base(efsSystem, "CheckNumber")
 {
     Number      = (Parameter)acceptor.getFactory().createParameter();
     Number.Name = "Number";
     Number.Type = EFSSystem.AnyType;
     Number.setFather(this);
     FormalParameters.Add(Number);
 }
Ejemplo n.º 5
0
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="efsSystem"></param>
 public DoubleToInteger(EfsSystem efsSystem)
     : base(efsSystem, "DoubleToInteger")
 {
     Value      = (Parameter)acceptor.getFactory().createParameter();
     Value.Name = "Value";
     Value.Type = EFSSystem.DoubleType;
     Value.setFather(this);
     FormalParameters.Add(Value);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="efsSystem"></param>
 public Characters(EfsSystem efsSystem)
     : base(efsSystem, "Characters")
 {
     Value      = (Parameter)acceptor.getFactory().createParameter();
     Value.Name = "String";
     Value.Type = EFSSystem.StringType;
     Value.setFather(this);
     FormalParameters.Add(Value);
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="efsSystem"></param>
 /// <param name="name">the name of the cast function</param>
 public EmptyDoubleToDoubleFunction(EFSSystem efsSystem)
     : base(efsSystem, "EmptyDoubleToDoubleFunction")
 {
     Value      = (Parameter)Generated.acceptor.getFactory().createParameter();
     Value.Name = "Value";
     Value.Type = EFSSystem.DoubleType;
     Value.setFather(this);
     FormalParameters.Add(Value);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Constructor
 /// </summary>
 public Available(EFSSystem efsSystem)
     : base(efsSystem, "Available")
 {
     Element      = (Parameter)Generated.acceptor.getFactory().createParameter();
     Element.Name = "Element";
     Element.Type = EFSSystem.AnyType;
     Element.setFather(this);
     FormalParameters.Add(Element);
 }
Ejemplo n.º 9
0
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="efsSystem"></param>
 /// <param name="name">the name of the cast function</param>
 public Not(EfsSystem efsSystem)
     : base(efsSystem, "NOT")
 {
     Value      = (Parameter)acceptor.getFactory().createParameter();
     Value.Name = "Value";
     Value.Type = EFSSystem.BoolType;
     Value.setFather(this);
     FormalParameters.Add(Value);
 }
Ejemplo n.º 10
0
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="efsSystem"></param>
 public Discontinuities(EfsSystem efsSystem)
     : base(efsSystem, "Discontinuities")
 {
     Targets      = (Parameter)acceptor.getFactory().createParameter();
     Targets.Name = "SpeedRestrictions";
     Targets.Type = EFSSystem.AnyType;
     Targets.setFather(this);
     FormalParameters.Add(Targets);
 }
Ejemplo n.º 11
0
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="efsSystem"></param>
 public Targets(EfsSystem efsSystem)
     : base(efsSystem, "TARGETS")
 {
     SpeedRestrictions      = (Parameter)acceptor.getFactory().createParameter();
     SpeedRestrictions.Name = "SpeedRestrictions";
     SpeedRestrictions.Type = EFSSystem.AnyType;
     SpeedRestrictions.setFather(this);
     FormalParameters.Add(SpeedRestrictions);
 }
Ejemplo n.º 12
0
 /// <summary>
 ///     Constructor
 /// </summary>
 public Allocate(EfsSystem efsSystem)
     : base(efsSystem, "Allocate")
 {
     Collection      = (Parameter)acceptor.getFactory().createParameter();
     Collection.Name = "Collection";
     Collection.Type = EFSSystem.GenericCollection;
     Collection.setFather(this);
     FormalParameters.Add(Collection);
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="efsSystem"></param>
        /// <param name="name">the name of the cast function</param>
        public Cast(Types.Range range)
            : base(range.EFSSystem, range.Name)
        {
            Range = range;

            Value      = (Parameter)Generated.acceptor.getFactory().createParameter();
            Value.Name = "Value";
            Value.Type = EFSSystem.AnyType;
            Value.setFather(this);
            FormalParameters.Add(Value);
        }
Ejemplo n.º 14
0
        /// <summary>
        ///     Constructor
        /// </summary>
        /// <param name="type">The type in which the cast is performed</param>
        public Cast(Type type)
            : base(type.EFSSystem, type.Name)
        {
            TargetType = type;

            Value      = (Parameter)acceptor.getFactory().createParameter();
            Value.Name = "Value";
            Value.Type = EFSSystem.AnyType;
            Value.setFather(this);
            FormalParameters.Add(Value);
        }
Ejemplo n.º 15
0
        public static FunctionObject FunctionCreate(FunctionCreateKind kind, FormalParameters parameters, FunctionStatementList body, LexicalEnvironment scope, bool strict, IValue?prototype = null)
        {
            if (prototype == null)
            {
                prototype = Interpreter.Instance().CurrentRealm().Intrinsics.FunctionPrototype;
            }
            var            functionKind = kind == FunctionCreateKind.Normal ? FunctionKind.Normal : FunctionKind.NonConstructor;
            FunctionObject F            = FunctionAllocate(prototype, strict, functionKind);

            return(FunctionInitialize(F, kind, parameters, body, scope));
        }
Ejemplo n.º 16
0
 /// <summary>
 /// Creates a native indexer.
 /// </summary>
 /// <param name="property"></param>
 public NativeIndexer(PropertyInfo property)
 {
     this.property = property;
     if (property.Name != "Item")
     {
         throw new InvalidOperationException("This property is not an index accessor!");
     }
     FormalParameters = property.GetIndexParameters().Select(p => p.ParameterType).ToArray();
     if (!FormalParameters.Any())
     {
         throw new InvalidOperationException("This index accessor has no parameters!");
     }
     ReturnType = property.PropertyType;
 }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="dictionary"></param>
        public FunctionDoubleToDouble(EFSSystem efsSystem)
            : base()
        {
            Enclosing = efsSystem;
            Name      = "FunctionDoubleToDouble";

            Parameter param = (Parameter)DataDictionary.Generated.acceptor.getFactory().createParameter();

            param.Name = "Distance";
            param.Type = EFSSystem.DoubleType;
            FormalParameters.Add(param);

            ReturnType = EFSSystem.DoubleType;
        }
Ejemplo n.º 18
0
        /// <summary>
        ///     Constructor
        /// </summary>
        /// <param name="efsSystem"></param>
        public Max(EfsSystem efsSystem)
            : base(efsSystem, "MAX")
        {
            First      = (Parameter)acceptor.getFactory().createParameter();
            First.Name = "First";
            First.Type = EFSSystem.AnyType;
            First.setFather(this);
            FormalParameters.Add(First);

            Second      = (Parameter)acceptor.getFactory().createParameter();
            Second.Name = "Second";
            Second.Type = EFSSystem.AnyType;
            Second.setFather(this);
            FormalParameters.Add(Second);
        }
Ejemplo n.º 19
0
        /// <summary>
        ///     Constructor
        /// </summary>
        /// <param name="efsSystem"></param>
        public AddIncrement(EfsSystem efsSystem)
            : base(efsSystem, "AddIncrement")
        {
            Function      = (Parameter)acceptor.getFactory().createParameter();
            Function.Name = "Function";
            Function.Type = EFSSystem.AnyType;
            Function.setFather(this);
            FormalParameters.Add(Function);

            Increment      = (Parameter)acceptor.getFactory().createParameter();
            Increment.Name = "Increment";
            Increment.Type = EFSSystem.AnyType;
            Increment.setFather(this);
            FormalParameters.Add(Increment);
        }
Ejemplo n.º 20
0
        /// <summary>
        ///     Constructor
        /// </summary>
        /// <param name="efsSystem"></param>
        public AddToDate(EfsSystem efsSystem)
            : base(efsSystem, "AddToDate")
        {
            StartDate      = (Parameter)acceptor.getFactory().createParameter();
            StartDate.Name = "StartDate";
            StartDate.Type = EFSSystem.AnyType;
            StartDate.setFather(this);
            FormalParameters.Add(StartDate);

            Increment      = (Parameter)acceptor.getFactory().createParameter();
            Increment.Name = "Increment";
            Increment.Type = EFSSystem.DoubleType;
            Increment.setFather(this);
            FormalParameters.Add(Increment);
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="efsSystem"></param>
        /// <param name="name">the name of the cast function</param>
        public DecelerationProfile(EFSSystem efsSystem)
            : base(efsSystem, "DecelerationProfile")
        {
            SpeedRestrictions      = (Parameter)Generated.acceptor.getFactory().createParameter();
            SpeedRestrictions.Name = "SpeedRestrictions";
            SpeedRestrictions.Type = EFSSystem.AnyType;
            SpeedRestrictions.setFather(this);
            FormalParameters.Add(SpeedRestrictions);

            DecelerationFactor      = (Parameter)Generated.acceptor.getFactory().createParameter();
            DecelerationFactor.Name = "DecelerationFactor";
            DecelerationFactor.Type = EFSSystem.AnyType;
            DecelerationFactor.setFather(this);
            FormalParameters.Add(DecelerationFactor);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="efsSystem"></param>
        /// <param name="name">the name of the cast function</param>
        public MinSurface(EFSSystem efsSystem)
            : base(efsSystem, "MINSURFACE")
        {
            First      = (Parameter)Generated.acceptor.getFactory().createParameter();
            First.Name = "First";
            First.Type = EFSSystem.AnyType;
            First.setFather(this);
            FormalParameters.Add(First);

            Second      = (Parameter)Generated.acceptor.getFactory().createParameter();
            Second.Name = "Second";
            Second.Type = EFSSystem.AnyType;
            Second.setFather(this);
            FormalParameters.Add(Second);
        }
Ejemplo n.º 23
0
        /// <summary>
        ///     Constructor
        /// </summary>
        /// <param name="efsSystem"></param>
        public DistanceForSpeed(EfsSystem efsSystem)
            : base(efsSystem, "DistanceForSpeed")
        {
            Function      = (Parameter)acceptor.getFactory().createParameter();
            Function.Name = "Function";
            Function.Type = EFSSystem.AnyType;
            Function.setFather(this);
            FormalParameters.Add(Function);

            Speed      = (Parameter)acceptor.getFactory().createParameter();
            Speed.Name = "Speed";
            Speed.Type = EFSSystem.DoubleType;
            Speed.setFather(this);
            FormalParameters.Add(Speed);
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="efsSystem"></param>
        /// <param name="name">the name of the cast function</param>
        public IntersectAt(EFSSystem efsSystem)
            : base(efsSystem, "IntersectAt")
        {
            FunctionA      = (Parameter)Generated.acceptor.getFactory().createParameter();
            FunctionA.Name = "FunctionA";
            FunctionA.Type = EFSSystem.AnyType;
            FunctionA.setFather(this);
            FormalParameters.Add(FunctionA);

            FunctionB      = (Parameter)Generated.acceptor.getFactory().createParameter();
            FunctionB.Name = "FunctionB";
            FunctionB.Type = EFSSystem.AnyType;
            FunctionB.setFather(this);
            FormalParameters.Add(FunctionB);
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="efsSystem"></param>
        public RoundToMultiple(EFSSystem efsSystem)
            : base(efsSystem, "RoundToMultiple")
        {
            Value      = (Parameter)Generated.acceptor.getFactory().createParameter();
            Value.Name = "Value";
            Value.Type = EFSSystem.DoubleType;
            Value.setFather(this);
            FormalParameters.Add(Value);

            Multiple      = (Parameter)Generated.acceptor.getFactory().createParameter();
            Multiple.Name = "Multiple";
            Multiple.Type = EFSSystem.DoubleType;
            Multiple.setFather(this);
            FormalParameters.Add(Multiple);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="efsSystem"></param>
        public Concat(EfsSystem efsSystem)
            : base(efsSystem, "Concat")
        {
            String1      = (Parameter)acceptor.getFactory().createParameter();
            String1.Name = "String1";
            String1.Type = EFSSystem.StringType;
            String1.setFather(this);
            FormalParameters.Add(String1);

            String2      = (Parameter)acceptor.getFactory().createParameter();
            String2.Name = "String2";
            String2.Type = EFSSystem.StringType;
            String2.setFather(this);
            FormalParameters.Add(String2);
        }
Ejemplo n.º 27
0
        /// <summary>
        ///     Constructor
        /// </summary>
        public Before(EfsSystem efsSystem)
            : base(efsSystem, "Before")
        {
            ExpectedFirst      = (Parameter)acceptor.getFactory().createParameter();
            ExpectedFirst.Name = "ExpectedFirst";
            ExpectedFirst.Type = EFSSystem.AnyType;
            ExpectedFirst.setFather(this);
            FormalParameters.Add(ExpectedFirst);

            ExpectedSecond      = (Parameter)acceptor.getFactory().createParameter();
            ExpectedSecond.Name = "ExpectedSecond";
            ExpectedSecond.Type = EFSSystem.AnyType;
            ExpectedSecond.setFather(this);
            FormalParameters.Add(ExpectedSecond);

            Collection      = (Parameter)acceptor.getFactory().createParameter();
            Collection.Name = "Collection";
            Collection.Type = EFSSystem.GenericCollection;
            Collection.setFather(this);
            FormalParameters.Add(Collection);
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="efsSystem"></param>
        public Targets(EFSSystem efsSystem)
            : base(efsSystem, "TARGETS")
        {
            Targets1      = (Parameter)Generated.acceptor.getFactory().createParameter();
            Targets1.Name = "Targets1";
            Targets1.Type = EFSSystem.AnyType;
            Targets1.setFather(this);
            FormalParameters.Add(Targets1);

            Targets2      = (Parameter)Generated.acceptor.getFactory().createParameter();
            Targets2.Name = "Targets2";
            Targets2.Type = EFSSystem.AnyType;
            Targets2.setFather(this);
            FormalParameters.Add(Targets2);

            Targets3      = (Parameter)Generated.acceptor.getFactory().createParameter();
            Targets3.Name = "Targets3";
            Targets3.Type = EFSSystem.AnyType;
            Targets3.setFather(this);
            FormalParameters.Add(Targets3);
        }
        public FullDecelerationForTarget(EfsSystem efsSystem)
            : base(efsSystem, "FullDecelerationForTarget")
        {
            Target      = (Parameter)acceptor.getFactory().createParameter();
            Target.Name = "Target";
            Target.Type = EFSSystem.AnyType;
            Target.setFather(this);
            FormalParameters.Add(Target);

            DecelerationFactor      = (Parameter)acceptor.getFactory().createParameter();
            DecelerationFactor.Name = "DecelerationFactor";
            DecelerationFactor.Type = EFSSystem.AnyType;
            DecelerationFactor.setFather(this);
            FormalParameters.Add(DecelerationFactor);

            // Third parameter end speed
            EndSpeed      = (Parameter)acceptor.getFactory().createParameter();
            EndSpeed.Name = "EndSpeed";
            EndSpeed.Type = EFSSystem.AnyType;
            EndSpeed.setFather(this);
            FormalParameters.Add(EndSpeed);
        }
Ejemplo n.º 30
0
 public FunctionDeclaration(FormalParameters formalParameters, FunctionStatementList functionBody, bool isStrictMode) : base(isStrictMode)
 {
     isAnonymous           = true;
     this.formalParameters = formalParameters;
     this.functionBody     = functionBody;
 }