public CLS_Content.Value Call(CLS_Environment environment, IList<CLS_Content.Value> param) { CLS_Content.Value v = new CLS_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] == param[i].type) { objs.Add(param[i].value); } else { object conv = environment.GetType(param[i].type).ConvertTo(environment, param[i].value, paramtype[i]); objs.Add(conv); } } } v.type = this.returntype; v.value = dele.DynamicInvoke(objs.ToArray()); return v; }
public CLS_Content.Value ComputeValue(CLS_Content content) { content.InStack(this); CLS_Content.Value rv = new CLS_Content.Value(); rv.breakBlock = 2; //跳出逻辑 content.OutStack(this); return rv; }
public bool MathLogic(CLS_Environment env, logictoken code, object left, CLS_Content.Value right) { if (code == logictoken.equal) { return((string)left == (string)right.value); } else if (code == logictoken.not_equal) { return((string)left != (string)right.value); } throw new NotImplementedException(); }
public CLS_Content.Value ComputeValue(CLS_Content content) { content.InStack(this); CLS_Content.Value r = listParam[0].ComputeValue(content); ICLS_Type type = content.environment.GetType(r.type); r.value = type.Math2Value(content.environment, '*', r.value, CLS_Content.Value.OneMinus, out r.type); content.OutStack(this); return(r); }
public CLS_Content.Value ComputeValue(CLS_Content content) { content.InStack(this); CLS_Content.Value r = listParam[0].ComputeValue(content); CLS_Content.Value r2 = new CLS_Content.Value(); r2.type = r.type; r2.breakBlock = r.breakBlock; r2.value = !(bool)r.value; content.OutStack(this); return r2; }
public virtual CLS_Content.Value IndexGet(CLS_Environment environment, object object_this, object key) { //var m =type.GetMembers(); var targetop = type.GetMethod("get_Item"); if (targetop == null) { targetop = type.GetMethod("Get"); } CLS_Content.Value v = new CLS_Content.Value(); v.type = targetop.ReturnType; v.value = targetop.Invoke(object_this, new object[] { key }); return(v); }
public CLS_Content.Value ComputeValue(CLS_Content content) { content.InStack(this); CLS_Content.Value result = null; { result = new CLS_Content.Value(); var left = listParam[0].ComputeValue(content); var right = listParam[1].ComputeValue(content); result.value = content.environment.GetType(left.type).Math2Value(content.environment, mathop, left.value, right, out result.type); } content.OutStack(this); return(result); }
public CLS_Content.Value ComputeValue(CLS_Content content) { content.InStack(this); CLS_Content.Value r = listParam[0].ComputeValue(content); CLS_Content.Value r2 = new CLS_Content.Value(); r2.type = r.type; r2.breakBlock = r.breakBlock; r2.value = !(bool)r.value; content.OutStack(this); return(r2); }
public CLS_Content.Value ComputeValue(CLS_Content content) { content.InStack(this); CLS_Content.Value result = null; { result = new CLS_Content.Value(); var left = listParam[0].ComputeValue(content); var right = listParam[1].ComputeValue(content); result.value = content.environment.GetType(left.type).Math2Value(content.environment, mathop, left.value, right, out result.type); } content.OutStack(this); return result; }
public virtual CLS_Content.Value New(CLS_Environment environment, IList <CLS_Content.Value> _params) { List <Type> types = new List <Type>(); List <object> objparams = new List <object>(); foreach (var p in _params) { types.Add(p.type); objparams.Add(p.value); } CLS_Content.Value value = new CLS_Content.Value(); value.type = type; var con = this.type.GetConstructor(types.ToArray()); value.value = con.Invoke(objparams.ToArray()); return(value); }
public virtual CLS_Content.Value StaticCall(CLS_Environment environment, string function, IList <CLS_Content.Value> _params) { List <object> _oparams = new List <object>(); List <Type> types = new List <Type>(); foreach (var p in _params) { _oparams.Add(p.value); types.Add(p.type); } var targetop = type.GetMethod(function, types.ToArray()); CLS_Content.Value v = new CLS_Content.Value(); v.value = targetop.Invoke(null, _oparams.ToArray()); v.type = targetop.ReturnType; return(v); }
public CLS_Content.Value ComputeValue(CLS_Content content) { content.InStack(this); { CLS_Content.Value v = listParam[0].ComputeValue(content); Type value_type = content.values[value_name].type; object val = v.value; if (value_type != typeof(CLS_Type_Var.var) && value_type != v.type) { val = content.environment.GetType(v.type).ConvertTo(content.environment, v.value, value_type); } content.Set(value_name, val); } content.OutStack(this); return(null); }
ICLS_Expression OptimizeSingle(ICLS_Expression expr, CLS_Content content) { if (expr is CLS_Expression_Math2Value || expr is CLS_Expression_Math2ValueAndOr || expr is CLS_Expression_Math2ValueLogic) { if (expr.listParam[0] is ICLS_Value && expr.listParam[1] is ICLS_Value) { CLS_Content.Value result = expr.ComputeValue(content); if (result.type == typeof(bool)) { CLS_Value_Value <bool> value = new CLS_Value_Value <bool>(); value.value_value = (bool)result.value; value.tokenBegin = expr.listParam[0].tokenBegin; value.tokenEnd = expr.listParam[1].tokenEnd; return(value); } else { ICLS_Type v = content.environment.GetType(result.type); ICLS_Value value = v.MakeValue(result.value); value.tokenBegin = expr.listParam[0].tokenBegin; value.tokenEnd = expr.listParam[1].tokenEnd; return(value); } } } if (expr is CLS_Expression_Math3Value) { CLS_Content.Value result = expr.listParam[0].ComputeValue(content); if (result.type == typeof(bool)) { bool bv = (bool)result.value; if (bv) { return(expr.listParam[1]); } else { return(expr.listParam[2]); } } } return(expr); }
public CLS_Content.Value ComputeValue(CLS_Content content) { content.InStack(this); var right = listParam[0].ComputeValue(content); ICLS_Type type = content.environment.GetType(right.type); CLS_Content.Value value = new CLS_Content.Value(); value.type = targettype; value.value = type.ConvertTo(content.environment, right.value, targettype); //操作变量之 //做数学计算 //从上下文取值 //_value = null; content.OutStack(this); return value; }
public CLS_Content.Value ComputeValue(CLS_Content content) { content.InStack(this); var right = listParam[0].ComputeValue(content); ICLS_Type type = content.environment.GetType(right.type); CLS_Content.Value value = new CLS_Content.Value(); value.type = targettype; value.value = type.ConvertTo(content.environment, right.value, targettype); //操作变量之 //做数学计算 //从上下文取值 //_value = null; content.OutStack(this); return(value); }
public CLS_Content.Value ComputeValue(CLS_Content content) { content.InStack(this); CLS_Content.Value result = new CLS_Content.Value(); //if (mathop == "&&" || mathop == "||") { bool bleft = false; bool bright = false; if (listParam[0] is ICLS_Value) { bleft = (bool)((listParam[0] as ICLS_Value).value); } else { bleft = (bool)listParam[0].ComputeValue(content).value; } if (listParam[1] is ICLS_Value) { bright = (bool)((listParam[1] as ICLS_Value).value); } else { bright = (bool)listParam[1].ComputeValue(content).value; } result.type = typeof(bool); if (mathop == '&') { result.value = (bool)(bleft && bright); } else if (mathop == '|') { result.value = (bool)(bleft || bright); } } content.OutStack(this); return(result); }
public CLS_Content.Value ComputeValue(CLS_Content content) { content.InStack(this); CLS_Content.Value result = new CLS_Content.Value(); //if (mathop == "&&" || mathop == "||") { bool bleft = false; bool bright = false; if (listParam[0] is ICLS_Value) { bleft = (bool)((listParam[0] as ICLS_Value).value); } else { bleft = (bool)listParam[0].ComputeValue(content).value; } if (listParam[1] is ICLS_Value) { bright = (bool)((listParam[1] as ICLS_Value).value); } else { bright = (bool)listParam[1].ComputeValue(content).value; } result.type = typeof(bool); if (mathop == '&') { result.value = (bool)(bleft && bright); } else if (mathop == '|') { result.value = (bool)(bleft || bright); } } content.OutStack(this); return result; }
public CLS_Content.Value ComputeValue(CLS_Content content) { content.InStack(this); CLS_Content.Value result = null; { result = new CLS_Content.Value(); var value = listParam[0].ComputeValue(content); if (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 virtual CLS_Content.Value MemberCall(CLS_Environment environment, object object_this, string func, IList <CLS_Content.Value> _params) { List <Type> types = new List <Type>(); List <object> _oparams = new List <object>(); foreach (var p in _params) { _oparams.Add(p.value); types.Add(p.type); } var targetop = type.GetMethod(func, types.ToArray()); CLS_Content.Value v = new CLS_Content.Value(); if (targetop == null) { throw new Exception("函数不存在function:" + type.ToString() + "." + func); } v.value = targetop.Invoke(object_this, _oparams.ToArray()); v.type = targetop.ReturnType; return(v); }
public CLS_Content.Value ComputeValue(CLS_Content content) { content.InStack(this); CLS_Content.Value result = new CLS_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 == typeof(bool) && 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.environment, mathop, left.value, right); } } content.OutStack(this); return result; }
public CLS_Content.Value ComputeValue(CLS_Content content) { content.InStack(this); content.DepthAdd(); CLS_Content.Value value = null; foreach (ICLS_Expression i in listParam) { ICLS_Expression e = i as ICLS_Expression; if (e != null) { value = e.ComputeValue(content); } if (value != null && value.breakBlock != 0) { break; } } content.DepthRemove(); content.OutStack(this); return(value); }
public CLS_Content.Value ComputeValue(CLS_Content content) { content.InStack(this); CLS_Content.Value result = new CLS_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 == typeof(bool) && 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.environment, mathop, left.value, right); } } content.OutStack(this); return(result); }
public virtual CLS_Content.Value StaticValueGet(CLS_Environment environment, string valuename) { var targetp = type.GetProperty(valuename); if (targetp != null) { CLS_Content.Value v = new CLS_Content.Value(); v.value = targetp.GetValue(null, null); v.type = targetp.PropertyType; return(v); } else { var targetf = type.GetField(valuename); if (targetf != null) { CLS_Content.Value v = new CLS_Content.Value(); v.value = targetf.GetValue(null); v.type = targetf.FieldType; return(v); } } return(null); }
public object Math2Value(CLS_Environment env, char code, object left, CLS_Content.Value right, out Type returntype) { throw new NotImplementedException(); }
public virtual bool MathLogic(CLS_Environment env, logictoken code, object left, CLS_Content.Value right) { System.Reflection.MethodInfo call = null; //var m = type.GetMethods(); if (code == logictoken.more)//[2] = {Boolean op_GreaterThan(CLScriptExt.Vector3, CLScriptExt.Vector3)} { call = type.GetMethod("op_GreaterThan"); } else if (code == logictoken.less)//[4] = {Boolean op_LessThan(CLScriptExt.Vector3, CLScriptExt.Vector3)} { call = type.GetMethod("op_LessThan"); } else if (code == logictoken.more_equal)//[3] = {Boolean op_GreaterThanOrEqual(CLScriptExt.Vector3, CLScriptExt.Vector3)} { call = type.GetMethod("op_GreaterThanOrEqual"); } else if (code == logictoken.less_equal)//[5] = {Boolean op_LessThanOrEqual(CLScriptExt.Vector3, CLScriptExt.Vector3)} { call = type.GetMethod("op_LessThanOrEqual"); } else if (code == logictoken.equal)//[6] = {Boolean op_Equality(CLScriptExt.Vector3, CLScriptExt.Vector3)} { if (left == null || right.type == null) { return(left == right.value); } call = type.GetMethod("op_Equality"); } else if (code == logictoken.not_equal)//[7] = {Boolean op_Inequality(CLScriptExt.Vector3, CLScriptExt.Vector3)} { if (left == null || right.type == null) { return(left != right.value); } call = type.GetMethod("op_Inequality"); } var obj = call.Invoke(null, new object[] { left, right.value }); return((bool)obj); }
public virtual object Math2Value(CLS_Environment env, char code, object left, CLS_Content.Value right, out Type returntype) { returntype = type; System.Reflection.MethodInfo call = null; //var m = type.GetMethods(); if (code == '+') { call = type.GetMethod("op_Addition", new Type[] { this.type, right.type }); } else if (code == '-')//base = {CLScriptExt.Vector3 op_Subtraction(CLScriptExt.Vector3, CLScriptExt.Vector3)} { call = type.GetMethod("op_Subtraction", new Type[] { this.type, right.type }); } else if (code == '*')//[2] = {CLScriptExt.Vector3 op_Multiply(CLScriptExt.Vector3, CLScriptExt.Vector3)} { call = type.GetMethod("op_Multiply", new Type[] { this.type, right.type }); } else if (code == '/')//[3] = {CLScriptExt.Vector3 op_Division(CLScriptExt.Vector3, CLScriptExt.Vector3)} { call = type.GetMethod("op_Division", new Type[] { this.type, right.type }); } else if (code == '%')//[4] = {CLScriptExt.Vector3 op_Modulus(CLScriptExt.Vector3, CLScriptExt.Vector3)} { call = type.GetMethod("op_Modulus", new Type[] { this.type, right.type }); } var obj = call.Invoke(null, new object[] { left, right.value }); //function.StaticCall(env,"op_Addtion",new List<ICL>{}) return(obj); }
public bool MathLogic(CLS_Environment env, logictoken code, object left, CLS_Content.Value right) { throw new NotImplementedException(); }
public virtual CLS_Content.Value MemberCall(CLS_Environment environment, object object_this, string func, IList<CLS_Content.Value> _params) { List<Type> types = new List<Type>(); List<object> _oparams = new List<object>(); foreach (var p in _params) { _oparams.Add(p.value); types.Add(p.type); } var targetop = type.GetMethod(func, types.ToArray()); CLS_Content.Value v = new CLS_Content.Value(); if (targetop == null) { throw new Exception("函数不存在function:" + type.ToString() + "." + func ); } v.value = targetop.Invoke(object_this, _oparams.ToArray()); v.type = targetop.ReturnType; return v; }
public object Math2Value(CLS_Environment env, char code, object left, CLS_Content.Value right, out Type returntype) { returntype = typeof(double); if (right.type == typeof(int)) { if (code == '+') { return((double)left + (double)(int)right.value); } else if (code == '-') { return((double)left - (double)(int)right.value); } else if (code == '*') { return((double)left * (double)(int)right.value); } else if (code == '/') { return((double)left / (double)(int)right.value); } else if (code == '%') { return((double)left % (double)(int)right.value); } } else if (right.type == typeof(uint)) { if (code == '+') { return((double)left + (double)(uint)right.value); } else if (code == '-') { return((double)left - (double)(uint)right.value); } else if (code == '*') { return((double)left * (double)(uint)right.value); } else if (code == '/') { return((double)left / (double)(uint)right.value); } else if (code == '%') { return((double)left % (double)(uint)right.value); } } else if (right.type == typeof(double)) { returntype = typeof(double); if (code == '+') { return((double)left + (double)right.value); } else if (code == '-') { return((double)left - (double)right.value); } else if (code == '*') { return((double)left * (double)right.value); } else if (code == '/') { return((double)left / (double)right.value); } else if (code == '%') { return((double)left % (double)right.value); } } else if (right.type == typeof(float)) { returntype = typeof(double); if (code == '+') { return((double)left + (double)(float)right.value); } else if (code == '-') { return((double)left - (double)(float)right.value); } else if (code == '*') { return((double)left * (double)(float)right.value); } else if (code == '/') { return((double)left / (double)(float)right.value); } else if (code == '%') { return((double)left % (double)(float)right.value); } } throw new NotImplementedException(); }
public virtual CLS_Content.Value StaticValueGet(CLS_Environment environment, string valuename) { var targetp = type.GetProperty(valuename); if (targetp != null) { CLS_Content.Value v = new CLS_Content.Value(); v.value = targetp.GetValue(null, null); v.type = targetp.PropertyType; return v; } else { var targetf = type.GetField(valuename); if (targetf != null) { CLS_Content.Value v = new CLS_Content.Value(); v.value = targetf.GetValue(null); v.type = targetf.FieldType; return v; } } return null; }
public virtual CLS_Content.Value StaticCall(CLS_Environment environment, string function, IList<CLS_Content.Value> _params) { List<object> _oparams = new List<object>(); List<Type> types = new List<Type>(); foreach (var p in _params) { _oparams.Add(p.value); types.Add(p.type); } var targetop = type.GetMethod(function, types.ToArray()); CLS_Content.Value v = new CLS_Content.Value(); v.value = targetop.Invoke(null, _oparams.ToArray()); v.type = targetop.ReturnType; return v; }
public virtual CLS_Content.Value New(CLS_Environment environment, IList<CLS_Content.Value> _params) { List<Type> types = new List<Type>(); List<object> objparams = new List<object>(); foreach (var p in _params) { types.Add(p.type); objparams.Add(p.value); } CLS_Content.Value value = new CLS_Content.Value(); value.type = type; var con = this.type.GetConstructor(types.ToArray()); value.value = con.Invoke(objparams.ToArray()); return value; }
public virtual CLS_Content.Value IndexGet(CLS_Environment environment, object object_this, object key) { //var m =type.GetMembers(); var targetop = type.GetMethod("get_Item"); if(targetop==null) { targetop = type.GetMethod("Get"); } CLS_Content.Value v = new CLS_Content.Value(); v.type = targetop.ReturnType; v.value = targetop.Invoke(object_this, new object[] { key }); return v; }
public bool MathLogic(CLS_Environment env, logictoken code, object left, CLS_Content.Value right) { if (right.type == typeof(int)) { if (code == logictoken.equal) { return((double)left == (int)right.value); } else if (code == logictoken.less) { return((double)left < (int)right.value); } else if (code == logictoken.less_equal) { return((double)left <= (int)right.value); } else if (code == logictoken.more) { return((double)left > (int)right.value); } else if (code == logictoken.more_equal) { return((double)left >= (int)right.value); } else if (code == logictoken.not_equal) { return((double)left != (int)right.value); } } else if (right.type == typeof(uint)) { if (code == logictoken.equal) { return((double)left == (uint)right.value); } else if (code == logictoken.less) { return((double)left < (uint)right.value); } else if (code == logictoken.less_equal) { return((double)left <= (uint)right.value); } else if (code == logictoken.more) { return((double)left > (uint)right.value); } else if (code == logictoken.more_equal) { return((double)left >= (uint)right.value); } else if (code == logictoken.not_equal) { return((double)left != (uint)right.value); } } else if (right.type == typeof(double)) { if (code == logictoken.equal) { return((double)left == (double)right.value); } else if (code == logictoken.less) { return((double)left < (double)right.value); } else if (code == logictoken.less_equal) { return((double)left <= (double)right.value); } else if (code == logictoken.more) { return((double)left > (double)right.value); } else if (code == logictoken.more_equal) { return((double)left >= (double)right.value); } else if (code == logictoken.not_equal) { return((double)left != (double)right.value); } } else if (right.type == typeof(float)) { if (code == logictoken.equal) { return((double)left == (float)right.value); } else if (code == logictoken.less) { return((double)left < (float)right.value); } else if (code == logictoken.less_equal) { return((double)left <= (float)right.value); } else if (code == logictoken.more) { return((double)left > (float)right.value); } else if (code == logictoken.more_equal) { return((double)left >= (float)right.value); } else if (code == logictoken.not_equal) { return((double)left != (float)right.value); } } throw new NotImplementedException(); }