public void Init(CLRSharp.ICLRSharp_Environment env) { if (bInited) return; if(bodyNative.HasVariables) { typelistForLoc = new MethodParamList(env, bodyNative.Variables); } }
/// <summary> /// 构造函数只是为了把脚本实例传进来,用其他的形式也可以 /// </summary> /// <param name="inst"></param> public Base_IMyType(CLRSharp.CLRSharp_Instance inst) { var context = ThreadContext.activeContext; this.inst = inst; //这里先把需要的脚本方法记下来,只是为了后面调用起来方便 var ms = this.inst.type.GetMethodNames(); foreach (string name in ms) { if (name.Contains("GetName")) _GetName = this.inst.type.GetMethod(name, MethodParamList.constEmpty()); if (name.Contains("GetDesc")) _GetDesc = this.inst.type.GetMethod(name, MethodParamList.constEmpty()); if (name.Contains("SetName")) _SetName = this.inst.type.GetMethod(name, MethodParamList.Make(context.environment.GetType(typeof(string)))); } }
/// <summary> /// 创建真正的绑定实例 /// </summary> /// <param name="inst">传入的脚本实例</param> /// <returns></returns> public object CreateBind(CLRSharp.CLRSharp_Instance inst) { return new Base_IMyType(inst); }
public void Init(CLRSharp.ICLRSharp_Environment env) { if (bInited) return; if (bodyNative.HasVariables) { typelistForLoc = new MethodParamList(env, bodyNative.Variables); } for (int i = 0; i < bodyNative.Instructions.Count; i++) { var code = bodyNative.Instructions[i]; OpCode c = new OpCode(); c.code = (CodeEx)(int)code.OpCode.Code; c.addr = code.Offset; if (code.SequencePoint != null) { if (debugDoc == null) debugDoc = new Dictionary<string, int>(); if (debugDoc.ContainsKey(code.SequencePoint.Document.Url) == false) { debugDoc.Add(code.SequencePoint.Document.Url, code.SequencePoint.StartLine); } c.debugline = code.SequencePoint.StartLine; } this.opCodes.Add(c); addr[c.addr] = i; ; } var context = ThreadContext.activeContext; for (int i = 0; i < bodyNative.Instructions.Count; i++) { OpCode c = opCodes[i]; var code = bodyNative.Instructions[i]; c.InitToken(context, this, code.Operand); } bInited = true; }
//以后准备用自定义Body采集一遍,可以先过滤处理掉Mono.Cecil的代码中的指向,执行会更快 public CodeBody(CLRSharp.ICLRSharp_Environment env, Mono.Cecil.MethodDefinition _def) { this.method = _def; Init(env); }
static object TestOne(CLRSharp.IMethod method, bool LogStep = false, bool notry = false) { int debug = LogStep ? 9 : 0; if (CLRSharp.ThreadContext.activeContext == null) { CLRSharp.ThreadContext context = new CLRSharp.ThreadContext(env, debug); } CLRSharp.ThreadContext.activeContext.SetNoTry = notry; return method.Invoke(CLRSharp.ThreadContext.activeContext, null, null); }
protected override void initDBModel(CLRSharp.ICLRType voCLRType = null, string sheet = "", bool order = false) { base.initDBModel(typeof(CellWarSceneDBVO) as ICLRType, "cell_war_scene"); }
public TestItem(CLRSharp.ICLRType type, string method) { this.type = type; this.method = method; }
void CallMethod(CLRSharp.IMethod method, object _this, params object[] _params) { CLRSharp.ThreadContext context = CLRSharp.ThreadContext.activeContext; method.Invoke(context, _this, _params); }
protected override void initDBModel(CLRSharp.ICLRType voCLRType = null, string sheet = "", bool order = false) { base.initDBModel(typeof(LevelDBVO) as ICLRType, "level", true); }