visicalc bug

This commit is contained in:
Denis Molony 2016-07-20 20:35:13 +10:00
parent bff1e8de2d
commit d84b4c4528
4 changed files with 24 additions and 19 deletions

View File

@ -15,9 +15,9 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
class CodeManager extends AbstractFile class CodeManager extends AbstractFile
{ {
Header header; private final Header header;
int codeSize; private int codeSize;
Map<Integer, Routine> routines = new TreeMap<Integer, Routine> (); private final Map<Integer, Routine> routines = new TreeMap<Integer, Routine> ();
public CodeManager (Header header) public CodeManager (Header header)
{ {
@ -60,7 +60,7 @@ class CodeManager extends AbstractFile
return blocks; return blocks;
} }
public void addMissingRoutines () void addMissingRoutines ()
{ {
System.out.printf ("%nWalking the code block%n%n"); System.out.printf ("%nWalking the code block%n%n");
int total = 0; int total = 0;
@ -125,12 +125,12 @@ class CodeManager extends AbstractFile
return text.toString (); return text.toString ();
} }
public boolean containsRoutineAt (int address) boolean containsRoutineAt (int address)
{ {
return (routines.containsKey (address)); return (routines.containsKey (address));
} }
public void addCodeRoutines () void addCodeRoutines ()
{ {
List<Integer> routines = header.objectManager.getCodeRoutines (); List<Integer> routines = header.objectManager.getCodeRoutines ();
System.out.println ("Adding " + routines.size () + " code routines"); System.out.println ("Adding " + routines.size () + " code routines");
@ -138,7 +138,7 @@ class CodeManager extends AbstractFile
addRoutine (address, 0); addRoutine (address, 0);
} }
public void addActionRoutines () void addActionRoutines ()
{ {
List<Integer> routines = header.grammar.getActionRoutines (); List<Integer> routines = header.grammar.getActionRoutines ();
System.out.println ("Adding " + routines.size () + " action routines"); System.out.println ("Adding " + routines.size () + " action routines");
@ -146,7 +146,7 @@ class CodeManager extends AbstractFile
addRoutine (address, 0); addRoutine (address, 0);
} }
public Routine addRoutine (int address, int caller) Routine addRoutine (int address, int caller)
{ {
if (address == 0) // stack-based call if (address == 0) // stack-based call
return null; return null;
@ -174,7 +174,7 @@ class CodeManager extends AbstractFile
return r; return r;
} }
public Routine getRoutine (int address) Routine getRoutine (int address)
{ {
return routines.get (address); return routines.get (address);
} }

View File

@ -22,13 +22,13 @@ class Header extends InfocomAbstractFile
int checksum; int checksum;
int stringPointer; int stringPointer;
Abbreviations abbreviations; final Abbreviations abbreviations;
Dictionary dictionary; final Dictionary dictionary;
ObjectManager objectManager; final ObjectManager objectManager;
StringManager stringManager; final StringManager stringManager;
CodeManager codeManager; final CodeManager codeManager;
Globals globals; final Globals globals;
Grammar grammar; final Grammar grammar;
public Header (String name, byte[] buffer, Disk disk) public Header (String name, byte[] buffer, Disk disk)
{ {

View File

@ -195,7 +195,7 @@ class Cell implements Comparable<Cell>, Value
@Override @Override
public boolean isError () public boolean isError ()
{ {
assert isValue () : "Cell type: " + type; // assert isValue () : "Cell type: " + type;
return value.isError (); return value.isError ();
} }
@ -211,7 +211,12 @@ class Cell implements Comparable<Cell>, Value
@Override @Override
public Value calculate () public Value calculate ()
{ {
assert type == CellType.VALUE; if (!isValue ())
{
System.out.println ("Not a value");
return this;
}
assert isValue () : "Cell type: " + type + " @ " + address;
if (expressionText == null) if (expressionText == null)
{ {
System.out.printf ("%s null expression text %n", address); System.out.printf ("%s null expression text %n", address);

View File

@ -124,7 +124,7 @@ class Expression implements Value
@Override @Override
public Value calculate () public Value calculate ()
{ {
// System.out.printf ("Calculating: %s%n", text); System.out.printf ("Calculating: %s%n", text);
// if (text.equals ("@NA")) // if (text.equals ("@NA"))
// Utility.printStackTrace (); // Utility.printStackTrace ();