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

compiles with -Xlint

parent efc5e2b6
# makefile for SSM, Simple Stack Machine
default: ssm
DIR_SRC := src
DIR_HELP := Help
DIR_IMGS := Images
DIR_BLD := build
DIR_BLD_JAR := build/ssm
SSM_JAR := $(DIR_BLD)/ssm.jar
SSM_SRC := $(wildcard $(DIR_SRC)/nl/uu/cs/ssm/*.java) $(wildcard $(DIR_SRC)/nl/uu/cs/ssmui/*.java)
SSM_SRC_HELP := $(wildcard $(DIR_SRC)/$(DIR_HELP)/*.prop)
SSM_SRC_IMGS := $(wildcard $(DIR_SRC)/$(DIR_IMGS)/*.gif) $(wildcard $(DIR_SRC)/$(DIR_IMGS)/*.GIF)
SSM_MKF := Makefile
JAVAC_OPTS := -Xlint
ssm: $(SSM_JAR)
$(SSM_JAR): $(SSM_SRC) $(SSM_SRC_HELP) $(SSM_SRC_IMGS) $(SSM_MKF)
mkdir -p $(DIR_BLD_JAR) $(DIR_BLD_JAR)/$(DIR_HELP) $(DIR_BLD_JAR)/$(DIR_IMGS)
cp $(SSM_SRC_HELP) $(DIR_BLD_JAR)/$(DIR_HELP)
cp $(SSM_SRC_IMGS) $(DIR_BLD_JAR)/$(DIR_IMGS)
javac $(JAVAC_OPTS) -d $(DIR_BLD_JAR) $(SSM_SRC) && \
cd $(DIR_BLD_JAR) && \
jar cf ../$(@F) .
/** * Simple Stack Machine * * Written by Atze Dijkstra, atze@cs.uu.nl, * Copyright Utrecht University. * */ package nl.uu.cs.ssm ; import java.util.* ; public interface HelpSupplier{ public Enumeration getTopics() ; public String getHelpSupplierName() ; public String getShortSummaryForTopic( String topic ) ; public void getHelpForTopic( String topic, HelpAccumulator acc ) ; }
\ No newline at end of file
/** * Simple Stack Machine * * Written by Atze Dijkstra, atze@cs.uu.nl, * Copyright Utrecht University. * */ package nl.uu.cs.ssm ; import java.util.* ; public interface HelpSupplier{ public Enumeration<String> getTopics() ; public String getHelpSupplierName() ; public String getShortSummaryForTopic( String topic ) ; public void getHelpForTopic( String topic, HelpAccumulator acc ) ; }
\ No newline at end of file
......
This diff is collapsed.
......@@ -12,9 +12,11 @@ import java.util.* ;
public class MachineStateEvent extends UndoableEvent
{
private static final long serialVersionUID = 1L ;
protected MachineStateEvent( Object src, Modification mdf )
{
super( src, mdf ) ;
}
}
\ No newline at end of file
}
/** * Simple Stack Machine * * Written by Atze Dijkstra, atze@cs.uu.nl, * Copyright Utrecht University. * */ package nl.uu.cs.ssm ; import java.util.* ; public class Memory extends AbstractMemoryCellModel implements MemoryCellModel{ private int cells[] ; private Hashtable annotations ; private int nUsedForCode ; private Messenger messenger ; protected Memory( int initCapacity, Messenger m ) { messenger = m ; cells = new int[ initCapacity ] ; for ( int i = 0 ; i < cells.length ; i++ ) cells[ i ] = 0 ; reset() ; } public void reset() { nUsedForCode = 0 ; annotations = new Hashtable() ; for ( int i = 0 ; i < cells.length ; i++ ) setAt( i, 0 ) ; } public int getCapacity() { return cells.length ; } public int getUsedForCode() { return nUsedForCode ; } private boolean checkWithinMemory( int addr ) { boolean res ; if ( res = ( addr < 0 || addr >= cells.length ) ) { messenger.println ( java.text.MessageFormat.format ( "attempt to access location {0} outside {1}" , new Object[] { Utils.asHex(addr), ""+this } ) ) ; } return ! res ; } class UndoMemoryModification implements Modification { private int offset, value ; UndoMemoryModification( int o, int v ) { offset = o ; value = v ; } public void modify() { setAt( offset, value ) ; } } public void setAt( int addr, int v ) { if ( checkWithinMemory( addr ) ) { int oldv = cells[ addr ] ; cells[ addr ] = v ; fireCellChange( this, addr, oldv, new UndoMemoryModification( addr, oldv ) ) ; } } public void setAt( int addr, String v ) { setAt( addr, Utils.fromHex( v ) ) ; } public int getAt( int addr ) { int res = 0 ; if ( checkWithinMemory( addr ) ) { res = cells[ addr ] ; } return res ; } public int[] getAt( int addr, int len ) { int res[] = new int[ len ] ; for ( int i = 0 ; i < len && checkWithinMemory( addr + i ) ; i++ ) { res[ i ] = cells[ addr + i ] ; } return res ; } public String getAsHexAt( int addr ) { return Utils.asHex( getAt( addr ) ) ; } class UndoAnnotationModification implements Modification { private int offset ; private MemoryAnnotation value ; UndoAnnotationModification( int o, MemoryAnnotation v ) { offset = o ; value = v ; } public void modify() { setAnnotationAt( offset, value ) ; } } public void setAnnotationAt( int addr, MemoryAnnotation v ) { if ( checkWithinMemory( addr ) ) { //System.out.println( "mem set annote at " + addr + "=" + v ) ; Integer a = new Integer( addr ) ; Object oldv ; if ( v != null ) oldv = annotations.put( a, v ) ; else oldv = annotations.remove( a ) ; if ( oldv != v ) fireCellChange( this, addr, (MemoryAnnotation)oldv, new UndoAnnotationModification( addr, (MemoryAnnotation)oldv ) ) ; } } public MemoryAnnotation getAnnotationAt( int addr ) { MemoryAnnotation res ; res = (MemoryAnnotation)annotations.get( new Integer(addr) ) ; //System.out.println( "mem got annote at " + addr + "=" + res ) ; return res ; } public void ensureCapacity( int nCells ) { if ( nCells > (cells.length - nUsedForCode) ) { int newCells[] = new int[ 2 * (nCells + 10) + cells.length ] ; System.arraycopy( cells, 0, newCells, 0, cells.length ) ; cells = newCells ; } } public void deleteAt( int pos, int n ) { for( int i = pos + n ; i < nUsedForCode ; i++ ) cells[ i-n ] = cells[ i ] ; nUsedForCode -= n ; } public void reserveAt( int pos, int n ) { ensureCapacity( n ) ; for( int i = nUsedForCode - 1 ; i >= pos ; i-- ) { cells[ i+n ] = cells[ i ] ; } for( int i = 0 ; i < n ; i++ ) cells[ i+pos ] = 0 ; nUsedForCode += n ; } public void shiftAt( int pos, int n ) { if ( n > 0 ) reserveAt( pos, n ) ; else if ( n < 0 ) deleteAt( pos, -n ) ; } public void copyAt( int pos, int[] vals ) { for( int i = 0 ; i < vals.length ; i++ ) cells[ i+pos ] = vals[ i ] ; } public void insertAt( int pos, int[] vals ) { reserveAt( pos, vals.length ) ; copyAt( pos, vals ) ; } public String toString() { return "memory [0(" + Utils.asHex(nUsedForCode,false) + ").." + Utils.asHex(getCapacity()-1,false) + "]" ; } }
\ No newline at end of file
/** * Simple Stack Machine * * Written by Atze Dijkstra, atze@cs.uu.nl, * Copyright Utrecht University. * */ package nl.uu.cs.ssm ; import java.util.* ; public class Memory extends AbstractMemoryCellModel implements MemoryCellModel{ private int cells[] ; private Hashtable<Integer,Object> annotations ; private int nUsedForCode ; private Messenger messenger ; protected Memory( int initCapacity, Messenger m ) { messenger = m ; cells = new int[ initCapacity ] ; for ( int i = 0 ; i < cells.length ; i++ ) cells[ i ] = 0 ; reset() ; } public void reset() { nUsedForCode = 0 ; annotations = new Hashtable<Integer,Object>() ; for ( int i = 0 ; i < cells.length ; i++ ) setAt( i, 0 ) ; } public int getCapacity() { return cells.length ; } public int getUsedForCode() { return nUsedForCode ; } private boolean checkWithinMemory( int addr ) { boolean res ; if ( res = ( addr < 0 || addr >= cells.length ) ) { messenger.println ( java.text.MessageFormat.format ( "attempt to access location {0} outside {1}" , new Object[] { Utils.asHex(addr), ""+this } ) ) ; } return ! res ; } class UndoMemoryModification implements Modification { private int offset, value ; UndoMemoryModification( int o, int v ) { offset = o ; value = v ; } public void modify() { setAt( offset, value ) ; } } public void setAt( int addr, int v ) { if ( checkWithinMemory( addr ) ) { int oldv = cells[ addr ] ; cells[ addr ] = v ; fireCellChange( this, addr, oldv, new UndoMemoryModification( addr, oldv ) ) ; } } public void setAt( int addr, String v ) { setAt( addr, Utils.fromHex( v ) ) ; } public int getAt( int addr ) { int res = 0 ; if ( checkWithinMemory( addr ) ) { res = cells[ addr ] ; } return res ; } public int[] getAt( int addr, int len ) { int res[] = new int[ len ] ; for ( int i = 0 ; i < len && checkWithinMemory( addr + i ) ; i++ ) { res[ i ] = cells[ addr + i ] ; } return res ; } public String getAsHexAt( int addr ) { return Utils.asHex( getAt( addr ) ) ; } class UndoAnnotationModification implements Modification { private int offset ; private MemoryAnnotation value ; UndoAnnotationModification( int o, MemoryAnnotation v ) { offset = o ; value = v ; } public void modify() { setAnnotationAt( offset, value ) ; } } public void setAnnotationAt( int addr, MemoryAnnotation v ) { if ( checkWithinMemory( addr ) ) { //System.out.println( "mem set annote at " + addr + "=" + v ) ; Integer a = new Integer( addr ) ; Object oldv ; if ( v != null ) oldv = annotations.put( a, v ) ; else oldv = annotations.remove( a ) ; if ( oldv != v ) fireCellChange( this, addr, (MemoryAnnotation)oldv, new UndoAnnotationModification( addr, (MemoryAnnotation)oldv ) ) ; } } public MemoryAnnotation getAnnotationAt( int addr ) { MemoryAnnotation res ; res = (MemoryAnnotation)annotations.get( new Integer(addr) ) ; //System.out.println( "mem got annote at " + addr + "=" + res ) ; return res ; } public void ensureCapacity( int nCells ) { if ( nCells > (cells.length - nUsedForCode) ) { int newCells[] = new int[ 2 * (nCells + 10) + cells.length ] ; System.arraycopy( cells, 0, newCells, 0, cells.length ) ; cells = newCells ; } } public void deleteAt( int pos, int n ) { for( int i = pos + n ; i < nUsedForCode ; i++ ) cells[ i-n ] = cells[ i ] ; nUsedForCode -= n ; } public void reserveAt( int pos, int n ) { ensureCapacity( n ) ; for( int i = nUsedForCode - 1 ; i >= pos ; i-- ) { cells[ i+n ] = cells[ i ] ; } for( int i = 0 ; i < n ; i++ ) cells[ i+pos ] = 0 ; nUsedForCode += n ; } public void shiftAt( int pos, int n ) { if ( n > 0 ) reserveAt( pos, n ) ; else if ( n < 0 ) deleteAt( pos, -n ) ; } public void copyAt( int pos, int[] vals ) { for( int i = 0 ; i < vals.length ; i++ ) cells[ i+pos ] = vals[ i ] ; } public void insertAt( int pos, int[] vals ) { reserveAt( pos, vals.length ) ; copyAt( pos, vals ) ; } public String toString() { return "memory [0(" + Utils.asHex(nUsedForCode,false) + ").." + Utils.asHex(getCapacity()-1,false) + "]" ; } }
\ No newline at end of file
......
/** * Simple Stack Machine * * Written by Atze Dijkstra, atze@cs.uu.nl, * Copyright Utrecht University. * */ package nl.uu.cs.ssm ; import java.util.* ; public class MemoryCellEvent extends UndoableEvent{ public static final int CELL = 0 ; public static final int ANNOTATION = 1 ; public int cellIndex ; public Object oldCellValue ; public int event ; protected MemoryCellEvent( Object src, int which, int previous, Modification mdf ) { super( src, mdf ) ; event = CELL ; cellIndex = which ; oldCellValue = new Integer( previous ) ; } protected MemoryCellEvent( Object src, int which, MemoryAnnotation previous, Modification mdf ) { super( src, mdf ) ; event = ANNOTATION ; cellIndex = which ; oldCellValue = previous ; } public int getCellIndex() { return cellIndex ; } public int getOldCellValue() { return ((Integer)oldCellValue).intValue() ; } public MemoryAnnotation getOldAnnotation() { return (MemoryAnnotation)oldCellValue ; } public String toString() { return "MemCellEvent src=" + getSource() + " inx=" + cellIndex + " prev=" + oldCellValue ; }}
\ No newline at end of file
/** * Simple Stack Machine * * Written by Atze Dijkstra, atze@cs.uu.nl, * Copyright Utrecht University. * */ package nl.uu.cs.ssm ; import java.util.* ; public class MemoryCellEvent extends UndoableEvent{ private static final long serialVersionUID = 1L ; public static final int CELL = 0 ; public static final int ANNOTATION = 1 ; public int cellIndex ; public Object oldCellValue ; public int event ; protected MemoryCellEvent( Object src, int which, int previous, Modification mdf ) { super( src, mdf ) ; event = CELL ; cellIndex = which ; oldCellValue = new Integer( previous ) ; } protected MemoryCellEvent( Object src, int which, MemoryAnnotation previous, Modification mdf ) { super( src, mdf ) ; event = ANNOTATION ; cellIndex = which ; oldCellValue = previous ; } public int getCellIndex() { return cellIndex ; } public int getOldCellValue() { return ((Integer)oldCellValue).intValue() ; } public MemoryAnnotation getOldAnnotation() { return (MemoryAnnotation)oldCellValue ; } public String toString() { return "MemCellEvent src=" + getSource() + " inx=" + cellIndex + " prev=" + oldCellValue ; }}
\ No newline at end of file
......
/** * Simple Stack Machine * * Written by Atze Dijkstra, atze@cs.uu.nl, * Copyright Utrecht University. * */ package nl.uu.cs.ssm ; import java.util.* ;import java.awt.* ; public abstract class MetaInstruction{ private static Hashtable colorMap ; static { colorMap = new Hashtable() ; colorMap.put( "black" , Color.black ) ; colorMap.put( "blue" , Color.blue ) ; colorMap.put( "cyan" , Color.cyan ) ; colorMap.put( "darkGray" , Color.darkGray ) ; colorMap.put( "gray" , Color.gray ) ; colorMap.put( "green" , Color.green ) ; colorMap.put( "lightGray" , Color.lightGray ) ; colorMap.put( "magenta" , Color.magenta ) ; colorMap.put( "orange" , Color.orange ) ; colorMap.put( "pink" , Color.pink ) ; colorMap.put( "red" , Color.red ) ; colorMap.put( "yellow" , Color.yellow ) ; } protected Instruction instruction ; private MetaInstruction( Instruction instr ) { instruction = instr ; } public abstract void exec( MachineState machineState ) ; private static class Annote extends MetaInstruction { int register ; int loDispl, hiDispl ; Color color ; String text ; Annote( Instruction i, int r, int l, int h, Color c, String t ) { super( i ) ; register = r ; loDispl = l ; hiDispl = h ; color = c ; text = t ; } public void exec( MachineState machineState ) { Memory mem = machineState.getMemory() ; Registers regs = machineState.getRegisters() ; for ( int i = loDispl ; i <= hiDispl ; i++ ) { mem.setAnnotationAt( regs.getRegDispl( register, i ), new MemoryAnnotation( text, color ) ) ; } } public String toString() { return "Annote reg=" + register + " displ=" + loDispl + "/" + hiDispl + " col=" + color + " text=" + text ; } } public static MetaInstruction newAnnote( Instruction instr, Vector args ) { int r = Registers.findRegOfName( (String)args.elementAt(0) ) ; int l = Utils.fromHex( (String)args.elementAt(1) ) ; int h = Utils.fromHex( (String)args.elementAt(2) ) ; Color c = (Color)colorMap.get( (String)args.elementAt(3) ) ; String t = (String)args.elementAt(4) ; if ( r >= 0 && l <= h && c != null && t != null ) return new Annote( instr, r, l, h, c, t ) ; else return null ; } }
\ No newline at end of file
/** * Simple Stack Machine * * Written by Atze Dijkstra, atze@cs.uu.nl, * Copyright Utrecht University. * */ package nl.uu.cs.ssm ; import java.util.* ;import java.awt.* ; public abstract class MetaInstruction{ private static Hashtable<String,Color> colorMap ; static { colorMap = new Hashtable<String,Color>() ; colorMap.put( "black" , Color.black ) ; colorMap.put( "blue" , Color.blue ) ; colorMap.put( "cyan" , Color.cyan ) ; colorMap.put( "darkGray" , Color.darkGray ) ; colorMap.put( "gray" , Color.gray ) ; colorMap.put( "green" , Color.green ) ; colorMap.put( "lightGray" , Color.lightGray ) ; colorMap.put( "magenta" , Color.magenta ) ; colorMap.put( "orange" , Color.orange ) ; colorMap.put( "pink" , Color.pink ) ; colorMap.put( "red" , Color.red ) ; colorMap.put( "yellow" , Color.yellow ) ; } protected Instruction instruction ; private MetaInstruction( Instruction instr ) { instruction = instr ; } public abstract void exec( MachineState machineState ) ; private static class Annote extends MetaInstruction { int register ; int loDispl, hiDispl ; Color color ; String text ; Annote( Instruction i, int r, int l, int h, Color c, String t ) { super( i ) ; register = r ; loDispl = l ; hiDispl = h ; color = c ; text = t ; } public void exec( MachineState machineState ) { Memory mem = machineState.getMemory() ; Registers regs = machineState.getRegisters() ; for ( int i = loDispl ; i <= hiDispl ; i++ ) { mem.setAnnotationAt( regs.getRegDispl( register, i ), new MemoryAnnotation( text, color ) ) ; } } public String toString() { return "Annote reg=" + register + " displ=" + loDispl + "/" + hiDispl + " col=" + color + " text=" + text ; } } public static MetaInstruction newAnnote( Instruction instr, Vector args ) { int r = Registers.findRegOfName( (String)args.elementAt(0) ) ; int l = Utils.fromHex( (String)args.elementAt(1) ) ; int h = Utils.fromHex( (String)args.elementAt(2) ) ; Color c = (Color)colorMap.get( (String)args.elementAt(3) ) ; String t = (String)args.elementAt(4) ; if ( r >= 0 && l <= h && c != null && t != null ) return new Annote( instr, r, l, h, c, t ) ; else return null ; } }
\ No newline at end of file
......
/** * Simple Stack Machine * * Written by Atze Dijkstra, atze@cs.uu.nl, * Copyright Utrecht University. * */ package nl.uu.cs.ssm ; import java.util.* ; public class Model{ private Vector listeners = new Vector() ; protected void addListener( EventListener l ) { listeners.addElement( l ) ; } protected void removeListener( EventListener l ) { listeners.removeElement( l ) ; } protected Enumeration getListeners() { return listeners.elements() ; } }
\ No newline at end of file
/** * Simple Stack Machine * * Written by Atze Dijkstra, atze@cs.uu.nl, * Copyright Utrecht University. * */ package nl.uu.cs.ssm ; import java.util.* ; public class Model{ private Vector<EventListener> listeners = new Vector<EventListener>() ; protected void addListener( EventListener l ) { listeners.addElement( l ) ; } protected void removeListener( EventListener l ) { listeners.removeElement( l ) ; } protected Enumeration getListeners() { return listeners.elements() ; } }
\ No newline at end of file
......
/** * Simple Stack Machine * * Written by Atze Dijkstra, atze@cs.uu.nl, * Copyright Utrecht University. * */ package nl.uu.cs.ssm ; import java.util.* ; public class Registers extends AbstractMemoryCellModel implements MemoryCellModel{ public static final int PC = 0 ; public static final int SP = 1 ; public static final int MP = 2 ; //public static final int RR = 3 ; private static final int nrRegs = 8 ; private static final String[] regNames = { "R0", "R1", "R2", "R3", "R4", "R5", "R6", "R7" } ; private static final String[] regNamesAlias = { "PC", "SP", "MP", "RR" } ; //private MemoryCell cells[] ; private int cells[] ; private Memory memory ; private Messenger messenger ; protected Registers( Memory m, Messenger msgr ) { messenger = msgr ; cells = new int[ nrRegs ] ; for ( int i = 0 ; i < cells.length ; i++ ) //cells[ i ] = new MemoryCell() ; cells[ i ] = 0 ; memory = m ; reset() ; } public void reset() { for ( int i = 0 ; i < cells.length ; i++ ) //cells[ i ].setValue( 0 ) ; cells[ i ] = 0 ; } public static int getNrRegs( ) { return nrRegs ; } /* private static String[] getRegNames( ) { return regNames ; } */ public static String getRegName( int r ) { return (r < regNames.length && r >= 0) ? regNames[ r ] : ("R"+r) ; } public static String getRegOrAliasName( int r ) { return r < regNamesAlias.length ? regNamesAlias[r] : getRegName( r ) ; } public static String getRegNAliasName( int r ) { return getRegName(r) + ( r < regNamesAlias.length ? ("(" + regNamesAlias[r] + ")") : "" ) ; } public static Enumeration getRegNAliasNames( ) { Vector v = new Vector() ; Utils.addAllTo( v, Utils.asVector( regNames ) ) ; Utils.addAllTo( v, Utils.asVector( regNamesAlias ) ) ; return v.elements() ; } public static int findRegOfName( String nm ) // should be in some kinda environment { for ( int i = 0 ; i < regNames.length ; i++ ) { if ( regNames[i].equals( nm ) ) return i ; } for ( int i = 0 ; i < regNamesAlias.length ; i++ ) { if ( regNamesAlias[i].equals( nm ) ) return i ; } return -1 ; } private boolean checkWithinMemory( int r ) { boolean res ; if ( res = ( r < 0 || r >= cells.length ) ) { messenger.println ( java.text.MessageFormat.format ( "attempt to access nonexisting register {0,number,integer}" , new Object[] { new Integer(r) } ) ) ; } return ! res ; } public int getReg( int r ) { int res = 0 ; if ( checkWithinMemory( r ) ) { res = cells[ r ] ; } return res ; } public int getRegDispl( int r, int d ) { return getReg( r ) + d ; } public int getRegDisplInd( int r, int d ) { return memory.getAt( getRegDispl( r, d ) ) ; } public int getRegInd( int r ) { return getRegDisplInd( r, 0 ) ; } class UndoRegistersModification implements Modification { private int offset, value ; UndoRegistersModification( int o, int v ) { offset = o ; value = v ; } public void modify() { setReg( offset, value ) ; } } public void setReg( int r, int v ) { if ( checkWithinMemory( r ) ) { int oldv = cells[ r ] ; cells[ r ] = v ; fireCellChange( this, r, oldv, new UndoRegistersModification( r, oldv ) ) ; } } public void setRegDisplInd( int r, int d, int v ) { memory.setAt( getRegDispl( r, d ), v ) ; } public void setRegInd( int r, int v ) { setRegDisplInd( r, 0, v ) ; } public int swapReg( int r, int v ) { int oldVal = getReg( r ) ; setReg( r, v ) ; return oldVal ; } public void adjustReg( int r, int v ) { setReg( r, getReg( r ) + v ) ; } public void setPC( int v ) { setReg( PC, v ) ; } public int getPC( ) { return getReg( PC ) ; } public void adjustPC( int v ) { setPC( getPC() + v ) ; } public void setSP( int v ) { setReg( SP, v ) ; } public int getSP( ) { return getReg( SP ) ; } public void adjustSP( int v ) { setSP( getSP() + v ) ; } public void setMP( int v ) { setReg( MP, v ) ; } public int getMP( ) { return getReg( MP ) ; } public void adjustMP( int v ) { setMP( getMP() + v ) ; } public int getTOS() { return getRegInd( SP ) ; } public String toString() { return "Register PC=" + getReg( PC ) + " SP=" + getReg( SP ) + " MP=" + getReg( MP ) ; } }
\ No newline at end of file
/** * Simple Stack Machine * * Written by Atze Dijkstra, atze@cs.uu.nl, * Copyright Utrecht University. * */ package nl.uu.cs.ssm ; import java.util.* ; public class Registers extends AbstractMemoryCellModel implements MemoryCellModel{ public static final int PC = 0 ; public static final int SP = 1 ; public static final int MP = 2 ; //public static final int RR = 3 ; private static final int nrRegs = 8 ; private static final String[] regNames = { "R0", "R1", "R2", "R3", "R4", "R5", "R6", "R7" } ; private static final String[] regNamesAlias = { "PC", "SP", "MP", "RR" } ; //private MemoryCell cells[] ; private int cells[] ; private Memory memory ; private Messenger messenger ; protected Registers( Memory m, Messenger msgr ) { messenger = msgr ; cells = new int[ nrRegs ] ; for ( int i = 0 ; i < cells.length ; i++ ) //cells[ i ] = new MemoryCell() ; cells[ i ] = 0 ; memory = m ; reset() ; } public void reset() { for ( int i = 0 ; i < cells.length ; i++ ) //cells[ i ].setValue( 0 ) ; cells[ i ] = 0 ; } public static int getNrRegs( ) { return nrRegs ; } /* private static String[] getRegNames( ) { return regNames ; } */ public static String getRegName( int r ) { return (r < regNames.length && r >= 0) ? regNames[ r ] : ("R"+r) ; } public static String getRegOrAliasName( int r ) { return r < regNamesAlias.length ? regNamesAlias[r] : getRegName( r ) ; } public static String getRegNAliasName( int r ) { return getRegName(r) + ( r < regNamesAlias.length ? ("(" + regNamesAlias[r] + ")") : "" ) ; } public static Enumeration<String> getRegNAliasNames( ) { Vector<String> v = new Vector<String>() ; Utils.addAllTo( v, Utils.asVector( regNames ) ) ; Utils.addAllTo( v, Utils.asVector( regNamesAlias ) ) ; return v.elements() ; } public static int findRegOfName( String nm ) // should be in some kinda environment { for ( int i = 0 ; i < regNames.length ; i++ ) { if ( regNames[i].equals( nm ) ) return i ; } for ( int i = 0 ; i < regNamesAlias.length ; i++ ) { if ( regNamesAlias[i].equals( nm ) ) return i ; } return -1 ; } private boolean checkWithinMemory( int r ) { boolean res ; if ( res = ( r < 0 || r >= cells.length ) ) { messenger.println ( java.text.MessageFormat.format ( "attempt to access nonexisting register {0,number,integer}" , new Object[] { new Integer(r) } ) ) ; } return ! res ; } public int getReg( int r ) { int res = 0 ; if ( checkWithinMemory( r ) ) { res = cells[ r ] ; } return res ; } public int getRegDispl( int r, int d ) { return getReg( r ) + d ; } public int getRegDisplInd( int r, int d ) { return memory.getAt( getRegDispl( r, d ) ) ; } public int getRegInd( int r ) { return getRegDisplInd( r, 0 ) ; } class UndoRegistersModification implements Modification { private int offset, value ; UndoRegistersModification( int o, int v ) { offset = o ; value = v ; } public void modify() { setReg( offset, value ) ; } } public void setReg( int r, int v ) { if ( checkWithinMemory( r ) ) { int oldv = cells[ r ] ; cells[ r ] = v ; fireCellChange( this, r, oldv, new UndoRegistersModification( r, oldv ) ) ; } } public void setRegDisplInd( int r, int d, int v ) { memory.setAt( getRegDispl( r, d ), v ) ; } public void setRegInd( int r, int v ) { setRegDisplInd( r, 0, v ) ; } public int swapReg( int r, int v ) { int oldVal = getReg( r ) ; setReg( r, v ) ; return oldVal ; } public void adjustReg( int r, int v ) { setReg( r, getReg( r ) + v ) ; } public void setPC( int v ) { setReg( PC, v ) ; } public int getPC( ) { return getReg( PC ) ; } public void adjustPC( int v ) { setPC( getPC() + v ) ; } public void setSP( int v ) { setReg( SP, v ) ; } public int getSP( ) { return getReg( SP ) ; } public void adjustSP( int v ) { setSP( getSP() + v ) ; } public void setMP( int v ) { setReg( MP, v ) ; } public int getMP( ) { return getReg( MP ) ; } public void adjustMP( int v ) { setMP( getMP() + v ) ; } public int getTOS() { return getRegInd( SP ) ; } public String toString() { return "Register PC=" + getReg( PC ) + " SP=" + getReg( SP ) + " MP=" + getReg( MP ) ; } }
\ No newline at end of file
......
......@@ -12,6 +12,8 @@ import java.util.* ;
public class UndoableEvent extends EventObject
{
private static final long serialVersionUID = 1L ;
private Modification undoModification ;
protected UndoableEvent( Object src, Modification mdf )
......@@ -25,4 +27,4 @@ public class UndoableEvent extends EventObject
return undoModification ;
}
}
\ No newline at end of file
}
/** * Simple Stack Machine * * Written by Atze Dijkstra, atze@cs.uu.nl, * Copyright Utrecht University. * */ package nl.uu.cs.ssm ; import java.util.* ;import java.io.* ;import java.awt.* ;import javax.swing.* ; public class Utils{ private static final String zeroChars = "00000000" ; private static final String hexReprPrefix = "0x" ; public static String asHex( int i, boolean hexIsDefault, boolean signed, boolean padZero ) { String sign = "" ; if ( signed && i < 0 ) { sign = "-" ; i = -i ; } String s = Integer.toHexString( i ) ; return sign + ( hexIsDefault ? ( padZero ? zeroChars.substring( s.length() ) : "" ) : ( i < 10 ? "" : "0x" ) ) + s ; } public static String asHex( int i, boolean hexIsDefault ) { return asHex( i, hexIsDefault, false, true ) ; } public static String asHex( int i ) { return asHex( i, true, false, true ) ; } public static void addAllTo( Vector v, Enumeration es ) { while( es.hasMoreElements() ) v.addElement( es.nextElement() ) ; } public static void addAllTo( Vector v, Vector es ) { addAllTo( v, es.elements() ) ; } public static Vector asVector( Object[] os ) { Vector v = new Vector() ; for ( int i = 0 ; i < os.length ; i++ ) v.addElement( os[i] ) ; return v ; } public static Vector splitAt( String s, char sep ) { Vector v = new Vector() ; while( true ) { int i = s.indexOf( sep ) ; if ( i >= 0 ) { v.addElement( s.substring( 0, i ) ) ; s = s.substring( i+1 ) ; } else { if ( s.length() > 0 ) v.addElement( s ) ; break ; } } return v ; } private static int toDigit( char c ) { if (c >= '0' && c <= '9') return c - '0' ; if (c >= 'a' && c <= 'f') return c - 'a' + 10 ; if (c >= 'A' && c <= 'F') return c - 'A' + 10 ; return -1 ; } public static boolean isNumberRepr( String s, boolean hexIsDefault ) { int radix = hexIsDefault ? 16 : 10 ; int pos = 0 ; if ( s.charAt( 0 ) == '-' ) pos += 1 ; if ( ( ! hexIsDefault ) && s.regionMatches( pos, hexReprPrefix, 0, 2 ) ) pos += 2 ; int max = s.length() ; for( ; pos < max ; pos++ ) { int d = toDigit( s.charAt( pos ) ) ; if ( d < 0 || d >= radix ) return false ; } return true ; } public static int fromHex( String s, boolean hexIsDefault ) { int radix = hexIsDefault ? 16 : 10 ; int res = 0 ; int pos = 0 ; int sign = 1 ; if ( s.charAt( 0 ) == '-' ) { pos += 1 ; sign = -1 ; } if ( ( ! hexIsDefault ) && s.regionMatches( pos, hexReprPrefix, 0, 2 ) ) { pos += 2 ; radix = 16 ; } int max = s.length() ; for( ; pos < max ; pos++ ) { int d = toDigit( s.charAt( pos ) ) ; //System.out.println( "from hex " + s + " dig " + s.charAt( pos ) + "=" + d ) ; if ( ( d < 0 ) || ( radix <= d ) ) return res ; res = res * radix + d ; } return res * sign ; } public static int fromHex( String s ) { return fromHex( s, true ) ; } public static String repeat( String s, int l ) { StringBuffer b = new StringBuffer() ; for ( int i = 0 ; i < l ; i++ ) b.append( s ) ; return b.toString() ; } public static class ExtensionFileFilter extends javax.swing.filechooser.FileFilter { private Vector extensions = new Vector() ; public ExtensionFileFilter( Enumeration exts ) { while ( exts.hasMoreElements() ) addExtension( (String)exts.nextElement() ) ; } public ExtensionFileFilter( String exts ) { this( new StringTokenizer( exts ) ) ; } public void addExtension( String ext ) { extensions.addElement( ext ) ; } public boolean accept( File f ) { boolean res = true ; if ( ! f.isDirectory() ) { String extension = Utils.getExtension( f ) ; res = (extension != null) && (extensions.contains( extension )) ; } return res ; } public String getDescription() { return ppList( extensions.elements(), "", ", ", "" ) + " files" ; } } /* * Get the extension of a file. */ public static String getExtension( File f ) { String ext = null ; String s = f.getName() ; int i = s.lastIndexOf( '.' ) ; if (i > 0 && i < s.length() - 1) { ext = s.substring( i+1 ).toLowerCase(); } return ext; } public static String ppList( Object l[] ) { return ppList( Arrays.asList( l ) ) ; } public static String ppList( java.util.List l ) { return ppList( Collections.enumeration( l ), "[", ",", "]" ) ; } public static String ppList( Enumeration e, String o, String s, String c ) { StringBuffer b = new StringBuffer() ; b.append( o ) ; if ( e.hasMoreElements() ) { b.append( e.nextElement().toString() ) ; while ( e.hasMoreElements() ) { b.append( s ) ; b.append( e.nextElement().toString() ) ; } } b.append( c ) ; return b.toString() ; } public static int indexOf( int a[], int v ) { for ( int i = 0 ; i < a.length ; i++ ) if ( a[i] == v ) return v ; return -1 ; } public static boolean contains( int a[], int v ) { return indexOf( a, v ) >= 0 ; } /** * Scroll a component contained in a JScrollPane to its end */ public static void scrollComponentTo( JComponent c, Rectangle r ) { int extraHeight = 40 ; // 2*r.height ; Rectangle rr = new Rectangle( r.x, r.y-extraHeight, r.width, 2*extraHeight+r.height ) ; Rectangle rrr = rr.intersection( c.getBounds() ) ; //System.out.println( "rr=" + rr + ", rrr=" + rrr + ", bounds=" + c.getBounds() ) ; if ( rrr.height > 0 ) c.scrollRectToVisible( rrr ) ; } /** * Scroll a component contained in a JScrollPane to its end */ public static void scrollComponentToEnd( JComponent c ) { Rectangle r = c.getBounds() ; scrollComponentTo( c, new Rectangle( 0, r.height-2, r.width, 2 ) ) ; } }
\ No newline at end of file
/** * Simple Stack Machine * * Written by Atze Dijkstra, atze@cs.uu.nl, * Copyright Utrecht University. * */ package nl.uu.cs.ssm ; import java.util.* ;import java.io.* ;import java.awt.* ;import javax.swing.* ; public class Utils{ private static final String zeroChars = "00000000" ; private static final String hexReprPrefix = "0x" ; public static String asHex( int i, boolean hexIsDefault, boolean signed, boolean padZero ) { String sign = "" ; if ( signed && i < 0 ) { sign = "-" ; i = -i ; } String s = Integer.toHexString( i ) ; return sign + ( hexIsDefault ? ( padZero ? zeroChars.substring( s.length() ) : "" ) : ( i < 10 ? "" : "0x" ) ) + s ; } public static String asHex( int i, boolean hexIsDefault ) { return asHex( i, hexIsDefault, false, true ) ; } public static String asHex( int i ) { return asHex( i, true, false, true ) ; } public static <T> void addAllTo( Vector<T> v, Enumeration<T> es ) { while( es.hasMoreElements() ) v.addElement( es.nextElement() ) ; } public static <T> void addAllTo( Vector<T> v, Vector<T> es ) { addAllTo( v, es.elements() ) ; } public static <T> Vector<T> asVector( T[] os ) { Vector<T> v = new Vector<T>() ; for ( int i = 0 ; i < os.length ; i++ ) v.addElement( os[i] ) ; return v ; } public static Vector<String> splitAt( String s, char sep ) { Vector<String> v = new Vector<String>() ; while( true ) { int i = s.indexOf( sep ) ; if ( i >= 0 ) { v.addElement( s.substring( 0, i ) ) ; s = s.substring( i+1 ) ; } else { if ( s.length() > 0 ) v.addElement( s ) ; break ; } } return v ; } private static int toDigit( char c ) { if (c >= '0' && c <= '9') return c - '0' ; if (c >= 'a' && c <= 'f') return c - 'a' + 10 ; if (c >= 'A' && c <= 'F') return c - 'A' + 10 ; return -1 ; } public static boolean isNumberRepr( String s, boolean hexIsDefault ) { int radix = hexIsDefault ? 16 : 10 ; int pos = 0 ; if ( s.charAt( 0 ) == '-' ) pos += 1 ; if ( ( ! hexIsDefault ) && s.regionMatches( pos, hexReprPrefix, 0, 2 ) ) pos += 2 ; int max = s.length() ; for( ; pos < max ; pos++ ) { int d = toDigit( s.charAt( pos ) ) ; if ( d < 0 || d >= radix ) return false ; } return true ; } public static int fromHex( String s, boolean hexIsDefault ) { int radix = hexIsDefault ? 16 : 10 ; int res = 0 ; int pos = 0 ; int sign = 1 ; if ( s.charAt( 0 ) == '-' ) { pos += 1 ; sign = -1 ; } if ( ( ! hexIsDefault ) && s.regionMatches( pos, hexReprPrefix, 0, 2 ) ) { pos += 2 ; radix = 16 ; } int max = s.length() ; for( ; pos < max ; pos++ ) { int d = toDigit( s.charAt( pos ) ) ; //System.out.println( "from hex " + s + " dig " + s.charAt( pos ) + "=" + d ) ; if ( ( d < 0 ) || ( radix <= d ) ) return res ; res = res * radix + d ; } return res * sign ; } public static int fromHex( String s ) { return fromHex( s, true ) ; } public static String repeat( String s, int l ) { StringBuffer b = new StringBuffer() ; for ( int i = 0 ; i < l ; i++ ) b.append( s ) ; return b.toString() ; } public static class ExtensionFileFilter extends javax.swing.filechooser.FileFilter { private Vector<Object> extensions = new Vector<Object>() ; public ExtensionFileFilter( Enumeration exts ) { while ( exts.hasMoreElements() ) addExtension( (String)exts.nextElement() ) ; } public ExtensionFileFilter( String exts ) { this( new StringTokenizer( exts ) ) ; } public void addExtension( String ext ) { extensions.addElement( ext ) ; } public boolean accept( File f ) { boolean res = true ; if ( ! f.isDirectory() ) { String extension = Utils.getExtension( f ) ; res = (extension != null) && (extensions.contains( extension )) ; } return res ; } public String getDescription() { return ppList( extensions.elements(), "", ", ", "" ) + " files" ; } } /* * Get the extension of a file. */ public static String getExtension( File f ) { String ext = null ; String s = f.getName() ; int i = s.lastIndexOf( '.' ) ; if (i > 0 && i < s.length() - 1) { ext = s.substring( i+1 ).toLowerCase(); } return ext; } public static String ppList( Object l[] ) { return ppList( Arrays.asList( l ) ) ; } public static String ppList( java.util.List<Object> l ) { return ppList( Collections.enumeration( l ), "[", ",", "]" ) ; } public static String ppList( Enumeration<Object> e, String o, String s, String c ) { StringBuffer b = new StringBuffer() ; b.append( o ) ; if ( e.hasMoreElements() ) { b.append( e.nextElement().toString() ) ; while ( e.hasMoreElements() ) { b.append( s ) ; b.append( e.nextElement().toString() ) ; } } b.append( c ) ; return b.toString() ; } public static int indexOf( int a[], int v ) { for ( int i = 0 ; i < a.length ; i++ ) if ( a[i] == v ) return v ; return -1 ; } public static boolean contains( int a[], int v ) { return indexOf( a, v ) >= 0 ; } /** * Scroll a component contained in a JScrollPane to its end */ public static void scrollComponentTo( JComponent c, Rectangle r ) { int extraHeight = 40 ; // 2*r.height ; Rectangle rr = new Rectangle( r.x, r.y-extraHeight, r.width, 2*extraHeight+r.height ) ; Rectangle rrr = rr.intersection( c.getBounds() ) ; //System.out.println( "rr=" + rr + ", rrr=" + rrr + ", bounds=" + c.getBounds() ) ; if ( rrr.height > 0 ) c.scrollRectToVisible( rrr ) ; } /** * Scroll a component contained in a JScrollPane to its end */ public static void scrollComponentToEnd( JComponent c ) { Rectangle r = c.getBounds() ; scrollComponentTo( c, new Rectangle( 0, r.height-2, r.width, 2 ) ) ; } }
\ 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.util.* ; import nl.uu.cs.ssm.* ; class AssemblyParseResult { protected int lineNr ; protected String message ; protected Vector definedLabels ; protected Vector instrNArgs ; protected AssemblyParseResult( int l, String m, String lb, Vector ia ) { definedLabels = new Vector() ; addInfo( l, m, lb, ia ) ; } protected AssemblyParseResult addInfo( int l, String m, String lb, Vector ia ) { lineNr = l ; message = m ; if ( lb != null ) definedLabels.addElement( lb ) ; instrNArgs = ia ; return this ; } public String toString() { return "line " + lineNr + "(" + message + "), " + definedLabels + ": " + instrNArgs ; } public void addLabels( Vector ls ) { Utils.addAllTo( definedLabels, ls.elements() ) ; } }
\ 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.util.* ; import nl.uu.cs.ssm.* ; class AssemblyParseResult { protected int lineNr ; protected String message ; protected Vector<String> definedLabels ; protected Vector<String> instrNArgs ; protected AssemblyParseResult( int l, String m, String lb, Vector<String> ia ) { definedLabels = new Vector<String>() ; addInfo( l, m, lb, ia ) ; } protected AssemblyParseResult addInfo( int l, String m, String lb, Vector<String> ia ) { lineNr = l ; message = m ; if ( lb != null ) definedLabels.addElement( lb ) ; instrNArgs = ia ; return this ; } public String toString() { return "line " + lineNr + "(" + message + "), " + definedLabels + ": " + instrNArgs ; } public void addLabels( Vector<String> ls ) { Utils.addAllTo( definedLabels, ls.elements() ) ; } }
\ 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.* ;import java.util.* ; public class AssemblyParser { private StreamTokenizer tokens ; private int tok ; protected AssemblyParser( Reader input ) { tokens = new StreamTokenizer( input ) ; tokens.resetSyntax() ; tokens.wordChars( '0', '9' ) ; tokens.wordChars( 'a', 'z' ) ; tokens.wordChars( 'A', 'Z' ) ; tokens.wordChars( 0xA0, 0xF0 ) ; tokens.wordChars( '_', '_' ) ; tokens.wordChars( '-', '-' ) ; tokens.whitespaceChars( 0x00, 0x20 ) ; tokens.commentChar( ';' ) ; tokens.quoteChar( '"' ) ; tokens.eolIsSignificant( true ) ; tokens.slashSlashComments( true ) ; next() ; } private void next() { try { if ( ! isAtEOF() ) tok = tokens.nextToken() ; } catch ( IOException ex ) { tok = tokens.TT_EOF ; } } public boolean isAtEOF() { return tok == tokens.TT_EOF ; } private boolean isAtEOL() { return tok == tokens.TT_EOL || isAtEOF() ; } protected AssemblyParseResult parse1Line( AssemblyParseResult prevAPR ) { int lineNr = tokens.lineno() ; String label = null ; String msg = null ; Vector instrNArgs = new Vector() ; if ( ! isAtEOL() ) { if ( tok == tokens.TT_WORD ) { String s = tokens.sval ; next() ; if ( tok == ':' ) { label = s ; next() ; } else { instrNArgs.addElement( s ) ; } while( ! isAtEOL() ) { if ( tok == tokens.TT_WORD || tok == '"' ) { instrNArgs.addElement( tokens.sval ) ; } else if ( tok == tokens.TT_NUMBER ) { msg = "did not expect number " + tokens.nval ; } else { msg = "did not expect `" + (char)tok + "'" ; } next() ; } } else { msg = "expected label or instruction" ; } } next() ; if ( prevAPR == null ) return new AssemblyParseResult( lineNr, msg, label, instrNArgs ) ; else return prevAPR.addInfo( lineNr, msg, label, instrNArgs ) ; } }
\ 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.* ;import java.util.* ; public class AssemblyParser { private StreamTokenizer tokens ; private int tok ; protected AssemblyParser( Reader input ) { tokens = new StreamTokenizer( input ) ; tokens.resetSyntax() ; tokens.wordChars( '0', '9' ) ; tokens.wordChars( 'a', 'z' ) ; tokens.wordChars( 'A', 'Z' ) ; tokens.wordChars( 0xA0, 0xF0 ) ; tokens.wordChars( '_', '_' ) ; tokens.wordChars( '-', '-' ) ; tokens.whitespaceChars( 0x00, 0x20 ) ; tokens.commentChar( ';' ) ; tokens.quoteChar( '"' ) ; tokens.eolIsSignificant( true ) ; tokens.slashSlashComments( true ) ; next() ; } private void next() { try { if ( ! isAtEOF() ) tok = tokens.nextToken() ; } catch ( IOException ex ) { tok = tokens.TT_EOF ; } } public boolean isAtEOF() { return tok == tokens.TT_EOF ; } private boolean isAtEOL() { return tok == tokens.TT_EOL || isAtEOF() ; } protected AssemblyParseResult parse1Line( AssemblyParseResult prevAPR ) { int lineNr = tokens.lineno() ; String label = null ; String msg = null ; Vector<String> instrNArgs = new Vector<String>() ; if ( ! isAtEOL() ) { if ( tok == tokens.TT_WORD ) { String s = tokens.sval ; next() ; if ( tok == ':' ) { label = s ; next() ; } else { instrNArgs.addElement( s ) ; } while( ! isAtEOL() ) { if ( tok == tokens.TT_WORD || tok == '"' ) { instrNArgs.addElement( tokens.sval ) ; } else if ( tok == tokens.TT_NUMBER ) { msg = "did not expect number " + tokens.nval ; } else { msg = "did not expect `" + (char)tok + "'" ; } next() ; } } else { msg = "expected label or instruction" ; } } next() ; if ( prevAPR == null ) return new AssemblyParseResult( lineNr, msg, label, instrNArgs ) ; else return prevAPR.addInfo( lineNr, msg, label, instrNArgs ) ; } }
\ No newline at end of file
......
This diff is collapsed.
/* 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
/* 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<HelpSupplier> helpSuppliers ; public Help() { helpSuppliers = new Vector<HelpSupplier>() ; } public void addHelpSupplier( HelpSupplier hs ) { helpSuppliers.addElement( hs ) ; } private static void addSorted( Vector<HelpTopic> 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<HelpTopic> findTopics( String key ) { Vector<HelpTopic> topics = new Vector<HelpTopic>() ; if ( key != null ) key = key.toLowerCase() ; for ( Enumeration<HelpSupplier> hss = helpSuppliers.elements() ; hss.hasMoreElements() ; ) { HelpSupplier hs = (HelpSupplier)hss.nextElement() ; for ( Enumeration<String> 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
/* 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<String> 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<String,String> ts = new Hashtable<String,String>() ; 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<String>( ) ; Utils.addAllTo( topics, ts.elements() ) ; } } public Enumeration<String> 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<String> splitByComma( String s ) { Vector<String> v = Utils.splitAt( s, SEP ) ; Vector<String> vv = new Vector<String>() ; for ( Enumeration<String> 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
......
/* 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
/* 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<String,Label> labels ; private Vector<UnresolvedLabelUsage> unresolvedUsages ; private CodeRowSupplier codeSupplier ; protected Labels( CodeRowSupplier cs ) { codeSupplier = cs ; reset(null) ; } protected void reset( Enumeration regNames ) { if ( regNames != null ) { labels = new Hashtable<String,Label>() ; for ( ; regNames.hasMoreElements() ; ) { String nm = (String)regNames.nextElement() ; defineRegName( nm, nl.uu.cs.ssm.Registers.findRegOfName( nm ) ) ; // not neat, ??? TBD } } unresolvedUsages = new Vector<UnresolvedLabelUsage>() ; } 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<Label> 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<UnresolvedLabelUsage> stillUnresolved = new Vector<UnresolvedLabelUsage>() ; for ( Enumeration<UnresolvedLabelUsage> 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
......
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
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 { private static final long serialVersionUID = 1L ; // 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
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
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