Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix file name information for .included code. #161

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/rars/ErrorMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -243,4 +242,4 @@ private static String getExpansionHistory(RISCVprogram sourceProgram) {
return sourceProgram.getLocalMacroPool().getExpansionHistory();
}

} // ErrorMessage
} // ErrorMessage
6 changes: 4 additions & 2 deletions src/rars/ProgramStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public class ProgramStatement implements Comparable<ProgramStatement> {
private int numOperands;
private Instruction instruction;
private int textAddress;
private String sourceFilename;
private int sourceLine;
private int binaryStatement;
private boolean altered;
Expand All @@ -83,7 +84,7 @@ public class ProgramStatement implements Comparable<ProgramStatement> {
* 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;
Expand All @@ -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();
Expand Down Expand Up @@ -533,7 +535,7 @@ public RISCVprogram getSourceProgram() {
* @return The file name.
**/
public String getSourceFile() {
return (sourceProgram == null) ? "" : sourceProgram.getFilename();
return sourceFilename;
}


Expand Down
7 changes: 4 additions & 3 deletions src/rars/assembler/Assembler.java
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public ArrayList<ProgramStatement> assemble(ArrayList<RISCVprogram> 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);
Expand Down Expand Up @@ -488,8 +488,9 @@ private ArrayList<ProgramStatement> 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
Expand Down
2 changes: 1 addition & 1 deletion src/rars/assembler/SourceLine.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,4 @@ public int getLineNumber() {
public RISCVprogram getRISCVprogram() {
return program;
}
}
}