mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2025-02-27 03:29:26 +00:00
tidying
This commit is contained in:
parent
8f019f7e8c
commit
14888c22e8
@ -255,20 +255,22 @@ public class ApplesoftBasicProgram extends BasicProgram
|
|||||||
programLoadAddress + ptr));
|
programLoadAddress + ptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (basicPreferences.showXref)
|
if (basicPreferences.showXref && !gosubLines.isEmpty ())
|
||||||
{
|
{
|
||||||
if (fullText.charAt (fullText.length () - 2) != '\n')
|
if (fullText.charAt (fullText.length () - 2) != '\n')
|
||||||
fullText.append ("\n");
|
fullText.append ("\n");
|
||||||
fullText.append ("Subroutine:\n");
|
fullText.append ("Subroutine:\n");
|
||||||
for (Integer line : gosubLines.keySet ())
|
for (Integer line : gosubLines.keySet ())
|
||||||
{
|
|
||||||
fullText.append (String.format (" %5s %s%n", line, gosubLines.get (line)));
|
fullText.append (String.format (" %5s %s%n", line, gosubLines.get (line)));
|
||||||
}
|
}
|
||||||
fullText.append ("\nGoTo:\n");
|
|
||||||
|
if (basicPreferences.showXref && !gotoLines.isEmpty ())
|
||||||
|
{
|
||||||
|
if (fullText.charAt (fullText.length () - 2) != '\n')
|
||||||
|
fullText.append ("\n");
|
||||||
|
fullText.append ("GoTo:\n");
|
||||||
for (Integer line : gotoLines.keySet ())
|
for (Integer line : gotoLines.keySet ())
|
||||||
{
|
|
||||||
fullText.append (String.format (" %5s %s%n", line, gotoLines.get (line)));
|
fullText.append (String.format (" %5s %s%n", line, gotoLines.get (line)));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fullText.length () > 0)
|
if (fullText.length () > 0)
|
||||||
@ -703,53 +705,12 @@ public class ApplesoftBasicProgram extends BasicProgram
|
|||||||
|
|
||||||
case TOKEN_GOTO:
|
case TOKEN_GOTO:
|
||||||
String target = new String (buffer, startPtr + 1, length - 2);
|
String target = new String (buffer, startPtr + 1, length - 2);
|
||||||
try
|
addXref (target, gotoLines);
|
||||||
{
|
|
||||||
int targetLine = Integer.parseInt (target);
|
|
||||||
// gotoLines.add (Integer.parseInt (target));
|
|
||||||
if (gotoLines.containsKey (targetLine))
|
|
||||||
{
|
|
||||||
List<Integer> lines = gotoLines.get (targetLine);
|
|
||||||
lines.add (parent.lineNumber);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
List<Integer> lines = new ArrayList<> ();
|
|
||||||
lines.add (parent.lineNumber);
|
|
||||||
gotoLines.put (targetLine, lines);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (NumberFormatException e)
|
|
||||||
{
|
|
||||||
System.out.println (
|
|
||||||
"Error parsing : GOTO " + target + " in " + parent.lineNumber);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TOKEN_GOSUB:
|
case TOKEN_GOSUB:
|
||||||
target = new String (buffer, startPtr + 1, length - 2);
|
target = new String (buffer, startPtr + 1, length - 2);
|
||||||
try
|
addXref (target, gosubLines);
|
||||||
{
|
|
||||||
int targetLine = Integer.parseInt (target);
|
|
||||||
// gosubLines.add (Integer.parseInt (target));
|
|
||||||
if (gosubLines.containsKey (targetLine))
|
|
||||||
{
|
|
||||||
List<Integer> lines = gosubLines.get (targetLine);
|
|
||||||
lines.add (parent.lineNumber);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
List<Integer> lines = new ArrayList<> ();
|
|
||||||
lines.add (parent.lineNumber);
|
|
||||||
gosubLines.put (targetLine, lines);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (NumberFormatException e)
|
|
||||||
{
|
|
||||||
System.out.println (HexFormatter.format (buffer, startPtr + 1, length - 2));
|
|
||||||
System.out.println (
|
|
||||||
"Error parsing : GOSUB " + target + " in " + parent.lineNumber);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -758,37 +719,39 @@ public class ApplesoftBasicProgram extends BasicProgram
|
|||||||
if (isDigit (b)) // numeric, so must be a line number
|
if (isDigit (b)) // numeric, so must be a line number
|
||||||
{
|
{
|
||||||
String target = new String (buffer, startPtr, length - 1);
|
String target = new String (buffer, startPtr, length - 1);
|
||||||
try
|
addXref (target, gotoLines);
|
||||||
{
|
|
||||||
targetLine = Integer.parseInt (target);
|
|
||||||
// gotoLines.add (targetLine);
|
|
||||||
if (gotoLines.containsKey (targetLine))
|
|
||||||
{
|
|
||||||
List<Integer> lines = gotoLines.get (targetLine);
|
|
||||||
lines.add (parent.lineNumber);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
List<Integer> lines = new ArrayList<> ();
|
|
||||||
lines.add (parent.lineNumber);
|
|
||||||
gotoLines.put (targetLine, lines);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (NumberFormatException e)
|
|
||||||
{
|
|
||||||
System.out.printf ("b: %d, start: %d, length: %d%n", b, startPtr,
|
|
||||||
(length - 1));
|
|
||||||
System.out.println (target);
|
|
||||||
System.out.println (HexFormatter.format (buffer, startPtr, length - 1));
|
|
||||||
System.out.println (e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// else if (basicPreferences.alignAssign)
|
|
||||||
else
|
else
|
||||||
recordEqualsPosition ();
|
recordEqualsPosition ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addXref (String target, Map<Integer, List<Integer>> map)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
targetLine = Integer.parseInt (target);
|
||||||
|
if (map.containsKey (targetLine))
|
||||||
|
{
|
||||||
|
List<Integer> lines = map.get (targetLine);
|
||||||
|
lines.add (parent.lineNumber);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
List<Integer> lines = new ArrayList<> ();
|
||||||
|
lines.add (parent.lineNumber);
|
||||||
|
map.put (targetLine, lines);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (NumberFormatException e)
|
||||||
|
{
|
||||||
|
// System.out.printf ("b: %d, start: %d, length: %d%n", b, startPtr, (length - 1));
|
||||||
|
System.out.println (target);
|
||||||
|
System.out.println (HexFormatter.format (buffer, startPtr, length - 1));
|
||||||
|
System.out.println (e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isImpliedGoto ()
|
private boolean isImpliedGoto ()
|
||||||
{
|
{
|
||||||
byte b = buffer[startPtr];
|
byte b = buffer[startPtr];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user