Exemplo n.º 1
0
        public void TestAstar()
        {
            var compiler  = new Compiler();
            var template  = new TemplateReader();
            var _manager  = new BinaryManager();
            var variables = new List <Entity>();
            var functions = new List <Entity>();
            var dataTypes = new List <Entity>();

            _manager.LoadCommandsFrom("AStarFix.dnai");
            var ids = _manager.Controller.GetIds(EntityType.CONTEXT | EntityType.PUBLIC);

            foreach (var id in ids)
            {
                dataTypes.AddRange(_manager.Controller.GetEntitiesOfType(ENTITY.DATA_TYPE, id));
                variables.AddRange(_manager.Controller.GetEntitiesOfType(ENTITY.VARIABLE, id));
                functions.AddRange(_manager.Controller.GetEntitiesOfType(ENTITY.FUNCTION, id));
            }
            //variables = _manager.Controller.GetEntitiesOfType(ENTITY.VARIABLE, ids[1]);
            //functions = _manager.Controller.GetEntitiesOfType(ENTITY.FUNCTION, ids[1]);
            //GenerateMoreOrLess(_manager, out List<Entity> variables, out List<Entity> functions);

            string code = template.GenerateTemplateContent(_manager, variables, functions, dataTypes);
            var    res  = compiler.Compile(code);

            res = compiler.Compile(code);
        }
Exemplo n.º 2
0
        public void TemplateFileTest()
        {
            var t = new TemplateReader();

            var content = t.GenerateTemplateContent();

            Assert.IsNotNull(content);
        }
Exemplo n.º 3
0
        public void GenerationAndCompile()
        {
            var compiler = new Compiler();
            var template = new TemplateReader();

            GenerateMoreOrLess();

            string code = template.GenerateTemplateContent();
            var    res  = compiler.Compile(code);

            var type = res.CompiledAssembly.GetType("DNAI.Behaviour.Behaviour");

            Assert.IsNotNull(type);
        }
Exemplo n.º 4
0
        public void GenerationFromController()
        {
            var compiler  = new Compiler();
            var template  = new TemplateReader();
            var _manager  = new BinaryManager();
            var variables = new List <Entity>();
            var functions = new List <Entity>();
            var dataTypes = new List <Entity>();

            //GenerateDulyFile();
            GenerateMoreOrLess();
            _manager.LoadCommandsFrom("More Or Less.dnai");
            //GenerateMoreOrLess(_manager, out variables, out functions);

            var ids = _manager.Controller.GetIds(EntityType.CONTEXT | EntityType.PUBLIC);

            foreach (var id in ids)
            {
                dataTypes.AddRange(_manager.Controller.GetEntitiesOfType(ENTITY.DATA_TYPE, id));
                variables.AddRange(_manager.Controller.GetEntitiesOfType(ENTITY.VARIABLE, id));
                functions.AddRange(_manager.Controller.GetEntitiesOfType(ENTITY.FUNCTION, id));
            }
            //variables = _manager.Controller.GetEntitiesOfType(ENTITY.VARIABLE, ids[1]);
            //functions = _manager.Controller.GetEntitiesOfType(ENTITY.FUNCTION, ids[1]);
            //GenerateMoreOrLess(_manager, out List<Entity> variables, out List<Entity> functions);

            string code = template.GenerateTemplateContent(_manager, variables, functions, dataTypes);
            var    res  = compiler.Compile(code);

            res = compiler.Compile(code);
            var type = res.CompiledAssembly.GetType("DNAI.MoreOrLess.MoreOrLess");

            Assert.IsNotNull(type);
            var func = type.GetMethod("ExecutePlay");

            Assert.IsNotNull(func);
        }