//public override RunTimeValueBase execute(RunTimeValueBase thisObj, SLOT[] argements, object stackframe, out string errormessage, out int errorno)
        //{


        //}

        public override void execute3(RunTimeValueBase thisObj,FunctionDefine functionDefine,SLOT returnSlot,SourceToken token,StackFrame stackframe,out bool success)
        {
            string b = TypeConverter.ConvertToString(
                ((ASBinCode.rtData.rtObjectBase)thisObj).value.memberData[0].getValue(),null,null);

            if (b == null)
            {
                //errormessage = "Cannot access a property or method of a null object reference.";
                //errorno = 1009;

                success = false;
                stackframe.throwError(token,1009,"Cannot access a property or method of a null object reference.");

                returnSlot.setValue(ASBinCode.rtData.rtUndefined.undefined);
            }
            else
            {
                success = true;
                int idx = TypeConverter.ConvertToInt(argements[0]);
                if (idx < 0 || idx >= b.Length)
                {
                    returnSlot.setValue(double.NaN);
                    //return new rtNumber(double.NaN);
                }
                else
                {
                    returnSlot.setValue((double)b[idx]);
                    //return new rtNumber(b[idx]);
                }
            }
        }
        //public override NativeFunctionMode mode
        //{
        //    get
        //    {
        //        return NativeFunctionMode.normal_1;
        //    }
        //}

        //public override RunTimeValueBase execute(RunTimeValueBase thisObj, SLOT[] argements, object stackframe, out string errormessage, out int errorno)
        //{
        //    throw new ASRunTimeException();
        //}

        //public override void execute2(RunTimeValueBase thisObj, FunctionDefine functionDefine, SLOT[] argements, SLOT returnSlot, SourceToken token, object stackframe, out bool success)
        //{

        //    success = true;

        //    ASBinCode.rtData.rtObject obj = argements[0].getValue() as ASBinCode.rtData.rtObject;
        //    if (obj == null)
        //    {
        //        returnSlot.setValue(ASBinCode.rtData.rtBoolean.False);
        //        return;
        //    }

        //    LinkSystemObject other = obj.value as LinkSystemObject;
        //    if (other == null)
        //    {
        //        returnSlot.setValue(ASBinCode.rtData.rtBoolean.False);
        //        return;
        //    }


        //    LinkSystemObject iv = ((LinkSystemObject)((ASBinCode.rtData.rtObject)thisObj).value);

        //    if (System.Object.Equals(iv, other))
        //    {
        //        returnSlot.setValue(ASBinCode.rtData.rtBoolean.True);
        //        return;
        //    }
        //    else
        //    {
        //        returnSlot.setValue(ASBinCode.rtData.rtBoolean.False);
        //        return;
        //    }

        //}

        public override void execute3(RunTimeValueBase thisObj,FunctionDefine functionDefine,SLOT returnSlot,SourceToken token,StackFrame stackframe,out bool success)
        {
            success = true;

            ASBinCode.rtData.rtObjectBase obj = argements[0] as ASBinCode.rtData.rtObjectBase;
            if (obj == null)
            {
                returnSlot.setValue(ASBinCode.rtData.rtBoolean.False);
                return;
            }

            LinkSystemObject other = obj.value as LinkSystemObject;

            if (other == null)
            {
                returnSlot.setValue(ASBinCode.rtData.rtBoolean.False);
                return;
            }


            LinkSystemObject iv = ((LinkSystemObject)((ASBinCode.rtData.rtObjectBase)thisObj).value);

            if (System.Object.Equals(iv,other))
            {
                returnSlot.setValue(ASBinCode.rtData.rtBoolean.True);
                return;
            }
            else
            {
                returnSlot.setValue(ASBinCode.rtData.rtBoolean.False);
                return;
            }
        }
        //public override RunTimeValueBase execute(RunTimeValueBase thisObj, SLOT[] argements,object stackframe,  out string errormessage, out int errorno)
        //{
        //    if (argements.Length < 1)
        //    {
        //        errormessage = "参数不足";
        //        errorno = 0;
        //        return ASBinCode.rtData.rtUndefined.undefined;
        //    }
        //    else
        //    {
        //        var v = argements[0].getValue();
        //        int r = TypeConverter.ConvertToInt(v, null, null);

        //        if (r < 1 || r > 21)
        //        {
        //            errormessage = "Number.toPrecision has a range of 1 to 21. Number.toFixed and Number.toExponential have a range of 0 to 20. Specified value is not within expected range.";
        //            errorno = 1002;

        //            return ASBinCode.rtData.rtUndefined.undefined;
        //        }
        //        else
        //        {
        //            errormessage = null;
        //            errorno = 0;

        //            return
        //                new rtString(

        //                ((rtNumber)((rtObject)thisObj).value.memberData[0].getValue()).value.ToString("g" + (r))

        //                );
        //        }



        //    }


        //}

        public override void execute3(RunTimeValueBase thisObj, FunctionDefine functionDefine, SLOT returnSlot,SourceToken token,StackFrame stackframe,out bool success)
        {
            success = true;
            {
                var v = argements[0];
                int r = TypeConverter.ConvertToInt(v);

                if (r < 1 || r > 21)
                {
                    success = false;
                    //errormessage = "Number.toPrecision has a range of 1 to 21. Number.toFixed and Number.toExponential have a range of 0 to 20. Specified value is not within expected range.";
                    //errorno = 1002;

                    //return ASBinCode.rtData.rtUndefined.undefined;
                    stackframe.throwError(token,1002,"Number.toPrecision has a range of 1 to 21. Number.toFixed and Number.toExponential have a range of 0 to 20. Specified value is not within expected range.");
                    returnSlot.setValue(rtUndefined.undefined);
                }
                else
                {
                    //errormessage = null;
                    //errorno = 0;

                    //return
                    //	new rtString(

                    //	((rtInt)((rtObject)thisObj).value.memberData[0].getValue()).value.ToString("g" + (r))

                    //	);
                    success = true;
                    returnSlot.setValue(((rtNumber)((rtObjectBase)thisObj).value.memberData[0].getValue()).value.ToString("g" + (r)));
                }
            }
        }
Beispiel #4
0
        //public override RunTimeValueBase execute(RunTimeValueBase thisObj, SLOT[] argements, object stackframe, out string errormessage, out int errorno)
        //{
        //    errormessage = null;
        //    errorno = 0;

        //    string str= TypeConverter.ConvertToString(argements[0].getValue(),null,null);
        //    uint radix = TypeConverter.ConvertToUInt(argements[1].getValue(), null, null);

        //    if (String.IsNullOrEmpty(str))
        //    {
        //        return new rtNumber(double.NaN);
        //    }
        //    //ASCII 48-57 : 0-9 ,65-90 : A-Z;

        //    str = str.ToUpper();
        //    str=str.TrimStart();
        //    str=str.TrimStart('0');

        //    if (radix == 0) { radix = 10; }
        //    if (radix < 2 || radix > 36) { return new rtNumber(double.NaN); }

        //    uint allowidx = 48 + radix;

        //    if (radix > 10)
        //    {
        //        allowidx = 65 + radix - 10;
        //    }

        //    double output = double.NaN;

        //    for (int i = 0; i < str.Length; i++)
        //    {
        //        char c = str[i];
        //        if (c < allowidx && ((c < 58 && c >= 48) || c>= 65))
        //        {
        //            if (double.IsNaN(output))
        //            {
        //                output = c < 58 ? (c - 48) : (c - 65 + 10);
        //            }
        //            else
        //            {
        //                output = output * radix + (c < 58 ? (c - 48) : (c - 65 + 10));
        //            }
        //        }
        //        else
        //        {
        //            break;
        //        }
        //    }


        //    return new rtNumber(output);

        //}

        public override void execute3(RunTimeValueBase thisObj,FunctionDefine functionDefine,SLOT returnSlot,SourceToken token,StackFrame stackframe,out bool success)
        {
            success = true;

            string str   = TypeConverter.ConvertToString(argements[0],null,null);
            uint   radix = TypeConverter.ConvertToUInt(argements[1],null,null);

            if (String.IsNullOrEmpty(str))
            {
                returnSlot.setValue(double.NaN);
                //new rtNumber(double.NaN);
            }
            //ASCII 48-57 : 0-9 ,65-90 : A-Z;

            str = str.ToUpper();
            str = str.TrimStart();
            str = str.TrimStart('0');

            if (radix == 0)
            {
                radix = 10;
            }
            if (radix < 2 || radix > 36)
            {
                returnSlot.setValue(double.NaN);
            }                                                                            //return new rtNumber(double.NaN); }

            uint allowidx = 48 + radix;

            if (radix > 10)
            {
                allowidx = 65 + radix - 10;
            }

            double output = double.NaN;

            for (int i = 0; i < str.Length; i++)
            {
                char c = str[i];
                if (c < allowidx && ((c < 58 && c >= 48) || c >= 65))
                {
                    if (double.IsNaN(output))
                    {
                        output = c < 58 ? (c - 48) : (c - 65 + 10);
                    }
                    else
                    {
                        output = output * radix + (c < 58 ? (c - 48) : (c - 65 + 10));
                    }
                }
                else
                {
                    break;
                }
            }

            returnSlot.setValue(output);
            //return new rtNumber(output);
        }
Beispiel #5
0
        //  public override RunTimeValueBase execute(RunTimeValueBase thisObj, SLOT[] argements,object stackframe,  out string errormessage, out int errorno)
        //  {
        //      if (argements.Length < 1)
        //      {
        //          errormessage = "参数不足";
        //          errorno = 0;
        //          return ASBinCode.rtData.rtUndefined.undefined;
        //      }
        //      else
        //      {
        //          var v = argements[0].getValue();
        //          int r = TypeConverter.ConvertToInt(v, null, null, false);

        //          if (r < 2 || r > 36)
        //          {
        //              errormessage = "The radix argument must be between 2 and 36; got "+r+".";
        //              errorno = 1002;

        //              return ASBinCode.rtData.rtUndefined.undefined;
        //          }
        //          else
        //          {
        //              errormessage = null;
        //              errorno = 0;

        //              var toCast = ((rtInt)((rtObject)thisObj).value.memberData[0].getValue()).value;

        //              if (r == 10)
        //              {
        //                  return new rtString(toCast.ToString());
        //              }
        //              else
        //              {
        //                  string result = string.Empty;

        //                  int sign = 1;
        //                  if (toCast < 0) { toCast = -toCast;sign = -1; }

        //result = symbols[toCast % r].ToString();
        //toCast = toCast / r;

        //while ( toCast > 0)
        //                  {
        //                      result = symbols[toCast % r] + result;
        //                      toCast = toCast / r;
        //                  }
        //                  if (sign == -1)
        //                  {
        //                      result = "-" + result;
        //                  }


        //                  return new rtString(result);

        //              }

        //          }
        //      }


        //  }

        public override void execute3(RunTimeValueBase thisObj,FunctionDefine functionDefine,SLOT returnSlot,SourceToken token,StackFrame stackframe,out bool success)
        {
            {
                var v = argements[0];
                int r = TypeConverter.ConvertToInt(v);

                if (r < 2 || r > 36)
                {
                    success = false;
                    //errormessage = "The radix argument must be between 2 and 36; got " + r + ".";
                    //errorno = 1002;

                    //return ASBinCode.rtData.rtUndefined.undefined;

                    stackframe.throwError(token,1002,"The radix argument must be between 2 and 36; got " + r + ".");
                    returnSlot.setValue(rtUndefined.undefined);
                }
                else
                {
                    success = true;

                    var toCast = ((rtInt)((rtObjectBase)thisObj).value.memberData[0].getValue()).value;

                    if (r == 10)
                    {
                        //return new rtString(toCast.ToString());
                        returnSlot.setValue(toCast.ToString());
                    }
                    else
                    {
                        string result = string.Empty;

                        int sign = 1;
                        if (toCast < 0)
                        {
                            toCast = -toCast; sign = -1;
                        }

                        result = symbols[toCast % r].ToString();
                        toCast = toCast / r;

                        while (toCast > 0)
                        {
                            result = symbols[toCast % r] + result;
                            toCast = toCast / r;
                        }
                        if (sign == -1)
                        {
                            result = "-" + result;
                        }

                        returnSlot.setValue(result);
                        //return new rtString(result);
                    }
                }
            }
        }
Beispiel #6
0
            public override void execute3(RunTimeValueBase thisObj,FunctionDefine functionDefine,SLOT returnSlot,SourceToken token,StackFrame stackframe,out bool success)
            {
                Queue queue =
                    (System.Collections.Queue)((LinkObj <object>)((ASBinCode.rtData.rtObjectBase)thisObj).value).value;

                try
                {
                    object lo;
                    if (stackframe.player.linktypemapper.rtValueToLinkObject(
                            argements[0],

                            stackframe.player.linktypemapper.getLinkType(argements[0].rtType)
                            ,
                            bin,false,out lo
                            ))
                    {
                        if (queue.Contains(lo))
                        {
                            returnSlot.setValue(ASBinCode.rtData.rtBoolean.True);
                        }
                        else
                        {
                            returnSlot.setValue(ASBinCode.rtData.rtBoolean.False);
                        }
                        success = true;
                    }
                    else
                    {
                        stackframe.throwCastException(token,argements[0].rtType,

                                                      functionDefine.signature.parameters[0].type
                                                      );
                        success = false;
                    }
                }
                catch (InvalidCastException ic)
                {
                    success = false;
                    stackframe.throwAneException(token,ic.Message);
                }
                catch (ArgumentException a)
                {
                    success = false;
                    stackframe.throwAneException(token,a.Message);
                }
                catch (IndexOutOfRangeException i)
                {
                    success = false;
                    stackframe.throwAneException(token,i.Message);
                }
                catch (NotSupportedException n)
                {
                    success = false;
                    stackframe.throwAneException(token,n.Message);
                }
            }
        //public override RunTimeValueBase execute(RunTimeValueBase thisObj, SLOT[] argements, object stackframe, out string errormessage, out int errorno)
        //{
        //    errormessage = null;
        //    errorno = 0;

        //    string b = TypeConverter.ConvertToString(
        //        ((ASBinCode.rtData.rtObject)thisObj).value.memberData[0].getValue(), null, null);

        //    if (b == null)
        //    {
        //        errormessage = "Cannot access a property or method of a null object reference.";
        //        errorno = 1009;

        //        return ASBinCode.rtData.rtUndefined.undefined;
        //    }
        //    else
        //    {

        //        int st = TypeConverter.ConvertToInt(argements[0].getValue(), null, null);
        //        int len = TypeConverter.ConvertToInt(argements[1].getValue(), null, null);

        //        if (st > b.Length)
        //        {
        //            return new rtString(string.Empty);
        //        }
        //        else if (st < 0)
        //        {
        //            st = b.Length + st;
        //            if (st < 0)
        //            {
        //                st = 0;
        //            }
        //        }

        //        if (len < 0)
        //        {
        //            len = 0;
        //        }


        //        if (len > b.Length - st)
        //        {
        //            return new rtString(b.Substring(st));
        //        }
        //        else
        //        {
        //            return new rtString(b.Substring(st, len));
        //        }
        //    }

        //}

        public override void execute3(RunTimeValueBase thisObj,FunctionDefine functionDefine,SLOT returnSlot,SourceToken token,StackFrame stackframe,out bool success)
        {
            string b = TypeConverter.ConvertToString(
                ((ASBinCode.rtData.rtObjectBase)thisObj).value.memberData[0].getValue(),null,null);

            if (b == null)
            {
                success = false;

                stackframe.throwError(token,1009,"Cannot access a property or method of a null object reference.");
                returnSlot.directSet(rtUndefined.undefined);
            }
            else
            {
                success = true;
                int st  = TypeConverter.ConvertToInt(argements[0]);
                int len = TypeConverter.ConvertToInt(argements[1]);

                if (st > b.Length)
                {
                    //return new rtString(string.Empty);
                    returnSlot.setValue(string.Empty);
                }
                else if (st < 0)
                {
                    st = b.Length + st;
                    if (st < 0)
                    {
                        st = 0;
                    }
                }

                if (len < 0)
                {
                    len = 0;
                }


                if (len > b.Length - st)
                {
                    //return new rtString(b.Substring(st));
                    returnSlot.setValue(b.Substring(st));
                }
                else
                {
                    //return new rtString(b.Substring(st, len));
                    returnSlot.setValue(b.Substring(st,len));
                }
            }
        }
        //public override RunTimeValueBase execute(RunTimeValueBase thisObj, SLOT[] argements, object stackframe, out string errormessage, out int errorno)
        //{
        //    errormessage = null;
        //    errorno = 0;

        //    string b = TypeConverter.ConvertToString(
        //        ((ASBinCode.rtData.rtObject)thisObj).value.memberData[0].getValue(), null, null);

        //    if (b == null)
        //    {
        //        errormessage = "Cannot access a property or method of a null object reference.";
        //        errorno = 1009;

        //        return ASBinCode.rtData.rtUndefined.undefined;
        //    }
        //    else
        //    {
        //        string search = TypeConverter.ConvertToString(argements[0].getValue(), null, null);
        //        int st = TypeConverter.ConvertToInt(argements[1].getValue(), null, null);

        //        return new rtInt(  b.IndexOf(search,st));

        //    }

        //}
        public override void execute3(RunTimeValueBase thisObj,FunctionDefine functionDefine,SLOT returnSlot,SourceToken token,StackFrame stackframe,out bool success)
        {
            string b = TypeConverter.ConvertToString(
                ((ASBinCode.rtData.rtObjectBase)thisObj).value.memberData[0].getValue(),null,null);

            if (b == null)
            {
                //errormessage = "Cannot access a property or method of a null object reference.";
                //errorno = 1009;

                //return ASBinCode.rtData.rtUndefined.undefined;

                success = false;

                stackframe.throwError(token,1009,"Cannot access a property or method of a null object reference.");

                returnSlot.directSet(rtUndefined.undefined);
            }
            else
            {
                string search = TypeConverter.ConvertToString(argements[0],null,null);
                int    st     = TypeConverter.ConvertToInt(argements[1]);

                //return new rtInt(b.IndexOf(search, st));
                success = true;

                returnSlot.setValue(b.IndexOf(search,st));
            }
        }
        //public override RunTimeValueBase execute(RunTimeValueBase thisObj, SLOT[] argements, object stackframe, out string errormessage, out int errorno)
        //{
        //    errormessage = null;
        //    errorno = 0;

        //    string b = TypeConverter.ConvertToString(
        //        ((ASBinCode.rtData.rtObject)thisObj).value.memberData[0].getValue(), null, null);

        //    if (b == null)
        //    {
        //        errormessage = "Cannot access a property or method of a null object reference.";
        //        errorno = 1009;

        //        return ASBinCode.rtData.rtUndefined.undefined;
        //    }
        //    else
        //    {

        //        string pattern = TypeConverter.ConvertToString(argements[0].getValue(), null, null);
        //        string repl = TypeConverter.ConvertToString(argements[1].getValue(), null, null);

        //        if (pattern == null) pattern = string.Empty;
        //        if (repl == null) repl = string.Empty;


        //        return new rtString(b.Replace(pattern, repl));


        //    }

        //}

        public override void execute3(RunTimeValueBase thisObj,FunctionDefine functionDefine,SLOT returnSlot,SourceToken token,StackFrame stackframe,out bool success)
        {
            string b = TypeConverter.ConvertToString(
                ((ASBinCode.rtData.rtObjectBase)thisObj).value.memberData[0].getValue(),null,null);

            if (b == null)
            {
                success = false;

                stackframe.throwError(token,1009,"Cannot access a property or method of a null object reference.");
                returnSlot.directSet(rtUndefined.undefined);
            }
            else
            {
                success = true;
                string pattern = TypeConverter.ConvertToString(argements[0],null,null);
                string repl    = TypeConverter.ConvertToString(argements[1],null,null);

                if (pattern == null)
                {
                    pattern = string.Empty;
                }
                if (repl == null)
                {
                    repl = string.Empty;
                }


                //return new rtString(b.Replace(pattern, repl));
                returnSlot.setValue(b.Replace(pattern,repl));
            }
        }
        public override void execute3(RunTimeValueBase thisObj, FunctionDefine functionDefine, SLOT returnSlot, SourceToken token, StackFrame stackframe, out bool success)
        {
            LinkObj<UInt64> obj = ((LinkObj<UInt64>)((ASBinCode.rtData.rtObjectBase)thisObj).value);

            returnSlot.setValue((double)obj.value);
            success = true;
        }
            public override void execute3(RunTimeValueBase thisObj,FunctionDefine functionDefine,SLOT returnSlot,SourceToken token,StackFrame stackframe,out bool success)
            {
                System.Collections.ArrayList arraylist =
                    (System.Collections.ArrayList)((LinkObj <object>)((ASBinCode.rtData.rtObjectBase)thisObj).value).value;

                try
                {
                    arraylist.Sort();
                    returnSlot.setValue(ASBinCode.rtData.rtUndefined.undefined);
                    success = true;
                }
                //catch (KeyNotFoundException)
                //{
                //    success = false;
                //    stackframe.throwAneException(token, arraylist.ToString() + "没有链接到脚本");
                //}
                catch (ArgumentException a)
                {
                    success = false;
                    stackframe.throwAneException(token,a.Message);
                }
                catch (IndexOutOfRangeException i)
                {
                    success = false;
                    stackframe.throwAneException(token,i.Message);
                }
            }
Beispiel #12
0
        //public override RunTimeValueBase execute(RunTimeValueBase thisObj, SLOT[] argements, object stackframe, out string errormessage, out int errorno)
        //{
        //    errormessage = null; errorno = 0;
        //    LinkObj<long> i64 = ((LinkObj<long>)((ASBinCode.rtData.rtObjectBase)thisObj).value);

        //    return new ASBinCode.rtData.rtNumber(i64.value);

        //}
        public override void execute3(RunTimeValueBase thisObj,FunctionDefine functionDefine,SLOT returnSlot,SourceToken token,StackFrame stackframe,out bool success)
        {
            success = true;
            LinkObj <long> i64 = ((LinkObj <long>)((ASBinCode.rtData.rtObjectBase)thisObj).value);

            returnSlot.setValue((double)i64.value);
            //return new ASBinCode.rtData.rtNumber(i64.value);
        }
Beispiel #13
0
        //public override RunTimeValueBase execute(RunTimeValueBase thisObj, SLOT[] argements,object stackframe,  out string errormessage, out int errorno)
        //{
        //    errormessage = null;
        //    errorno = 0;

        //    rtArray arr = (rtArray)((rtObject)thisObj).value.memberData[0].getValue();

        //    return new rtString(arr.ToString());
        //}

        public override void execute3(RunTimeValueBase thisObj,FunctionDefine functionDefine,SLOT returnSlot,SourceToken token,StackFrame stackframe,out bool success)
        {
            success = true;

            rtArray arr = (rtArray)((rtObjectBase)thisObj).value.memberData[0].getValue();

            //return new rtString(arr.ToString());
            returnSlot.setValue(arr.ToString());
        }
Beispiel #14
0
        //public override RunTimeValueBase execute(RunTimeValueBase thisObj, SLOT[] argements,object stackframe,  out string errormessage, out int errorno)
        //{
        //    errormessage = null;
        //    errorno = 0;

        //    StackFrame frame = (StackFrame)stackframe;
        //    return new rtString(frame.player.stackTrace(1));

        //    //throw new NotImplementedException();
        //}

        public override void execute3(RunTimeValueBase thisObj, FunctionDefine functionDefine, SLOT returnSlot,SourceToken token,StackFrame stackframe,out bool success)
        {
            success = true;


            StackFrame frame = (StackFrame)stackframe;

            returnSlot.setValue(frame.player.stackTrace(1));
        }
        public override void execute3(RunTimeValueBase thisObj,FunctionDefine functionDefine,SLOT returnSlot,SourceToken token,StackFrame stackframe,out bool success)
        {
            success = true;


            var array = (Array)((LinkObj <object>)((ASBinCode.rtData.rtObjectBase)thisObj).value).value;

            returnSlot.setValue(array.Rank);
        }
Beispiel #16
0
        //public override RunTimeValueBase execute(RunTimeValueBase thisObj, SLOT[] argements, object stackframe, out string errormessage, out int errorno)
        //{



        //    errormessage = null;
        //    errorno = 0;

        //    ASBinCode.rtData.rtBoolean b = (ASBinCode.rtData.rtBoolean)((ASBinCode.rtData.rtObject)thisObj).value.memberData[0].getValue();


        //    if (b.value == true)
        //    {
        //        return new ASBinCode.rtData.rtString("true");
        //    }
        //    else
        //    {
        //        return new ASBinCode.rtData.rtString("false");
        //    }

        //}
        public override void execute3(RunTimeValueBase thisObj, FunctionDefine functionDefine, SLOT returnSlot,SourceToken token,StackFrame stackframe,out bool success)
        {
            success = true;

            ASBinCode.rtData.rtBoolean b = (ASBinCode.rtData.rtBoolean)((ASBinCode.rtData.rtObjectBase)thisObj).value.memberData[0].getValue();


            if (b.value == true)
            {
                returnSlot.setValue("true");
                //return new ASBinCode.rtData.rtString("true");
            }
            else
            {
                returnSlot.setValue("false");
                //return new ASBinCode.rtData.rtString("false");
            }
        }
        public override void execute3(RunTimeValueBase thisObj,FunctionDefine functionDefine,SLOT returnSlot,SourceToken token,StackFrame stackframe,out bool success)
        {
            success = true;
            int dimension = TypeConverter.ConvertToInt(argements[0]);

            var array = (Array)((LinkObj <object>)((ASBinCode.rtData.rtObjectBase)thisObj).value).value;

            returnSlot.setValue(array.GetUpperBound(dimension));
        }
            public override void execute3(RunTimeValueBase thisObj,FunctionDefine functionDefine,SLOT returnSlot,SourceToken token,StackFrame stackframe,out bool success)
            {
                RunTimeValueBase kv = argements[0];

                if (kv.rtType > RunTimeDataType.unknown)
                {
                    RunTimeDataType ot;
                    if (TypeConverter.Object_CanImplicit_ToPrimitive(
                            bin.getClassByRunTimeDataType(kv.rtType),out ot
                            ))
                    {
                        kv = TypeConverter.ObjectImplicit_ToPrimitive((ASBinCode.rtData.rtObjectBase)kv);
                    }
                }

                try
                {
                    object lo;
                    if (stackframe.player.linktypemapper.rtValueToLinkObject(
                            argements[1],

                            stackframe.player.linktypemapper.getLinkType(argements[1].rtType),

                            bin,true,out lo
                            ))
                    {
                        ((LinkObj <object>)((ASBinCode.rtData.rtObjectBase)thisObj).value).value
                            = new DictionaryEntry(kv,lo);

                        returnSlot.setValue(ASBinCode.rtData.rtUndefined.undefined);
                        success = true;
                    }
                    else
                    {
                        stackframe.throwCastException(token,argements[1].rtType,
                                                      functionDefine.signature.parameters[1].type
                                                      );
                        success = false;
                    }
                }
                catch (InvalidCastException ic)
                {
                    success = false;
                    stackframe.throwAneException(token,ic.Message);
                }
                catch (ArgumentException a)
                {
                    success = false;
                    stackframe.throwAneException(token,a.Message);
                }
                catch (IndexOutOfRangeException i)
                {
                    success = false;
                    stackframe.throwAneException(token,i.Message);
                }
            }
        public override void execute3(RunTimeValueBase thisObj,FunctionDefine functionDefine,SLOT returnSlot,SourceToken token,StackFrame stackframe,out bool success)
        {
            string format = TypeConverter.ConvertToString(argements[0],stackframe,token);


            LinkObj <byte> obj = ((LinkObj <byte>)((ASBinCode.rtData.rtObjectBase)thisObj).value);

            returnSlot.setValue(obj.value.ToString(format));
            success = true;
        }
        //public override NativeFunctionMode mode
        //{
        //    get
        //    {
        //        return NativeFunctionMode.normal_1;
        //    }
        //}

        //public override RunTimeValueBase execute(RunTimeValueBase thisObj, SLOT[] argements, object stackframe, out string errormessage, out int errorno)
        //{
        //    throw new EngineException();
        //}

        //public override void execute2(RunTimeValueBase thisObj, FunctionDefine functionDefine, SLOT[] argements, SLOT returnSlot,SourceToken token, object stackframe, out bool success)
        //{
        //    //base.execute2(thisObj, functionDefine, argements, returnSlot, stackframe, out success);
        //    success = true;

        //    LinkSystemObject iv = ((LinkSystemObject)((ASBinCode.rtData.rtObjectBase)thisObj).value);

        //    string tostr = iv.ToString();

        //    returnSlot.setValue(tostr);

        //    //return new ASBinCode.rtData.rtString(iv.ToString());


        //}

        public override void execute3(RunTimeValueBase thisObj,FunctionDefine functionDefine,SLOT returnSlot,SourceToken token,StackFrame stackframe,out bool success)
        {
            success = true;

            LinkSystemObject iv = ((LinkSystemObject)((ASBinCode.rtData.rtObjectBase)thisObj).value);

            string tostr = iv.ToString();

            returnSlot.setValue(tostr);
        }
        public override void execute2(RunTimeValueBase thisObj,FunctionDefine functionDefine,SLOT[] argements,SLOT returnSlot,SourceToken token,object stackframe,out bool success)
        {
            //base.execute2(thisObj, functionDefine, argements, returnSlot, stackframe, out success);
            success = true;

            var a1 = argements[0].getValue();
            var a2 = argements[1].getValue();

            if (a1.rtType == a2.rtType && a1.rtType == RunTimeDataType.rt_null)
            {
                returnSlot.setValue(ASBinCode.rtData.rtBoolean.True);
                return;
            }


            ASBinCode.rtData.rtObjectBase obj = a1 as ASBinCode.rtData.rtObjectBase;
            if (obj == null)
            {
                returnSlot.setValue(ASBinCode.rtData.rtBoolean.False);
                return;
            }

            LinkSystemObject o1 = obj.value as LinkSystemObject;

            if (o1 == null)
            {
                returnSlot.setValue(ASBinCode.rtData.rtBoolean.False);
                return;
            }


            ASBinCode.rtData.rtObjectBase obj2 = a2 as ASBinCode.rtData.rtObjectBase;
            if (obj2 == null)
            {
                returnSlot.setValue(ASBinCode.rtData.rtBoolean.False);
                return;
            }

            LinkSystemObject o2 = obj2.value as LinkSystemObject;

            if (o2 == null)
            {
                returnSlot.setValue(ASBinCode.rtData.rtBoolean.False);
                return;
            }

            if (object.ReferenceEquals(o1.GetLinkData(),o2.GetLinkData()))
            {
                returnSlot.setValue(ASBinCode.rtData.rtBoolean.True);
                return;
            }
            else
            {
                returnSlot.setValue(ASBinCode.rtData.rtBoolean.False);
                return;
            }
        }
        //public override RunTimeValueBase execute(RunTimeValueBase thisObj, SLOT[] argements,object stackframe,  out string errormessage, out int errorno)
        //{


        //    //throw new NotImplementedException();
        //}

        public override void execute3(RunTimeValueBase thisObj, FunctionDefine functionDefine, SLOT returnSlot,SourceToken token,StackFrame stackframe,out bool success)
        {
            ((rtObjectBase)argements[0]).value.memberData[0].directSet(argements[1]);
            ((rtFunction)argements[1]).objHandle = ((rtObjectBase)argements[0]);

            success = true;
            returnSlot.setValue(rtUndefined.undefined);

            //errormessage = null;
            //errorno = 0;
            //return rtUndefined.undefined;
        }
        //public override RunTimeValueBase execute(RunTimeValueBase thisObj, SLOT[] argements,object stackframe,  out string errormessage, out int errorno)
        //{


        //    //throw new NotImplementedException();
        //}

        public override void execute3(RunTimeValueBase thisObj,FunctionDefine functionDefine,SLOT returnSlot,SourceToken token,StackFrame stackframe,out bool success)
        {
            rtFunction func = (rtFunction)((rtObjectBase)thisObj).value.memberData[0].getValue();

            var signature = stackframe.player.swc.functions[func.functionId].signature;

            success = true;

            if (signature.parameters.Count == 0)
            {
                returnSlot.setValue(0);
            }
            else if (signature.parameters[signature.parameters.Count - 1].isPara)
            {
                returnSlot.setValue(signature.parameters.Count - 1);
            }
            else
            {
                returnSlot.setValue(signature.parameters.Count);
            }
        }
            public override void execute3(RunTimeValueBase thisObj,FunctionDefine functionDefine,SLOT returnSlot,SourceToken token,StackFrame stackframe,out bool success)
            {
                ArrayList arraylist =
                    (ArrayList)((LinkObj <object>)((ASBinCode.rtData.rtObjectBase)thisObj).value).value;

                try
                {
                    int index      = TypeConverter.ConvertToInt(argements[0]);
                    int arrayIndex = TypeConverter.ConvertToInt(argements[2]);
                    int count      = TypeConverter.ConvertToInt(argements[3]);


                    object lo;
                    if (stackframe.player.linktypemapper.rtValueToLinkObject(
                            argements[1],

                            stackframe.player.linktypemapper.getLinkType(
                                functionDefine.signature.parameters[1].type
                                ),

                            bin,true,out lo
                            ))
                    {
                        arraylist.CopyTo(index,(Array)lo,arrayIndex,count);

                        returnSlot.setValue(ASBinCode.rtData.rtUndefined.undefined);

                        success = true;
                    }
                    else
                    {
                        stackframe.throwCastException(token,argements[0].rtType,
                                                      functionDefine.signature.parameters[0].type
                                                      );
                        success = false;
                    }
                }
                catch (KeyNotFoundException)
                {
                    success = false;
                    stackframe.throwAneException(token,functionDefine.signature.parameters[0].type + "没有链接到脚本");
                }
                catch (ArgumentException a)
                {
                    success = false;
                    stackframe.throwAneException(token,a.Message);
                }
                catch (IndexOutOfRangeException i)
                {
                    success = false;
                    stackframe.throwAneException(token,i.Message);
                }
            }
        //public override NativeFunctionMode mode
        //{
        //    get
        //    {
        //        return NativeFunctionMode.normal_1;
        //    }
        //}

        //public override RunTimeValueBase execute(RunTimeValueBase thisObj, SLOT[] argements, object stackframe, out string errormessage, out int errorno)
        //{
        //    throw new EngineException();
        //}

        //public override void execute2(RunTimeValueBase thisObj, FunctionDefine functionDefine, SLOT[] argements, SLOT returnSlot, SourceToken token, object stackframe, out bool success)
        //{
        //    //base.execute2(thisObj, functionDefine, argements, returnSlot, stackframe, out success);
        //    success = true;

        //    LinkSystemObject iv = ((LinkSystemObject)((ASBinCode.rtData.rtObjectBase)thisObj).value);

        //    int hashcode = iv.GetHashCode();

        //    returnSlot.setValue(hashcode);

        //    //return new ASBinCode.rtData.rtString(iv.ToString());


        //}

        public override void execute3(RunTimeValueBase thisObj,FunctionDefine functionDefine,SLOT returnSlot,SourceToken token,StackFrame stackframe,out bool success)
        {
            //base.execute2(thisObj, functionDefine, argements, returnSlot, stackframe, out success);
            success = true;

            LinkSystemObject iv = ((LinkSystemObject)((ASBinCode.rtData.rtObjectBase)thisObj).value);

            int hashcode = iv.GetHashCode();

            returnSlot.setValue(hashcode);

            //return new ASBinCode.rtData.rtString(iv.ToString());
        }
        public override void execute3(RunTimeValueBase thisObj,FunctionDefine functionDefine,SLOT returnSlot,SourceToken token,StackFrame stackframe,out bool success)
        {
            int   index1 = TypeConverter.ConvertToInt(argements[1]);
            int   index2 = TypeConverter.ConvertToInt(argements[2]);
            Array array  =
                (Array)((LinkObj <object>)((ASBinCode.rtData.rtObjectBase)thisObj).value).value;

            try
            {
                object lo;
                if (stackframe.player.linktypemapper.rtValueToLinkObject(
                        argements[0],array.GetType().GetElementType(),bin,true,out lo
                        ))
                {
                    array.SetValue(lo,index1,index2);
                    returnSlot.setValue(ASBinCode.rtData.rtUndefined.undefined);
                    success = true;
                }
                else
                {
                    stackframe.throwCastException(token,argements[0].rtType,
                                                  stackframe.player.linktypemapper.getRuntimeDataType(array.GetType().GetElementType())
                                                  );
                    success = false;
                }
            }
            catch (RuntimeLinkTypeMapper.TypeLinkClassException tlc)
            {
                success = false;
                stackframe.throwAneException(token,tlc.Message);
            }
            catch (InvalidCastException ic)
            {
                success = false;
                stackframe.throwAneException(token,ic.Message);
            }
            catch (ArgumentException a)
            {
                success = false;
                stackframe.throwAneException(token,a.Message);
            }
            catch (IndexOutOfRangeException i)
            {
                success = false;
                stackframe.throwAneException(token,i.Message);
            }
        }
Beispiel #27
0
        //public override RunTimeValueBase execute(RunTimeValueBase thisObj, SLOT[] argements,object stackframe,  out string errormessage, out int errorno)
        //{
        //    errormessage = null;
        //    errorno = 0;

        //    return
        //        new rtUInt(
        //            (uint)
        //            ((rtArray)(((rtObject)thisObj).value.memberData[0].getValue())).innerArray.Count
        //        )
        //        ;
        //}

        public override void execute3(RunTimeValueBase thisObj,FunctionDefine functionDefine,SLOT returnSlot,SourceToken token,StackFrame stackframe,out bool success)
        {
            //throw new NotImplementedException();
            //errormessage = null;
            //errorno = 0;

            success = true;
            returnSlot.setValue((uint)
                                ((rtArray)(((rtObjectBase)thisObj).value.memberData[0].getValue())).innerArray.Count);

            //return
            //	new rtUInt(
            //		(uint)
            //		((rtArray)(((rtObject)thisObj).value.memberData[0].getValue())).innerArray.Count
            //	)
            //	;
        }
            public override void execute3(RunTimeValueBase thisObj,FunctionDefine functionDefine,SLOT returnSlot,SourceToken token,StackFrame stackframe,out bool success)
            {
                try
                {
                    object lo;
                    if (stackframe.player.linktypemapper.rtValueToLinkObject(
                            argements[0],

                            stackframe.player.linktypemapper.getLinkType(argements[0].rtType),

                            bin,true,out lo
                            ))
                    {
                        //链接结构体,不能缓存到变量,必须直接对其赋值....
                        (((LinkObj <DictionaryEntry>)
                              ((ASBinCode.rtData.rtObjectBase)thisObj).value).value).Value = lo;


                        returnSlot.setValue(ASBinCode.rtData.rtUndefined.undefined);
                        success = true;
                    }
                    else
                    {
                        stackframe.throwCastException(token,argements[0].rtType,
                                                      functionDefine.signature.parameters[0].type
                                                      );
                        success = false;
                    }
                }
                catch (InvalidCastException ic)
                {
                    success = false;
                    stackframe.throwAneException(token,ic.Message);
                }
                catch (ArgumentException a)
                {
                    success = false;
                    stackframe.throwAneException(token,a.Message);
                }
                catch (IndexOutOfRangeException i)
                {
                    success = false;
                    stackframe.throwAneException(token,i.Message);
                }
            }
        //public override RunTimeValueBase execute(RunTimeValueBase thisObj, SLOT[] argements,object stackframe,  out string errormessage, out int errorno)
        //{
        //    if (argements.Length < 1)
        //    {
        //        errormessage = "参数不足";
        //        errorno = 0;
        //        return ASBinCode.rtData.rtUndefined.undefined;
        //    }
        //    else
        //    {
        //        var v = argements[0].getValue();
        //        int r = TypeConverter.ConvertToInt(v, null, null);

        //        if (r < 0 || r > 20)
        //        {
        //            errormessage = "Number.toPrecision has a range of 1 to 21. Number.toFixed and Number.toExponential have a range of 0 to 20. Specified value is not within expected range.";
        //            errorno = 1002;

        //            return ASBinCode.rtData.rtUndefined.undefined;
        //        }
        //        else
        //        {
        //            errormessage = null;
        //            errorno = 0;

        //            return
        //                new rtString(

        //                ((rtUInt)((rtObject)thisObj).value.memberData[0].getValue()).value.ToString("e" + (r + 1))

        //                );
        //        }



        //    }


        //}

        public override void execute3(RunTimeValueBase thisObj,FunctionDefine functionDefine,SLOT returnSlot,SourceToken token,StackFrame stackframe,out bool success)
        {
            {
                var v = argements[0];
                int r = TypeConverter.ConvertToInt(v);

                if (r < 0 || r > 20)
                {
                    success = false;
                    stackframe.throwError(token,1002,"Number.toPrecision has a range of 1 to 21. Number.toFixed and Number.toExponential have a range of 0 to 20. Specified value is not within expected range.");

                    returnSlot.directSet(rtUndefined.undefined);
                }
                else
                {
                    success = true;
                    returnSlot.setValue(((rtUInt)((rtObjectBase)thisObj).value.memberData[0].getValue()).value.ToString("e" + (r)));
                }
            }
        }
        public override void execute2(RunTimeValueBase thisObj,FunctionDefine functionDefine,SLOT[] argements,SLOT returnSlot,SourceToken token,object stackframe,out bool success)
        {
            //base.execute2(thisObj, functionDefine, argements, returnSlot, stackframe, out success);
            success = true;

            ASBinCode.rtData.rtObjectBase obj = argements[0].getValue() as ASBinCode.rtData.rtObjectBase;
            if (obj == null)
            {
                returnSlot.setValue(ASBinCode.rtData.rtBoolean.False);
                return;
            }

            LinkSystemObject o1 = obj.value as LinkSystemObject;

            if (o1 == null)
            {
                returnSlot.setValue(ASBinCode.rtData.rtBoolean.False);
                return;
            }


            ASBinCode.rtData.rtObjectBase obj2 = argements[1].getValue() as ASBinCode.rtData.rtObjectBase;
            if (obj2 == null)
            {
                returnSlot.setValue(ASBinCode.rtData.rtBoolean.False);
                return;
            }

            LinkSystemObject o2 = obj2.value as LinkSystemObject;

            if (o2 == null)
            {
                returnSlot.setValue(ASBinCode.rtData.rtBoolean.False);
                return;
            }

            if (System.Object.Equals(o1,o2))
            {
                returnSlot.setValue(ASBinCode.rtData.rtBoolean.True);
                return;
            }
            else
            {
                returnSlot.setValue(ASBinCode.rtData.rtBoolean.False);
                return;
            }
        }