Exemplo n.º 1
0
 protected override bool PreExecuteInstruction()
 {
     if (CurrentContext.InstructionPointer >= CurrentContext.Script.Length)
     {
         return(true);
     }
     gas_consumed = checked (gas_consumed + GetPrice() * ratio);
     if (!testMode && gas_consumed > gas_amount)
     {
         if (DumpInfo != null)
         {
             DumpInfo.Error("gas_consumed > gas_amount");
         }
         return(false);
     }
     if (!CheckDynamicInvoke())
     {
         if (DumpInfo != null)
         {
             DumpInfo.Error("CheckDynamicInvoke");
         }
         return(false);
     }
     return(true);
 }
Exemplo n.º 2
0
 internal String GetNodeRealizer(NodeType type, DumpInfo dumpInfo)
 {
     return(GetNodeRealizer(dumpInfo.GetNodeTypeColor(type),
                            dumpInfo.GetNodeTypeBorderColor(type),
                            dumpInfo.GetNodeTypeTextColor(type),
                            dumpInfo.GetNodeTypeShape(type)).Name);
 }
Exemplo n.º 3
0
 internal String GetEdgeRealizer(EdgeType type, DumpInfo dumpInfo)
 {
     return(GetEdgeRealizer(dumpInfo.GetEdgeTypeColor(type),
                            dumpInfo.GetEdgeTypeTextColor(type),
                            dumpInfo.GetEdgeTypeThickness(type),
                            dumpInfo.GetEdgeTypeLineStyle(type)).Name);
 }
Exemplo n.º 4
0
        public void DumpToJson()
        {
            if (dumpInfo != null)
            {
                return;
            }
            dumpInfo = new DumpInfo();
            dumpInfo.collectionName = this.variantCollection.name;
            dumpInfo.shaderInfos    = new List <DumpShaderInfo>();

            foreach (var shader in this.shaders)
            {
                ShaderVariants variants;
                DumpShaderInfo shaderInfo = new DumpShaderInfo();
                shaderInfo.shaderName = shader.name;
                if (shaderVariants.TryGetValue(shader, out variants))
                {
                    shaderInfo.keywords = new List <string>(variants.keywordNames);
                    shaderInfo.keywords.Sort();
                }
                this.dumpInfo.shaderInfos.Add(shaderInfo);
            }

            string str = JsonUtility.ToJson(this.dumpInfo);
            string dir = ShaderItemUI.SaveDIR + '/' + this.dateStr + "/variants";

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            string jsonFile = Path.Combine(dir, this.variantCollection.name + ".json");

            File.WriteAllText(jsonFile, str);
        }
Exemplo n.º 5
0
 private bool PreStepInto(OpCode nextOpcode)
 {
     if (CurrentContext.InstructionPointer >= CurrentContext.Script.Length)
     {
         return(true);
     }
     gas_consumed = checked (gas_consumed + GetPrice(nextOpcode) * ratio);
     if (!testMode && gas_consumed > gas_amount)
     {
         if (DumpInfo != null)
         {
             DumpInfo.Error("gas_consumed > gas_amount");
         }
         return(false);
     }
     if (!CheckItemSize(nextOpcode))
     {
         if (DumpInfo != null)
         {
             DumpInfo.Error("CheckItemSize");
         }
         return(false);
     }
     if (!CheckArraySize(nextOpcode))
     {
         if (DumpInfo != null)
         {
             DumpInfo.Error("CheckArraySize");
         }
         return(false);
     }
     if (!CheckInvocationStack(nextOpcode))
     {
         if (DumpInfo != null)
         {
             DumpInfo.Error("CheckInvocationStack");
         }
         return(false);
     }
     if (!CheckBigIntegers(nextOpcode))
     {
         if (DumpInfo != null)
         {
             DumpInfo.Error("CheckBigIntegers");
         }
         return(false);
     }
     if (!CheckDynamicInvoke(nextOpcode))
     {
         if (DumpInfo != null)
         {
             DumpInfo.Error("CheckDynamicInvoke");
         }
         return(false);
     }
     return(true);
 }
Exemplo n.º 6
0
        public static string GetNewDumpPath(DumpInfo dump)
        {
            string result;

            do
            {
                result = Path.Combine(dump.Location, $"{dump.Name}_{DateTime.Now:yyMMdd_HHmmss}.dmp");
            }while (File.Exists(result));

            return(result);
        }
Exemplo n.º 7
0
        public ShellGraphProcessingEnvironment(INamedGraph graph, String backendFilename, String[] backendParameters, String modelFilename)
        {
            LGSPNamedGraph Graph = (LGSPNamedGraph)graph;

            DumpInfo           = new DumpInfo(Graph.GetElementName);
            SubruleDebugConfig = new SubruleDebuggingConfiguration();
            BackendFilename    = backendFilename;
            BackendParameters  = backendParameters;
            ModelFilename      = modelFilename;
            ProcEnv            = new LGSPGraphProcessingEnvironment(Graph, null);
            NameToSubgraph.Add(Graph.Name, Graph);
        }
Exemplo n.º 8
0
        public static void Main(string[] args)
        {
            LGSPNamedGraph graph;
            LGSPActions    actions;
            LGSPGraphProcessingEnvironment procEnv;

            try
            {
                LGSPBackend.Instance.CreateNamedFromSpec("Mutex.grg", null, 0, out graph, out actions);
                procEnv = new LGSPGraphProcessingEnvironment(graph, actions);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Unable to create graph from specification: " + ex.Message);
                return;
            }

            DumpInfo    dumpInfo = new DumpInfo(graph.GetElementName);
            YCompClient ycomp    = YCompClient.CreateYCompClient(graph, "Organic", dumpInfo);

            // Let yComp observe any changes to the graph
            ycomp.RegisterLibGrEvents();

            NodeType processType = graph.GetNodeType("Process");
            EdgeType nextType    = graph.GetEdgeType("next");

            LGSPNode p1 = graph.AddLGSPNode(processType);
            LGSPNode p2 = graph.AddLGSPNode(processType);

            graph.AddEdge(nextType, p1, p2);
            graph.AddEdge(nextType, p2, p1);
            PrintAndWait("Initial 2-process ring constructed.", ycomp);

            procEnv.ApplyGraphRewriteSequence("newRule[5] && mountRule && requestRule[7]");
            PrintAndWait("Initialized 7-process ring with resource and requests.", ycomp);

            ycomp.UnregisterLibGrEvents();
            Console.WriteLine("Do many changes slowing down too much with YComp (not in this example)...");
            procEnv.ApplyGraphRewriteSequence("(takeRule && releaseRule && giveRule)*");
            PrintAndWait("Nothing changed so far on the display.", ycomp);

            ycomp.ClearGraph();
            UploadGraph(graph, ycomp);
            PrintAndWait("Graph newly uploaded to yComp.", ycomp);

            ycomp.RegisterLibGrEvents();

            actions.GetAction("newRule").ApplyMinMax(procEnv, 4, 4);
            PrintAndWait("Added 4 processes in the ring.", ycomp);

            ycomp.Close();
        }
Exemplo n.º 9
0
        public static void Main(string[] args)
        {
            LGSPNamedGraph graph;
            LGSPActions actions;
            LGSPGraphProcessingEnvironment procEnv;

            try
            {
                new LGSPBackend().CreateNamedFromSpec("Mutex.grg", null, 0, out graph, out actions);
                procEnv = new LGSPGraphProcessingEnvironment(graph, actions);
            }
            catch(Exception ex)
            {
                Console.WriteLine("Unable to create graph from specification: " + ex.Message);
                return;
            }

            DumpInfo dumpInfo = new DumpInfo(graph.GetElementName);
            YCompClient ycomp = YCompClient.CreateYCompClient(graph, "Organic", dumpInfo);

            // Let yComp observe any changes to the graph
            ycomp.RegisterLibGrEvents();

            NodeType processType = graph.GetNodeType("Process");
            EdgeType nextType = graph.GetEdgeType("next");

            LGSPNode p1 = graph.AddLGSPNode(processType);
            LGSPNode p2 = graph.AddLGSPNode(processType);
            graph.AddEdge(nextType, p1, p2);
            graph.AddEdge(nextType, p2, p1);
            PrintAndWait("Initial 2-process ring constructed.", ycomp);

            procEnv.ApplyGraphRewriteSequence("newRule[5] && mountRule && requestRule[7]");
            PrintAndWait("Initialized 7-process ring with resource and requests.", ycomp);

            ycomp.UnregisterLibGrEvents();
            Console.WriteLine("Do many changes slowing down too much with YComp (not in this example)...");
            procEnv.ApplyGraphRewriteSequence("(takeRule && releaseRule && giveRule)*");
            PrintAndWait("Nothing changed so far on the display.", ycomp);

            ycomp.ClearGraph();
            UploadGraph(graph, ycomp);
            PrintAndWait("Graph newly uploaded to yComp.", ycomp);

            ycomp.RegisterLibGrEvents();

            actions.GetAction("newRule").ApplyMinMax(procEnv, 4, 4);
            PrintAndWait("Added 4 processes in the ring.", ycomp);

            ycomp.Close();
        }
Exemplo n.º 10
0
        /// <summary>
        /// Creates a new YCompClient instance and connects to the local YComp server.
        /// If it is not available a SocketException is thrown
        /// </summary>
        public YCompClient(INamedGraph graph, String layoutModule, int connectionTimeout, int port, DumpInfo dumpInfo)
        {
            this.graph    = graph;
            this.dumpInfo = dumpInfo;

            int startTime = Environment.TickCount;

            do
            {
                try
                {
                    ycompClient = new TcpClient("localhost", port);
                }
                catch (SocketException)
                {
                    ycompClient = null;
                    Thread.Sleep(1000);
                }
            } while(ycompClient == null && Environment.TickCount - startTime < connectionTimeout);

            if (ycompClient == null)
            {
                throw new Exception("Connection timeout!");
            }

            ycompStream = new YCompStream(ycompClient);

            SetLayout(layoutModule);

            NormalNodeRealizer  = GetNodeRealizer(GrColor.Yellow, GrColor.DarkYellow, GrColor.Black, GrNodeShape.Box);
            MatchedNodeRealizer = GetNodeRealizer(GrColor.Khaki, GrColor.DarkYellow, GrColor.Black, GrNodeShape.Box);
            NewNodeRealizer     = GetNodeRealizer(GrColor.LightRed, GrColor.DarkYellow, GrColor.Black, GrNodeShape.Box);
            DeletedNodeRealizer = GetNodeRealizer(GrColor.LightGrey, GrColor.DarkYellow, GrColor.Black, GrNodeShape.Box);

            NormalEdgeRealizer  = GetEdgeRealizer(GrColor.DarkYellow, GrColor.Black, 1, GrLineStyle.Continuous);
            MatchedEdgeRealizer = GetEdgeRealizer(GrColor.DarkYellow, GrColor.Black, 2, GrLineStyle.Continuous);
            NewEdgeRealizer     = GetEdgeRealizer(GrColor.LightRed, GrColor.Black, 2, GrLineStyle.Continuous);
            DeletedEdgeRealizer = GetEdgeRealizer(GrColor.LightGrey, GrColor.Black, 2, GrLineStyle.Continuous);

            dumpInfo.OnNodeTypeAppearanceChanged += new NodeTypeAppearanceChangedHandler(OnNodeTypeAppearanceChanged);
            dumpInfo.OnEdgeTypeAppearanceChanged += new EdgeTypeAppearanceChangedHandler(OnEdgeTypeAppearanceChanged);
            dumpInfo.OnTypeInfotagsChanged       += new TypeInfotagsChangedHandler(OnTypeInfotagsChanged);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Creates a new YCompClient instance and connects to the local YComp server.
        /// If it is not available a SocketException is thrown
        /// </summary>
        public YCompClient(INamedGraph graph, String layoutModule, int connectionTimeout, int port,
                           DumpInfo dumpInfo, ElementRealizers realizers, Dictionary <string, IObject> nameToClassObject)
        {
            this.graph    = graph;
            this.dumpInfo = dumpInfo;

            int startTime = Environment.TickCount;

            do
            {
                try
                {
                    ycompClient = new TcpClient("localhost", port);
                }
                catch (SocketException)
                {
                    ycompClient = null;
                    Thread.Sleep(1000);
                }
            }while(ycompClient == null && Environment.TickCount - startTime < connectionTimeout);

            if (ycompClient == null)
            {
                throw new Exception("Connection timeout!");
            }

            ycompStream = new YCompStream(ycompClient);

            SetLayout(layoutModule);

            dumpInfo.OnNodeTypeAppearanceChanged += new NodeTypeAppearanceChangedHandler(OnNodeTypeAppearanceChanged);
            dumpInfo.OnEdgeTypeAppearanceChanged += new EdgeTypeAppearanceChangedHandler(OnEdgeTypeAppearanceChanged);
            dumpInfo.OnTypeInfotagsChanged       += new TypeInfotagsChangedHandler(OnTypeInfotagsChanged);

            this.realizers = realizers;
            realizers.RegisterYComp(this);

            this.nameToClassObject = nameToClassObject;
            // TODO: Add group related events
        }
Exemplo n.º 12
0
        /// <summary>
        /// Creates a new YCompClient instance and connects to the local YComp server.
        /// If it is not available a SocketException is thrown
        /// </summary>
        public YCompClient(INamedGraph graph, String layoutModule, int connectionTimeout, int port, DumpInfo dumpInfo, ElementRealizers realizers)
        {
            this.graph = graph;
            this.dumpInfo = dumpInfo;

            int startTime = Environment.TickCount;

            do
            {
                try
                {
                    ycompClient = new TcpClient("localhost", port);
                }
                catch(SocketException)
                {
                    ycompClient = null;
                    Thread.Sleep(1000);
                }
            } while(ycompClient == null && Environment.TickCount - startTime < connectionTimeout);

            if(ycompClient == null)
                throw new Exception("Connection timeout!");

            ycompStream = new YCompStream(ycompClient);

            SetLayout(layoutModule);

            dumpInfo.OnNodeTypeAppearanceChanged += new NodeTypeAppearanceChangedHandler(OnNodeTypeAppearanceChanged);
            dumpInfo.OnEdgeTypeAppearanceChanged += new EdgeTypeAppearanceChangedHandler(OnEdgeTypeAppearanceChanged);
            dumpInfo.OnTypeInfotagsChanged += new TypeInfotagsChangedHandler(OnTypeInfotagsChanged);

            this.realizers = realizers;
            realizers.RegisterYComp(this);

            // TODO: Add group related events
        }
Exemplo n.º 13
0
 private static void DumpNode(INode node, GrColor textColor, GrColor color, GrColor borderColor,
     GrNodeShape shape, IDumper dumper, DumpInfo dumpInfo)
 {
     dumper.DumpNode(node, GetElemLabel(node, dumpInfo), DumpAttributes(node), textColor,
         color, borderColor, shape);
 }
Exemplo n.º 14
0
 private static void DumpEdge(IEdge edge, GrColor textColor, GrColor color, GrLineStyle style,
     int thickness, IDumper dumper, DumpInfo dumpInfo)
 {
     dumper.DumpEdge(edge.Source, edge.Target, GetElemLabel(edge, dumpInfo), DumpAttributes(edge),
         textColor, color, style, thickness);
 }
Exemplo n.º 15
0
        /// <summary>
        /// Dumps the given matches.
        /// </summary>
        /// <param name="dumper">The graph dumper to be used.</param>
        /// <param name="dumpInfo">Specifies how the graph shall be dumped.</param>
        /// <param name="matches">An IMatches object containing the matches.</param>
        /// <param name="which">Which match to dump, or AllMatches for dumping all matches
        /// adding connections between them, or OnlyMatches to dump the matches only</param>
        public static void DumpMatchOnly(IDumper dumper, DumpInfo dumpInfo, IMatches matches, DumpMatchSpecial which,
            ref Set<INode> matchedNodes, ref Set<INode> multiMatchedNodes, ref Set<IEdge> matchedEdges, ref Set<IEdge> multiMatchedEdges)
        {
            matchedNodes = new Set<INode>();
            matchedEdges = new Set<IEdge>();

            if((int)which >= 0 && (int)which < matches.Count)
            {
                // Show exactly one match

                IMatch match = matches.GetMatch((int)which);
                matchedNodes.Add(match.Nodes);
                matchedEdges.Add(match.Edges);
            }
            else
            {
                GrColor vnodeColor = dumpInfo.GetNodeDumpTypeColor(GrElemDumpType.VirtualMatch);
                GrColor vedgeColor = dumpInfo.GetEdgeDumpTypeColor(GrElemDumpType.VirtualMatch);
                GrColor vnodeBorderColor = dumpInfo.GetNodeDumpTypeBorderColor(GrElemDumpType.VirtualMatch);
                GrColor vnodeTextColor = dumpInfo.GetNodeDumpTypeTextColor(GrElemDumpType.VirtualMatch);
                GrColor vedgeTextColor = dumpInfo.GetEdgeDumpTypeTextColor(GrElemDumpType.VirtualMatch);
                GrNodeShape vnodeShape = dumpInfo.GetNodeDumpTypeShape(GrElemDumpType.VirtualMatch);
                GrLineStyle vedgeLineStyle = dumpInfo.GetEdgeDumpTypeLineStyle(GrElemDumpType.VirtualMatch);
                int vedgeThickness = dumpInfo.GetEdgeDumpTypeThickness(GrElemDumpType.VirtualMatch);

                multiMatchedNodes = new Set<INode>();
                multiMatchedEdges = new Set<IEdge>();

                // TODO: May edges to nodes be dumped before those nodes exist??
                // TODO: Should indices in strings start at 0 or 1? (original: 0)

                // Dump all matches with virtual nodes
                int i = 0;
                foreach(IMatch match in matches)
                {
                    VirtualNode virtNode = new VirtualNode(-i - 1);
                    dumper.DumpNode(virtNode, String.Format("{0}. match of {1}", i + 1, matches.Producer.Name),
                        null, vnodeTextColor, vnodeColor, vnodeBorderColor, vnodeShape);
                    int j = 1;
                    foreach(INode node in match.Nodes)
                    {
                        dumper.DumpEdge(virtNode, node, String.Format("node {0}", j++), null,
                            vedgeTextColor, vedgeColor, vedgeLineStyle, vedgeThickness);

                        if(matchedNodes.Contains(node)) multiMatchedNodes.Add(node);
                        else matchedNodes.Add(node);
                    }

                    // Collect matched edges
                    foreach(IEdge edge in match.Edges)
                    {
                        if(matchedEdges.Contains(edge)) multiMatchedEdges.Add(edge);
                        else matchedEdges.Add(edge);
                    }
                    i++;
                }

                if(which == DumpMatchSpecial.OnlyMatches)
                {
                    // Dump the matches only
                    // First dump the matched nodes

                    foreach(INode node in matchedNodes)
                    {
                        GrElemDumpType dumpType;
                        if(multiMatchedNodes.Contains(node))
                            dumpType = GrElemDumpType.MultiMatched;
                        else
                            dumpType = GrElemDumpType.SingleMatched;

                        DumpNode(node, dumpInfo.GetNodeDumpTypeTextColor(dumpType),
                            dumpInfo.GetNodeDumpTypeColor(dumpType),
                            dumpInfo.GetNodeDumpTypeBorderColor(dumpType),
                            dumpInfo.GetNodeDumpTypeShape(dumpType),
                            dumper, dumpInfo);
                    }

                    // Now add the matched edges (possibly including "Not matched" nodes)

                    foreach(IEdge edge in matchedEdges)
                    {
                        if(!matchedNodes.Contains(edge.Source))
                            DumpNode(edge.Source,
                                dumpInfo.GetNodeTypeTextColor(edge.Source.Type),
                                dumpInfo.GetNodeTypeColor(edge.Source.Type),
                                dumpInfo.GetNodeTypeBorderColor(edge.Source.Type),
                                dumpInfo.GetNodeTypeShape(edge.Source.Type),
                                dumper, dumpInfo);

                        if(!matchedNodes.Contains(edge.Target))
                            DumpNode(edge.Target,
                                dumpInfo.GetNodeTypeTextColor(edge.Target.Type),
                                dumpInfo.GetNodeTypeColor(edge.Target.Type),
                                dumpInfo.GetNodeTypeBorderColor(edge.Target.Type),
                                dumpInfo.GetNodeTypeShape(edge.Target.Type),
                                dumper, dumpInfo);

                        GrElemDumpType dumpType;
                        if(multiMatchedEdges.Contains(edge))
                            dumpType = GrElemDumpType.MultiMatched;
                        else
                            dumpType = GrElemDumpType.SingleMatched;

                        DumpEdge(edge, dumpInfo.GetEdgeDumpTypeTextColor(dumpType),
                            dumpInfo.GetEdgeDumpTypeColor(dumpType),
                            dumpInfo.GetEdgeDumpTypeLineStyle(dumpType),
                            dumpInfo.GetEdgeDumpTypeThickness(dumpType),
                            dumper, dumpInfo);
                    }
                    return;
                }
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Dumps one or more matches with a given graph dumper.
        /// </summary>
        /// <param name="graph">The graph to be dumped.</param>
        /// <param name="dumper">The graph dumper to be used.</param>
        /// <param name="dumpInfo">Specifies how the graph shall be dumped.</param>
        /// <param name="matches">An IMatches object containing the matches.</param>
        /// <param name="which">Which match to dump, or AllMatches for dumping all matches
        /// adding connections between them, or OnlyMatches to dump the matches only</param>
        public static void DumpMatch(IGraph graph, IDumper dumper, DumpInfo dumpInfo, IMatches matches, DumpMatchSpecial which)
        {
            Set<INode> matchedNodes = null;
            Set<INode> multiMatchedNodes = null;
            Set<IEdge> matchedEdges = null;
            Set<IEdge> multiMatchedEdges = null;

            if(matches != null)
            {
                DumpMatchOnly(dumper, dumpInfo, matches, which,
                    ref matchedNodes, ref multiMatchedNodes, ref matchedEdges, ref multiMatchedEdges);
            }

            // Dump the graph, but color the matches if any exist

            DumpContext dc = new DumpContext(dumper, dumpInfo,
                matchedNodes, multiMatchedNodes, matchedEdges, multiMatchedEdges);

            foreach(NodeType nodeType in graph.Model.NodeModel.Types)
            {
                if(dumpInfo.IsExcludedNodeType(nodeType)) continue;
                dc.Nodes.Add(graph.GetExactNodes(nodeType));
            }

            dc.InitialNodes = new Set<INode>(dc.Nodes);
            Set<INode> nodes = new Set<INode>(dc.Nodes);
            DumpGroups(graph, nodes, dc);
        }
Exemplo n.º 17
0
 public void Dump(DumpInfo info) => Dump(info.ProcessId, GetNewDumpPath(info));
Exemplo n.º 18
0
 /// <summary>
 /// Dumps the graph with a given graph dumper.
 /// </summary>
 /// <param name="graph">The graph to be dumped.</param>
 /// <param name="dumper">The graph dumper to be used.</param>
 /// <param name="dumpInfo">Specifies how the graph shall be dumped.</param>
 public static void Dump(IGraph graph, IDumper dumper, DumpInfo dumpInfo)
 {
     DumpMatch(graph, dumper, dumpInfo, null, 0);
 }
Exemplo n.º 19
0
        private static String GetElemLabel(IGraphElement elem, DumpInfo dumpInfo)
        {
            List<InfoTag> infoTagTypes = dumpInfo.GetTypeInfoTags(elem.Type);
            String label = dumpInfo.GetElemTypeLabel(elem.Type);
            bool first = true;

            if(label == null)
            {
                label = dumpInfo.GetElementName(elem) + ":" + elem.Type.Name;
                first = false;
            }

            if(infoTagTypes != null)
            {
                foreach(InfoTag infoTag in infoTagTypes)
                {
                    object attr = elem.GetAttribute(infoTag.AttributeType.Name);
                    if(attr == null) continue;

                    if(!first) label += "\n";
                    else first = false;

                    if(infoTag.ShortInfoTag)
                        label += attr.ToString();
                    else
                        label += infoTag.AttributeType.Name + " = " + attr.ToString();
                }
            }

            return label;
        }
Exemplo n.º 20
0
        public new bool Execute()
        {
            try
            {
                while (true)
                {
                    OpCode nextOpcode = CurrentContext.InstructionPointer >= CurrentContext.Script.Length ? OpCode.RET : CurrentContext.NextInstruction;

                    if (this.DumpInfo != null)
                    {
                        this.DumpInfo.NextOp(CurrentContext.InstructionPointer, nextOpcode);
                        this.CurrentContext.EvaluationStack.ClearRecord();
                    }
                    if (!PreStepInto(nextOpcode))
                    {
                        State |= VMState.FAULT;
                        return(false);
                    }
                    StepInto();
                    if (State.HasFlag(VMState.HALT) || State.HasFlag(VMState.FAULT))
                    {
                        break;
                    }
                    if (DumpInfo != null)
                    {
                        if (State.HasFlag(VMState.HALT) || State.HasFlag(VMState.FAULT))
                        {
                            continue;
                        }
                        var          EvaluationStackRec  = this.CurrentContext.EvaluationStack;
                        VM.StackItem result              = null;
                        ExecutionStackRecord.Op[] record = EvaluationStackRec.record.ToArray();
                        var ltype = EvaluationStackRec.GetLastRecordType();
                        if (ltype == ExecutionStackRecord.OpType.Push)
                        {
                            result = EvaluationStackRec.PeekWithoutLog();
                        }
                        else if (ltype == ExecutionStackRecord.OpType.Insert)
                        {
                            result = EvaluationStackRec.PeekWithoutLog(EvaluationStackRec.record.Last().ind);
                        }
                        else if (ltype == ExecutionStackRecord.OpType.Set)
                        {
                            result = EvaluationStackRec.PeekWithoutLog(EvaluationStackRec.record.Last().ind);
                        }
                        else if (ltype == ExecutionStackRecord.OpType.Peek)
                        {
                            result = EvaluationStackRec.PeekWithoutLog();
                        }
                        LogResult(nextOpcode, record, result);
                    }
                }
            }
            catch
            {
                State |= VMState.FAULT;
                return(false);
            }
            if (DumpInfo != null)
            {
                DumpInfo.Finish(State);
            }
            return(!State.HasFlag(VMState.FAULT));
        }
Exemplo n.º 21
0
        /// <summary>
        /// Starts YComp on a free TCP port in the range 4242-4251.
        /// </summary>
        /// <param name="graph">The named graph to be displayed.</param>
        /// <param name="layout">Sets the layouter in YComp.
        ///     Can be one of:
        ///     - Random
        ///     - Hierarchic
        ///     - Organic
        ///     - Orthogonal
        ///     - Circular
        ///     - Tree
        ///     - Diagonal
        ///     - Incremental Hierarchic
        ///     - Compilergraph
        /// </param>
        /// <param name="dumpInfo">Sets the dump information setting colors, shapes,
        ///     excluded types, etc.</param>
        /// <returns>An YCompClient object, or null on error.</returns>
        public static YCompClient CreateYCompClient(INamedGraph graph, String layout, DumpInfo dumpInfo)
        {
            int ycompPort = GetFreeTCPPort();

            if (ycompPort < 0)
            {
                Console.WriteLine("Didn't find a free TCP port in the range 4242-4251!");
                return(null);
            }
            try
            {
                Process.Start("ycomp", "-p " + ycompPort);
            }
            catch (Exception e)
            {
                Console.WriteLine("Unable to start ycomp: " + e.ToString());
                return(null);
            }

            try
            {
                return(new YCompClient(graph, layout, 20000, ycompPort, dumpInfo));
            }
            catch (Exception ex)
            {
                Console.WriteLine("Unable to connect to YComp at port " + ycompPort + ": " + ex.Message);
                return(null);
            }
        }
Exemplo n.º 22
0
 public DumpContext(IDumper dumper, DumpInfo dumpInfo, Set<INode> matchedNodes, Set<INode> multiMatchedNodes,
     Set<IEdge> matchedEdges, Set<IEdge> multiMatchedEdges)
 {
     Dumper = dumper;
     DumpInfo = dumpInfo;
     MatchedNodes = matchedNodes;
     MultiMatchedNodes = multiMatchedNodes;
     MatchedEdges = matchedEdges;
     MultiMatchedEdges = multiMatchedEdges;
 }