Commit efc5e2b6 authored by atzedijkstra@gmail.com's avatar atzedijkstra@gmail.com
Browse files

initial

parents
package nl.uu.cs.ssmui; import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.table.*;import javax.swing.event.*; import java.util.* ; import nl.uu.cs.ssm.* ; public class CodeTableModel extends AbstractTableModel implements MemoryCellListener, CodeRowSupplier{ protected static final int C_LABEL = 0 ; protected static final int C_ADDRESS = 1 ; protected static final int C_PC = 2 ; protected static final int C_BP = 3 ; protected static final int C_VALUE = 4 ; protected static final int C_INSTR = 5 ; protected static final int C_ARG1 = 6 ; protected static final int C_ARG2 = 7 ; private static final String[] columnNames = { "Label", "Address", "PC", "BP", "Value", "Instr", "Arg1", "Arg2" } ; private SSMRunner ssmRunner ; private MachineState machineState ; private Memory memory ; private Registers registers ; private Labels labels ; private int lastPCRow ; private BoundedRangeModel verticalScrollBarModel ; private class Row { int memLoc ; Instruction cachedInstr ; boolean hasBreakPoint = false ; String labelName ; String usedLabelName ; Vector metaInstructions ; Row( Instruction i, int loc, String l ) { cachedInstr = i ; memLoc = loc ; memory.reserveAt( loc, cachedInstr.getNrMemCells() ) ; memory.setAt( loc, cachedInstr.getCode() ) ; labelName = l ; usedLabelName = null ; metaInstructions = null ; } Row( String i, int loc, String l ) { this( Instruction.findByRepr( i ), loc, l ) ; } String getInstrRepr( int memLoc ) { //System.out.println( "row mem at " + memLoc ) ; if ( usedLabelName == null ) return cachedInstr.getRepr( memory.getAt( memLoc+1, cachedInstr.getNrInlineOpnds() ) ) ; else return cachedInstr.getRepr( usedLabelName ) ; } boolean replaceInstr( int row, Instruction instr ) { int shiftUp = instr.getNrMemCells() - getNrMemCells() ; memory.shiftAt( memLoc, shiftUp ) ; shiftMemLocations( row+1, shiftUp ) ; memory.setAt( memLoc, instr.getCode() ) ; cachedInstr = instr ; return shiftUp != 0 ; } int getNrMemCells() { return cachedInstr.getNrMemCells() ; } int getNrInlineOpnds() { return cachedInstr.getNrInlineOpnds() ; } void addMetaInstruction( MetaInstruction mi ) { if ( metaInstructions == null ) metaInstructions = new Vector() ; if ( mi != null ) metaInstructions.addElement( mi ) ; } void setUsedLabel( String l ) { usedLabelName = l ; } } private Vector rows ; private Row getRowAt( int row ) { return (Row)rows.elementAt( row ) ; } private boolean isValidRow( int row ) { return row >= 0 && row < getRowCount() ; } private int memLocOfRow( int row, boolean before ) { Row r = getRowAt( row ) ; return r.memLoc + ( before ? 0 : r.getNrMemCells() ) ; } public int memLocOfRow( int row ) { return memLocOfRow( row, true ) ; } private int rowOfMemLoc( int loc ) { int row ; int max = getRowCount() ; for ( row = 0 ; row < max ; row++ ) { Row r = getRowAt( row ) ; if ( ( loc >= r.memLoc ) && ( loc < ( r.memLoc + r.getNrMemCells() ) ) ) return row ; } return -1 ; } protected boolean hasBreakpointAtPC() { boolean res = false ; int memLoc = registers.getReg( registers.PC ) ; int row = rowOfMemLoc( memLoc ) ; if ( isValidRow( row ) ) { Row r = getRowAt( row ) ; res = r.hasBreakPoint ; } return res ; } private void shiftMemLocations( int row, int shift ) { if ( shift != 0 ) { int max = getRowCount() ; for ( int i = row ; i < max ; i++ ) { Row r = getRowAt( i ) ; r.memLoc += shift ; } } } public void insertNewInstrAt( int row, boolean doBefore ) { Row r = new Row( "nop", memLocOfRow( row, doBefore ), null ) ; int insertRow = row + (doBefore ? 0 : 1) ; shiftMemLocations( insertRow, r.getNrMemCells() ) ; rows.insertElementAt( r, insertRow ) ; fireTableRowsInserted( insertRow, insertRow ) ; //fireTableChanged( new TableModelEvent( this, insertRow, insertRow, TableModelEvent.ALL_COLUMNS, TableModelEvent.INSERT) ) ; fireTableRowsUpdated( insertRow+1, getRowCount()-1 ) ; //fireTableChanged( new TableModelEvent( this, insertRow+1, getRowCount()-1 ) ) ; } public void beforeReset() { if ( memory != null ) memory.removeMemoryCellListener( this ) ; if ( registers != null ) registers.removeMemoryCellListener( this ) ; } public void reset() { int oldRowCount = rows == null ? 0 : getRowCount() ; labels.reset( registers.getRegNAliasNames() ) ; rows = new Vector() ; memory = machineState.getMemory() ; registers = machineState.getRegisters() ; memory.addMemoryCellListener( this ) ; registers.addMemoryCellListener( this ) ; rows.addElement( new Row( "halt", 0, null ) ) ; lastPCRow = 0 ; fireTableChanged( new TableModelEvent( this ) ) ; //fireTableStructureChanged() ; } public CodeTableModel( SSMRunner sr, MachineState mst ) { ssmRunner = sr ; machineState = mst ; labels = new Labels( this ) ; reset() ; } protected void setPCNBWidths( JTable jt ) { TableColumn tc ; int w = Images.white.getIconWidth() ; tc = jt.getColumn( getColumnName( C_PC ) ) ; tc.setPreferredWidth( 3*w/2 ) ; tc.setMaxWidth( 2*w ) ; tc = jt.getColumn( getColumnName( C_BP ) ) ; tc.setPreferredWidth( 3*w/2 ) ; tc.setMaxWidth( 2*w ) ; } protected void setScrollBarModel( BoundedRangeModel m ) { verticalScrollBarModel = m ; } public int getColumnCount() { return columnNames.length ; } public int getRowCount() { return rows.size() ; } public Vector getMetaInstructionsAtPC() { int row = rowOfMemLoc( registers.getPC() ) ; return isValidRow( row ) ? getRowAt( row ).metaInstructions : null ; } public boolean isCellEditable( int row, int column ) { boolean res ; Row r = (Row)rows.elementAt( row ) ; res = ( column == C_VALUE ) || ( column == C_INSTR ) || ( column == C_ARG1 && r.getNrInlineOpnds() > 0 ) || ( column == C_ARG2 && r.getNrInlineOpnds() > 1 ) ; return res ; } public Object getValueAt( int row, int column ) { Object res ; Row r = (Row)rows.elementAt( row ) ; if ( column == C_PC ) { res = (r.memLoc == registers.getPC()) ? Images.redball : Images.white ; } else if ( column == C_BP ) { res = r.hasBreakPoint ? Images.check : Images.white ; } else { if ( column == C_VALUE ) { res = memory.getAsHexAt( r.memLoc ) ; } else if ( column == C_LABEL && r.labelName != null ) { res = r.labelName ; } else if ( column == C_ADDRESS ) { res = Utils.asHex( r.memLoc ) ; } else if ( column == C_INSTR ) { res = r.getInstrRepr( r.memLoc ) ; } else if ( column == C_ARG1 && r.getNrInlineOpnds() > 0 ) { res = memory.getAsHexAt( r.memLoc+1 ) ; } else if ( column == C_ARG2 && r.getNrInlineOpnds() > 1 ) { res = memory.getAsHexAt( r.memLoc+2 ) ; } else res = "" ; } return res ; } public void setValueAt( Object aValue, int row, int column ) { boolean onlyThisRowChanged = true ; Row r = (Row)rows.elementAt( row ) ; String strValue ; if ( aValue instanceof String ) strValue = (String)aValue ; else strValue = aValue.toString() ; if ( column == C_VALUE ) { Instruction instr = Instruction.findByCode( Utils.fromHex( strValue ) ) ; if ( instr != null ) { onlyThisRowChanged = ! r.replaceInstr( row, instr ) ; } } else if ( column == C_ADDRESS ) { } else if ( column == C_INSTR ) { Instruction instr = Instruction.findByRepr( strValue ) ; if ( instr != null ) { onlyThisRowChanged = ! r.replaceInstr( row, instr ) ; } } else if ( column == C_ARG1 ) { memory.setAt( r.memLoc + 1, strValue ) ; } else if ( column == C_ARG2 ) { memory.setAt( r.memLoc + 2, strValue ) ; } if ( ! onlyThisRowChanged ) fireTableRowsUpdated( row+1, getRowCount()-1 ) ; } public void setInstrArgAt( int row, int argOffset, int val ) { Row r = (Row)rows.elementAt( row ) ; memory.setAt( r.memLoc + argOffset, val ) ; } public String getColumnName( int column ) { return columnNames[ column ] ; } public Class getColumnClass( int column ) { if ( column == C_PC || column == C_BP ) return ImageIcon.class ; else return SSMRunner.tableModelColumnClass ; } public void cellChanged( MemoryCellEvent e ) { Object src = e.getSource() ; //System.out.println( "memcell evt=" + e + " row=" + row ) ; if ( src == memory && e.event == e.CELL ) { int row = rowOfMemLoc( e.cellIndex ) ; if ( row >= 0 ) { //fireTableChanged( new TableModelEvent( this, row ) ) ; fireTableRowsUpdated( row, row ) ; if ( ! ssmRunner.isSettingUp() ) ssmRunner.println( "Warning: code modified at " + Utils.asHex( e.cellIndex ) ) ; } } else if ( src == registers && e.event == e.CELL ) { if ( e.cellIndex == registers.PC ) { int row = rowOfMemLoc( registers.getReg( registers.PC ) ) ; if ( isValidRow( lastPCRow ) ) //fireTableChanged( new TableModelEvent( this, lastPCRow, lastPCRow, C_PC ) ) ; fireTableCellUpdated( lastPCRow, C_PC ) ; lastPCRow = row ; if ( isValidRow( row ) ) { fireTableCellUpdated( row, C_PC ) ; //System.out.println( "scroll row " + row + " bar=" + verticalScrollBarModel ) ; try { int rowRange = getRowCount() ; int barRange = verticalScrollBarModel.getMaximum() - verticalScrollBarModel.getMinimum() ; int barToRowRatio = barRange / rowRange ; int barValue = verticalScrollBarModel.getValue() ; int barExtent = verticalScrollBarModel.getExtent() ; if ( row < ( barValue / barToRowRatio ) || row >= ( (barValue+barExtent) / barToRowRatio ) ) { int prefBarValue = row * barToRowRatio - barExtent / 2 ; int newBarValue = Math.max( 0, Math.min( prefBarValue, barRange - barExtent ) ) ; verticalScrollBarModel.setValue( newBarValue ) ; } } catch ( Exception ex ) { } } } } } public void handleBreakpointMouseEvent( int row, int column ) { if ( column == C_BP ) { Row r = getRowAt( row ) ; r.hasBreakPoint = ! r.hasBreakPoint ; //fireTableChanged( new TableModelEvent( this, row, row, column ) ) ; fireTableCellUpdated( row, column ) ; } } protected void parseInitialize() { } protected String parseFinalize() { Vector v = labels.resolveUnresolved() ; return v.size() == 0 ? null : ("unresolved labels " + v) ; } protected String enterParsedLine( Vector definedLabels, Vector instrNArgs, Vector leftOverLabels ) { Instruction instr = null ; instr = Instruction.findByRepr( ((String)instrNArgs.elementAt(0)).toLowerCase() ) ; if ( instr == null ) { return "unknown instruction: " + instrNArgs ; } else { if ( (instrNArgs.size() - 1) < instr.getNrInlineOpnds() ) return "not enough arguments for " + instr.getRepr() ; int insertionPos = getRowCount() - 1 ; // assuming halt at end if ( instr.isMeta() ) { if ( insertionPos <= 0 ) return "cannot add meta at start of code (currently)" ; Row r = getRowAt( insertionPos-1 ) ; Utils.addAllTo( leftOverLabels, definedLabels.elements() ) ; instrNArgs.removeElementAt( 0 ) ; MetaInstruction m = instr.instantiateMeta( instrNArgs ) ; //System.out.println( "added meta " + m ) ; r.addMetaInstruction( m ) ; } else { insertNewInstrAt( insertionPos, true ) ; Row r = getRowAt( insertionPos ) ; for ( int i = 0 ; i < definedLabels.size() ; i++ ) { r.labelName = (String)definedLabels.elementAt(i) ; labels.defineLabel( r.labelName, insertionPos ) ; } //System.out.println( "code table parse instr " + instr + " vec=" + toks ) ; setValueAt( instr.getRepr(), insertionPos, C_INSTR ) ; //int args[] = new int[ instr.getNrInlineOpnds() ] ; for ( int arg = 0 ; arg < instr.getNrInlineOpnds() ; arg++ ) { String s = (String)instrNArgs.elementAt( arg + 1 ) ; int val ; if ( Utils.isNumberRepr( s, false ) ) { val = Utils.fromHex( s, false ) ; } else { val = labels.useLabel( s, insertionPos, arg+1, instr.getNrMemCells(), instr.isRelativeOpnd(arg) ) ; r.setUsedLabel( s ) ; } memory.setAt( r.memLoc + arg + 1, val ) ; //args[ arg ] = val ; } //setValueAt( instr.getRepr( args ), insertionPos, C_INSTR ) ; } } //System.out.println( "added row=" + insertionPos + " loc=" + r.memLoc + " instr" + instr ) ; return null ; } }
\ No newline at end of file
/* Help.java Title: Simple Stack Machine Runner Author: atze Description: */ package nl.uu.cs.ssmui; //import javax.swing.*; import java.util.* ; import nl.uu.cs.ssm.* ; public class Help { private Vector helpSuppliers ; public Help() { helpSuppliers = new Vector() ; } public void addHelpSupplier( HelpSupplier hs ) { helpSuppliers.addElement( hs ) ; } private static void addSorted( Vector v, HelpTopic ht ) { int max = v.size() ; int i ; for ( i = 0 ; i < max ; i++ ) { if ( ht.toString().toLowerCase().compareTo( v.elementAt(i).toString().toLowerCase() ) < 0 ) break ; } if ( i >= max ) v.addElement( ht ) ; else v.insertElementAt( ht, i ) ; } public Vector findTopics( String key ) { Vector topics = new Vector() ; if ( key != null ) key = key.toLowerCase() ; for ( Enumeration hss = helpSuppliers.elements() ; hss.hasMoreElements() ; ) { HelpSupplier hs = (HelpSupplier)hss.nextElement() ; for ( Enumeration ts = hs.getTopics() ; ts.hasMoreElements() ; ) { String t = (String)ts.nextElement() ; if ( key == null || t.toLowerCase().indexOf( key ) >= 0 ) addSorted( topics, new HelpTopic( hs, t ) ) ; } } return topics ; } }
\ No newline at end of file
/* Runner.java Title: Simple Stack Machine Runner Author: atze Description: */ package nl.uu.cs.ssmui; import nl.uu.cs.ssm.* ; import java.net.* ;import java.util.* ;import java.io.* ; public class HelpFromProp implements HelpSupplier{ private static final char US = '_' ; private static final char SEP = ',' ; private static final char INDIRECT = '@' ; private static final String PROP_DESCR = "descr" ; private static final String PROP_PREPOST = "prepost" ; private static final String PROP_EXAMPLE = "example" ; private boolean doForInstr ; private static Properties getProps( String nm ) { URL url = nm.getClass().getResource( "/Help/" + nm + ".prop" ) ; Properties props = new Properties() ; try { props.load( url.openStream() ) ; } catch( IOException ex ) { } return props ; } private Properties props ; private Vector topics = null ; private HelpSupplier instrHelpSupplier ; protected HelpFromProp( String propnm, HelpSupplier ih, boolean doForInstr ) { this.doForInstr = doForInstr ; props = getProps( propnm ) ; instrHelpSupplier = ih ; } private void checkTopics() { if ( topics == null ) { Hashtable ts = new Hashtable() ; for ( Enumeration ps = props.propertyNames() ; ps.hasMoreElements() ; ) { String s = (String)ps.nextElement() ; if ( doForInstr ) { int i = s.indexOf( US ) ; if ( i > 0 ) s = s.substring( 0, i ) ; } ts.put( s, s ) ; } topics = new Vector( ) ; Utils.addAllTo( topics, ts.elements() ) ; } } public Enumeration getTopics() { checkTopics() ; return topics.elements() ; } public String getHelpSupplierName() { return doForInstr ? "Semantics" : "General" ; } public String getShortSummaryForTopic( String topic ) { return topic + " " + getHelpSupplierName().toLowerCase() ; } private String getTopicProperty( String topicProp ) { String p = props.getProperty( topicProp ) ; if ( p != null && p.length() > 0 && p.charAt(0) == INDIRECT ) { p = getTopicProperty( p.substring(1) ) ; } if ( p == null ) p = "No info" ; return p ; } private String getTopicProperty( String topic, String prop ) { return getTopicProperty( topic + US + prop ) ; } /* private void commasep( String s, HelpAccumulator acc ) { Vector v = Utils.splitAt( s, SEP ) ; if ( v.size() < 1 ) return ; int max = v.size() - 1 ; for ( int i = 0 ; i < max ; i++ ) { acc.append( ((String)v.elementAt(i)).trim() ) ; acc.linebreak() ; } acc.append( ((String)v.elementAt( max )).trim() ) ; } */ private Enumeration splitByComma( String s ) { Vector v = Utils.splitAt( s, SEP ) ; Vector vv = new Vector() ; for ( Enumeration e = v.elements() ; e.hasMoreElements() ; ) vv.addElement( ((String)e.nextElement()).trim() ) ; return vv.elements() ; } public void getHelpForTopic( String topic, HelpAccumulator acc ) { Vector v ; Enumeration e ; if ( doForInstr ) { instrHelpSupplier.getHelpForTopic( topic, acc ) ; acc.linebreak() ; acc.beginAttributeList() ; acc.attributeName( "Description" ) ; acc.beginAttributeValue() ; acc.append( getTopicProperty( topic, PROP_DESCR ) ) ; acc.endAttributeValue() ; acc.attributeName( "Pre and Post State" ) ; acc.beginAttributeValue() ; e = splitByComma( getTopicProperty( topic, PROP_PREPOST) ) ; acc.mathEquationList( e, US ) ; acc.endAttributeValue() ; acc.attributeName( "Example" ) ; acc.beginAttributeValue() ; e = splitByComma( getTopicProperty( topic, PROP_EXAMPLE) ) ; acc.verbatimList( e ) ; acc.endAttributeValue() ; acc.endAttributeList() ; } else { acc.beginBlockQuote() ; acc.append( getTopicProperty( topic ) ) ; acc.endBlockQuote() ; } } }
\ No newline at end of file
/** * Simple Stack Machine * * Written by Atze Dijkstra, atze@cs.uu.nl, * Copyright Utrecht University. * */ package nl.uu.cs.ssmui ; import nl.uu.cs.ssm.* ; public class HelpTopic{ private HelpSupplier helpSupplier ; private String topic ; protected HelpTopic( HelpSupplier hs, String t ) { helpSupplier = hs ; topic = t ; } public void genTitle( HelpAccumulator acc ) { acc.append( helpSupplier.getHelpSupplierName( ) ) ; } public String getTopic() { return topic ; } public void genTopic( HelpAccumulator acc ) { acc.append( getTopic() ) ; } public void genHelp( HelpAccumulator acc ) { helpSupplier.getHelpForTopic( topic, acc ) ; } public String toString() { //return helpSupplier.getShortSummaryForTopic( topic ) ; return getTopic() + " (" + helpSupplier.getHelpSupplierName().toLowerCase() + ")" ; } }
\ No newline at end of file
/* Runner.java Title: Simple Stack Machine Runner Author: atze Description: */ package nl.uu.cs.ssmui; import javax.swing.*; public class Images { public static ImageIcon redball ; public static ImageIcon white ; public static ImageIcon check ; public static ImageIcon tbStart ; public static ImageIcon tbStartBack ; public static ImageIcon tbPause ; public static ImageIcon tbReset ; public static ImageIcon tbStep1 ; public static ImageIcon tbStep1Back ; public static ImageIcon tbNew ; public static ImageIcon tbLoad ; public static ImageIcon tbReload ; public static ImageIcon tbSave ; public static ImageIcon tbNewInstr ; private static ImageIcon getImage( String nm ) { return new ImageIcon( nm.getClass().getResource( "/Images/" + nm + ".gif" ) ) ; } static { redball = getImage( "redball" ) ; white = getImage( "white" ) ; check = getImage( "check" ) ; tbStart = getImage( "tb-start" ) ; tbStartBack = getImage( "tb-startback" ) ; tbPause = getImage( "tb-pause" ) ; tbReset = getImage( "tb-reset" ) ; tbStep1 = getImage( "tb-step1" ) ; tbStep1Back = getImage( "tb-step1back" ) ; tbNew = getImage( "tb-new" ) ; tbLoad = getImage( "tb-load" ) ; tbReload = getImage( "tb-reload" ) ; tbSave = getImage( "tb-save" ) ; tbNewInstr = getImage( "tb-newinstr" ) ; }}
\ No newline at end of file
/* Title: Simple Stack Machine Runner Author: atze Description: */ package nl.uu.cs.ssmui; import java.util.*; class Labels{ public static final int UNDEFINED = Integer.MAX_VALUE ; private class Label { String label ; boolean isAbsolute ; boolean isWhatItIs ; boolean isResolved ; int row ; Label( String nm, int r, boolean reslv ) { label = nm ; row = r ; isAbsolute = false ; isResolved = reslv ; isWhatItIs = false ; } } private class UnresolvedLabelUsage { Label label ; int row ; int insideInstOffset ; int pcOffset ; boolean isRelative ; UnresolvedLabelUsage( Label l, int r, int offs, int pcoffs, boolean isRel ) { label = l ; row = r ; insideInstOffset = offs ; pcOffset = pcoffs ; isRelative = isRel ; } public String toString() { return label.label ; } } private Hashtable labels ; private Vector unresolvedUsages ; private CodeRowSupplier codeSupplier ; protected Labels( CodeRowSupplier cs ) { codeSupplier = cs ; reset(null) ; } protected void reset( Enumeration regNames ) { if ( regNames != null ) { labels = new Hashtable() ; for ( ; regNames.hasMoreElements() ; ) { String nm = (String)regNames.nextElement() ; defineRegName( nm, nl.uu.cs.ssm.Registers.findRegOfName( nm ) ) ; // not neat, ??? TBD } } unresolvedUsages = new Vector() ; } protected void shiftAt( int row, int v ) { } private Label findLabelByName( String nm ) { Label res = (Label)labels.get( nm ) ; return res ; } protected String findLabelNameAtRow( int row ) { for ( Enumeration e = labels.elements() ; e.hasMoreElements() ; ) { Label l = (Label)e.nextElement() ; if ( l.row == row ) return l.label ; } return "" ; } protected boolean labelIsDefined( String nm ) { return findLabelByName( nm ) != null ; } private void defineRegName( String nm, int val ) { Label l = new Label( nm, val, true ) ; l.isAbsolute = l.isWhatItIs = true ; labels.put( nm, l ) ; } private Label defineLabel( String nm, int row, boolean resolved ) { Label l ; if ( ( l = findLabelByName( nm ) ) != null ) { if ( ! l.isResolved ) { l.isResolved = true ; l.row = row ; } } else { l = new Label( nm, row, resolved ) ; labels.put( nm, l ) ; } //System.out.println( "defined label " + nm + " row=" + row + " loc=" + codeSupplier.memLocOfRow(row) ) ; return l ; } protected void defineLabel( String nm, int row ) { defineLabel( nm, row, true ) ; } protected int useLabel( String nm, int row, int offset, int pcOffset, boolean isRelative ) { return useLabel( nm, row, offset, pcOffset, true, isRelative) ; } private int useLabel( String nm, int row, int offset, int pcOffset, boolean doAddUnresolved, boolean isRelative ) { int res ; Label l = findLabelByName( nm ) ; if ( l != null && l.isResolved ) { if ( l.isWhatItIs ) { res = l.row ; } else { int labelLoc = codeSupplier.memLocOfRow( l.row ) ; int useLoc = codeSupplier.memLocOfRow( row ) + pcOffset ; res = ( (l.isAbsolute || (! isRelative)) ? labelLoc : labelLoc - useLoc ) ; //System.out.println( "use label " + nm + " res=" + res + " useloc=" + useLoc ) ; } } else { if ( l == null ) { l = defineLabel( nm, 0, false ) ; } if ( doAddUnresolved ) unresolvedUsages.addElement( new UnresolvedLabelUsage( l, row, offset, pcOffset, isRelative ) ) ; res = UNDEFINED ; } return res ; } protected Vector resolveUnresolved() { Vector stillUnresolved = new Vector() ; for ( Enumeration ls = unresolvedUsages.elements() ; ls.hasMoreElements() ; ) { UnresolvedLabelUsage ul = (UnresolvedLabelUsage)ls.nextElement() ; int val = useLabel( ul.label.label, ul.row, ul.insideInstOffset, ul.pcOffset, false, ul.isRelative ) ; if ( val == UNDEFINED ) stillUnresolved.addElement( ul ) ; else codeSupplier.setInstrArgAt( ul.row, ul.insideInstOffset, val ) ; } return stillUnresolved ; } }
\ No newline at end of file
/* Runner.java Title: Simple Stack Machine Runner Author: atze Description: */ package nl.uu.cs.ssmui; import javax.swing.*;import java.io.* ; public class Runner extends Thread{ protected int delay = 50 ; SSMRunner ssmRunner ; public Runner( File initialFile ) { try { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { } ssmRunner = new SSMRunner( this ); ssmRunner.initComponents(); ssmRunner.setVisible(true); //System.out.println( "Foc Trav=" + ssmRunner.isFocusTraversable() ) ; ssmRunner.requestFocus() ; if ( initialFile != null ) ssmRunner.loadFile( initialFile ) ; } catch (Exception e) { e.printStackTrace(); } } public void run() { while( true ) { int steppingState = ssmRunner.steppingState() ; if ( steppingState != ssmRunner.STEP_BY_STEP ) { if ( ssmRunner.hasBreakpointAtPC() ) ssmRunner.stopContinuouslyDoingSteps() ; else if ( steppingState == ssmRunner.STEP_CONT_FORWARD ) ssmRunner.doAStepForward() ; else if ( steppingState == ssmRunner.STEP_CONT_BACKWARD ) ssmRunner.doAStepBack() ; } try { sleep( delay ) ; } catch ( InterruptedException e ) {} } } // Main entry point static public void main(String[] args) { File initialFile = null ; if ( args.length > 0 ) { File f = new File( args[0] ) ; if ( f.exists() ) initialFile = f ; } new Runner( initialFile ) ; } }
\ No newline at end of file
package nl.uu.cs.ssmui; import java.awt.*;import java.awt.event.*;import javax.swing.*; import nl.uu.cs.ssm.* ; public class SSMAbout extends JFrame { // IMPORTANT: Source code between BEGIN/END comment pair will be regenerated // every time the form is saved. All manual changes will be overwritten. // BEGIN GENERATED CODE // member declarations javax.swing.JPanel onTopOfAllPanel = new javax.swing.JPanel(); javax.swing.JLabel versionLabel = new javax.swing.JLabel(); javax.swing.JLabel authorLabel = new javax.swing.JLabel(); javax.swing.JLabel dateLabel = new javax.swing.JLabel(); javax.swing.JTextField versionTextField = new javax.swing.JTextField(); javax.swing.JTextField dateTextField = new javax.swing.JTextField(); javax.swing.JTextField authorTextField = new javax.swing.JTextField(); javax.swing.JLabel authorEmailLabel = new javax.swing.JLabel(); javax.swing.JTextField authorEmailTextField = new javax.swing.JTextField(); // END GENERATED CODE public SSMAbout() { try { initComponents() ; } catch( Exception ex ) {} setVisible( true ) ; } public void initComponents() throws Exception { // IMPORTANT: Source code between BEGIN/END comment pair will be regenerated // every time the form is saved. All manual changes will be overwritten. // BEGIN GENERATED CODE // the following code sets the frame's initial state onTopOfAllPanel.setForeground(null); onTopOfAllPanel.setLocation(new java.awt.Point(0, 0)); onTopOfAllPanel.setVisible(true); onTopOfAllPanel.setBackground(null); onTopOfAllPanel.setFont(null); onTopOfAllPanel.setLayout(null); onTopOfAllPanel.setOpaque(false); onTopOfAllPanel.setSize(new java.awt.Dimension(320, 120)); versionLabel.setText("Version:"); versionLabel.setLocation(new java.awt.Point(10, 10)); versionLabel.setVisible(true); versionLabel.setFont(null); versionLabel.setSize(new java.awt.Dimension(80, 20)); authorLabel.setText("Author & :"); authorLabel.setLocation(new java.awt.Point(10, 50)); authorLabel.setVisible(true); authorLabel.setFont(null); authorLabel.setSize(new java.awt.Dimension(80, 20)); dateLabel.setText("Date:"); dateLabel.setLocation(new java.awt.Point(10, 30)); dateLabel.setVisible(true); dateLabel.setFont(null); dateLabel.setSize(new java.awt.Dimension(80, 20)); versionTextField.setLocation(new java.awt.Point(90, 10)); versionTextField.setVisible(true); versionTextField.setFont(null); versionTextField.setSize(new java.awt.Dimension(220, 20)); versionTextField.setEditable(false); dateTextField.setLocation(new java.awt.Point(90, 30)); dateTextField.setVisible(true); dateTextField.setFont(null); dateTextField.setSize(new java.awt.Dimension(220, 20)); dateTextField.setEditable(false); authorTextField.setLocation(new java.awt.Point(90, 50)); authorTextField.setVisible(true); authorTextField.setFont(null); authorTextField.setSize(new java.awt.Dimension(220, 20)); authorTextField.setEditable(false); authorEmailLabel.setText("Email:"); authorEmailLabel.setLocation(new java.awt.Point(10, 70)); authorEmailLabel.setVisible(true); authorEmailLabel.setFont(null); authorEmailLabel.setSize(new java.awt.Dimension(80, 20)); authorEmailTextField.setLocation(new java.awt.Point(90, 70)); authorEmailTextField.setVisible(true); authorEmailTextField.setFont(null); authorEmailTextField.setSize(new java.awt.Dimension(220, 20)); authorEmailTextField.setEditable(false); setLocation(new java.awt.Point(0, 0)); setTitle("About the Simple Stack Machine"); setResizable(false); setFont(new java.awt.Font("SansSerif", 0, 10)); getContentPane().setLayout(null); setSize(new java.awt.Dimension(321, 121)); getContentPane().add(onTopOfAllPanel); getContentPane().add(versionLabel); getContentPane().add(authorLabel); getContentPane().add(dateLabel); getContentPane().add(versionTextField); getContentPane().add(dateTextField); getContentPane().add(authorTextField); getContentPane().add(authorEmailLabel); getContentPane().add(authorEmailTextField); onTopOfAllPanel.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent e) { onTopOfAllPanelMouseClicked(e); } }); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent e) { thisWindowClosing(e); } }); // END GENERATED CODE versionTextField.setText( Config.version() ) ; dateTextField.setText( Config.versionDate() ) ; authorTextField.setText( Config.author() ) ; authorEmailTextField.setText( Config.authorEmail() ) ; } /* private boolean mShown = false; public void addNotify() { super.addNotify(); if (mShown) return; // resize frame to account for menubar JMenuBar jMenuBar = getJMenuBar(); if (jMenuBar != null) { int jMenuBarHeight = jMenuBar.getPreferredSize().height; Dimension dimension = getSize(); dimension.height += jMenuBarHeight; setSize(dimension); } mShown = true; } */ private void done() { setVisible(false); dispose(); } // Close the window when the close box is clicked void thisWindowClosing(java.awt.event.WindowEvent e) { done() ; } public void onTopOfAllPanelMouseClicked(java.awt.event.MouseEvent e) { done() ; } }
\ No newline at end of file
Metrowerks RAD Data V 1 BeginClasses {9BE3D9E0-166E-11D1-B2D8-0060081C5489} "#base-object-class" {24A693F8-14E5-11D2-B334-00600819ADE3} "Runner" {5FA17216-8612-11D1-B2AD-006008A5C0A5} "Frame1" {5FA17216-8612-11D1-B2AD-006008A5C0A5} "SSMRunner" {5FA17216-8612-11D1-B2AD-006008A5C0A5} "SSMAbout" {AF105FF8-70D9-11D1-B010-00805F6114CC} "javax.swing.JLabel" {AF105FF8-70D9-11D1-B010-00805F6114CC} "javax.swing.JTextField" {8AC75CA0-A339-11D1-B2BE-006008A5C0A5} "javax.swing.JPanel" EndClasses BeginObject nl.uu.cs.ssmui.SSMAbout "SSMAbout" BeginProperties enabled = True JMenuBar = <none> foreground = black location = "0, 0" title = "About the Simple Stack Machine" resizable = False locale = US background = "204, 204, 204" font = SansSerif-PLAIN-10 layout = None cursor = Default menuBar = <none> size = "321, 121" EndProperties BeginInternalProperties UseSwing 11 = 1 IsApplet 11 = 0 EndInternalProperties BeginEventConnections BeginEventConnection {796E35A1-9372-11D2-9A19-00104B70C619} SourcePath = "\\\\nl.uu.cs.ssmui.SSMAbout" SinkPath = "\\\\nl.uu.cs.ssmui.SSMAbout" EventName = windowClosing EventSetName = window HandlerName = thisWindowClosing EndEventConnection BeginEventConnection {796E35A1-9372-11D2-9A19-00104B70C619} SourcePath = "\\\\nl.uu.cs.ssmui.SSMAbout\\onTopOfAllPanel" SinkPath = "\\\\nl.uu.cs.ssmui.SSMAbout" EventName = mouseClicked EventSetName = mouse HandlerName = onTopOfAllPanelMouseClicked EndEventConnection EndEventConnections BeginObject onTopOfAllPanel "javax.swing.JPanel" BeginProperties requestFocusEnabled = True maximumSize = "32767, 32767" enabled = True preferredSize = "10, 10" foreground = none location = "0, 0" autoscrolls = False visible = True locale = US background = none font = inherit layout = None cursor = Default alignmentY = 0.5 alignmentX = 0.5 opaque = False debugGraphicsOptions = 0 toolTipText = "" minimumSize = "10, 10" size = "320, 120" doubleBuffered = True EndProperties BeginInternalProperties EndInternalProperties EndObject BeginObject versionLabel "javax.swing.JLabel" BeginProperties requestFocusEnabled = True verticalAlignment = 0 iconTextGap = 4 maximumSize = "0, 0" enabled = True text = Version: foreground = "102, 102, 153" location = "10, 10" autoscrolls = False visible = True locale = US background = "204, 204, 204" font = inherit horizontalAlignment = 2 cursor = Default alignmentY = 0.5 alignmentX = 0.0 opaque = False verticalTextPosition = 0 debugGraphicsOptions = 0 toolTipText = "" minimumSize = "0, 0" size = "80, 20" doubleBuffered = False horizontalTextPosition = 4 EndProperties BeginInternalProperties EndInternalProperties EndObject BeginObject authorLabel "javax.swing.JLabel" BeginProperties requestFocusEnabled = True verticalAlignment = 0 iconTextGap = 4 maximumSize = "0, 0" enabled = True text = "Author & :" foreground = "102, 102, 153" location = "10, 50" autoscrolls = False visible = True locale = US background = "204, 204, 204" font = inherit horizontalAlignment = 2 cursor = Default alignmentY = 0.5 alignmentX = 0.0 opaque = False verticalTextPosition = 0 debugGraphicsOptions = 0 toolTipText = "" minimumSize = "0, 0" size = "80, 20" doubleBuffered = False horizontalTextPosition = 4 EndProperties BeginInternalProperties EndInternalProperties EndObject BeginObject dateLabel "javax.swing.JLabel" BeginProperties requestFocusEnabled = True verticalAlignment = 0 iconTextGap = 4 maximumSize = "0, 0" enabled = True text = Date: foreground = "102, 102, 153" location = "10, 30" autoscrolls = False visible = True locale = US background = "204, 204, 204" font = inherit horizontalAlignment = 2 cursor = Default alignmentY = 0.5 alignmentX = 0.0 opaque = False verticalTextPosition = 0 debugGraphicsOptions = 0 toolTipText = "" minimumSize = "0, 0" size = "80, 20" doubleBuffered = False horizontalTextPosition = 4 EndProperties BeginInternalProperties EndInternalProperties EndObject BeginObject versionTextField "javax.swing.JTextField" BeginProperties requestFocusEnabled = True selectionStart = 0 maximumSize = "2147483647, 2147483647" enabled = True scrollOffset = 0 text = "" selectedTextColor = black location = "90, 10" foreground = black autoscrolls = True visible = True locale = US background = white selectionColor = "204, 204, 255" caretColor = black font = inherit columns = 0 horizontalAlignment = 2 cursor = Default alignmentY = 0.5 alignmentX = 0.5 opaque = True caretPosition = 0 selectionEnd = 0 disabledTextColor = "153, 153, 153" debugGraphicsOptions = 0 toolTipText = "" minimumSize = "4, 17" size = "220, 20" doubleBuffered = False editable = False EndProperties BeginInternalProperties EndInternalProperties EndObject BeginObject dateTextField "javax.swing.JTextField" BeginProperties requestFocusEnabled = True selectionStart = 0 maximumSize = "2147483647, 2147483647" enabled = True scrollOffset = 0 text = "" selectedTextColor = black location = "90, 30" foreground = black autoscrolls = True visible = True locale = US background = white selectionColor = "204, 204, 255" caretColor = black font = inherit columns = 0 horizontalAlignment = 2 cursor = Default alignmentY = 0.5 alignmentX = 0.5 opaque = True caretPosition = 0 selectionEnd = 0 disabledTextColor = "153, 153, 153" debugGraphicsOptions = 0 toolTipText = "" minimumSize = "4, 17" size = "220, 20" doubleBuffered = False editable = False EndProperties BeginInternalProperties EndInternalProperties EndObject BeginObject authorTextField "javax.swing.JTextField" BeginProperties requestFocusEnabled = True selectionStart = 0 maximumSize = "2147483647, 2147483647" enabled = True scrollOffset = 0 text = "" selectedTextColor = black location = "90, 50" foreground = black autoscrolls = True visible = True locale = US background = white selectionColor = "204, 204, 255" caretColor = black font = inherit columns = 0 horizontalAlignment = 2 cursor = Default alignmentY = 0.5 alignmentX = 0.5 opaque = True caretPosition = 0 selectionEnd = 0 disabledTextColor = "153, 153, 153" debugGraphicsOptions = 0 toolTipText = "" minimumSize = "4, 17" size = "220, 20" doubleBuffered = False editable = False EndProperties BeginInternalProperties EndInternalProperties EndObject BeginObject authorEmailLabel "javax.swing.JLabel" BeginProperties requestFocusEnabled = True verticalAlignment = 0 iconTextGap = 4 maximumSize = "0, 0" enabled = True text = Email: foreground = "102, 102, 153" location = "10, 70" autoscrolls = False visible = True locale = US background = "204, 204, 204" font = inherit horizontalAlignment = 2 cursor = Default alignmentY = 0.5 alignmentX = 0.0 opaque = False verticalTextPosition = 0 debugGraphicsOptions = 0 toolTipText = "" minimumSize = "0, 0" size = "80, 20" doubleBuffered = False horizontalTextPosition = 4 EndProperties BeginInternalProperties EndInternalProperties EndObject BeginObject authorEmailTextField "javax.swing.JTextField" BeginProperties requestFocusEnabled = True selectionStart = 0 maximumSize = "2147483647, 2147483647" enabled = True scrollOffset = 0 text = "" selectedTextColor = black location = "90, 70" foreground = black autoscrolls = True visible = True locale = US background = white selectionColor = "204, 204, 255" caretColor = black font = inherit columns = 0 horizontalAlignment = 2 cursor = Default alignmentY = 0.5 alignmentX = 0.5 opaque = True caretPosition = 0 selectionEnd = 0 disabledTextColor = "153, 153, 153" debugGraphicsOptions = 0 toolTipText = "" minimumSize = "4, 17" size = "220, 20" doubleBuffered = False editable = False EndProperties BeginInternalProperties EndInternalProperties EndObject EndObject
\ No newline at end of file
package nl.uu.cs.ssmui; import java.awt.*;import java.awt.event.*;import javax.swing.*; import java.util.* ; import nl.uu.cs.ssm.* ; public class SSMHelp extends JFrame { private abstract class AccumulatorFactory { public abstract HelpAccumulator make( boolean b, String f ) ; } private class HTMLAccumulatorFactory extends AccumulatorFactory { public HelpAccumulator make( boolean b, String f ) { return new HelpHTMLAccumulator( b, f ) ; } } private Help helper ; // IMPORTANT: Source code between BEGIN/END comment pair will be regenerated // every time the form is saved. All manual changes will be overwritten. // BEGIN GENERATED CODE // member declarations javax.swing.JScrollPane helpTextScrollPane = new javax.swing.JScrollPane(); javax.swing.JEditorPane helpTextEditorPane = new javax.swing.JEditorPane(); javax.swing.JPanel findPanel = new javax.swing.JPanel(); javax.swing.JLabel topicLabel = new javax.swing.JLabel(); javax.swing.JTextField topicTextField = new javax.swing.JTextField(); javax.swing.JButton findButton = new javax.swing.JButton(); javax.swing.JButton allTopicsButton = new javax.swing.JButton(); javax.swing.JScrollPane foundTopicsScrollPane = new javax.swing.JScrollPane(); javax.swing.JList foundTopicsList = new javax.swing.JList(); // END GENERATED CODE public SSMHelp( Help h ) { helper = h ; try { initComponents() ; } catch( Exception ex ) {} setVisible( true ) ; } public void initComponents() throws Exception { // IMPORTANT: Source code between BEGIN/END comment pair will be regenerated // every time the form is saved. All manual changes will be overwritten. // BEGIN GENERATED CODE // the following code sets the frame's initial state helpTextScrollPane.setLocation(new java.awt.Point(10, 140)); helpTextScrollPane.setVisible(true); helpTextScrollPane.setFont(null); helpTextScrollPane.setSize(new java.awt.Dimension(600, 470)); helpTextScrollPane.getViewport().add(helpTextEditorPane); helpTextEditorPane.setContentType("text/html"); helpTextEditorPane.setVisible(true); helpTextEditorPane.setFont(null); helpTextEditorPane.setEditable(false); findPanel.setLocation(new java.awt.Point(0, 10)); findPanel.setVisible(true); findPanel.setFont(null); findPanel.setLayout(null); findPanel.setSize(new java.awt.Dimension(490, 120)); findPanel.add(topicLabel); findPanel.add(topicTextField); findPanel.add(findButton); findPanel.add(allTopicsButton); findPanel.add(foundTopicsScrollPane); topicLabel.setText("Topic:"); topicLabel.setLocation(new java.awt.Point(10, 10)); topicLabel.setVisible(true); topicLabel.setFont(new java.awt.Font("SansSerif", 1, 10)); topicLabel.setSize(new java.awt.Dimension(50, 20)); topicTextField.setLocation(new java.awt.Point(60, 10)); topicTextField.setVisible(true); topicTextField.setFont(new java.awt.Font("SansSerif", 0, 10)); topicTextField.setMinimumSize(new java.awt.Dimension(150, 20)); topicTextField.setSize(new java.awt.Dimension(150, 20)); findButton.setText("Find"); findButton.setLocation(new java.awt.Point(220, 10)); findButton.setVisible(true); findButton.setFont(new java.awt.Font("SansSerif", 1, 10)); findButton.setToolTipText("Find Help for Topic"); findButton.setSize(new java.awt.Dimension(80, 20)); allTopicsButton.setText("All Topics"); allTopicsButton.setLocation(new java.awt.Point(360, 10)); allTopicsButton.setVisible(true); allTopicsButton.setFont(new java.awt.Font("SansSerif", 1, 10)); allTopicsButton.setSize(new java.awt.Dimension(120, 20)); foundTopicsScrollPane.setLocation(new java.awt.Point(60, 40)); foundTopicsScrollPane.setVisible(true); foundTopicsScrollPane.setFont(new java.awt.Font("SansSerif", 0, 10)); foundTopicsScrollPane.setMinimumSize(new java.awt.Dimension(430, 70)); foundTopicsScrollPane.setSize(new java.awt.Dimension(420, 70)); foundTopicsScrollPane.getViewport().add(foundTopicsList); foundTopicsList.setMaximumSize(new java.awt.Dimension(1000, 1000)); foundTopicsList.setVisible(true); foundTopicsList.setFont(null); setLocation(new java.awt.Point(0, 0)); setTitle("Simple Stack Machine Help"); setResizable(false); setFont(new java.awt.Font("SansSerif", 0, 10)); getContentPane().setLayout(null); setSize(new java.awt.Dimension(618, 644)); getContentPane().add(helpTextScrollPane); getContentPane().add(findPanel); topicTextField.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { topicTextFieldActionPerformed(e); } }); findButton.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseReleased(java.awt.event.MouseEvent e) { findButtonMouseReleased(e); } }); allTopicsButton.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseReleased(java.awt.event.MouseEvent e) { allTopicsButtonMouseReleased(e); } }); foundTopicsList.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseReleased(java.awt.event.MouseEvent e) { foundTopicsListMouseReleased(e); } }); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent e) { thisWindowClosing(e); } }); // END GENERATED CODE /* getContentPane().setLayout(new java.awt.BorderLayout(0, 0)); getContentPane().add(findPanel, "North"); getContentPane().add(helpTextScrollPane, "Center"); */ /* GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); getContentPane().setLayout(gridbag); c.fill = GridBagConstraints.BOTH ; c.gridwidth = GridBagConstraints.REMAINDER ; c.gridheight = 1 ; c.weightx = 1.0 ; c.weighty = 1.0 ; gridbag.setConstraints( findPanel, c ) ; c.fill = GridBagConstraints.BOTH ; c.gridheight = 3 ; gridbag.setConstraints( helpTextScrollPane, c ) ; */ /* GridBagLayout gridbag = new GridBagLayout() ; GridBagConstraints c = new GridBagConstraints() ; findPanel.setLayout( gridbag ) ; c.insets = new Insets( 4, 4, 4, 4 ) ; c.weightx = 0.0 ; c.gridx = GridBagConstraints.RELATIVE ; c.gridy = 0 ; c.anchor = GridBagConstraints.EAST ; gridbag.setConstraints( topicLabel, c ) ; c.weightx = 0.5 ; c.anchor = GridBagConstraints.WEST ; gridbag.setConstraints( topicTextField, c ) ; c.anchor = GridBagConstraints.WEST ; c.weightx = 0.0 ; gridbag.setConstraints( findButton, c ) ; c.gridwidth = GridBagConstraints.REMAINDER ; c.anchor = GridBagConstraints.EAST ; gridbag.setConstraints( allTopicsButton, c ) ; c.gridy = GridBagConstraints.RELATIVE ; c.gridwidth = GridBagConstraints.REMAINDER ; c.gridheight = GridBagConstraints.REMAINDER ; c.weightx = 1.0 ; gridbag.setConstraints( foundTopicsScrollPane, c ) ; */ helpTextEditorPane.setContentType( "text/html" ) ; } private boolean mShown = false; public void addNotify() { super.addNotify(); if (mShown) return; // resize frame to account for menubar JMenuBar jMenuBar = getJMenuBar(); if (jMenuBar != null) { int jMenuBarHeight = jMenuBar.getPreferredSize().height; Dimension dimension = getSize(); dimension.height += jMenuBarHeight; setSize(dimension); } mShown = true; } // Close the window when the close box is clicked void thisWindowClosing(java.awt.event.WindowEvent e) { setVisible(false); dispose(); //System.exit(0); } private void displayFoundHelp( boolean doAll, AccumulatorFactory accfac, String fileName ) { Vector helpTopics = helper.findTopics( doAll ? null : topicTextField.getText().trim() ) ; foundTopicsList.setListData( helpTopics ) ; if ( helpTopics.size() == 1 || fileName != null ) { HelpAccumulator acc = outputAllSelectedHelp( helpTopics, accfac, fileName ) ; //displayOneSelectedHelp( (HelpTopic)helpTopics.elementAt( 0 ) ) ; helpTextEditorPane.setText( acc.toString() ) ; } } private void output1HelpTopic( HelpAccumulator acc, HelpTopic helpTopic ) { acc.beginSectionTitle() ; helpTopic.genTitle( acc ) ; acc.append( ": " ) ; helpTopic.genTopic( acc ) ; acc.endSectionTitle() ; acc.anchor( helpTopic.getTopic() ) ; acc.nl() ; acc.beginPara( ) ; helpTopic.genHelp( acc ) ; acc.endPara() ; } private void displayOneSelectedHelp( HelpTopic helpTopic ) { Vector helpTopics = new Vector() ; helpTopics.addElement( helpTopic ) ; HelpAccumulator acc = outputAllSelectedHelp( helpTopics ) ; helpTextEditorPane.setText( acc.toString() ) ; } private HelpAccumulator outputAllSelectedHelp( Vector helpTopics, AccumulatorFactory accfac, String fileName ) { HelpAccumulator acc = accfac.make( fileName == null, fileName ) ; //System.out.println( "Help " + fileName ) ; acc.beginHeadTitleBody( "SSM Help" ) ; if ( fileName != null ) { acc.para( "Generated by SSM " + Config.version() + " at " + (new Date().toString()) ) ; acc.sectionTitle( "Topics" ) ; acc.beginCentered( ) ; for ( Enumeration e = helpTopics.elements() ; e.hasMoreElements() ; ) { HelpTopic helpTopic = (HelpTopic)e.nextElement() ; String topic = helpTopic.getTopic() ; acc.anchorA( topic, topic ) ; if ( e.hasMoreElements() ) acc.append( ", " ) ; } acc.endCentered() ; } for ( Enumeration e = helpTopics.elements() ; e.hasMoreElements() ; ) { HelpTopic helpTopic = (HelpTopic)e.nextElement() ; output1HelpTopic( acc, helpTopic ) ; acc.nl() ; } acc.endHeadTitleBody() ; return acc ; } private HelpAccumulator outputAllSelectedHelp( Vector helpTopics ) { return outputAllSelectedHelp( helpTopics, new HTMLAccumulatorFactory(), null ) ; } public void findButtonMouseReleased(java.awt.event.MouseEvent e) { displayFoundHelp( false, new HTMLAccumulatorFactory(), null ) ; } public void topicTextFieldActionPerformed(java.awt.event.ActionEvent e) { displayFoundHelp( false, new HTMLAccumulatorFactory(), null ) ; } public void foundTopicsListMouseReleased(java.awt.event.MouseEvent e) { HelpTopic helpTopic = (HelpTopic)foundTopicsList.getSelectedValue() ; if ( helpTopic != null ) displayOneSelectedHelp( helpTopic ) ; } /* public void allTopicsButtonActionPerformed(java.awt.event.ActionEvent e) { //topicTextField.setText( "" ) ; //System.out.println( "all topics event modf " + e.getModifiers() ) ; //displayFoundHelp( true ) ; } */ public void allTopicsButtonMouseReleased(java.awt.event.MouseEvent e) { if ( e.isAltDown() ) { displayFoundHelp ( true , new HTMLAccumulatorFactory() , "ssmtopics.html" ) ; } else if ( e.isControlDown() || e.isMetaDown() ) { displayFoundHelp ( true , new AccumulatorFactory() { public HelpAccumulator make( boolean b, String f ) { return new HelpLaTeXAccumulator( f ) ; } } , "ssmtopics.tex" ) ; } else displayFoundHelp( true, new HTMLAccumulatorFactory(), null ) ; } }
\ No newline at end of file
Metrowerks RAD Data V 1 BeginClasses {9BE3D9E0-166E-11D1-B2D8-0060081C5489} "#base-object-class" {24A693F8-14E5-11D2-B334-00600819ADE3} "Runner" {5FA17216-8612-11D1-B2AD-006008A5C0A5} "Frame1" {5FA17216-8612-11D1-B2AD-006008A5C0A5} "SSMRunner" {5FA17216-8612-11D1-B2AD-006008A5C0A5} "SSMAbout" {AF105FF8-70D9-11D1-B010-00805F6114CC} "javax.swing.JLabel" {AF105FF8-70D9-11D1-B010-00805F6114CC} "javax.swing.JTextField" {5FA17216-8612-11D1-B2AD-006008A5C0A5} "SSMHelp" {AF105FF8-70D9-11D1-B010-00805F6114CC} "javax.swing.JButton" {AF105FF8-70D9-11D1-B010-00805F6114CC} "javax.swing.JEditorPane" {8AC75CA0-A339-11D1-B2BE-006008A5C0A5} "javax.swing.JScrollPane" {AF105FF8-70D9-11D1-B010-00805F6114CC} "javax.swing.JList" {8AC75CA0-A339-11D1-B2BE-006008A5C0A5} "javax.swing.JPanel" {B0D36520-A309-11D1-B30F-00600819ADE3} "Resource File Error ^0." EndClasses BeginObject nl.uu.cs.ssmui.SSMHelp "SSMHelp" BeginProperties enabled = True JMenuBar = <none> foreground = black location = "0, 0" title = "Simple Stack Machine Help" resizable = False locale = US background = "204, 204, 204" font = SansSerif-PLAIN-10 layout = None cursor = Default menuBar = <none> size = "618, 644" EndProperties BeginInternalProperties UseSwing 11 = 1 IsApplet 11 = 0 EndInternalProperties BeginEventConnections BeginEventConnection {796E35A1-9372-11D2-9A19-00104B70C619} SourcePath = "\\\\nl.uu.cs.ssmui.SSMHelp" SinkPath = "\\\\nl.uu.cs.ssmui.SSMHelp" EventName = windowClosing EventSetName = window HandlerName = thisWindowClosing EndEventConnection BeginEventConnection {796E35A1-9372-11D2-9A19-00104B70C619} SourcePath = "\\\\nl.uu.cs.ssmui.SSMHelp\\findPanel\\topicTextField" SinkPath = "\\\\nl.uu.cs.ssmui.SSMHelp" EventName = actionPerformed EventSetName = action HandlerName = topicTextFieldActionPerformed EndEventConnection BeginEventConnection {796E35A1-9372-11D2-9A19-00104B70C619} SourcePath = "\\\\nl.uu.cs.ssmui.SSMHelp\\findPanel\\findButton" SinkPath = "\\\\nl.uu.cs.ssmui.SSMHelp" EventName = mouseReleased EventSetName = mouse HandlerName = findButtonMouseReleased EndEventConnection BeginEventConnection {796E35A1-9372-11D2-9A19-00104B70C619} SourcePath = "\\\\nl.uu.cs.ssmui.SSMHelp\\findPanel\\foundTopicsScrollPane\\foundTopicsList" SinkPath = "\\\\nl.uu.cs.ssmui.SSMHelp" EventName = mouseReleased EventSetName = mouse HandlerName = foundTopicsListMouseReleased EndEventConnection BeginEventConnection {796E35A1-9372-11D2-9A19-00104B70C619} SourcePath = "\\\\nl.uu.cs.ssmui.SSMHelp\\findPanel\\allTopicsButton" SinkPath = "\\\\nl.uu.cs.ssmui.SSMHelp" EventName = mouseReleased EventSetName = mouse HandlerName = allTopicsButtonMouseReleased EndEventConnection EndEventConnections BeginObject helpTextScrollPane "javax.swing.JScrollPane" BeginProperties requestFocusEnabled = True maximumSize = "32767, 32767" enabled = True foreground = black location = "10, 140" autoscrolls = False visible = True locale = US background = "204, 204, 204" font = inherit verticalScrollBarPolicy = 20 cursor = Default alignmentY = 0.5 alignmentX = 0.5 opaque = False debugGraphicsOptions = 0 toolTipText = "" minimumSize = "22, 22" size = "600, 470" doubleBuffered = False horizontalScrollBarPolicy = 30 EndProperties BeginInternalProperties EndInternalProperties BeginObject helpTextEditorPane "javax.swing.JEditorPane" BeginProperties contentType = text/html requestFocusEnabled = True selectionStart = 0 maximumSize = "2147483647, 2147483647" enabled = True text = "" selectedTextColor = black location = "0, 0" foreground = black autoscrolls = True visible = True locale = US background = white selectionColor = "204, 204, 255" caretColor = black font = inherit cursor = Default alignmentY = 0.5 alignmentX = 0.5 opaque = True caretPosition = 0 selectionEnd = 0 disabledTextColor = "153, 153, 153" debugGraphicsOptions = 0 toolTipText = "" minimumSize = "6, 19" size = "597, 467" doubleBuffered = False editable = False EndProperties BeginInternalProperties EndInternalProperties EndObject EndObject BeginObject findPanel "javax.swing.JPanel" BeginProperties requestFocusEnabled = True maximumSize = "32767, 32767" enabled = True preferredSize = "10, 10" foreground = black location = "0, 10" autoscrolls = False visible = True locale = US background = "204, 204, 204" font = inherit layout = None cursor = Default alignmentY = 0.5 alignmentX = 0.5 opaque = True debugGraphicsOptions = 0 toolTipText = "" minimumSize = "10, 10" size = "490, 120" doubleBuffered = True EndProperties BeginInternalProperties EndInternalProperties BeginObject topicLabel "javax.swing.JLabel" BeginProperties requestFocusEnabled = True verticalAlignment = 0 iconTextGap = 4 maximumSize = "0, 0" enabled = True text = Topic: foreground = "102, 102, 153" location = "10, 10" autoscrolls = False visible = True locale = US background = "204, 204, 204" font = SansSerif-BOLD-10 horizontalAlignment = 2 cursor = Default alignmentY = 0.5 alignmentX = 0.0 opaque = False verticalTextPosition = 0 debugGraphicsOptions = 0 toolTipText = "" minimumSize = "0, 0" size = "50, 20" doubleBuffered = False horizontalTextPosition = 4 EndProperties BeginInternalProperties EndInternalProperties EndObject BeginObject topicTextField "javax.swing.JTextField" BeginProperties requestFocusEnabled = True selectionStart = 0 maximumSize = "2147483647, 2147483647" enabled = True scrollOffset = 0 text = "" selectedTextColor = black location = "60, 10" foreground = black autoscrolls = True visible = True locale = US background = white selectionColor = "204, 204, 255" caretColor = black font = SansSerif-PLAIN-10 columns = 0 horizontalAlignment = 2 cursor = Default alignmentY = 0.5 alignmentX = 0.5 opaque = True caretPosition = 0 selectionEnd = 0 disabledTextColor = "153, 153, 153" debugGraphicsOptions = 0 toolTipText = "" minimumSize = "150, 20" size = "150, 20" doubleBuffered = False editable = True EndProperties BeginInternalProperties EndInternalProperties EndObject BeginObject findButton "javax.swing.JButton" BeginProperties requestFocusEnabled = True verticalAlignment = 0 maximumSize = "35, 11" enabled = True text = Find actionCommand = "" contentAreaFilled = True location = "220, 10" foreground = black autoscrolls = False visible = True locale = US rolloverEnabled = False background = "204, 204, 204" borderPainted = True font = SansSerif-BOLD-10 horizontalAlignment = 0 cursor = Default alignmentY = 0.0 alignmentX = 0.0 opaque = True defaultCapable = True selected = False verticalTextPosition = 0 debugGraphicsOptions = 0 toolTipText = "Find Help for Topic" minimumSize = "35, 11" size = "80, 20" focusPainted = True doubleBuffered = False horizontalTextPosition = 4 EndProperties BeginInternalProperties EndInternalProperties EndObject BeginObject allTopicsButton "javax.swing.JButton" BeginProperties requestFocusEnabled = True verticalAlignment = 0 maximumSize = "35, 11" enabled = True text = "All Topics" actionCommand = "" contentAreaFilled = True location = "360, 10" foreground = black autoscrolls = False visible = True locale = US rolloverEnabled = False background = "204, 204, 204" borderPainted = True font = SansSerif-BOLD-10 horizontalAlignment = 0 cursor = Default alignmentY = 0.0 alignmentX = 0.0 opaque = True defaultCapable = True selected = False verticalTextPosition = 0 debugGraphicsOptions = 0 toolTipText = "" minimumSize = "35, 11" size = "120, 20" focusPainted = True doubleBuffered = False horizontalTextPosition = 4 EndProperties BeginInternalProperties EndInternalProperties EndObject BeginObject foundTopicsScrollPane "javax.swing.JScrollPane" BeginProperties requestFocusEnabled = True maximumSize = "32767, 32767" enabled = True foreground = black location = "60, 40" autoscrolls = False visible = True locale = US background = "204, 204, 204" font = SansSerif-PLAIN-10 verticalScrollBarPolicy = 20 cursor = Default alignmentY = 0.5 alignmentX = 0.5 opaque = False debugGraphicsOptions = 0 toolTipText = "" minimumSize = "430, 70" size = "420, 70" doubleBuffered = False horizontalScrollBarPolicy = 30 EndProperties BeginInternalProperties EndInternalProperties BeginObject foundTopicsList "javax.swing.JList" BeginProperties selectionForeground = black requestFocusEnabled = True selectionBackground = "204, 204, 255" maximumSize = "1000, 1000" enabled = True fixedCellHeight = -1 foreground = black location = "0, 0" autoscrolls = True visible = True locale = US selectedIndex = -1 background = white selectionMode = 2 fixedCellWidth = -1 font = inherit cursor = Default alignmentY = 0.5 alignmentX = 0.5 opaque = True valueIsAdjusting = False debugGraphicsOptions = 0 toolTipText = "" minimumSize = "0, 0" size = "417, 67" visibleRowCount = 8 doubleBuffered = False EndProperties BeginInternalProperties EndInternalProperties EndObject EndObject EndObject EndObject
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
package nl.uu.cs.ssmui; import java.awt.*;import java.awt.event.*;import javax.swing.*; public class SSMRunner2 extends javax.swing.JFrame { // IMPORTANT: Source code between BEGIN/END comment pair will be regenerated // every time the form is saved. All manual changes will be overwritten. // BEGIN GENERATED CODE // member declarations javax.swing.JToolBar ssmToolBar = new javax.swing.JToolBar(); javax.swing.JSplitPane memNRestSplitPane = new javax.swing.JSplitPane(); javax.swing.JSplitPane codeNStackSplitPane = new javax.swing.JSplitPane(); javax.swing.JTable codeTable = new javax.swing.JTable(); javax.swing.JTable stackTable = new javax.swing.JTable(); javax.swing.JSplitPane statusNOutputSplitPane = new javax.swing.JSplitPane(); javax.swing.JTable statusTable = new javax.swing.JTable(); javax.swing.JTextArea outputTextArea = new javax.swing.JTextArea(); // END GENERATED CODE public SSMRunner2() { } public void initComponents() throws Exception { // IMPORTANT: Source code between BEGIN/END comment pair will be regenerated // every time the form is saved. All manual changes will be overwritten. // BEGIN GENERATED CODE // the following code sets the frame's initial state ssmToolBar.setSize(new java.awt.Dimension(600, 32)); ssmToolBar.setLocation(new java.awt.Point(0, 0)); ssmToolBar.setVisible(true); ssmToolBar.setLayout(null); memNRestSplitPane.setDividerLocation(500); memNRestSplitPane.setSize(new java.awt.Dimension(849, 670)); memNRestSplitPane.setDividerSize(8); memNRestSplitPane.setLocation(new java.awt.Point(0, 32)); memNRestSplitPane.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT); memNRestSplitPane.setVisible(true); codeNStackSplitPane.setDividerLocation(400); codeNStackSplitPane.setDividerSize(6); codeNStackSplitPane.setVisible(true); codeTable.setVisible(true); stackTable.setVisible(true); stackTable.setPreferredScrollableViewportSize(new java.awt.Dimension(400, 400)); statusNOutputSplitPane.setDividerLocation(80); statusNOutputSplitPane.setDividerSize(6); statusNOutputSplitPane.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT); statusNOutputSplitPane.setVisible(true); statusTable.setVisible(true); statusTable.setPreferredScrollableViewportSize(new java.awt.Dimension(830, 200)); outputTextArea.setVisible(true); outputTextArea.setText("outputTextArea"); setLocation(new java.awt.Point(0, 0)); getContentPane().setLayout(null); setTitle("Simple Stack Machine Interpreter(2)"); memNRestSplitPane.add(codeNStackSplitPane, javax.swing.JSplitPane.TOP); memNRestSplitPane.add(statusNOutputSplitPane, javax.swing.JSplitPane.BOTTOM); codeNStackSplitPane.add(codeTable, javax.swing.JSplitPane.LEFT); codeNStackSplitPane.add(stackTable, javax.swing.JSplitPane.RIGHT); statusNOutputSplitPane.add(statusTable, javax.swing.JSplitPane.TOP); statusNOutputSplitPane.add(outputTextArea, javax.swing.JSplitPane.BOTTOM); getContentPane().add(ssmToolBar); getContentPane().add(memNRestSplitPane); setSize(new java.awt.Dimension(850, 700)); // event handling addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent e) { thisWindowClosing(e); } }); // END GENERATED CODE } private boolean mShown = false; public void addNotify() { super.addNotify(); if (mShown) return; // resize frame to account for menubar JMenuBar jMenuBar = getJMenuBar(); if (jMenuBar != null) { int jMenuBarHeight = jMenuBar.getPreferredSize().height; Dimension dimension = getSize(); dimension.height += jMenuBarHeight; setSize(dimension); } mShown = true; } // Close the window when the close box is clicked void thisWindowClosing(java.awt.event.WindowEvent e) { setVisible(false); dispose(); System.exit(0); } }
\ No newline at end of file
Metrowerks RAD Data V 1 BeginClasses {9BE3D9E0-166E-11D1-B2D8-0060081C5489} "#base-object-class" {24A693F8-14E5-11D2-B334-00600819ADE3} "Runner" {5FA17216-8612-11D1-B2AD-006008A5C0A5} "Frame1" {5FA17216-8612-11D1-B2AD-006008A5C0A5} "SSMRunner" {5FA17216-8612-11D1-B2AD-006008A5C0A5} "SSMAbout" {AF105FF8-70D9-11D1-B010-00805F6114CC} "javax.swing.JLabel" {AF105FF8-70D9-11D1-B010-00805F6114CC} "javax.swing.JTextField" {5FA17216-8612-11D1-B2AD-006008A5C0A5} "SSMHelp" {AF105FF8-70D9-11D1-B010-00805F6114CC} "javax.swing.JButton" {AF105FF8-70D9-11D1-B010-00805F6114CC} "javax.swing.JEditorPane" {5FA17216-8612-11D1-B2AD-006008A5C0A5} "SSMRunner2" {8AC75CA0-A339-11D1-B2BE-006008A5C0A5} "javax.swing.JSplitPane" {8AC75CA0-A339-11D1-B2BE-006008A5C0A5} "javax.swing.JToolBar" {AF105FF8-70D9-11D1-B010-00805F6114CC} "javax.swing.JTable" {8AC75CA0-A339-11D1-B2BE-006008A5C0A5} "javax.swing.JInternalFrame" {AF105FF8-70D9-11D1-B010-00805F6114CC} "javax.swing.JTextArea" EndClasses BeginObject nl.uu.cs.ssmui.SSMRunner2 "SSMRunner2" BeginProperties location = "0, 0" layout = <none> title = "Simple Stack Machine Interpreter(2)" size = "850, 700" EndProperties BeginInternalProperties UseSwing 11 = 1 IsApplet 11 = 0 EndInternalProperties BeginEventConnections BeginEventConnection {796E35A1-9372-11D2-9A19-00104B70C619} SourcePath = "\\\\nl.uu.cs.ssmui.SSMRunner2" SinkPath = "\\\\nl.uu.cs.ssmui.SSMRunner2" EventName = windowClosing EventSetName = window HandlerName = thisWindowClosing EndEventConnection EndEventConnections BeginObject ssmToolBar "javax.swing.JToolBar" LayoutClass {5FA17216-8612-11D1-B2AD-006008A5C0A5} "SSMRunner2" BeginProperties size = "600, 32" location = "0, 0" layout = <none> EndProperties BeginInternalProperties EndInternalProperties EndObject BeginObject memNRestSplitPane "javax.swing.JSplitPane" LayoutClass {5FA17216-8612-11D1-B2AD-006008A5C0A5} "SSMRunner2" BeginProperties dividerLocation = 500 size = "849, 670" dividerSize = 8 location = "0, 32" orientation = VERTICAL_SPLIT EndProperties BeginInternalProperties EndInternalProperties BeginObject codeNStackSplitPane "javax.swing.JSplitPane" LayoutClass {5FA17216-8612-11D1-B2AD-006008A5C0A5} "SSMRunner2" BeginProperties dividerLocation = 400 size = "847, 448" dividerSize = 6 location = "1, 1" EndProperties BeginInternalProperties EndInternalProperties BeginObject codeTable "javax.swing.JTable" LayoutClass {5FA17216-8612-11D1-B2AD-006008A5C0A5} "SSMRunner2" BeginProperties size = "835, 446" location = "1, 1" EndProperties BeginInternalProperties EndInternalProperties EndObject BeginObject stackTable "javax.swing.JTable" LayoutClass {5FA17216-8612-11D1-B2AD-006008A5C0A5} "SSMRunner2" BeginProperties size = "0, 446" preferredScrollableViewportSize = "400, 400" location = "846, 1" EndProperties BeginInternalProperties EndInternalProperties EndObject EndObject BeginObject statusNOutputSplitPane "javax.swing.JSplitPane" LayoutClass {5FA17216-8612-11D1-B2AD-006008A5C0A5} "SSMRunner2" BeginProperties dividerLocation = 80 size = "847, 161" dividerSize = 6 location = "1, 508" orientation = VERTICAL_SPLIT EndProperties BeginInternalProperties EndInternalProperties BeginObject statusTable "javax.swing.JTable" LayoutClass {5FA17216-8612-11D1-B2AD-006008A5C0A5} "SSMRunner2" BeginProperties size = "845, 198" preferredScrollableViewportSize = "830, 200" location = "1, 1" EndProperties BeginInternalProperties EndInternalProperties EndObject BeginObject outputTextArea "javax.swing.JTextArea" LayoutClass {5FA17216-8612-11D1-B2AD-006008A5C0A5} "SSMRunner2" BeginProperties size = "845, 0" text = outputTextArea location = "1, 209" EndProperties BeginInternalProperties EndInternalProperties EndObject EndObject EndObject EndObject
\ No newline at end of file
package nl.uu.cs.ssmui; import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.table.*;import javax.swing.event.*; import nl.uu.cs.ssm.* ; public class StackTableModel extends AbstractTableModel implements MemoryCellListener{ private static final int C_ADDRESS = 0 ; private static final int C_VALUE = 1 ; protected static final int C_REGPTRS = 2 ; public static final int C_ANNOTE = 3 ; private static final String[] columnNames = { "Address", "Value", "RegPtrs", "Annote" } ; private MachineState machineState ; private Memory memory ; private Registers registers ; private int beforeMinAccessedSP ; private int maxAccessedSP ; private boolean isSPChanged = false ; public void beforeReset() { } public void reset() { if ( memory != null ) memory.removeMemoryCellListener( this ) ; if ( registers != null ) registers.removeMemoryCellListener( this ) ; memory = machineState.getMemory() ; registers = machineState.getRegisters() ; memory.addMemoryCellListener( this ) ; registers.addMemoryCellListener( this ) ; beforeMinAccessedSP = maxAccessedSP = registers.getReg( registers.SP ) ; fireTableChanged( new TableModelEvent( this ) ) ; //fireTableStructureChanged() ; } public StackTableModel( MachineState mst ) { machineState = mst ; reset() ; } protected boolean isSPChanged() { return isSPChanged ; } public int getColumnCount() { return columnNames.length ; } public int getRowCount() { return machineState.dir( maxAccessedSP - beforeMinAccessedSP ) ; //return memory.getCapacity() ; } private int rowToMemLoc( int row ) { return row + (beforeMinAccessedSP + 1) ; //return getRowCount() - row - 1 ; } protected int memLocToRow( int loc ) { return loc - (beforeMinAccessedSP + 1) ; //return rowToMemLoc( loc ) ; } public boolean isCellEditable( int row, int column ) { return column == C_VALUE ; } private boolean isMemLocWithinStackRange( int memLoc ) { return memLoc <= maxAccessedSP && memLoc > beforeMinAccessedSP ; } public Object getValueAt( int row, int column ) { Object res = "" ; int memLoc = rowToMemLoc( row ) ; switch( column ) { case C_ADDRESS : res = Utils.asHex( memLoc ) ; break ; case C_VALUE : res = Utils.asHex( memory.getAt( memLoc ) ) ; break ; case C_REGPTRS : { String pc, sp, mp ; pc = sp = mp = "" ; if ( memLoc == registers.getReg( registers.PC ) ) pc = " PC" ; if ( memLoc == registers.getReg( registers.SP ) ) sp = " SP" ; if ( memLoc == registers.getReg( registers.MP ) ) mp = " MP" ; res = pc + sp + mp ; } break ; case C_ANNOTE : MemoryAnnotation ann = memory.getAnnotationAt( memLoc ) ; //System.out.println( "annote stack at " + memLoc + "=" + ann ) ; res = ann == null ? ColoredText.blankDefault : ann ; break ; } return res ; } public void setValueAt( Object aValue, int row, int column ) { if ( column == C_VALUE ) { String strValue = null ; if ( aValue instanceof String ) strValue = (String)aValue ; else strValue = aValue.toString() ; memory.setAt( rowToMemLoc( row ), strValue ) ; } } public String getColumnName( int column ) { return columnNames[ column ] ; } public Class getColumnClass( int column ) { if ( column == C_ANNOTE ) return ColoredText.class ; else return SSMRunner.tableModelColumnClass ; } public void cellChanged( MemoryCellEvent e ) { Object src = e.getSource() ; int v ; if ( src == memory ) { int row = memLocToRow( e.cellIndex ) ; if ( isMemLocWithinStackRange( e.cellIndex ) ) fireTableRowsUpdated( row, row ) ; } else if ( src == registers && e.event == e.CELL ) { int loc = registers.getReg( e.cellIndex ) ; if ( e.cellIndex == registers.SP && maxAccessedSP < loc ) { int oldSPRow = rowToMemLoc( maxAccessedSP ) ; int newSPRow = rowToMemLoc( loc ) ; maxAccessedSP = loc ; isSPChanged = true ; fireTableRowsInserted( oldSPRow+1, newSPRow ) ; } else isSPChanged = false ; if ( isMemLocWithinStackRange( v = e.getOldCellValue() ) ) { int oldrow = memLocToRow( v ) ; fireTableCellUpdated( oldrow, C_REGPTRS ) ; } if ( isMemLocWithinStackRange( loc ) ) { int row = memLocToRow( loc ) ; fireTableCellUpdated( row, C_REGPTRS ) ; } } } }
\ No newline at end of file
package nl.uu.cs.ssmui; import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.table.*;import javax.swing.event.*; import nl.uu.cs.ssm.* ; public class StatusTableModel extends AbstractTableModel implements MemoryCellListener{ private static final int C_PC = 0 ; private static final int C_SP = 1 ; private static final int C_MP = 2 ; private static final int C_R3 = 3 ; private static final int C_R4 = 4 ; private static final int C_R5 = 5 ; private static final int C_R6 = 6 ; private static final int C_R7 = 7 ; private static final int C_SR = 8 ; //private static final String[] columnNames = { "PC", "SP", "MP", "RR", "SR" } ; private MachineState machineState ; private Registers registers ; public void beforeReset() { } public void reset() { if ( registers != null ) registers.removeMemoryCellListener( this ) ; /* if ( memory != null ) memory.removeMemoryCellListener( this ) ; */ registers = machineState.getRegisters() ; registers.addMemoryCellListener( this ) ; /* memory = machineState.getMemory() ; memory.addMemoryCellListener( this ) ; */ fireTableChanged( new TableModelEvent( this ) ) ; //fireTableStructureChanged() ; } public StatusTableModel( MachineState mst ) { machineState = mst ; reset() ; } public int getColumnCount() { return registers.getNrRegs() + 1 ; } public int getRowCount() { return 1 ; } public boolean isCellEditable( int row, int column ) { return column != C_SR ; } public Object getValueAt( int row, int column ) { Object res ; if ( column == C_SR ) { res = machineState.getSRAsString() ; } else { int reg = column ; res = Utils.asHex( registers.getReg( reg ) ) ; } return res ; } public void setValueAt( Object aValue, int row, int column ) { String strValue ; if ( aValue instanceof String ) strValue = (String)aValue ; else strValue = aValue.toString() ; if ( column != C_SR ) { int reg = column ; registers.setReg( reg, Utils.fromHex( strValue ) ) ; } } public String getColumnName( int column ) { return column == C_SR ? "SR" : registers.getRegNAliasName( column ) ; } public Class getColumnClass( int column ) { return SSMRunner.tableModelColumnClass ; } public void cellChanged( MemoryCellEvent e ) { fireTableCellUpdated( 0, e.cellIndex ) ; } }
\ No newline at end of file
/**
* Simple Stack Machine
*
* Written by Atze Dijkstra, atze@cs.uu.nl,
* Copyright Utrecht University.
*
*/
package nl.uu.cs.ssmui ;
import nl.uu.cs.ssm.* ;
import java.util.* ;
public class StepManager
implements MemoryCellListener, MachineStateListener
{
private MachineState machineState ;
private Memory memory ;
private Registers registers ;
private Vector history ;
private Vector curStepHistory ;
private StepManager( Memory m, Registers r )
{
memory = m ;
registers = r ;
history = new Vector() ;
}
protected StepManager( Machine m )
{
this( m.memory(), m.registers() ) ;
machineState = m.state() ;
}
public void cellChanged( MemoryCellEvent e )
{
curStepHistory.addElement( e ) ;
}
public void stateChanged( MachineStateEvent e )
{
curStepHistory.addElement( e ) ;
}
protected void beginForwardStep()
{
curStepHistory = new Vector() ;
memory.addMemoryCellListener( this ) ;
registers.addMemoryCellListener( this ) ;
machineState.addMachineStateListener( this ) ;
}
protected void endForwardStep()
{
machineState.removeMachineStateListener( this ) ;
memory.removeMemoryCellListener( this ) ;
registers.removeMemoryCellListener( this ) ;
history.addElement( curStepHistory ) ;
}
protected boolean canDoBackStep()
{
return history.size() > 0 ;
}
protected void backStep()
{
int sz ;
if ( (sz=history.size()) > 0 )
{
Vector events = (Vector)history.elementAt( sz-1 ) ;
for ( int i = events.size() - 1 ; i >= 0 ; i-- )
{
UndoableEvent e = (UndoableEvent)events.elementAt( i ) ;
e.undoModification().modify() ;
}
history.removeElementAt( sz-1 ) ;
}
}
}
#!/bin/sh
java -jar ssmui.jar $*
#java -cp ssmui.jar nl.uu.cs.ssmui.Runner $*
java -jar ssmui.jar %1
rem java -cp ssmui.jar nl.uu.cs.ssmui.Runner %1
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment