protected virtual PrologCompilerResults FromFile(PrologCompilerParameters options, string fileName)
        {
            PrologCompilerResults results = new PrologCompilerResults();
            PrologCodeParser      parser  = new PrologCodeParser();
            PrologCodeUnit        unit    = new PrologCodeUnit();

            try
            {
                StreamReader reader = new StreamReader(fileName);
                unit = parser.Parse(reader);
            }
            catch (FileNotFoundException)
            {
                results.Errors.Add(new PrologCompilerError("P0008", "Input file not found.", fileName, false, 0, 0));
                return(results);
            }
            return(FromUnit(options, unit));
        }
        protected virtual PrologCompilerResults FromUnit(PrologCompilerParameters options, PrologCodeUnit e)
        {
            ArrayList             instructions = new ArrayList();
            PrologCompilerResults results      = new PrologCompilerResults();

            /* Generate abstract machine instructions */
            GenerateCodeFromUnit(e, instructions);


            /* Determine assembly name and type to generate */
            if (options.GenerateExecutable)
            {
                results.CompiledAssembly = GenerateExecutableAssembly(options, instructions);
            }
            else
            {
                results.CompiledAssembly = GenerateDllAssembly(options, instructions, e);
            }
            return(results);
        }
Esempio n. 3
0
        PrologCompilerResults IPrologCompiler.CompileAbstractCodeFromUnit(PrologCompilerParameters p, PrologCodeUnit unit)
        {
            PrologCompilerResults results = new PrologCompilerResults();
            results.AbstractInstructions = new ArrayList();
            GenerateCodeFromUnit(unit, results.AbstractInstructions);

            /* patch predicates */
            //PatchPredicates(results.AbstractInstructions, GetPredicateAddresses(results.AbstractInstructions));

            /* save foreign methods */
            //results.ForeignMethods = GetForeignMethods(unit.Methods);

            /* save namespaces */
            results.Namespaces = unit.Namespaces;

            /* save assembly files */
            results.AssemblyFiles = unit.AssemblyFiles;

            /* return results */
            return results;
        }
        PrologCompilerResults IPrologCompiler.CompileAbstractCodeFromUnit(PrologCompilerParameters p, PrologCodeUnit unit)
        {
            PrologCompilerResults results = new PrologCompilerResults();

            results.AbstractInstructions = new ArrayList();
            GenerateCodeFromUnit(unit, results.AbstractInstructions);

            /* patch predicates */
            //PatchPredicates(results.AbstractInstructions, GetPredicateAddresses(results.AbstractInstructions));

            /* save foreign methods */
            //results.ForeignMethods = GetForeignMethods(unit.Methods);

            /* save namespaces */
            results.Namespaces = unit.Namespaces;

            /* save assembly files */
            results.AssemblyFiles = unit.AssemblyFiles;

            /* return results */
            return(results);
        }
        PrologCompilerResults IPrologCompiler.CompileAbstractCodeFromFile(PrologCompilerParameters p, string fileName)
        {
            PrologCompilerResults results = new PrologCompilerResults();
            PrologCodeParser      parser  = new PrologCodeParser();
            PrologCodeUnit        unit    = new PrologCodeUnit();

            try
            {
                StreamReader reader = new StreamReader(fileName);
                unit = parser.Parse(reader);

                /* Get errors after parsing */
                results.Errors = parser.Errors;
            }
            catch (FileNotFoundException)
            {
                results.Errors.Add(new PrologCompilerError("P0008", "Input file not found.", fileName, false, 0, 0));
                return(results);
            }
            results.AbstractInstructions = new ArrayList();
            GenerateCodeFromUnit(unit, results.AbstractInstructions);

            /* patch predicates */
            //PatchPredicates(results.AbstractInstructions, GetPredicateAddresses(results.AbstractInstructions));

            /* Save foreign methods */
            //results.ForeignMethods = GetForeignMethods(unit.Methods);

            /* save namespaces */
            results.Namespaces = unit.Namespaces;

            /* save assembly files */
            results.AssemblyFiles = unit.AssemblyFiles;

            /* return results */
            return(results);
        }
Esempio n. 6
0
        PrologCompilerResults IPrologCompiler.CompileAbstractCodeFromFile(PrologCompilerParameters p, string fileName)
        {
            PrologCompilerResults results = new PrologCompilerResults();
            PrologCodeParser parser = new PrologCodeParser();
            PrologCodeUnit unit = new PrologCodeUnit();
            try
            {
                StreamReader reader = new StreamReader(fileName);
                unit = parser.Parse(reader);

                /* Get errors after parsing */
                results.Errors = parser.Errors;
            }
            catch (FileNotFoundException)
            {
                results.Errors.Add(new PrologCompilerError("P0008", "Input file not found.", fileName, false, 0, 0));
                return results;
            }
            results.AbstractInstructions = new ArrayList();
            GenerateCodeFromUnit(unit, results.AbstractInstructions);

            /* patch predicates */
            //PatchPredicates(results.AbstractInstructions, GetPredicateAddresses(results.AbstractInstructions));

            /* Save foreign methods */
            //results.ForeignMethods = GetForeignMethods(unit.Methods);

            /* save namespaces */
            results.Namespaces = unit.Namespaces;

            /* save assembly files */
            results.AssemblyFiles = unit.AssemblyFiles;

            /* return results */
            return results;
        }
Esempio n. 7
0
        protected virtual PrologCompilerResults FromUnit(PrologCompilerParameters options, PrologCodeUnit e)
        {
            ArrayList instructions = new ArrayList();
            PrologCompilerResults results = new PrologCompilerResults();

            /* Generate abstract machine instructions */
            GenerateCodeFromUnit(e, instructions);

            /* Determine assembly name and type to generate */
            if (options.GenerateExecutable)
            {
                results.CompiledAssembly = GenerateExecutableAssembly(options, instructions);

            }
            else
            {
               results.CompiledAssembly = GenerateDllAssembly(options, instructions, e);
            }
            return results;
        }
Esempio n. 8
0
 protected virtual PrologCompilerResults FromFile(PrologCompilerParameters options, string fileName)
 {
     PrologCompilerResults results = new PrologCompilerResults();
     PrologCodeParser parser = new PrologCodeParser();
     PrologCodeUnit unit = new PrologCodeUnit();
     try
     {
         StreamReader reader = new StreamReader(fileName);
         unit = parser.Parse(reader);
     }
     catch (FileNotFoundException)
     {
         results.Errors.Add(new PrologCompilerError("P0008", "Input file not found.", fileName, false, 0, 0));
         return results;
     }
     return FromUnit(options, unit);
 }