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