Ejemplo n.º 1
0
        public bool Compile(CompilationPass pass, ICompiler compiler, CompileToolContext context)
        {
            var sourceRefs = new SourceReference[] { this._sourceRef };
            var project = (IProjectScope)Parent;

            switch (pass)
            {
                case CompilationPass.Pass1RegisterIdentifiers:
                    IIdentifierScope scope;
                    var existingDef = project.Find(this._labelIdentifier, out scope);
                    if (existingDef != null && scope == project)
                    {
                        context.AddMessage(new BinaryCompileMessage { Filename = this._filename, Line = 0, Message = "Identifier already exists in this scope", MessageLevel = Level.Error });
                        return false;
                    }
                    this._labelInstruction = new LabelInstruction(sourceRefs);
                    project.Add(new BinaryFileLabel(this._labelIdentifier, this._labelInstruction, this._sourceRef));
                    break;

                case CompilationPass.Pass3GenerateCode:
                    compiler.AddInstruction(this._labelInstruction, context);
                    compiler.AddInstruction(new BinaryFileDataInstruction(this._filename, sourceRefs), context);
                    break;
            }

            return true;
        }
Ejemplo n.º 2
0
 public int GetSize(CompileToolContext context)
 {
     return this._label.GetSize(context);
 }
Ejemplo n.º 3
0
 public ISourceFileScope CreateFileScope(IFile file, IProjectScope projectScope, CompileToolContext context)
 {
     return this._asmProvider.CreateFileScope(file, projectScope, context);
 }
Ejemplo n.º 4
0
 public ISourceFileScope CreateFileScope(IFile file, IProjectScope projectScope, CompileToolContext context)
 {
     return new FileScope(file.AbsolutePath, projectScope);
 }
Ejemplo n.º 5
0
        public ISourceFileScope CreateFileScope(IFile file, IProjectScope projectScope, CompileToolContext context)
        {
            var identifier = file.GetProperty("Identifier");
            if (string.IsNullOrEmpty(identifier))
            {
                context.AddMessage(new BinaryCompileMessage { Filename = file.AbsolutePath, Line = 0, Message = "No identifier was specified for the file", MessageLevel = Level.Error});
                return null;
            }

            return new BinaryFileScope(projectScope, identifier, file.AbsolutePath);
        }
 public override ushort[] GetWords(CompileToolContext context)
 {
     var wordArr = ReadBytes().ToArray();
     if (wordArr.Length != GetSize(context)) throw new ApplicationException("Word count mismatch");
     return wordArr;
 }
 public override int GetSize(CompileToolContext context)
 {
     return (int)(new FileInfo(this._filename).Length + 1) / 2;
 }
 public override IEnumerable<int> GetRelocatableWordIndices(CompileToolContext context)
 {
     return new int[] { };
 }