示例#1
0
    /* Comparison Operations */
    /* --------------------- */

    public static void op1_zerop(SObject arg) {
        if (arg is SFixnum) {
            Reg.Result = Factory.makeBoolean(((SFixnum)arg).value == 0);
            return;
        } else if (arg is SVL) {
            SVL a = (SVL) arg;
            if (a.tag == Tags.RatnumTag) {
                Reg.Result = Factory.False; // FIXME???
            } else if (a.tag == Tags.RectnumTag) {
                op2_numeric_equals(arg, Factory.makeFixnum(0));
                return;
            }
        } else if (arg is SByteVL) {
            SByteVL a = (SByteVL) arg;
            if (a.tag == Tags.BignumTag) {
                Reg.Result = Factory.makeBoolean(Number.getBignumLength(a) == 0);
                return;
            } else if (a.tag == Tags.FlonumTag) {
                Reg.Result = Factory.makeBoolean(a.unsafeAsDouble(0) == 0.0);
                return;
            } else if (a.tag == Tags.CompnumTag) {
                Reg.Result = Factory.makeBoolean
                    (a.unsafeAsDouble(0) == 0.0 &
                     a.unsafeAsDouble(1) == 0.0);
                return;
            }
        }
        Reg.Result = Factory.makeBoolean(false);
        return;
    }
示例#2
0
 public void ShouldAddArrays()
 {
     dynamic e = new SObject();
     e.Owners = new[] { "Steve", "Bill" };
     Assert.That(e.Owners[0], Is.EqualTo("Steve"));
     Assert.That(e.Owners[1], Is.EqualTo("Bill"));
 }
示例#3
0
        private void ReadElement(XmlReader reader, SObject parent) {
            var name = XmlConvert.DecodeName(reader.LocalName);
            var type = reader["type"];

            // is it a value node ? i.e. type=""
            if (type != null) {
                if (type == "Array") {
                    // go to first item
                    parent.SetMember(name, ReadArray(reader));
                    reader.Read();
                }
                else {
                    var typeCode = (TypeCode)Enum.Parse(typeof(TypeCode), type);
                    var value = SConvert.XmlDecode(typeCode, reader.ReadElementString());
                    parent.SetMember(name, value);
                }
            }
            else {
                var grappe = new SObject();
                reader.Read();
                parent.SetMember(name, grappe);
                while (reader.MoveToContent() == XmlNodeType.Element) {
                    ReadElement(reader, grappe);
                }

                reader.Read();
            }
        }
示例#4
0
        internal override SObject ExecuteMethod(ScriptProcessor processor, string methodName, SObject caller, SObject This, SObject[] parameters)
        {
            InitializeStatic();

            AddObjectPrototypeAsExtends(processor);

            bool isStaticCall = ReferenceEquals(caller, this);

            // Call any static function defined in this prototype:
            if (_prototypeMembers.ContainsKey(methodName) && _prototypeMembers[methodName].IsStatic)
            {
                if (_prototypeMembers[methodName].IsFunction)
                {
                    var cFunction = (SFunction)_prototypeMembers[methodName].Data;
                    return cFunction.Call(processor, caller, this, parameters); // For a static method, the "This" attribute is the prototype.
                }
                else
                {
                    return processor.ErrorHandler.ThrowError(ErrorType.TypeError, ErrorHandler.MESSAGE_TYPE_NOT_A_FUNCTION, methodName);
                }
            }

            // Call the super class prototype, if one exists:
            if (Extends != null)
            {
                return Extends.ExecuteMethod(processor, methodName, caller, This, parameters);
            }

            return processor.ErrorHandler.ThrowError(ErrorType.ReferenceError, ErrorHandler.MESSAGE_REFERENCE_NOT_DEFINED, methodName);
        }
		public static void Update (this SalesforceClient self, SObject sobject)
		{
			var updateRequest = new UpdateRequest (sobject);
			var result = self.ProcessAsync (updateRequest);
			if (!result.Wait (TimeSpan.FromSeconds (SalesforceClient.DefaultNetworkTimeout)))
				return; // TODO : Error handling/reporting
		}
示例#6
0
文件: SConvert.cs 项目: dioptre/nkd
        public static ISItem ToSettings(object o) {
            if (o is SValue) {
                return (ISItem)o;
            }

            if (o is SObject) {
                return (ISItem)o;
            }

            if (o is SArray) {
                return (ISItem)o;
            }

            if (o is Array) {
                return new SArray((Array)o);
            }

            if (IsAnonymousType(o.GetType())) {
                dynamic grappe = new SObject();

                foreach (var p in o.GetType().GetProperties()) {
                    grappe[p.Name] = p.GetValue(o, null);
                }

                return grappe;
            }

            return new SValue(o);
        }
示例#7
0
        public static SObject Create(ScriptProcessor processor, SObject instance, SObject This, SObject[] parameters)
        {
            Prototype prototype = null;

            if (parameters.Length > 0)
            {
                var protoParam = parameters[0];
                if (protoParam.TypeOf() == LITERAL_TYPE_STRING)
                {
                    prototype = processor.Context.GetPrototype(((SString)protoParam).Value);
                }
                else if (IsPrototype(protoParam.GetType()))
                {
                    prototype = (Prototype)protoParam;
                }
                else
                {
                    return processor.ErrorHandler.ThrowError(ErrorType.TypeError, ErrorHandler.MESSAGE_REFERENCE_NO_PROTOTYPE, protoParam.TypeOf());
                }
            }

            if (prototype != null)
            {
                var instParams = new SObject[parameters.Length - 1];
                Array.Copy(parameters, 1, instParams, 0, parameters.Length - 1);

                return processor.Context.CreateInstance(prototype, instParams);
            }
            else
            {
                return processor.ErrorHandler.ThrowError(ErrorType.TypeError, ErrorHandler.MESSAGE_REFERENCE_NO_PROTOTYPE, LITERAL_UNDEFINED);
            }
        }
示例#8
0
        public void ShouldAddAnonymousObject() {
            dynamic e = new SObject();

            e.Foos = new { Foo1 = "Bar1", Foo2 = "Bar2" };
            Assert.That(e.Foos.Foo1, Is.EqualTo("Bar1"));
            Assert.That(e.Foos.Foo2, Is.EqualTo("Bar2"));
        }
示例#9
0
        public static SObject IndexerSet(ScriptProcessor processor, SObject instance, SObject This, SObject[] parameters)
        {
            var arr = (SArray)instance;

            if (parameters.Length >= 2)
            {
                var accessor = (int)parameters[0].ToNumber(processor).Value;

                if (accessor >= 0)
                {
                    if (accessor < arr.ArrayMembers.Length)
                    {
                        arr.ArrayMembers[accessor] = parameters[1];
                    }
                    else
                    {
                        var arrMembers = arr.ArrayMembers;
                        Array.Resize(ref arrMembers, accessor + 1);
                        arrMembers[accessor] = parameters[1];
                        arr.ArrayMembers = arrMembers;
                    }
                }
            }

            return processor.Undefined;
        }
示例#10
0
        /// <summary>
        /// Unboxes an <see cref="SVariable"/> if the passed in object is one.
        /// </summary>
        internal static SObject Unbox(SObject obj)
        {
            while (obj is SVariable)
                obj = ((SVariable)obj).Data;

            return obj;
        }
示例#11
0
    /* // from <larceny_src>/Lib/Common/malcode.mal:
       ; Syscall has to be coded in mal because the arguments are passed in a
       ; non-standard way and because the compiler cannot handle a primitive
       ; with a variable, large, number of parameters.  Syscall is simply a
       ; trampoline into a millicode procedure.  RESULT has the number of 
       ; arguments, and the arguments are passed in registers as usual.
    */
    public static void op1_syscall(SObject arg) {
        // subtract one 'cuz the first arg is just the value
        // to which we want to dispatch.
//        System.Console.WriteLine("*** syscall {0}", Reg.register2);
        int num_args = ((SFixnum)arg).intValue() - 1;
        Sys num_syscall = (Sys) ((SFixnum)Reg.register1).intValue();
        Syscall.dispatch(num_args, num_syscall);
    }
示例#12
0
  public static CodeAddress fault (int blame, string m,
				   SObject arg1, SObject arg2, SObject arg3)
  {
    Reg.Result = arg1;
    Reg.Second = arg2;
    Reg.Third = arg3;
    return Exn.fault (blame, m);
  }
示例#13
0
 public void ShouldAddDynamicObjects() {
     dynamic e = new SObject();
     e.Address = new SObject();
     
     e.Address.Street = "One Microsoft Way";
     Assert.That(e["Address"]["Street"], Is.EqualTo("One Microsoft Way"));
     Assert.That(e.Address.Street, Is.EqualTo("One Microsoft Way"));
 }
示例#14
0
 public PrototypeMember(string identifier, SObject data, bool isStatic, bool isReadOnly, bool isIndexerGet, bool isIndexerSet)
 {
     Identifier = identifier;
     Data = data;
     IsStatic = isStatic;
     IsReadOnly = isReadOnly;
     IsIndexerGet = isIndexerGet;
     IsIndexerSet = isIndexerSet;
 }
示例#15
0
 public static void rangeCheckVL(SObject arg1, SObject arg2, SObject arg3, int blame) {
     SVL bv = (SVL) arg1;
     int index = ((SFixnum) arg2).value;
     if (index >= 0 && index < bv.elements.Length) {
         
     } else {
         Exn.fault(blame, "index out of range", arg1, arg2, arg3);
     }
 }
示例#16
0
        public void Serialize(TextWriter tw, SObject o) {
            using (var writer = new XmlTextWriter(tw)) {
                writer.WriteStartDocument();
                writer.WriteStartElement(Root);
                WriteGrappe(writer, o);

                writer.WriteEndDocument();
            }
        }
		public static async Task UpdateAsync (this SalesforceClient self, SObject sobject)
		{
			var updateRequest = new UpdateRequest (sobject);
			try {
				await self.ProcessAsync (updateRequest).ConfigureAwait (true);
			} catch (AggregateException ex) {
				Debug.WriteLine (ex.Message);
			}
		}
示例#18
0
        public void ShouldRemoveMember() {
            dynamic e = new SObject();
            e.Foo = "Bar";
            Assert.That(e, Is.Not.Empty);
            Assert.That(e.Foo, Is.EqualTo("Bar"));

            e.Foo = null;
            Assert.That(e, Is.Empty);
        }
示例#19
0
		async void Save () 
		{
			var selectedObject = new SObject (data);

			await RootActivity.Client.CreateAsync (selectedObject).ContinueWith (response => {
				Debug.WriteLine ("save finished.");
				StartActivity (typeof(RootActivity));
			});
		}
示例#20
0
 public static void op1_disable_interrupts(SObject arg) {
     if (Reg.interruptsEnabled) {
         Reg.interruptsEnabled = false;
         Reg.Result = Factory.makeFixnum((int)Reg.timer);
     } else {
         Reg.Result = Factory.makeBoolean(false);
     }
     Exn.checkSignals();
 }
示例#21
0
 public static void expect2(bool b1, SObject arg1,
                            bool b2, SObject arg2,
                            int blame) {
     if (!b1) {
         Exn.fault(blame, "bad argument 1: " + arg1, arg1, arg2);
     }
     if (!b2) {
         Exn.fault(blame, "bad argument 2: " + arg2, arg1, arg2);
     }
 }
示例#22
0
        private static SObject constructor(ScriptProcessor processor, SObject instance, SObject This, SObject[] parameters)
        {
            var arr = (SArray)instance;

            var length = (int)((SNumber)parameters[0]).Value;
            arr.ArrayMembers = new SObject[length];

            Array.Copy(parameters, 1, arr.ArrayMembers, 0, parameters.Length - 1);
            return arr;
        }
示例#23
0
        public SArray ReadArray(XmlReader reader) {
            var list = new List<object>();
            reader.Read();
            while (reader.MoveToContent() == XmlNodeType.Element && reader.LocalName == "Item") {
                dynamic o = new SObject();
                ReadElement(reader, o);
                list.Add(o.Item);
            }

            return new SArray(list.ToArray());
        }
示例#24
0
        private static SObject constructor(ScriptProcessor processor, SObject instance, SObject This, SObject[] parameters)
        {
            var obj = (SNumber)instance;

            if (parameters[0] is SNumber)
                obj.Value = ((SNumber)parameters[0]).Value;
            else
                obj.Value = parameters[0].ToNumber(processor).Value;

            return obj;
        }
示例#25
0
 public static void op2_eqvp(SObject arg1, SObject arg2) {
     // EQ test first, get that out of the way.
     if (arg1 == arg2) {
         Reg.Result = Factory.True;
         return;
     } else if (arg1 is SChar & arg2 is SChar) {
         Reg.Result = Factory.wrap(((SChar)arg1).val == ((SChar)arg2).val);
         return;
     } else if (arg1 is SFixnum & arg2 is SFixnum) {
         bool result =
             ((SFixnum)arg1).value == ((SFixnum)arg2).value;
         Reg.Result = Factory.makeBoolean(result);
         return;
     } else if (arg1 is SVL & arg2 is SVL) {
         SVL a = (SVL)arg1;
         SVL b = (SVL)arg2;
         if (a.tag == Tags.RatnumTag & b.tag == Tags.RatnumTag) {
             Call.callMillicodeSupport2(Constants.MS_RATNUM_EQUAL, a, b);
             return; // TAIL CALL
         } else if (a.tag == Tags.RectnumTag & b.tag == Tags.RectnumTag) {
             Call.callMillicodeSupport2(Constants.MS_RECTNUM_EQUAL, a, b);
             return; // TAIL CALL
         } else {
             Reg.Result = Factory.False;
             return;
         }
     } else if (arg1 is SByteVL & arg2 is SByteVL) {
         SByteVL a = (SByteVL)arg1;
         SByteVL b = (SByteVL)arg2;
         if (a.tag == Tags.BignumTag & b.tag == Tags.BignumTag) {
             Call.callMillicodeSupport2(Constants.MS_BIGNUM_EQUAL, a, b);
             return; // TAIL CALL
         } else if (a.tag == Tags.FlonumTag & b.tag == Tags.FlonumTag) {
             double av = a.unsafeAsDouble(0);
             double bv = b.unsafeAsDouble(0);
             Reg.Result = Factory.makeBoolean(av == bv);
             return;
         } else if (a.tag == Tags.CompnumTag & b.tag == Tags.CompnumTag) {
             double ar = a.unsafeAsDouble(0);
             double ai = a.unsafeAsDouble(1);
             double br = b.unsafeAsDouble(0);
             double bi = b.unsafeAsDouble(1);
             Reg.Result = Factory.makeBoolean(ar == br & ai == bi);
             return;
         } else {
             Reg.Result = Factory.False;
             return;
         }
     } else {
         Reg.Result = Factory.False;
         return;
     }
 }
示例#26
0
        public void ShouldBeEnumerable() {
            dynamic e = new SObject();
            e.Address = new SObject();

            e.Address.Street = "One Microsoft Way";
            e.Foos = new[] { new { Foo1 = "Bar1", Foo2 = "Bar2" } };
            e.Owners = new[] { "Steve", "Bill" };

            // IEnumerable
            Assert.That(e, Has.Some.Matches<KeyValuePair<string, object>>(x => x.Key == "Address"));
            Assert.That(e, Has.Some.Matches<KeyValuePair<string, object>>(x => x.Key == "Owners"));
            Assert.That(e, Has.Some.Matches<KeyValuePair<string, object>>(x => x.Key == "Foos"));
        }
示例#27
0
        private static SObject constructor(ScriptProcessor processor, SObject instance, SObject This, SObject[] parameters)
        {
            var obj = (SError)instance;

            if (parameters.Length > 0)
            {
                SString message;

                if (parameters[0] is SString)
                    message = (SString)parameters[0];
                else
                    message = parameters[0].ToString(processor);

                obj.Members[MEMBER_NAME_MESSAGE].Data = message;
            }

            if (parameters.Length > 1)
            {
                SString errorType;

                if (parameters[1] is SString)
                    errorType = (SString)parameters[1];
                else
                    errorType = parameters[1].ToString(processor);

                obj.Members[MEMBER_NAME_TYPE].Data = errorType;
            }
            else
            {
                obj.Members[MEMBER_NAME_TYPE].Data = processor.CreateString("UserError");
            }

            if (parameters.Length > 2)
            {
                SNumber errorLine;

                if (parameters[2] is SNumber)
                    errorLine = (SNumber)parameters[2];
                else
                    errorLine = parameters[2].ToNumber(processor);

                obj.Members[MEMBER_NAME_LINE].Data = errorLine;
            }
            else
            {
                obj.Members[MEMBER_NAME_LINE].Data = processor.CreateNumber(-1);
            }

            return obj;
        }
示例#28
0
        private static SObject constructor(ScriptProcessor processor, SObject instance, SObject This, SObject[] parameters)
        {
            var obj = (SString)instance;

            if (parameters[0] is SString)
            {
                obj.Value = ((SString)parameters[0]).Value;
                obj.Escaped = ((SString)parameters[0]).Escaped;
            }
            else
                obj.Value = parameters[0].ToString(processor).Value;

            return obj;
        }
示例#29
0
    /* Misc */
    /* ---- */

    public static void op1_enable_interrupts(SObject arg) {
        Ops.expect1(arg.isFixnum(), arg, Constants.EX_EINTR);
        int time = ((SFixnum)arg).value;

        if (time > 0) {
            Reg.interruptsEnabled = true;
            Reg.timer = time;
        } else {
            Exn.fault(Constants.EX_EINTR,
                      "enable-interrupts: expected positive value");
        }
        Reg.Result = Factory.Unspecified;
        Exn.checkSignals();
    }
示例#30
0
        public SObject Deserialize(TextReader tr) {
            var reader = new XmlTextReader(tr);
            var result = new SObject();

            // ignore root element
            while (reader.MoveToContent() == XmlNodeType.Element && reader.LocalName == Root) {
                reader.Read();
            }

            while (reader.MoveToContent() == XmlNodeType.Element) {
                ReadElement(reader, result);
            }

            return result;
        }
示例#31
0
 public static SObject op3_vector_set_trusted(SObject arg1, SObject arg2, SObject arg3)
 {
     ((SVL)arg1).elements[((SFixnum)arg2).value] = arg3;
     return(Factory.Unspecified);
 }
示例#32
0
        /* String operations */
        /* ----------------- */

        public static SObject op1_make_string(SObject arg)
        {
            expect1(arg.isFixnum(), arg, Constants.EX_MKBVL);
            return(Factory.makeString(((SFixnum)arg).value, (char)0));
        }
示例#33
0
 public static SObject op1_most_negative_fixnum(SObject unused)
 {
     return(Factory.makeFixnum(SFixnum.MIN));
 }
示例#34
0
        /// <summary>
        /// Throws an error with the given error object.
        /// </summary>
        public SObject ThrowError(SObject errorObject)
        {
            ErrorObject = errorObject;

            throw new ScriptException(ErrorObject);
        }
 // API
 public KnowledgeArticleVersionStandardController(SObject article)
 {
     Self = Implementation.Constructor(article);
 }
示例#36
0
    void createObjects(MapSchema <ObjectState> objects)
    {
        objects.ForEach((string s, ObjectState ob) =>
        {
            Debug.Log("Creating " + ob.type + " / [" + ((BoxObject)ob).halfSize.x + "]");
            GameObject gameOb = null;

            SObject serverObject = null;

            if (ob.instantiate)
            {
                if (ob.GetType().Equals(typeof(SphereObject)))
                {
                    SphereObject sphereState = (SphereObject)ob;
                    if (ob.mesh.Length > 0)
                    {
                        //Debug.Log("Instantiating a mesh");
                        UnityEngine.Object prefab = Resources.Load(ob.mesh); // Assets/Resources/Prefabs/prefab1.FBX
                        gameOb = (GameObject)Instantiate(prefab);
                    }
                    else
                    {
                        gameOb = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                        gameOb.GetComponent <Renderer>().material = material;
                    }

                    gameOb.name = "Esfera (" + ob.uID + ")";
                    float size  = (sphereState.radius) * 2;
                    gameOb.transform.localScale = new Vector3(size, size, size);
                    serverObject = gameOb.AddComponent <SObject>();
                    serverObject.setState(sphereState);

                    this.objects.Add(s, serverObject);
                }
                if (ob.GetType().Equals(typeof(BoxObject)))
                {
                    BoxObject boxState = (BoxObject)ob;
                    if (ob.mesh.Length > 0)
                    {
                        //Debug.Log("Instantiating a mesh");
                        UnityEngine.Object prefab = Resources.Load(ob.mesh); // Assets/Resources/Prefabs/prefab1.FBX
                        gameOb = (GameObject)Instantiate(prefab);
                    }
                    else
                    {
                        gameOb = GameObject.CreatePrimitive(PrimitiveType.Cube);
                        gameOb.GetComponent <Renderer>().material = material;
                    }

                    gameOb.name  = ob.type + "(" + ob.uID + ")";
                    Vector3 size = new Vector3(boxState.halfSize.x, boxState.halfSize.y, boxState.halfSize.z);
                    size.Scale(new Vector3(2, 2, 2));
                    gameOb.transform.localScale = size;

                    serverObject = gameOb.AddComponent <SObject>();
                    serverObject.setState(boxState);
                    this.objects.Add(s, serverObject);
                }

                gameOb.transform.parent = ServerObjects.transform;

                gameOb.transform.position = new Vector3(ob.position.x, ob.position.y, ob.position.z);
                gameOb.transform.rotation = new Quaternion(ob.quaternion.x, ob.quaternion.y, ob.quaternion.z, ob.quaternion.w);
            }

            if (gameOb != null)
            {
                /*gameOb.name = ob.type + " [" + ob.uID + "]";
                 * if (ob.owner.sessionId != "")
                 * {
                 *  gameOb.name += "=> " + ob.owner.sessionId;
                 * }
                 * if (ob.type == "golfball")
                 * {
                 *  Debug.Log("Creating GolfBall");
                 *  GolfBall objComp = gameOb.AddComponent<GolfBall>();
                 *  gameOb.layer = 8;
                 *  objComp.setState(ob);
                 * // mMaterial = BallMaterial;
                 *  //this.golfballs.Add(ob.owner.sessionId, serverObject);
                 * }
                 * if (ob.type == "player")
                 * {
                 *  Debug.Log("Creating player " + ob.owner.sessionId);
                 *  Player objComp = gameOb.AddComponent<Player>();
                 *  gameOb.layer = 8;
                 *  objComp.setState(ob);
                 *  //mMaterial = BallMaterial;
                 *  // this.golfballs.Add(ob.owner.sessionId, serverObject);
                 * }
                 * if (ob.type == "trownobj")
                 * {
                 * // mMaterial = WallMaterial;
                 * }
                 * if (ob.type == "characer")
                 * {
                 *
                 * }
                 * if (ob.mesh.Length == 0)
                 * {
                 * // gameOb.GetComponent<Renderer>().material = mMaterial;
                 * }
                 *
                 * gameOb.transform.position = new Vector3(ob.position.x, ob.position.y, ob.position.z);
                 * gameOb.transform.rotation = new Quaternion(ob.quaternion.x, ob.quaternion.y, ob.quaternion.z, ob.quaternion.w);
                 */
            }
        });
    }
示例#37
0
 public static SObject op2_vector_ref(SObject arg1, SObject arg2)
 {
     expect2(arg1.isVector(), arg1, arg2.isFixnum(), arg2, Constants.EX_VECTOR_REF);
     rangeCheckVL(arg1, arg2, Constants.EX_VLREF);
     return(((SVL)arg1).elements[((SFixnum)arg2).value]);
 }
 public ScriptStopException(ScriptStopReason reason, SObject returnObject) : base()
 {
     ReturnObject = returnObject;
     Reason       = reason;
 }
示例#39
0
        public static SObject AddMember(ScriptProcessor processor, SObject instance, SObject This, SObject[] parameters)
        {
            // Parameter #1: (String)Name of the new member
            // [Parameter #2: Default value of the new member ] / Undefined
            // [Parameter #3: Signature config of the new member] / instance member, no special settings

            if (parameters.Length == 0)
            {
                return(processor.Undefined);
            }

            Prototype prototype;

            if (IsPrototype(instance.GetType()))
            {
                prototype = (Prototype)instance;
            }
            else
            {
                // The instance will be a prototype instance, so get its prototype from there:
                var protoObj = (SProtoObject)instance;
                prototype = protoObj.Prototype;
            }

            var memberAsString = parameters[0] as SString;
            var memberName     = memberAsString != null ? memberAsString.Value : parameters[0].ToString(processor).Value;

            var defaultValue = processor.Undefined;

            if (parameters.Length > 1)
            {
                defaultValue = parameters[1];
            }

            var isReadOnly   = false;
            var isStatic     = false;
            var isIndexerGet = false;
            var isIndexerSet = false;

            if (parameters.Length > 2)
            {
                var signature = parameters[2];
                var array     = signature as SArray;
                if (array != null)
                {
                    foreach (var arrayMember in array.ArrayMembers)
                    {
                        var arrayMemberAsString = arrayMember as SString;
                        if (arrayMemberAsString == null)
                        {
                            continue;
                        }

                        var signatureMember = arrayMemberAsString.Value;
                        switch (signatureMember)
                        {
                        case "readOnly":
                            isReadOnly = true;
                            break;

                        case "static":
                            isStatic = true;
                            break;

                        case "indexerGet":
                            isIndexerGet = true;
                            break;

                        case "indexerSet":
                            isIndexerSet = true;
                            break;
                        }
                    }
                }
            }

            if ((isIndexerSet || isIndexerGet) && !(defaultValue is SFunction))
            {
                processor.ErrorHandler.ThrowError(ErrorType.TypeError, ErrorHandler.MessageTypeGetterSetterNotAFunction);
            }

            if (!ScriptProcessor.IsValidIdentifier(memberName))
            {
                processor.ErrorHandler.ThrowError(ErrorType.SyntaxError, ErrorHandler.MessageSyntaxMissingVarName);
            }

            prototype.AddMember(processor, new PrototypeMember(memberName, defaultValue, isStatic, isReadOnly, isIndexerGet, isIndexerSet));

            return(processor.Undefined);
        }
示例#40
0
 // ReSharper disable InconsistentNaming
 public static SObject toString(ScriptProcessor processor, SObject instance, SObject This, SObject[] parameters)
 // ReSharper restore InconsistentNaming
 {
     return(processor.CreateString(LiteralObjectStr));
 }
示例#41
0
 public static SObject op2_string_ref(SObject arg1, SObject arg2)
 {
     expect2(arg1.isString(), arg1, arg2.isFixnum(), arg2, Constants.EX_STRING_REF);
     rangeCheckBVL(arg1, arg2, Constants.EX_STRING_REF);
     return(Factory.makeChar(((SByteVL)arg1).elements[((SFixnum)arg2).value]));
 }
示例#42
0
        /* Bytevector-likoe operations */
        /* -------------------------- */

        public static SObject op1_bytevector_like_length(SObject arg)
        {
            expect1(arg.isByteVectorLike(), arg, Constants.EX_BVLLEN);
            return(Factory.makeFixnum(((SByteVL)arg).length()));
        }
示例#43
0
 public static SObject op1_string_length_str(SObject arg)
 {
     return(Factory.makeFixnum(((SByteVL)arg).length()));
 }
示例#44
0
 public void flowPostProcessing(ProvisioningProcessHandlerOutput param1, SObject param2)
 {
     Self.flowPostProcessing(param1, param2);
 }
        public void TrueOrTrueTest()
        {
            SObject result = ResetParseAndGo("true || true");

            Assert.AreEqual(new SObject(true), result);
        }
        public void FalseOrFalseTest()
        {
            SObject result = ResetParseAndGo("false || false");

            Assert.AreEqual(new SObject(false), result);
        }
示例#47
0
 public static SObject op1_string_length(SObject arg)
 {
     expect1(arg.isString(), arg, Constants.EX_STRING_LENGTH);
     return(Factory.makeFixnum(((SByteVL)arg).length()));
 }
示例#48
0
        /* Fixnum Ops                */
        /* ------------------------- */

        public static SObject op1_fxzerop(SObject arg)
        {
            int a = ((SFixnum)arg).value;

            return(Factory.makeBoolean(a == 0));
        }
示例#49
0
 public static SObject op2_make_string(SObject arg1, SObject arg2)
 {
     expect2(arg1.isFixnum(), arg1, arg2.isChar(), arg2, Constants.EX_MKBVL);
     return(Factory.makeString(((SFixnum)arg1).value, ((SChar)arg2).val));
 }
示例#50
0
 internal void Clean()
 {
     _errorObject = null;
 }
示例#51
0
 public static SObject op1_most_positive_fixnum(SObject unused)
 {
     return(Factory.makeFixnum(SFixnum.MAX));
 }
示例#52
0
        /* Bytevector operations */
        /* --------------------- */

        public static SObject op1_make_bytevector(SObject arg)
        {
            expect1(arg.isFixnum(), arg, Constants.EX_MKBVL);
            return(Factory.makeByteVector(((SFixnum)arg).intValue(), (byte)0));
        }
示例#53
0
 public static SObject op2_vector_ref_trusted(SObject arg1, SObject arg2)
 {
     return(((SVL)arg1).elements[((SFixnum)arg2).value]);
 }
示例#54
0
 public static SObject op2_string_ref_trusted(SObject arg1, SObject arg2)
 {
     return(Factory.makeChar(((SByteVL)arg1).elements[((SFixnum)arg2).value]));
 }
示例#55
0
 public void StateInit(SObject so)
 {
 }
示例#56
0
 public void StopScriptAndReturnValue(SObject obj)
 {
     throw new ScriptStopException(ScriptStopReason.InFunctionStop, obj);
 }
示例#57
0
 public static SObject op2_bytevector_fill(SObject arg1, SObject arg2)
 {
     expect2(arg1.isByteVector(), arg1, arg2.isFixnum(), arg2, Constants.EX_BVFILL);
     ((SByteVL)arg1).fill((byte)((SFixnum)arg2).value);
     return(Factory.Unspecified);
 }
示例#58
0
 public static SObject op1_bytevector_length(SObject arg)
 {
     expect1(arg.isByteVector(), arg, Constants.EX_BYTEVECTOR_LENGTH);
     return(Factory.makeFixnum(((SByteVL)arg).length()));
 }
示例#59
0
        public void NotFalseTest()
        {
            SObject result = ResetParseAndGo("!false");

            Assert.AreEqual(new SObject(true), result);
        }
示例#60
0
 public static SObject op2_bytevector_like_ref(SObject arg1, SObject arg2)
 {
     expect2(arg1.isByteVectorLike(), arg1, arg2.isFixnum(), arg2, Constants.EX_BVLREF);
     rangeCheckBVL(arg1, arg2, Constants.EX_BVLREF);
     return(Factory.wrap(((SByteVL)arg1).elements[((SFixnum)arg2).value]));
 }