Esempio n. 1
0
 public void Add(Kirikiri.Tjs2.ExprNode node)
 {
     if (mNodes == null)
     {
         mNodes = new AList<Kirikiri.Tjs2.ExprNode>();
     }
     mNodes.AddItem(node);
 }
Esempio n. 2
0
 /// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
 public bool NormalCompare(Kirikiri.Tjs2.Variant val2)
 {
     if (mObject != null && val2.mObject != null)
     {
         if (mObject.GetType().IsAssignableFrom(val2.mObject.GetType()))
         {
             // 同じクラス
             if (mObject is int)
             {
                 return ((int)mObject) == ((int)val2.mObject);
             }
             if (mObject is string)
             {
                 return ((string)mObject).Equals(((string)val2.mObject));
             }
             if (mObject is ByteBuffer)
             {
                 //return ((ByteBuffer)mObject).compareTo( ((ByteBuffer)val2.mObject) ) == 0;
                 ByteBuffer v1 = (ByteBuffer)mObject;
                 ByteBuffer v2 = (ByteBuffer)val2.mObject;
                 int c1 = v1.Limit();
                 int c2 = v2.Limit();
                 if (c1 == c2)
                 {
                     for (int i = 0; i < c1; i++)
                     {
                         byte b1 = v1.Get(i);
                         byte b2 = v2.Get(i);
                         if (b1 != b2)
                         {
                             return false;
                         }
                     }
                 }
                 else
                 {
                     return false;
                 }
                 return true;
             }
             if (mObject is double)
             {
                 return ((double)mObject) == ((double)val2.mObject);
             }
             return mObject.Equals(val2.mObject);
         }
         else
         {
             if (mObject is string || val2.mObject is string)
             {
                 string v1 = AsString();
                 string v2 = val2.AsString();
                 return v1.Equals(v2);
             }
             else
             {
                 if (mObject is Number && val2.mObject is Number)
                 {
                     double r1 = ((Number)mObject);
                     double r2 = ((Number)val2.mObject);
                     if (Double.IsNaN(r1) || Double.IsNaN(r2))
                     {
                         return false;
                     }
                     if (Double.IsInfinite(r1) || Double.IsInfinite(r2))
                     {
                         return Double.Compare(r1, r2) == 0;
                     }
                     return r1 == r2;
                 }
                 else
                 {
                     return false;
                 }
             }
         }
     }
     else
     {
         // 片方はnull
         if (mObject == null && val2.mObject == null)
         {
             return true;
         }
         if (mObject == null)
         {
             if (val2.mObject is int)
             {
                 return ((int)val2.mObject) == 0;
             }
             if (val2.mObject is double)
             {
                 return ((double)val2.mObject) == 0.0;
             }
             if (val2.mObject is string)
             {
                 return ((string)val2.mObject).Length == 0;
             }
             return false;
         }
         else
         {
             if (mObject is int)
             {
                 return ((int)mObject) == 0;
             }
             if (mObject is double)
             {
                 return ((double)mObject) == 0.0;
             }
             if (mObject is string)
             {
                 return ((string)mObject).Length == 0;
             }
             return false;
         }
     }
 }
Esempio n. 3
0
 public static void ConsoleOutput(string msg, Kirikiri.Tjs2.ScriptBlock blk)
 {
     TJS.OutputToConsole(msg);
 }
Esempio n. 4
0
 public bool DiscernCompareInternal(Kirikiri.Tjs2.Variant val)
 {
     if (mObject != null && val.mObject != null)
     {
         if ((mObject is int) && (val.mObject is int))
         {
             return ((int)mObject) == ((int)val.mObject);
         }
         else
         {
             if ((mObject is string) && (val.mObject is string))
             {
                 return ((string)mObject).Equals(((string)val.mObject));
             }
             else
             {
                 if ((mObject is double) && (val.mObject is double))
                 {
                     double r1 = ((Number)mObject);
                     double r2 = ((Number)val.mObject);
                     if (Double.IsNaN(r1) || Double.IsNaN(r2))
                     {
                         return false;
                     }
                     if (Double.IsInfinite(r1) || Double.IsInfinite(r2))
                     {
                         return Double.Compare(r1, r2) == 0;
                     }
                     return r1 == r2;
                 }
                 else
                 {
                     if ((mObject is VariantClosure) && (val.mObject is VariantClosure))
                     {
                         VariantClosure v1 = (VariantClosure)mObject;
                         VariantClosure v2 = (VariantClosure)val.mObject;
                         return (v1.mObject == v2.mObject && v1.mObjThis == v2.mObjThis);
                     }
                     else
                     {
                         if ((mObject is ByteBuffer) && (val.mObject is ByteBuffer))
                         {
                             //return ((ByteBuffer)mObject).compareTo( ((ByteBuffer)val.mObject) ) == 0;
                             ByteBuffer v1 = (ByteBuffer)mObject;
                             ByteBuffer v2 = (ByteBuffer)val.mObject;
                             int c1 = v1.Limit();
                             int c2 = v2.Limit();
                             if (c1 == c2)
                             {
                                 for (int i = 0; i < c1; i++)
                                 {
                                     byte b1 = v1.Get(i);
                                     byte b2 = v2.Get(i);
                                     if (b1 != b2)
                                     {
                                         return false;
                                     }
                                 }
                             }
                             else
                             {
                                 return false;
                             }
                             return true;
                         }
                         else
                         {
                             if (mObject.GetType().IsAssignableFrom(val.mObject.GetType()))
                             {
                                 // 同じクラス
                                 return mObject.Equals(val.mObject);
                             }
                             else
                             {
                                 return false;
                             }
                         }
                     }
                 }
             }
         }
     }
     else
     {
         if (mObject == null && val.mObject == null)
         {
             return true;
         }
         else
         {
             return false;
         }
     }
 }
Esempio n. 5
0
 public virtual void SetCodeObject(Kirikiri.Tjs2.InterCodeObject parent, Kirikiri.Tjs2.InterCodeObject
     setter, Kirikiri.Tjs2.InterCodeObject getter, Kirikiri.Tjs2.InterCodeObject superclass
     )
 {
     mParent = parent;
     mPropSetter = setter;
     mPropGetter = getter;
     mSuperClassGetter = superclass;
 }
Esempio n. 6
0
 // ^
 /// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
 public Kirikiri.Tjs2.Variant BitXor(Kirikiri.Tjs2.Variant val)
 {
     int v = AsInteger() ^ val.AsInteger();
     return new Kirikiri.Tjs2.Variant(v);
 }
Esempio n. 7
0
 public void CopyRef(Kirikiri.Tjs2.Variant value)
 {
     if (value.mObject is VariantClosure)
     {
         VariantClosure clo = (VariantClosure)value.mObject;
         mObject = new VariantClosure(clo.mObject, clo.mObjThis);
     }
     else
     {
         if (mObject != value.mObject)
         {
             {
                 mObject = value.mObject;
             }
         }
     }
 }
Esempio n. 8
0
 // >>
 /// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
 public Kirikiri.Tjs2.Variant RightShift(Kirikiri.Tjs2.Variant val)
 {
     int v = AsInteger() >> val.AsInteger();
     return new Kirikiri.Tjs2.Variant(v);
 }
Esempio n. 9
0
 // >>=
 /// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
 public void RightShiftEqual(Kirikiri.Tjs2.Variant rhs)
 {
     int l = AsInteger();
     int r = rhs.AsInteger();
     mObject = Sharpen.Extensions.ValueOf(l >> r);
 }
Esempio n. 10
0
 // %=
 /// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
 public void ResidueEqual(Kirikiri.Tjs2.Variant rhs)
 {
     int r = rhs.AsInteger();
     if (r == 0)
     {
         ThrowDividedByZero();
     }
     int l = AsInteger();
     mObject = Sharpen.Extensions.ValueOf(l % r);
 }
Esempio n. 11
0
 // >>>
 /// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
 public Kirikiri.Tjs2.Variant RightBitShift(Kirikiri.Tjs2.Variant val)
 {
     int v = AsInteger();
     v = (int)(((uint)v) >> val.AsInteger());
     return new Kirikiri.Tjs2.Variant((int)v);
 }
Esempio n. 12
0
 // %
 /// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
 public Kirikiri.Tjs2.Variant Residue(Kirikiri.Tjs2.Variant val)
 {
     int r = val.AsInteger();
     if (r == 0)
     {
         ThrowDividedByZero();
     }
     int l = AsInteger();
     return new Kirikiri.Tjs2.Variant(l % r);
 }
Esempio n. 13
0
 /// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
 public void Rbitshiftequal(Kirikiri.Tjs2.Variant rhs)
 {
     int l = AsInteger();
     int r = rhs.AsInteger();
     mObject = Sharpen.Extensions.ValueOf((int)((int)(((uint)l) >> r)));
 }
Esempio n. 14
0
 // !=
 /// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
 public Kirikiri.Tjs2.Variant NotEqual(Kirikiri.Tjs2.Variant val)
 {
     bool v = NormalCompare(val);
     return new Kirikiri.Tjs2.Variant((!v) ? 1 : 0);
 }
Esempio n. 15
0
 /// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
 public void AsNumber(Kirikiri.Tjs2.Variant targ)
 {
     if (mObject == null)
     {
         targ.Set(0);
     }
     else
     {
         if (mObject is Number)
         {
             // Integer or Double
             if (mObject is int)
             {
                 targ.Set(((int)mObject));
             }
             else
             {
                 targ.Set(((Number)mObject));
             }
         }
         else
         {
             if (mObject is string)
             {
                 LexBase lex = new LexBase((string)mObject);
                 Number num = lex.ParseNumber();
                 if (num != null)
                 {
                     if (num.IsInt())
                     {
                         targ.Set(((int)num));
                     }
                     else
                     {
                         targ.Set(((Number)num));
                     }
                 }
                 else
                 {
                     targ.Set(0);
                 }
             }
             else
             {
                 // convert error
                 ThrowVariantConvertError(this, TYPE_INTEGER, TYPE_REAL);
             }
         }
     }
 }
Esempio n. 16
0
 public void Set(Kirikiri.Tjs2.Variant value)
 {
     //mObject = value.mObject;
     CopyRef(value);
 }
Esempio n. 17
0
 public Variant(Kirikiri.Tjs2.Variant value)
 {
     mObject = value.CloneSeparate();
 }
Esempio n. 18
0
 // -
 /// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
 public Kirikiri.Tjs2.Variant Subtract(Kirikiri.Tjs2.Variant val)
 {
     if (mObject is int && val.mObject is int)
     {
         int result = ((int)mObject) - ((int)val.mObject);
         return new Kirikiri.Tjs2.Variant(result);
     }
     Number n1 = AsNumber();
     Number n2 = val.AsNumber();
     if (n1.IsInt() && n2.IsInt())
     {
         int result = n1 - n2;
         return new Kirikiri.Tjs2.Variant(result);
     }
     else
     {
         double result = n1 - n2;
         return new Kirikiri.Tjs2.Variant(result);
     }
 }
Esempio n. 19
0
 // ^=
 /// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
 public void BitXorEqual(Kirikiri.Tjs2.Variant rhs)
 {
     int l = AsInteger();
     mObject = null;
     mObject = Sharpen.Extensions.ValueOf(l ^ rhs.AsInteger());
 }
Esempio n. 20
0
 // -=
 /// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
 public void SubtractEqual(Kirikiri.Tjs2.Variant rhs)
 {
     if (mObject is int && rhs.mObject is int)
     {
         mObject = Sharpen.Extensions.ValueOf(((int)mObject) - ((int)rhs.mObject));
         return;
     }
     Number l = AsNumber();
     Number r = rhs.AsNumber();
     if (l.IsInt() && r.IsInt())
     {
         mObject = Sharpen.Extensions.ValueOf(((int)l) - ((int)r));
     }
     else
     {
         mObject = (l - r);
     }
 }
Esempio n. 21
0
 // ===
 public Kirikiri.Tjs2.Variant DiscernCompare(Kirikiri.Tjs2.Variant val)
 {
     bool v = DiscernCompareInternal(val);
     return new Kirikiri.Tjs2.Variant(v ? 1 : 0);
 }
Esempio n. 22
0
 /// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
 public static void ThrowVariantConvertError(Kirikiri.Tjs2.Variant from, string to
     )
 {
     if (to.Equals(TYPE_OBJECT))
     {
         string mes = Error.VariantConvertErrorToObject.Replace("%1", Utils.VariantToReadableString
             (from));
         throw new VariantException(mes);
     }
     else
     {
         string mes = Error.VariantConvertError.Replace("%1", Utils.VariantToReadableString
             (from));
         string mes2 = mes.Replace("%2", to);
         throw new VariantException(mes2);
     }
 }
Esempio n. 23
0
 public TJSScriptException(Kirikiri.Tjs2.TJSScriptException @ref)
     : base(@ref)
 {
     mValue = @ref.mValue;
 }
Esempio n. 24
0
 /// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
 public static void ThrowVariantConvertError(Kirikiri.Tjs2.Variant from, string to1
     , string to2)
 {
     string mes = Error.VariantConvertError.Replace("%1", Utils.VariantToReadableString
         (from));
     string mes2 = mes.Replace("%2", to1 + "/" + to2);
     throw new VariantException(mes2);
 }
Esempio n. 25
0
 /// <summary>new する时のメンバコピー</summary>
 /// <param name="dest">コピー先</param>
 /// <returns>エラーコード</returns>
 /// <exception cref="TJSException">TJSException</exception>
 /// <exception cref="Kirikiri.Tjs2.TJSException"></exception>
 protected internal virtual int CopyAllMembers(Kirikiri.Tjs2.CustomObject dest)
 {
     if (!GetValidity())
     {
         return Error.E_INVALIDOBJECT;
     }
     if (!dest.GetValidity())
     {
         return Error.E_INVALIDOBJECT;
     }
     Variant result = new Variant();
     for (int i = 0; i < mHashSize; i++)
     {
         SymbolData lv1 = mSymbols[i];
         SymbolData d = lv1.mNext;
         while (d != null)
         {
             SymbolData nextd = d.mNext;
             if (((d.mSymFlags & SYMBOL_USING) != 0) && ((d.mSymFlags & SYMBOL_STATIC) == 0))
             {
                 if (d.mValue.IsObject())
                 {
                     result.Set(d.mValue);
                     if (result.AsObjectThis() == null)
                     {
                         result.ChangeClosureObjThis(dest);
                     }
                     SymbolData data = dest.Add(d.mName);
                     if ((d.mSymFlags & SYMBOL_HIDDEN) != 0)
                     {
                         data.mSymFlags |= SYMBOL_HIDDEN;
                     }
                     else
                     {
                         data.mSymFlags &= ~SYMBOL_HIDDEN;
                     }
                     data.mValue.CopyRef(result);
                 }
             }
             d = nextd;
         }
         if (((lv1.mSymFlags & SYMBOL_USING) != 0) && ((lv1.mSymFlags & SYMBOL_STATIC) ==
             0))
         {
             if (lv1.mValue.IsObject())
             {
                 result.Set(lv1.mValue);
                 if (result.AsObjectThis() == null)
                 {
                     result.ChangeClosureObjThis(dest);
                 }
                 SymbolData data = dest.Add(lv1.mName);
                 if ((lv1.mSymFlags & SYMBOL_HIDDEN) != 0)
                 {
                     data.mSymFlags |= SYMBOL_HIDDEN;
                 }
                 else
                 {
                     data.mSymFlags &= ~SYMBOL_HIDDEN;
                 }
                 data.mValue.CopyRef(result);
             }
         }
     }
     return Error.S_OK;
 }
Esempio n. 26
0
 // +
 /// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
 public Kirikiri.Tjs2.Variant Add(Kirikiri.Tjs2.Variant val)
 {
     if (mObject is string || val.mObject is string)
     {
         string s1 = AsString();
         string s2 = val.AsString();
         if (s1 != null && s2 != null)
         {
             StringBuilder builder = new StringBuilder(256);
             builder.Append(s1);
             builder.Append(s2);
             return new Kirikiri.Tjs2.Variant(builder.ToString());
         }
         else
         {
             if (s1 != null)
             {
                 return new Kirikiri.Tjs2.Variant(s1);
             }
             else
             {
                 return new Kirikiri.Tjs2.Variant(s2);
             }
         }
     }
     if (mObject != null && val.mObject != null)
     {
         if (mObject.GetType().IsAssignableFrom(val.mObject.GetType()))
         {
             // 同じクラス
             if (mObject is ByteBuffer)
             {
                 ByteBuffer b1 = (ByteBuffer)mObject;
                 ByteBuffer b2 = (ByteBuffer)val.mObject;
                 ByteBuffer result = ByteBuffer.Allocate(b1.Capacity() + b2.Capacity());
                 b1.Position(0);
                 b2.Position(0);
                 result.Put(b1);
                 result.Put(b2);
                 result.Position(0);
                 return new Kirikiri.Tjs2.Variant(result);
             }
             if (mObject is int)
             {
                 int result = ((int)mObject) + ((int)val.mObject);
                 return new Kirikiri.Tjs2.Variant(result);
             }
         }
     }
     if (mObject == null)
     {
         if (val.mObject != null)
         {
             if (val.mObject is int)
             {
                 return new Kirikiri.Tjs2.Variant(((int)val.mObject));
             }
             else
             {
                 if (val.mObject is double)
                 {
                     return new Kirikiri.Tjs2.Variant(((double)val.mObject));
                 }
             }
         }
     }
     if (val.mObject == null)
     {
         if (mObject != null)
         {
             if (mObject is int)
             {
                 return new Kirikiri.Tjs2.Variant(((int)mObject));
             }
             else
             {
                 if (mObject is double)
                 {
                     return new Kirikiri.Tjs2.Variant(((double)mObject));
                 }
             }
         }
     }
     return new Kirikiri.Tjs2.Variant(AsDouble() + val.AsDouble());
 }
Esempio n. 27
0
 public TJSScriptError(Kirikiri.Tjs2.TJSScriptError @ref)
 {
     mAccessor = @ref.mAccessor;
     mPosition = @ref.mPosition;
     mTrace = @ref.mTrace;
 }
Esempio n. 28
0
 // +=
 /// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
 public void AddEqual(Kirikiri.Tjs2.Variant rhs)
 {
     if (mObject is string || rhs.mObject is string)
     {
         if (mObject is string && rhs.mObject is string)
         {
             // both are string
             mObject = (string)mObject + (string)rhs.mObject;
             return;
         }
         string s1 = AsString();
         string s2 = rhs.AsString();
         if (s1 != null && s2 != null)
         {
             StringBuilder builder = new StringBuilder(256);
             builder.Append(s1);
             builder.Append(s2);
             mObject = builder.ToString();
         }
         else
         {
             if (s1 != null)
             {
                 mObject = s1;
             }
             else
             {
                 mObject = s2;
             }
         }
         //mObject = s1 + s2;
         return;
     }
     if (mObject != null && rhs.mObject != null)
     {
         if (mObject.GetType().IsAssignableFrom(rhs.mObject.GetType()))
         {
             // 同じクラス
             if (mObject is ByteBuffer)
             {
                 ByteBuffer b1 = (ByteBuffer)mObject;
                 ByteBuffer b2 = (ByteBuffer)rhs.mObject;
                 ByteBuffer result = ByteBuffer.Allocate(b1.Capacity() + b2.Capacity());
                 b1.Position(0);
                 b2.Position(0);
                 result.Put(b1);
                 result.Put(b2);
                 result.Position(0);
                 mObject = result;
                 return;
             }
             if (mObject is int)
             {
                 int result = ((int)mObject) + ((int)rhs.mObject);
                 mObject = Sharpen.Extensions.ValueOf(result);
                 return;
             }
         }
     }
     if (mObject == null)
     {
         if (rhs.mObject != null)
         {
             if (rhs.mObject is int)
             {
                 mObject = Sharpen.Extensions.ValueOf(((int)rhs.mObject));
                 return;
             }
             else
             {
                 if (rhs.mObject is double)
                 {
                     mObject = (((double)rhs.mObject));
                     return;
                 }
             }
         }
     }
     if (rhs.mObject == null)
     {
         if (mObject != null)
         {
             if (mObject is int)
             {
                 return;
             }
             else
             {
                 if (mObject is double)
                 {
                     return;
                 }
             }
         }
     }
     mObject = (AsDouble() + rhs.AsDouble());
 }
Esempio n. 29
0
 public virtual void Set(Kirikiri.Tjs2.VariantClosure clo)
 {
     mObject = clo.mObject;
     mObjThis = clo.mObjThis;
 }
Esempio n. 30
0
 // *=
 /// <exception cref="Kirikiri.Tjs2.VariantException"></exception>
 public void MultiplyEqual(Kirikiri.Tjs2.Variant rhs)
 {
     if (mObject is int && rhs.mObject is int)
     {
         mObject = Sharpen.Extensions.ValueOf(((int)mObject) * ((int)rhs.mObject));
         return;
     }
     Number l = AsNumber();
     Number r = rhs.AsNumber();
     if (l.IsInt() && r.IsInt())
     {
         mObject = Sharpen.Extensions.ValueOf(l * r);
         return;
     }
     mObject = (l * r);
 }