Example #1
0
        public Assembler(string asmName, string asm, IFileSystem fileLoader)
        {
            originalSource  = asm;
            this.fileLoader = fileLoader;

            // Note that order of instantiation matters here, as some object depend on others in slightly stupid ways that can be fixed in needed to avoid circular issues with instantiation
            parser      = new Parser(this);
            LineManager = new LineManager(asmName);
            assembly    = new AssemblyData(this);
            evaluator   = new ExpressionEvaluator(Values);
        }
Example #2
0
        public Assembler(string asmName, Stream asmFile, IFileSystem fileLoader)
        {
            // Read file (as UTF-8) to string
            StreamReader reader = new StreamReader(asmFile, Encoding.UTF8, true);
            string       asm    = reader.ReadToEnd();

            originalSource  = asm;
            this.fileLoader = fileLoader;

            // Note that order of instantiation matters here, as some object depend on others in slightly stupid ways that can be fixed in needed to avoid circular issues with instantiation
            parser      = new Parser(this);
            LineManager = new LineManager(asmName);
            assembly    = new AssemblyData(this);
            evaluator   = new ExpressionEvaluator(Values);
        }
Example #3
0
        /// <summary>
        /// Parses code from a list of sub-strings. (Useful if the code
        /// is in the form of a single long string.)
        /// </summary>
        /// <param name="lines"></param>
        public void ParseCode(IList <StringSection> lines)
        {
            assembly = Assembler.Assembly;

            Error error;

            for (int i = 0; i < lines.Count; i++)
            {
                ParseLine(lines[i], i, out error);

                if (error.Code != ErrorCode.None)
                {
                    Assembler.AddError(error);
                }
            }
        }