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; }
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); }