diff --git a/src/rars/ErrorMessage.java b/src/rars/ErrorMessage.java index ef019e23..ddba6901 100644 --- a/src/rars/ErrorMessage.java +++ b/src/rars/ErrorMessage.java @@ -114,8 +114,7 @@ public ErrorMessage(boolean isWarning, RISCVprogram sourceProgram, int line, int // Added January 2013 public ErrorMessage(ProgramStatement statement, String message) { this.isWarning = ERROR; - this.filename = (statement.getSourceProgram() == null) - ? "" : statement.getSourceProgram().getFilename(); + this.filename = statement.getSourceFile(); this.position = 0; this.message = message; // Somewhere along the way we lose the macro history, but can @@ -243,4 +242,4 @@ private static String getExpansionHistory(RISCVprogram sourceProgram) { return sourceProgram.getLocalMacroPool().getExpansionHistory(); } -} // ErrorMessage \ No newline at end of file +} // ErrorMessage diff --git a/src/rars/ProgramStatement.java b/src/rars/ProgramStatement.java index 1499dff3..6de7acde 100644 --- a/src/rars/ProgramStatement.java +++ b/src/rars/ProgramStatement.java @@ -63,6 +63,7 @@ public class ProgramStatement implements Comparable { private int numOperands; private Instruction instruction; private int textAddress; + private String sourceFilename; private int sourceLine; private int binaryStatement; private boolean altered; @@ -83,7 +84,7 @@ public class ProgramStatement implements Comparable { * is stored. **/ public ProgramStatement(RISCVprogram sourceProgram, String source, TokenList origTokenList, TokenList strippedTokenList, - Instruction inst, int textAddress, int sourceLine) { + Instruction inst, int textAddress, String filename, int sourceLine) { this.sourceProgram = sourceProgram; this.source = source; this.originalTokenList = origTokenList; @@ -92,6 +93,7 @@ public ProgramStatement(RISCVprogram sourceProgram, String source, TokenList ori this.numOperands = 0; this.instruction = inst; this.textAddress = textAddress; + this.sourceFilename = filename; this.sourceLine = sourceLine; this.basicAssemblyStatement = null; this.basicStatementList = new BasicStatementList(); @@ -533,7 +535,7 @@ public RISCVprogram getSourceProgram() { * @return The file name. **/ public String getSourceFile() { - return (sourceProgram == null) ? "" : sourceProgram.getFilename(); + return sourceFilename; } diff --git a/src/rars/assembler/Assembler.java b/src/rars/assembler/Assembler.java index e4dc2164..fb648172 100644 --- a/src/rars/assembler/Assembler.java +++ b/src/rars/assembler/Assembler.java @@ -262,7 +262,7 @@ public ArrayList assemble(ArrayList tokenizedPro ProgramStatement ps = new ProgramStatement( this.fileCurrentlyBeingAssembled, (instrNumber == 0) ? statement.getSource() : "", newTokenList, - newTokenList, instr, textAddress.get(), statement.getSourceLine()); + newTokenList, instr, textAddress.get(), statement.getSourceFile(), statement.getSourceLine()); textAddress.increment(Instruction.INSTRUCTION_LENGTH); ps.buildBasicStatementFromBasicInstruction(errors); machineList.add(ps); @@ -488,8 +488,9 @@ private ArrayList parseLine(TokenList tokenList, String source "Extended (pseudo) instruction or format not permitted. See Settings.")); } if (OperandFormat.tokenOperandMatch(tokens, inst, errors)) { - programStatement = new ProgramStatement(this.fileCurrentlyBeingAssembled, source, - tokenList, tokens, inst, textAddress.get(), sourceLineNumber); + programStatement = new ProgramStatement(this.fileCurrentlyBeingAssembled, + source, + tokenList, tokens, inst, textAddress.get(), token.getOriginalProgram().getFilename(), sourceLineNumber); // instruction length is 4 for all basic instruction, varies for extended instruction // Modified to permit use of compact expansion if address fits // in 15 bits. DPS 4-Aug-2009 diff --git a/src/rars/assembler/SourceLine.java b/src/rars/assembler/SourceLine.java index a0fdcf47..fa19d5c7 100644 --- a/src/rars/assembler/SourceLine.java +++ b/src/rars/assembler/SourceLine.java @@ -97,4 +97,4 @@ public int getLineNumber() { public RISCVprogram getRISCVprogram() { return program; } -} \ No newline at end of file +}