Example #1
0
        public CQ_Value ComputeValue(CQ_Content content)
        {
#if CQUARK_DEBUG
            content.InStack(this);
#endif
            var      right = _expressions[0].ComputeValue(content);
            IType    type  = CQuark.AppDomain.GetITypeByCQValue(right);
            CQ_Value value = new CQ_Value();

            if (targettype.type != null)
            {
                value.SetObject(targettype.type, type.ConvertTo(right.GetObject(), targettype));
            }
            else if (targettype.stype != null)
            {
                value.SetObject(targettype.stype, type.ConvertTo(right.GetObject(), targettype));
            }


#if CQUARK_DEBUG
            content.OutStack(this);
#endif

            return(value);
        }
Example #2
0
        public CQ_Value ComputeValue(CQ_Content content)
        {
#if CQUARK_DEBUG
            content.InStack(this);
#endif

            CQ_Value left  = _expressions[0].ComputeValue(content);
            CQ_Value right = _expressions[1].ComputeValue(content);
            IType    type  = CQuark.AppDomain.GetType(left.type);

            CQ_Type returntype;
            object  value = type.Math2Value(mathop, left.value, right, out returntype);
            value = type.ConvertTo(value, left.type);

            CQ_Value val = new CQ_Value();
            val.type  = returntype;
            val.value = value;

            if (_expressions[0] is CQ_Expression_MemberValueGet)
            {
                CQ_Expression_MemberValueGet f = _expressions[0] as CQ_Expression_MemberValueGet;

                var parent = f._expressions[0].ComputeValue(content);
                if (parent == null)
                {
                    throw new Exception("调用空对象的方法:" + f._expressions[0].ToString() + ":" + ToString());
                }

                //这几行是为了快速获取Unity的静态变量,而不需要反射
                if (!Wrap.MemberValueSet(parent.type.type, parent.value, f.membername, val))
                {
                    var ptype = CQuark.AppDomain.GetType(parent.type);
                    ptype._class.MemberValueSet(content, parent.value, f.membername, value);
                }
            }
            if (_expressions[0] is CQ_Expression_StaticValueGet)
            {
                CQ_Expression_StaticValueGet f = _expressions[0] as CQ_Expression_StaticValueGet;

                //这几行是为了快速获取Unity的静态变量,而不需要反射
                if (!Wrap.StaticValueSet(type.typeBridge.type, f.staticmembername, val))
                {
                    f.type._class.StaticValueSet(content, f.staticmembername, value);
                }
            }


#if CQUARK_DEBUG
            content.OutStack(this);
#endif

            return(null);
        }
Example #3
0
        public CQ_Value ComputeValue(CQ_Content content)
        {
#if CQUARK_DEBUG
            content.InStack(this);
#endif
            var      right = _expressions[0].ComputeValue(content);
            IType    type  = CQuark.AppDomain.GetType(right.type);
            CQ_Value value = new CQ_Value();
            value.type  = typeof(bool);
            value.value = type.ConvertTo(right.value, targettype) != null;

#if CQUARK_DEBUG
            content.OutStack(this);
#endif
            return(value);
        }
Example #4
0
        public LLVMValueRef GenerateConversion(IType from, IType to, LLVMValueRef value)
        {
            if (from.Equals(to))
            {
                return(value);
            }
            LLVMValueRef?converted = from.ConvertTo(this, to, value);

            if (converted.HasValue)
            {
                return(converted.Value);
            }
            converted = to.ConvertFrom(this, from, value);
            if (converted.HasValue)
            {
                return(converted.Value);
            }
            throw new NotSupportedException("Unable to convert from " + from + " to " + to);
        }
        public CQ_Value ComputeValue(CQ_Content content)
        {
#if CQUARK_DEBUG
            content.InStack(this);
#endif
            var     v    = content.Get(value_name);
            IType   type = CQuark.AppDomain.GetType(v.type);
            CQ_Type returntype;
            object  value = type.Math2Value(mathop, v.value, CQ_Value.One, out returntype);
            value = type.ConvertTo(value, v.type);
            content.Set(value_name, value);

            //操作变量之
            //做数学计算
            //从上下文取值
            //_value = null;
#if CQUARK_DEBUG
            content.OutStack(this);
#endif
            return(content.Get(value_name));
        }