public CQ_Content.Value ComputeValue(CQ_Content content) { content.InStack(this); var parent = listParam[0].ComputeValue(content); if (parent == null) { throw new Exception("调用空对象的方法:" + listParam[0].ToString() + ":" + ToString()); } var type = content.environment.GetType(parent.type); //string membername=null; var getvalue = type.function.MemberValueGet(content, parent.value, membername); CQ_Content.Value vright = CQ_Content.Value.One; if (listParam.Count > 1) { vright = listParam[1].ComputeValue(content); } CQ_Content.Value vout = new CQ_Content.Value(); var mtype = content.environment.GetType(getvalue.type); vout.value = mtype.Math2Value(content, mathop, getvalue.value, vright, out vout.type); type.function.MemberValueSet(content, parent.value, membername, vout.value); //CQ_Content.Value v = new CQ_Content.Value(); content.OutStack(this); return(vout); //做数学计算 //从上下文取值 //_value = null; //return null; }
public IEnumerator CoroutineCompute(CQ_Content content, ICoroutine coroutine) { content.InStack(this); content.DepthAdd(); CQ_Content.Value value = null; foreach (ICQ_Expression i in listParam) { ICQ_Expression e = i as ICQ_Expression; if (e != null) { if (e.hasCoroutine) { yield return(coroutine.StartNewCoroutine(e.CoroutineCompute(content, coroutine))); } else { value = e.ComputeValue(content); if (value != null && value.breakBlock != 0) { yield break; } } } } content.DepthRemove(); content.OutStack(this); yield break; }
public CQ_Content.Value ComputeValue(CQ_Content content) { content.InStack(this); CQ_Content.Value result = null; { result = new CQ_Content.Value(); var value = listParam[0].ComputeValue(content); if ((Type)value.type != typeof(bool)) { throw new Exception("三元表达式要求条件为bool型"); } bool bv = (bool)value.value; if (bv) { result = listParam[1].ComputeValue(content); } else { result = listParam[2].ComputeValue(content); } } content.OutStack(this); return(result); }
public CQ_Content.Value ComputeValue(CQ_Content content) { content.InStack(this); CQ_Content.Value rv = new CQ_Content.Value(); { var v = listParam[0].ComputeValue(content); { rv.type = v.type; rv.value = v.value; } Exception err = v.value as Exception; if (err != null) { throw err; } else { throw new Exception(v.ToString()); } } //content.OutStack(this); //return rv; //for 逻辑 //做数学计算 //从上下文取值 //_value = null; }
public CQ_Content.Value Call(CQ_Content content, IList <CQ_Content.Value> param) { CQ_Content.Value v = new CQ_Content.Value(); List <object> objs = new List <object>(); //var _params = dele.Method.GetParameters(); for (int i = 0; i < this.defvalues.Count; i++) { if (i >= param.Count) { objs.Add(defvalues[i]); } else { if (this.paramtype[i] == (Type)param[i].type) { objs.Add(param[i].value); } else { object conv = content.environment.GetType(param[i].type).ConvertTo(content, param[i].value, paramtype[i]); objs.Add(conv); } } } v.type = this.returntype; v.value = dele.DynamicInvoke(objs.ToArray()); return(v); }
public CQ_Content.Value ComputeValue(CQ_Content content) { content.InStack(this); if (_listParam != null && _listParam.Count > 0) { CQ_Content.Value v = _listParam[0].ComputeValue(content); object val = v.value; if ((Type)value_type == typeof(CQ_Type_Var.var)) { if (v.type != null) { value_type = v.type; } } else if (v.type != value_type) { val = content.environment.GetType(v.type).ConvertTo(content, v.value, value_type); } content.DefineAndSet(value_name, value_type, val); } else { content.Define(value_name, value_type); } //设置环境变量为 content.OutStack(this); return(null); }
public bool MathLogic(CQ_Content env, logictoken code, object left, CQ_Content.Value right) { if (code == logictoken.equal)//[6] = {Boolean op_Equality(CQcriptExt.Vector3, CQcriptExt.Vector3)} { if (left == null || right.type == null) { return(left == right.value); } else { return(left == right.value); } } else if (code == logictoken.not_equal)//[7] = {Boolean op_Inequality(CQcriptExt.Vector3, CQcriptExt.Vector3)} { if (left == null || right.type == null) { return(left != right.value); } else { return(left != right.value); } } throw new NotImplementedException(); }
public CQ_Content.Value ComputeValue(CQ_Content content) { content.InStack(this); CQ_Content.Value rv = new CQ_Content.Value(); rv.breakBlock = 10; if (listParam.Count > 0 && listParam[0] != null) { var v = listParam[0].ComputeValue(content); { rv.type = v.type; rv.value = v.value; } } else { rv.type = typeof(void); } content.OutStack(this); return(rv); //for 逻辑 //做数学计算 //从上下文取值 //_value = null; }
public CQ_Content.Value ComputeValue(CQ_Content content) { content.InStack(this); CQ_Content.Value result = new CQ_Content.Value(); //if (mathop == "&&" || mathop == "||") { bool bleft = false; bool bright = false; if (listParam[0] is ICQ_Value) { bleft = (bool)((listParam[0] as ICQ_Value).value); } else { bleft = (bool)listParam[0].ComputeValue(content).value; } result.type = typeof(bool); if (mathop == '&') { if (!bleft) { result.value = false; } else { if (listParam[1] is ICQ_Value) { bright = (bool)((listParam[1] as ICQ_Value).value); } else { bright = (bool)listParam[1].ComputeValue(content).value; } result.value = (bool)(bleft && bright); } } else if (mathop == '|') { if (bleft) { result.value = true; } else { if (listParam[1] is ICQ_Value) { bright = (bool)((listParam[1] as ICQ_Value).value); } else { bright = (bool)listParam[1].ComputeValue(content).value; } result.value = (bool)(bleft || bright); } } } content.OutStack(this); return(result); }
public CQ_Content.Value ComputeValue(CQ_Content content) { content.InStack(this); List <object> list = new List <object>(); int count = listParam[0] == null ? (listParam.Count - 1) : (int)listParam[0].ComputeValue(content).value; if (count == 0) { throw new Exception("不能创建0长度数组"); } CQ_Content.Value vcount = new CQ_Content.Value(); vcount.type = typeof(int); vcount.value = count; for (int i = 1; i < listParam.Count; i++) { //if (listParam[i] != null) { list.Add(listParam[i].ComputeValue(content).value); } } List <CQ_Content.Value> p = new List <CQ_Content.Value>(); p.Add(vcount); var outvalue = type.function.New(content, p); for (int i = 0; i < list.Count; i++) { type.function.IndexSet(content, outvalue.value, i, list[i]); } content.OutStack(this); return(outvalue); }
public CQ_Content.Value ComputeValue(CQ_Content content) { content.InStack(this); //var parent = listParam[0].ComputeValue(content); //var type = content.environment.GetType(parent.type); List <CQ_Content.Value> _params = new List <CQ_Content.Value>(); for (int i = 0; i < listParam.Count; i++) { _params.Add(listParam[i].ComputeValue(content)); } CQ_Content.Value value = null; if (cache == null || cache.cachefail) { cache = new MethodCache(); value = type.function.StaticCall(content, functionName, _params, cache); } else { value = type.function.StaticCallCache(content, _params, cache); } content.OutStack(this); return(value); //做数学计算 //从上下文取值 //_value = null; //return null; }
public IEnumerator CoroutineCompute(CQ_Content content, ICoroutine coroutine) { content.InStack(this); content.DepthAdd(); ICQ_Expression expr_switch = listParam[0] as ICQ_Expression; CQ_Content.Value switchVal = null; // CQ_Content.Value vrt = null; if (expr_switch != null) { switchVal = expr_switch.ComputeValue(content); //switch// } for (int i = 1; i < listParam.Count - 1; i += 2) { if (listParam[i] != null) { //case xxx:// if (switchVal.value.Equals(listParam[i].ComputeValue(content).value)) { while (listParam[i + 1] == null) { i += 2; } content.DepthAdd(); if (listParam[i + 1].hasCoroutine) { yield return(coroutine.StartNewCoroutine(listParam[i + 1].CoroutineCompute(content, coroutine))); } else { listParam[i + 1].ComputeValue(content); } break; } else { continue; } } else { //default: content.DepthAdd(); if (listParam[i + 1].hasCoroutine) { yield return(coroutine.StartNewCoroutine(listParam[i + 1].CoroutineCompute(content, coroutine))); } else { listParam[i + 1].ComputeValue(content); } break; } } content.DepthRemove(); content.OutStack(this); }
public object Math2Value(CQ_Content env, char code, object left, CQ_Content.Value right, out CQType returntype) { if ((Type)right.type == typeof(string)) { returntype = typeof(String); return("null" + right.value); } throw new NotImplementedException(); }
public virtual CQ_Content.Value IndexGet(CQ_Content environment, object object_this, object key) { //var m = type.GetMembers(); if (indexGetCache == null) { indexGetCache = type.GetMethod("get_Item"); if (indexGetCache != null) { indexGetCacheType = indexGetCache.ReturnType; } // CQ_Content.Value v = new CQ_Content.Value(); // v.type = targetop.ReturnType; // v.value = targetop.Invoke(object_this, new object[] { key }); // return v; //} if (indexGetCache == null) { indexGetCache = type.GetMethod("GetValue", new Type[] { typeof(int) }); if (indexGetCache != null) { indexGetCacheType = type.GetElementType(); } } indexGetCachetypeindex = indexGetCache.GetParameters()[0].ParameterType; //if (indexGetCache != null) //{ // CQ_Content.Value v = new CQ_Content.Value(); // v.type = indexGetCacheType; // v.value = indexGetCache.Invoke(object_this, new object[] { key }); // return v; //} //{ // targetop = type.GetMethod("GetValue", new Type[] { typeof(int) }); // if (targetop != null) // { // //targetop = type.GetMethod("Get"); // CQ_Content.Value v = new CQ_Content.Value(); // v.type = type.GetElementType(); // v.value = targetop.Invoke(object_this, new object[] { key }); // return v; // } //} } //else { CQ_Content.Value v = new CQ_Content.Value(); v.type = indexGetCacheType; if (key != null && key.GetType() != indexGetCachetypeindex) { key = environment.environment.GetType(key.GetType()).ConvertTo(environment, key, (CQuark.CQType)indexGetCachetypeindex); } v.value = indexGetCache.Invoke(object_this, new object[] { key }); return(v); } //throw new NotImplementedException(); }
public CQ_Content.Value ComputeValue(CQ_Content content) { content.InStack(this); CQ_Content.Value rv = new CQ_Content.Value(); rv.breakBlock = 1; //跳出逻辑 content.OutStack(this); return(rv); }
public CQ_Content.Value ComputeValue(CQ_Content content) { content.InStack(this); CQ_Content.Value v = new CQ_Content.Value(); v.type = this.type; v.value = this.value_value; content.OutStack(this); return(v); }
public CQ_Content.Value ComputeValue(CQ_Content content) { content.InStack(this); //List<CQ_Content.Value> list = new List<CQ_Content.Value>(); CQ_Content.Value value = new CQ_Content.Value(); value.type = typeof(DeleLambda); value.value = new DeleLambda(content, (this.listParam[0] as CQ_Expression_Block).listParam, this.listParam[1]); //创建一个匿名方法 content.OutStack(this); return(value); }
public bool MathLogic(CQ_Content env, logictoken code, object left, CQ_Content.Value right) { if (code == logictoken.equal) { return(null == right.value); } else if (code == logictoken.not_equal) { return(null != right.value); } throw new NotImplementedException(); }
public override object Math2Value(CQ_Content env, char code, object left, CQ_Content.Value right, out CQType returntype) { bool math2ValueSuccess = false; object value = NumericTypeUtils.Math2Value <ulong>(code, left, right, out returntype, out math2ValueSuccess); if (math2ValueSuccess) { return(value); } return(base.Math2Value(env, code, left, right, out returntype)); }
public override bool MathLogic(CQ_Content env, logictoken code, object left, CQ_Content.Value right) { bool mathLogicSuccess = false; bool value = NumericTypeUtils.MathLogic <ulong>(code, left, right, out mathLogicSuccess); if (mathLogicSuccess) { return(value); } return(base.MathLogic(env, code, left, right)); }
public CQ_Content.Value ComputeValue(CQ_Content content) { content.InStack(this); CQ_Content.Value r = listParam[0].ComputeValue(content); ICQ_Type type = content.environment.GetType(r.type); r.value = type.Math2Value(content, '*', r.value, CQ_Content.Value.OneMinus, out r.type); content.OutStack(this); return(r); }
public Delegate CreateDelegate(ICQ_Environment env, DeleFunction delefunc) { DeleFunction _func = delefunc; Delegate _dele = delefunc.cacheFunction(this._type, null); if (_dele != null) { return(_dele); } NonVoidDelegate dele = delegate(T param0, T1 param1, T2 param2) { var func = _func.calltype.functions[_func.function]; if (func.expr_runtime != null) { CQ_Content content = new CQ_Content(env, true); try { content.DepthAdd(); content.CallThis = _func.callthis; content.CallType = _func.calltype; content.function = _func.function; content.DefineAndSet(func._paramnames[0], func._paramtypes[0].type, param0); content.DefineAndSet(func._paramnames[1], func._paramtypes[1].type, param1); content.DefineAndSet(func._paramnames[2], func._paramtypes[2].type, param2); CQ_Content.Value retValue = func.expr_runtime.ComputeValue(content); content.DepthRemove(); return((ReturnType)retValue.value); } catch (Exception err) { string errinfo = "Dump Call in:"; if (_func.calltype != null) { errinfo += _func.calltype.Name + "::"; } if (_func.function != null) { errinfo += _func.function; } errinfo += "\n"; env.logger.Log(errinfo + content.Dump()); throw err; } } return(default(ReturnType)); }; _dele = Delegate.CreateDelegate(this.type, dele.Target, dele.Method); return(delefunc.cacheFunction(this._type, _dele)); }
public CQ_Content.Value MemberValueGet(CQ_Content environment, object object_this, string valuename) { SInstance sin = object_this as SInstance; if (sin.member.ContainsKey(valuename)) { CQ_Content.Value v = new CQ_Content.Value(); v.type = sin.member[valuename].type; v.value = sin.member[valuename].value; return(v); } throw new NotImplementedException(); }
public CQ_Content.Value StaticValueGet(CQ_Content content, string valuename) { NewStatic(content.environment); if (this.staticMemberInstance.ContainsKey(valuename)) { CQ_Content.Value v = new CQ_Content.Value(); v.type = this.staticMemberInstance[valuename].type; v.value = this.staticMemberInstance[valuename].value; return(v); } throw new NotImplementedException(); }
public CQ_Content.Value ComputeValue(CQ_Content content) { content.InStack(this); ICQ_Expression expr_if = listParam[0]; bool bif = (bool)expr_if.ComputeValue(content).value; //if (expr_init != null) expr_init.ComputeValue(content); ICQ_Expression expr_go1 = listParam[1]; ICQ_Expression expr_go2 = null; if (listParam.Count > 2) { expr_go2 = listParam[2]; } CQ_Content.Value value = null; if (bif && expr_go1 != null) { if (expr_go1 is CQ_Expression_Block) { value = expr_go1.ComputeValue(content); } else { content.DepthAdd(); value = expr_go1.ComputeValue(content); content.DepthRemove(); } } else if (!bif && expr_go2 != null) { if (expr_go2 is CQ_Expression_Block) { value = expr_go2.ComputeValue(content); } else { content.DepthAdd(); value = expr_go2.ComputeValue(content); content.DepthRemove(); } } //while((bool)expr_continue.value); //for 逻辑 //做数学计算 //从上下文取值 //_value = null; content.OutStack(this); return(value); }
public virtual bool MathLogic(CQ_Content env, logictoken code, object left, CQ_Content.Value right) { System.Reflection.MethodInfo call = null; //var m = _type.GetMethods(); if (code == logictoken.more)//[2] = {Boolean op_GreaterThan(CQcriptExt.Vector3, CQcriptExt.Vector3)} { call = _type.GetMethod("op_GreaterThan"); } else if (code == logictoken.less)//[4] = {Boolean op_LessThan(CQcriptExt.Vector3, CQcriptExt.Vector3)} { call = _type.GetMethod("op_LessThan"); } else if (code == logictoken.more_equal)//[3] = {Boolean op_GreaterThanOrEqual(CQcriptExt.Vector3, CQcriptExt.Vector3)} { call = _type.GetMethod("op_GreaterThanOrEqual"); } else if (code == logictoken.less_equal)//[5] = {Boolean op_LessThanOrEqual(CQcriptExt.Vector3, CQcriptExt.Vector3)} { call = _type.GetMethod("op_LessThanOrEqual"); } else if (code == logictoken.equal)//[6] = {Boolean op_Equality(CQcriptExt.Vector3, CQcriptExt.Vector3)} { if (left == null || right.type == null) { return(left == right.value); } call = _type.GetMethod("op_Equality"); if (call == null) { return(left.Equals(right.value)); } } else if (code == logictoken.not_equal)//[7] = {Boolean op_Inequality(CQcriptExt.Vector3, CQcriptExt.Vector3)} { if (left == null || right.type == null) { return(left != right.value); } call = _type.GetMethod("op_Inequality"); if (call == null) { return(!left.Equals(right.value)); } } var obj = call.Invoke(null, new object[] { left, right.value }); return((bool)obj); }
public IEnumerator CoroutineCompute(CQ_Content content, ICoroutine coroutine) { content.InStack(this); { if (listParam[0].hasCoroutine) { yield return(coroutine.StartNewCoroutine(listParam[0].CoroutineCompute(content, coroutine))); } else { CQ_Content.Value v = listParam[0].ComputeValue(content); { object val = v.value; CQType value_type = null; if (content.values.ContainsKey(value_name)) { value_type = content.values[value_name].type; } else { if (content.CallType != null) { if (content.CallType.members.ContainsKey(value_name)) { if (content.CallType.members[value_name].bStatic) { value_type = content.CallType.staticMemberInstance[value_name].type; } else { value_type = content.CallThis.member[value_name].type; } } } } //val = v.value; if ((Type)value_type != typeof(CQ_Type_Var.var) && value_type != v.type) { val = content.environment.GetType(v.type).ConvertTo(content, v.value, value_type); } content.Set(value_name, val); } } } content.OutStack(this); }
public CQ_Content.Value ComputeValue(CQ_Content content) { content.InStack(this); CQ_Content.Value result = null; { result = new CQ_Content.Value(); var left = listParam[0].ComputeValue(content); var right = listParam[1].ComputeValue(content); result.value = content.environment.GetType(left.type).Math2Value(content, mathop, left.value, right, out result.type); } content.OutStack(this); return(result); }
public CQ_Content.Value ComputeValue(CQ_Content content) { content.InStack(this); CQ_Content.Value r = listParam[0].ComputeValue(content); CQ_Content.Value r2 = new CQ_Content.Value(); r2.type = r.type; r2.breakBlock = r.breakBlock; r2.value = !(bool)r.value; content.OutStack(this); return(r2); }
public CQ_Content.Value ComputeValue(CQ_Content content) { content.InStack(this); CQ_Content.Value result = new CQ_Content.Value(); //if(mathop=="<"||mathop=="<="||mathop==">"||mathop==">="||mathop=="=="||mathop=="!=") { result.type = typeof(bool); var left = listParam[0].ComputeValue(content); var right = listParam[1].ComputeValue(content); if (left.type == null || right.type == null) { if (mathop == logictoken.equal) { result.value = left.value == right.value; } if (mathop == logictoken.not_equal) { result.value = left.value != right.value; } } else if ((Type)left.type == typeof(bool) && (Type)right.type == typeof(bool)) { if (mathop == logictoken.equal) { result.value = (bool)left.value == (bool)right.value; //return result; } else if (mathop == logictoken.not_equal) { result.value = (bool)left.value != (bool)right.value; //return result; } else { throw new Exception("bool 不支持此运算符"); } } else { result.value = content.environment.GetType(left.type).MathLogic(content, mathop, left.value, right); } } content.OutStack(this); return(result); }