Example #1
0
        public void Recursion_Call()
        {
            var engine = new Motor();

            engine.Load(new Bytecode(GetLines()));

            Assert.AreEqual(9, engine.Executar("pow", new object[] {3, 2} ));
            Assert.AreEqual(27, engine.Executar("pow", new object[] { 3, 3 } ));
            Assert.AreEqual(16, engine.Executar("pow", new object[] { 2, 4 } ));
            Assert.AreEqual(125, engine.Executar("pow", new object[] { 5, 3 } ));
        }
Example #2
0
        private static void Execute(string script)
        {
            var engine = new Motor();

            engine.Instalar(new WebModulo());
            engine.Instalar(new HtmlModulo());

            var modules = RetrieveModules();

            foreach (var module in modules)
                engine.Instalar(module);

            engine.Load(script);

            engine.Executar("page", new Infra(HttpContext.Current));
        }
Example #3
0
        private static void Run(string filename, string function, string parameters)
        {
            if (!FileExists(filename)) return;

            var engine = new Motor();
            engine.Load(new NPortugol.Npc().CompilarArquivo(filename));

            engine.Instalar(new ConsoleModulo());

            if (string.IsNullOrEmpty(function))
                engine.Executar();
            else
            {
                var list = new List<object>();

                foreach (var parameter in parameters.Split(','))
                {
                    list.Add(parameter.Trim());
                }

                engine.Executar(function, list.ToArray());
            }

            Console.WriteLine("");
            Console.WriteLine("");
            Console.WriteLine("----------------------------------------");
            Console.WriteLine(string.Format("{0} executado com sucesso. <ENTER>", filename));
        }