Ejemplo n.º 1
0
        //数字用这个方法,参考Lua,用double避免装箱
        public void SetNumber(Type type, double val)
        {
            if (!NumberUtil.IsNumberType(type))
            {
                throw new InvalidCastException();
            }

            if (m_type == typeof(Type_Var.var))
            {
                m_type  = type;
                m_stype = null;
                _isNum  = true;
                _num    = val;
            }
            else if (m_type == null)
            {
                m_type  = type;
                m_stype = null;
                _isNum  = true;
                _num    = val;
            }
            else
            {
                //可能存进来一个(int)1.5,这里要转到对应类型
                _isNum = true;
                _num   = NumberUtil.ConvertNumber(val, type);
            }
        }
Ejemplo n.º 2
0
 public void SetObject(Class_CQuark stype, object obj)
 {
     if (m_type == typeof(Type_Var.var))
     {
         m_type  = null;
         m_stype = stype;
         _isNum  = false;
         _obj    = obj;
     }
     else if (m_stype == null)
     {
         m_type  = null;
         m_stype = stype;
         _isNum  = false;
         _obj    = obj;
     }
     else if (obj == null)
     {
         _obj   = obj;
         _isNum = false;
     }
     else
     {
         IType itype = AppDomain.GetITypeByCQValue(this);
         if ((obj as CQ_ClassInstance).type != (Class_CQuark)itype.typeBridge)
         {
             obj = CQuark.AppDomain.GetITypeByClassCQ((obj as CQ_ClassInstance).type).ConvertTo(obj, itype.typeBridge);
         }
         _obj   = obj;
         _isNum = false;
     }
 }
Ejemplo n.º 3
0
 public Type_Class(string keyword, bool bInterface, string filename)
 {
     this.keyword    = keyword;
     this._namespace = "";
     typeBridge      = new Class_CQuark(keyword, "", filename, bInterface);
     compiled        = false;
 }
Ejemplo n.º 4
0
 public void Restore()
 {
     tvalues.Clear();
     values.Clear();
     tvalueDepth.Clear();
     tvalueDepth.Push(0);
     CallType = null;
     CallThis = null;
 }
Ejemplo n.º 5
0
        public static IType GetITypeByClassCQ(Class_CQuark stype)
        {
            if (stype == null)
            {
                return(str2itype["null"]);
            }

            IType ret = null;

            if (!ccq2itype.TryGetValue(stype, out ret))
            {
                DebugUtil.LogWarning("(Class_CQuark)类型未注册,将自动注册一份匿名:" + stype.ToString());
            }
            return(ret);
        }
Ejemplo n.º 6
0
 public void SetObject(Type type, object obj)
 {
     if (type == typeof(bool))
     {
         SetBool((bool)obj);
     }
     else if (NumberUtil.IsNumberType(type))
     {
         SetNumber(type, NumberUtil.GetDouble(type, obj));
     }
     else
     {
         if (m_type == typeof(Type_Var.var))
         {
             m_type  = type;
             m_stype = null;
             _isNum  = false;
             _obj    = obj;
         }
         else if (m_type == null)
         {
             m_type  = type;
             m_stype = null;
             _isNum  = false;
             _obj    = obj;
         }
         else if (obj == null)
         {
             _isNum = false;
             _obj   = obj;
         }
         else
         {
             if (m_type != type)
             {
                 obj = CQuark.AppDomain.ConvertTo(obj, m_type);
             }
             _obj   = obj;
             _isNum = false;
         }
     }
 }
Ejemplo n.º 7
0
 public DeleFunction(Class_CQuark stype, CQClassInstance _this, string function)
 {
     this.calltype = stype;
     this.callthis = _this;
     this.function = function;
 }
Ejemplo n.º 8
0
        public Type_Class(string fullName, bool bInterface, string filename)
        {
            this.keyword = fullName;
//            this._namespace = "";
            typeBridge = new Class_CQuark(fullName, "", filename, bInterface);
        }
Ejemplo n.º 9
0
 private CQ_Type(Class_CQuark type)
 {
     this.stype = type;
 }
Ejemplo n.º 10
0
 private TypeBridge(Class_CQuark type)
 {
     this.stype = type;
 }