本文整理汇总了C#中CSLE.CLS_Content类的典型用法代码示例。如果您正苦于以下问题:C# CLS_Content类的具体用法?C# CLS_Content怎么用?C# CLS_Content使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CLS_Content类属于CSLE命名空间,在下文中一共展示了CLS_Content类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ComputeValue
public CLS_Content.Value ComputeValue(CLS_Content content)
{
content.InStack(this);
CLS_Content.Value result = new CLS_Content.Value();
result.type = typeof(bool);
bool bleft = (bool)listParam[0].ComputeValue(content).value;
if (mathop == '&')
{
if (!bleft)
{
result.value = false;
}
else
{
result.value = bleft && (bool)listParam[1].ComputeValue(content).value;
}
}
else if (mathop == '|')
{
if (bleft)
{
result.value = true;
}
else
{
result.value = bleft || (bool)listParam[1].ComputeValue(content).value;
}
}
content.OutStack(this);
return result;
}
示例2: ComputeValue
public CLS_Content.Value ComputeValue(CLS_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长度数组");
CLS_Content.Value vcount = new CLS_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<CLS_Content.Value> p = new List<CLS_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;
}
示例3: ComputeValue
public CLS_Content.Value ComputeValue(CLS_Content content)
{
content.InStack(this);
content.DepthAdd();
CLS_Content.Value vrt = null;
CLS_Expression_Define define = listParam[0] as CLS_Expression_Define;
define.ComputeValue(content);
IEnumerator it = (listParam[1].ComputeValue(content).value as IEnumerable).GetEnumerator();
ICLS_Expression expr_block = listParam[2];
while (it.MoveNext())
{
content.Set(define.value_name, it.Current);
if (expr_block != null)
{
CLS_Content.Value v = expr_block.ComputeValue(content);
if (v != null)
{
if (v.breakBlock > 2)
vrt = v;
if (v.breakBlock > 1)
break;
}
}
}
content.DepthRemove();
content.OutStack(this);
return vrt;
}
示例4: ComputeValue
public CLS_Content.Value ComputeValue(CLS_Content content)
{
CLS_Content.Value value = new CLS_Content.Value();
value.type = typeof(DeleLambda);
value.value = new DeleLambda(content, this.listParam[0].listParam, this.listParam[1]);
return value;
}
示例5: Call
public CLS_Content.Value Call(CLS_Content content, 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] == (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;
}
示例6: New
public override CLS_Content.Value New(CLS_Content content, BetterList<CLS_Content.Value> _params)
{
CLS_Content.Value val = new CLS_Content.Value();
val.type = typeof(SphereCollider);
val.value = new SphereCollider();
return val;
}
示例7: Math2Value
public object Math2Value(CLS_Content env, char code, object left, CLS_Content.Value right, out CLType returntype)
{
returntype = typeof(float);
if ((Type)right.type == typeof(int))
{
if (code == '+')
return (float)left + (float)(int)right.value;
else if (code == '-')
return (float)left - (float)(int)right.value;
else if (code == '*')
return (float)left * (float)(int)right.value;
else if (code == '/')
return (float)left / (float)(int)right.value;
else if (code == '%')
return (float)left % (float)(int)right.value;
}
else if ((Type)right.type == typeof(uint))
{
if (code == '+')
return (float)left + (float)(uint)right.value;
else if (code == '-')
return (float)left - (float)(uint)right.value;
else if (code == '*')
return (float)left * (float)(uint)right.value;
else if (code == '/')
return (float)left / (float)(uint)right.value;
else if (code == '%')
return (float)left % (float)(uint)right.value;
}
else if ((Type)right.type == typeof(double))
{
returntype = typeof(double);
if (code == '+')
return (double)(float)left + (double)right.value;
else if (code == '-')
return (double)(float)left - (double)right.value;
else if (code == '*')
return (double)(float)left * (double)right.value;
else if (code == '/')
return (double)(float)left / (double)right.value;
else if (code == '%')
return (double)(float)left % (double)right.value;
}
else if ((Type)right.type == typeof(float))
{
returntype = typeof(float);
if (code == '+')
return (float)left + (float)right.value;
else if (code == '-')
return (float)left - (float)right.value;
else if (code == '*')
return (float)left * (float)right.value;
else if (code == '/')
return (float)left / (float)right.value;
else if (code == '%')
return (float)left % (float)right.value;
}
throw new NotImplementedException();
}
示例8: OnGUI
void OnGUI()
{
if (GUI.Button(new Rect(0, 0, 200, 50), "Eval use String"))
{
Script.ClearValue();
string callExpr ="ScriptClass1 sc =new ScriptClass1();\n"+
"sc.defHP1=200;\n"+
"sc.defHP2=300;\n"+
"return sc.GetHP();";
object i = Script.Execute(callExpr);
result = "result=" + i;
}
if (GUI.Button(new Rect(200, 0, 200, 50), "Eval use Code"))
{
Script.ClearValue();
CSLE.CLS_Content content = new CSLE.CLS_Content(Script.env);
//得到脚本类型
var typeOfScript = Script.env.GetTypeByKeyword("ScriptClass1");
//调用脚本类构造创造一个实例
var thisOfScript = typeOfScript.function.New(content, null).value;
//调用脚本类成员变量赋值
//Debug.LogWarning(thisOfScript+","+ typeOfScript+","+ typeOfScript.function);
typeOfScript.function.MemberValueSet(content, thisOfScript, "defHP1", 200);
typeOfScript.function.MemberValueSet(content, thisOfScript, "defHP2", 300);
//调用脚本类成员函数
var returnvalue = typeOfScript.function.MemberCall(content, thisOfScript, "GetHP", null);
object i = returnvalue.value;
result = "result=" + i;
}
GUI.Label(new Rect(0, 50, 200, 50), result);
}
示例9: ComputeValue
public CLS_Content.Value ComputeValue(CLS_Content content)
{
content.InStack(this);
content.DepthAdd();
CLS_Content.Value vrt = null;
ICLS_Expression expr_while = listParam[1];
ICLS_Expression expr_block = listParam[0];
do
{
if (expr_block != null)
{
CLS_Content.Value v = expr_block.ComputeValue(content);
if (v != null)
{
if (v.breakBlock > 2)
vrt = v;
if (v.breakBlock > 1)
break;
}
}
} while ((bool)expr_while.ComputeValue(content).value);
content.DepthRemove();
content.OutStack(this);
return vrt;
}
示例10: ComputeValue
public CLS_Content.Value ComputeValue(CLS_Content content)
{
content.InStack(this);
int arraySize = listParam[0] == null ? (listParam.Count - 1) : (int)listParam[0].ComputeValue(content).value;
if (arraySize == 0)
throw new Exception("不能创建0长度数组");
int initValCount = listParam.Count - 1;
object[] initVals = new object[initValCount];
for (int i = 1; i < listParam.Count; i++)
{
initVals[i - 1] = listParam[i].ComputeValue(content).value;
}
CLS_Content.Value vcount = new CLS_Content.Value();
vcount.type = typeof(int);
vcount.value = arraySize;
BetterList<CLS_Content.Value> _params = CLS_Content.NewParamList();
_params.Add(vcount);
CLS_Content.Value newVal = type.function.New(content, _params);
for (int i = 0; i < initValCount; i++)
{
type.function.IndexSet(content, newVal.value, i, initVals[i]);
}
CLS_Content.PoolParamList(_params);
content.OutStack(this);
return newVal;
}
示例11: ComputeValue
public CLS_Content.Value ComputeValue(CLS_Content content)
{
content.InStack(this);
//var parent = listParam[0].ComputeValue(content);
//var type = content.environment.GetType(parent.type);
List<CLS_Content.Value> _params = new List<CLS_Content.Value>();
for (int i = 0; i < listParam.Count; i++)
{
_params.Add(listParam[i].ComputeValue(content));
}
CLS_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;
}
示例12: Math2Value
public override object Math2Value(CLS_Content env, char code, object left, CLS_Content.Value right, out CLType returntype)
{
returntype = null;
Delegate rightDele = null;
if (right.value is DeleFunction)
rightDele = CreateDelegate(env.environment, right.value as DeleFunction);
else if (right.value is DeleLambda)
rightDele = CreateDelegate(env.environment, right.value as DeleLambda);
else if (right.value is Delegate)
rightDele = right.value as Delegate;
if (rightDele != null)
{
Delegate leftDele = left as Delegate;
if (left == null)
return rightDele;
if (code == '+')
return Delegate.Combine(leftDele, rightDele);
if (code == '-')
return Delegate.Remove(leftDele, rightDele);
}
throw new NotSupportedException("" + right.value);
}
示例13: ComputeValue
public CLS_Content.Value ComputeValue(CLS_Content content)
{
content.InStack(this);
var parent = listParam[0].ComputeValue(content);
var typefunction = content.environment.GetType(parent.type).function;
if(parent.type is object)
{
SInstance s = parent.value as SInstance;
if(s!=null)
{
typefunction = s.type;
}
}
List<CLS_Content.Value> _params = new List<CLS_Content.Value>();
for (int i = 1; i < listParam.Count; i++)
{
_params.Add(listParam[i].ComputeValue(content));
}
CLS_Content.Value value = null;
if (cache == null||cache.cachefail)
{
cache = new MethodCache();
value = typefunction.MemberCall(content, parent.value, functionName, _params,cache);
}
else
{
value = typefunction.MemberCallCache(content, parent.value, _params, cache);
}
content.OutStack(this);
return value;
//做数学计算
//从上下文取值
//_value = null;
//return null;
}
示例14: ComputeValue
public CLS_Content.Value ComputeValue(CLS_Content content)
{
content.InStack(this);
CLS_Content.Value rv = new CLS_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;
}
示例15: ComputeValue
public CLS_Content.Value ComputeValue(CLS_Content content)
{
content.InStack(this);
var parent = listParam[0].ComputeValue(content);
if (parent == null)
{
throw new Exception("调用空对象的方法:" + listParam[0].ToString() + ":" + ToString());
}
ICLS_TypeFunction typefunction = content.environment.GetType(parent.type).function;
if(parent.type is object)
{
SInstance s =parent.value as SInstance;
if(s!=null)
{
typefunction = s.type;
}
}
//var type = content.environment.GetType(parent.type);
var value=typefunction.MemberValueGet(content, parent.value, membername);
content.OutStack(this);
return value;
//做数学计算
//从上下文取值
//_value = null;
//return null;
}