public StateWeaver(AsyncMethodDecompiler me, Statement body) { _me = me; _body = body; }
public CoStateAssigner(AsyncMethodDecompiler me, IList<Variable> activeVars, Statement body, int ownState) { _me = me; _activeVars = activeVars; _body = body; _ownState = ownState; }
private CoFSMs DecompileCoFSMs(IEnumerable<MethodCallInfo> calledMethods) { var result = default(CoFSMs); result.Map = new Dictionary<Task, CoFSM>(); var q = new Queue<MethodCallInfo>(); foreach (var mci in calledMethods) { if (mci.Method.IsAsync()) q.Enqueue(mci); } var scim = new ScopedIdentifierManager(); while (q.Any()) { var mci = q.Dequeue(); var md = ConstructMethodDescriptor(mci, true); var task = (Task)mci.ResultSample; var dec = new AsyncMethodDecompiler(_context, md, mci.Instance, md.ArgValueSamples); string prefix = scim.GetUniqueName(md.Name, task); prefix += "$_"; var r = dec.DecompileToCoFSM(prefix); r.CoTask = task; result.Map[task] = r; foreach (var callee in r.CalledMethods) { var calleeTask = (Task)mci.ResultSample; if (callee.Method.IsAsync() && !result.Map.ContainsKey(calleeTask)) q.Enqueue(callee); } } result.CreateOrder(); return result; }
public StateAssigner(AsyncMethodDecompiler me, Statement body, bool singleState = false) { _me = me; _body = body; _singleState = singleState; }
private void DecompileAndEnqueueCallees(CodeDescriptor cd, object instance, object[] arguments, MethodCallInfo mymci = null) { IPackageOrComponentDescriptor owner = cd.Owner as IPackageOrComponentDescriptor; var rmd = cd.Method.GetCustomOrInjectedAttribute<RewriteMethodDefinition>(); IDecompilationResult result; var md = cd as MethodDescriptor; var pd = cd as ProcessDescriptor; if (pd != null) _context.CurrentProcess = pd.Instance; else _context.CurrentProcess = md.CallingProcess.Instance; EVariability[] argVar; if (md == null) argVar = new EVariability[0]; else argVar = md.ArgVariabilities; if (rmd != null) { result = rmd.Rewrite(_context, cd, instance, arguments); } else if (cd.Method.IsMoveNext()) { var decomp = new AsyncMethodDecompiler(_context, cd, instance, arguments); result = decomp.Decompile(); cd.Implementation = result.Decompiled; cd.GenuineImplementation = result.Decompiled; } else { var decomp = new MSILDecompiler(cd, instance, arguments, argVar); if (cd is ProcessDescriptor) { decomp.Template.DisallowReturnStatements = true; } decomp.Template.DisallowConditionals = true; if (mymci != null) mymci.Inherit(decomp.Template); result = decomp.Decompile(); cd.Implementation = result.Decompiled; cd.GenuineImplementation = result.Decompiled; } foreach (var mci in result.CalledMethods) { _methodQ.Enqueue(mci); } foreach (var fri in result.ReferencedFields) { AnalyzeFieldRef(fri, cd); } _allMethods.Add(cd); }