Ejemplo n.º 1
0
        public CQ_Value ComputeValue(CQ_Content content)
        {
#if CQUARK_DEBUG
            content.InStack(this);
#endif
            var parent = _expressions[0].ComputeValue(content);
            if (parent == CQ_Value.Null)
            {
                throw new Exception("调用空对象的方法:" + _expressions[0].ToString() + ":" + ToString());
            }
            var value = _expressions[1].ComputeValue(content);

            //这几行是为了快速获取Unity的静态变量,而不需要反射
            object obj = parent.GetObject();
            if (!Wrap.MemberValueSet(parent.m_type, obj, membername, value))
            {
                IClass iclass = CQuark.AppDomain.GetITypeByCQValue(parent)._class;

                CQ_ClassInstance s = obj as CQ_ClassInstance;
                if (s != null)
                {
                    iclass = s.type;
                }
                iclass.MemberValueSet(content, obj, membername, value);
            }
#if CQUARK_DEBUG
            content.OutStack(this);
#endif
            return(CQ_Value.Null);
        }
Ejemplo n.º 2
0
 public void Restore()
 {
     tvalues.Clear();
     values.Clear();
     tvalueDepth.Clear();
     tvalueDepth.Push(0);
     CallType = null;
     CallThis = null;
 }
Ejemplo n.º 3
0
        public CQ_Value New(CQ_Content content, CQ_Value[] _params)
        {
            if (contentMemberCalc == null)
            {
                contentMemberCalc = CQ_ObjPool.PopContent();
            }

            NewStatic();


            CQ_ClassInstance c = new CQ_ClassInstance();

            c.type = this;

            foreach (KeyValuePair <string, Member> i in this.members)
            {
                if (i.Value.bStatic == false)
                {
                    if (i.Value.expr_defvalue == null)
                    {
                        CQ_Value val = new CQ_Value();
                        val.SetObject(i.Value.m_itype.typeBridge, i.Value.m_itype.defaultValue);
                        c.member[i.Key] = val;
                        //sv.value_value.member[i.Key] = new CQ_Value();
                        //sv.value_value.member[i.Key].SetCQType(i.Value.type.cqType);
                        //sv.value_value.member[i.Key].value = i.Value.type.defaultValue;
                    }
                    else
                    {
                        var value = i.Value.expr_defvalue.ComputeValue(contentMemberCalc);
                        if (i.Value.m_itype.typeBridge != value.typeBridge)
                        {
                            CQ_Value val = new CQ_Value();
                            val.SetObject(i.Value.m_itype.typeBridge, value.ConvertTo(i.Value.m_itype.typeBridge));
                            c.member[i.Key] = val;
                            //sv.value_value.member[i.Key] = val;
                            //sv.value_value.member[i.Key] = new CQ_Value();
                            //sv.value_value.member[i.Key].SetCQType(i.Value.type.cqType);
                            //sv.value_value.member[i.Key].value = value.ConvertTo(i.Value.type.cqType);
                        }
                        else
                        {
                            c.member[i.Key] = value;
                        }
                    }
                }
            }
            if (this.functions.ContainsKey(this.Name))//有同名函数就调用
            {
                MemberCall(content, c, this.Name, _params);
            }

            CQ_Value v = new CQ_Value();

            v.SetObject(this, c);
            return(v);
        }
Ejemplo n.º 4
0
        public CQ_Value MemberValueGet(CQ_Content content, object object_this, string valuename)
        {
            CQ_ClassInstance sin  = object_this as CQ_ClassInstance;
            CQ_Value         temp = CQ_Value.Null;

            if (sin.member.TryGetValue(valuename, out temp))
            {
                return(temp);
            }
            throw new NotImplementedException();
        }
Ejemplo n.º 5
0
        public bool MemberValueSet(CQ_Content content, object object_this, string valuename, CQ_Value value)
        {
            CQ_ClassInstance sin = object_this as CQ_ClassInstance;

            if (sin.member.ContainsKey(valuename))
            {
                CQ_Value oldVal = sin.member[valuename];
                oldVal.UsingValue(value);
                sin.member[valuename] = oldVal;
                return(true);
            }
            throw new NotImplementedException();
        }
Ejemplo n.º 6
0
 public DeleFunction(Class_CQuark stype, CQ_ClassInstance _this, string function)
 {
     this.calltype = stype;
     this.callthis = _this;
     this.function = function;
 }