예제 #1
0
        static void Main(string[] args)
        {
            if (args.Length < 2)
            {
                System.Console.WriteLine("Syntax: model2mbed <a.xml> <outdir> [template1 [template2 ...]]");
                System.Console.WriteLine("Syntax: model2mbed <a.xml> <outdir> <@template.lst>");
                return;
            }

            try
            {
                List <string> templates = new List <string>();
                for (int i = 2; i < args.Length; ++i)
                {
                    if (args[i].StartsWith("@"))
                    {
                        templates.AddRange(File.ReadAllLines(args[i].Substring(1)).Where(s => !string.IsNullOrWhiteSpace(s)));
                    }
                    else
                    {
                        templates.Add(args[i]);
                    }
                }
                Model m = UPAALParser.Parse(args[0], templates);
                ReferenceOptimizer.cleanup(m);
                Generator g = new Generator(m);
                g.generate(args[1]);
            }
            catch (Exception e)
            {
                System.Console.WriteLine("Error: " + e.Message);
                System.Console.WriteLine("At:");
                System.Console.WriteLine(e.StackTrace);
            }
        }
예제 #2
0
        public static void cleanup(Model m)
        {
            ReferenceOptimizer r = new ReferenceOptimizer(m);

            r.markUnreferenced();
            r.markReferences();
            r.discardUnreferenced();
        }