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; }
private ScopedIdentifierManager(ScopedIdentifierManager other) { CaseSensitive = other.CaseSensitive; _rootScope = other._rootScope; _scopes.Push(_rootScope); }
public FunctionInliner(Function root) { _root = root; _funStack.Push(root); _sim = new ScopedIdentifierManager(true); _locals = new CacheDictionary<Tuple<Function, IStorableLiteral>, IStorableLiteral>(CreateLocal); }
string MakeIDName(string name, object item, ScopedIdentifierManager sim) { string goodName = MakeValidVHDLIdentifier(name); return sim.GetUniqueName(goodName, item, false); }