mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-11-27 04:49:27 +00:00
Fixed duplicate file info comments.
This commit is contained in:
parent
0e59591d6c
commit
031e9e6423
@ -252,7 +252,9 @@ public class AsmProgram {
|
||||
// Current indent - used during printing
|
||||
private String indent;
|
||||
// The current value of code info. Set/get during printing to avoid duplicate source code info comment lines.
|
||||
private String currentCode;
|
||||
private String currentCodeInfo;
|
||||
// The current value of file info. Set/get during printing to avoid duplicate source code info comment lines.
|
||||
private String currentFileInfo;
|
||||
|
||||
public AsmPrintState(boolean sourceFileInfo, boolean sourceCodeInfo, boolean sourceIclInfo, boolean asmLineNumber) {
|
||||
this.sourceFileInfo = sourceFileInfo;
|
||||
@ -324,12 +326,20 @@ public class AsmProgram {
|
||||
return asmLineNumber;
|
||||
}
|
||||
|
||||
public String getCurrentCode() {
|
||||
return currentCode;
|
||||
public String getCurrentCodeInfo() {
|
||||
return currentCodeInfo;
|
||||
}
|
||||
|
||||
public void setCurrentCode(String currentCode) {
|
||||
this.currentCode = currentCode;
|
||||
public void setCurrentCodeInfo(String currentCodeInfo) {
|
||||
this.currentCodeInfo = currentCodeInfo;
|
||||
}
|
||||
|
||||
public String getCurrentFileInfo() {
|
||||
return currentFileInfo;
|
||||
}
|
||||
|
||||
public void setCurrentFileInfo(String currentFileInfo) {
|
||||
this.currentFileInfo = currentFileInfo;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -206,13 +206,18 @@ public class AsmSegment {
|
||||
StatementSource source = statement.getSource();
|
||||
if(source != null) {
|
||||
if(source.getFile() != null || source.getLineNumber() != null) {
|
||||
out.append(printState.getIndent()).append(" // ");
|
||||
String fileInfo = "";
|
||||
if(source.getFile() != null)
|
||||
out.append(source.getFile());
|
||||
out.append(":");
|
||||
fileInfo += source.getFile();
|
||||
fileInfo += ":";
|
||||
if(source.getLineNumber() != null)
|
||||
out.append(source.getLineNumber());
|
||||
out.append("\n");
|
||||
fileInfo += source.getLineNumber();
|
||||
if(!fileInfo.equals(printState.getCurrentFileInfo())) {
|
||||
out.append(printState.getIndent()).append(" // ").append(fileInfo).append("\n");
|
||||
printState.setCurrentFileInfo(fileInfo);
|
||||
}
|
||||
} else {
|
||||
printState.setCurrentFileInfo(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -225,15 +230,15 @@ public class AsmSegment {
|
||||
StatementSource source = statement.getSource();
|
||||
if(source != null) {
|
||||
if(source.getCode() != null) {
|
||||
if(!source.getCode().equals(printState.getCurrentCode())) {
|
||||
printState.setCurrentCode(source.getCode());
|
||||
if(!source.getCode().equals(printState.getCurrentCodeInfo())) {
|
||||
printState.setCurrentCodeInfo(source.getCode());
|
||||
out.append(printState.getIndent()).append(" // ");
|
||||
if(source.getCode() != null)
|
||||
out.append(source.getCode().replace("\n", "\n" + printState.getIndent() + " // "));
|
||||
out.append("\n");
|
||||
}
|
||||
} else {
|
||||
printState.setCurrentCode(null);
|
||||
printState.setCurrentCodeInfo(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user