public Delegate CreateDelegate(ICLS_Environment env, DeleFunction delefunc)
{
DeleFunction _func = delefunc;
Delegate _dele = delefunc.cacheFunction(this._type, null);
if (_dele != null) return _dele;
Action dele = () =>
{
var func = _func.calltype.functions[_func.function];
if (func.expr_runtime != null)
{
CLS_Content content = new CLS_Content(env, true);
try
{
content.DepthAdd();
content.CallThis = _func.callthis;
content.CallType = _func.calltype;
content.function = _func.function;
//content.DefineAndSet(function._paramnames[0], function._paramtypes[0].type, param0);
func.expr_runtime.ComputeValue(content);
content.DepthRemove();
}
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;
}
}
};
Delegate d = dele as Delegate;
if ((Type)this.type != typeof(Action))
{
_dele = Delegate.CreateDelegate(this.type, d.Target, d.Method);
}
else
{
_dele = dele;
}
return delefunc.cacheFunction(this._type, _dele);
}