Commit def72399 authored by thomas@cs.ru.nl's avatar thomas@cs.ru.nl
Browse files

Fixed several Java generics warnings (where easily possible)

parent fbcf1ee8
/** * Simple Stack Machine * * Written by Atze Dijkstra, atze@cs.uu.nl, * Copyright Utrecht University. * */ package nl.uu.cs.ssm ; import java.io.FileWriter;import java.io.IOException;import java.io.StringWriter;import java.io.Writer;import java.util.Enumeration; public abstract class HelpAccumulator{ //private StringBuffer accumulator ; protected Writer accumulator ; public HelpAccumulator( String fileName ) { try { //System.out.println( "help acc " + fileName ) ; if ( fileName == null ) accumulator = new StringWriter() ; else accumulator = new FileWriter( fileName ) ; } catch( IOException ex ) { ex.printStackTrace() ; accumulator = null ; } } protected boolean canWrite() { return accumulator != null ; } public abstract void beginHeadTitleBody( String t ) ; public abstract void endHeadTitleBody() ; public abstract void anchor( String a ) ; public abstract void a( String href, String title ) ; public abstract void anchorA( String href, String title ) ; public abstract void beginCentered() ; public abstract void endCentered() ; public abstract void beginPara() ; public abstract void endPara() ; public void para( String text ) { beginPara( ) ; append( text ) ; endPara() ; } public abstract void beginSectionTitle() ; public abstract void endSectionTitle() ; public void sectionTitle( String s ) { beginSectionTitle() ; append( s ) ; endSectionTitle() ; } public abstract void beginSubsectionTitle() ; public abstract void endSubsectionTitle() ; public void subsectionTitle( String s ) { beginSubsectionTitle() ; append( s ) ; endSubsectionTitle() ; } public abstract void beginTable( int nCols, int widthPerc, int[] colWidthWeight ) ; public abstract void endTable() ; public abstract void beginTableRow( ) ; public abstract void endTableRow() ; public abstract void beginTableData( ) ; public abstract void endTableData() ; public void tableRow( Object[] data ) // not recursive (yet) { beginTableRow() ; for ( int i = 0 ; i < data.length ; i++ ) { beginTableData() ; append( data[i].toString() ) ; endTableData() ; } endTableRow() ; } public void tableHeaderRow( Object[] data ) // not recursive (yet) { beginTableRow() ; for ( int i = 0 ; i < data.length ; i++ ) { beginTableData() ; bold( data[i].toString() ) ; endTableData() ; } endTableRow() ; } public abstract void beginBlockQuote( ) ; public abstract void endBlockQuote() ; public abstract void linebreak() ; public void append( String o ) { if ( ! canWrite() ) return ; try { accumulator.write( o ) ; } catch ( IOException ex ) { accumulator = null ; } } public void append( char o ) { append( "" + o ) ; } public void append( int o ) { append( "" + o ) ; } public void nl( ) { append( '\n' ) ; } //public abstract void font( String f, String s ) ; public abstract void bold( String s ) ; public void string( String s ) { append( "\"" ) ; append( s ) ; append( "\"" ) ; } //public abstract void define( String nm, String val ) ; public void close( ) { try { accumulator.close() ; } catch ( IOException ex ) { } } public String toString() { close() ; if ( accumulator instanceof StringWriter ) return accumulator.toString() ; else return "" ; } public abstract void mathEquationList( Enumeration e, char subscript ) ; public abstract void beginVerbatimList() ; public abstract void endVerbatimList() ; public abstract void verbatimLine( String s ) ; public void verbatimList( Enumeration e ) { if ( ! e.hasMoreElements() ) return ; beginVerbatimList() ; for ( ; e.hasMoreElements() ; ) { verbatimLine( (String)e.nextElement() ) ; } endVerbatimList() ; } public abstract void beginAttributeList( ) ; public abstract void endAttributeList( ) ; public abstract void attributeName( String s ) ; public abstract void beginAttributeValue( ) ; public abstract void endAttributeValue( ) ; public String reprAsHex( int v ) { return Utils.asHex( v, 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.io.FileWriter;import java.io.IOException;import java.io.StringWriter;import java.io.Writer;import java.util.Enumeration; public abstract class HelpAccumulator{ //private StringBuffer accumulator ; protected Writer accumulator ; public HelpAccumulator( String fileName ) { try { //System.out.println( "help acc " + fileName ) ; if ( fileName == null ) accumulator = new StringWriter() ; else accumulator = new FileWriter( fileName ) ; } catch( IOException ex ) { ex.printStackTrace() ; accumulator = null ; } } protected boolean canWrite() { return accumulator != null ; } public abstract void beginHeadTitleBody( String t ) ; public abstract void endHeadTitleBody() ; public abstract void anchor( String a ) ; public abstract void a( String href, String title ) ; public abstract void anchorA( String href, String title ) ; public abstract void beginCentered() ; public abstract void endCentered() ; public abstract void beginPara() ; public abstract void endPara() ; public void para( String text ) { beginPara( ) ; append( text ) ; endPara() ; } public abstract void beginSectionTitle() ; public abstract void endSectionTitle() ; public void sectionTitle( String s ) { beginSectionTitle() ; append( s ) ; endSectionTitle() ; } public abstract void beginSubsectionTitle() ; public abstract void endSubsectionTitle() ; public void subsectionTitle( String s ) { beginSubsectionTitle() ; append( s ) ; endSubsectionTitle() ; } public abstract void beginTable( int nCols, int widthPerc, int[] colWidthWeight ) ; public abstract void endTable() ; public abstract void beginTableRow( ) ; public abstract void endTableRow() ; public abstract void beginTableData( ) ; public abstract void endTableData() ; public void tableRow( Object[] data ) // not recursive (yet) { beginTableRow() ; for ( int i = 0 ; i < data.length ; i++ ) { beginTableData() ; append( data[i].toString() ) ; endTableData() ; } endTableRow() ; } public void tableHeaderRow( Object[] data ) // not recursive (yet) { beginTableRow() ; for ( int i = 0 ; i < data.length ; i++ ) { beginTableData() ; bold( data[i].toString() ) ; endTableData() ; } endTableRow() ; } public abstract void beginBlockQuote( ) ; public abstract void endBlockQuote() ; public abstract void linebreak() ; public void append( String o ) { if ( ! canWrite() ) return ; try { accumulator.write( o ) ; } catch ( IOException ex ) { accumulator = null ; } } public void append( char o ) { append( "" + o ) ; } public void append( int o ) { append( "" + o ) ; } public void nl( ) { append( '\n' ) ; } //public abstract void font( String f, String s ) ; public abstract void bold( String s ) ; public void string( String s ) { append( "\"" ) ; append( s ) ; append( "\"" ) ; } //public abstract void define( String nm, String val ) ; public void close( ) { try { accumulator.close() ; } catch ( IOException ex ) { } } public String toString() { close() ; if ( accumulator instanceof StringWriter ) return accumulator.toString() ; else return "" ; } public abstract void mathEquationList( Enumeration<String> e, char subscript ) ; public abstract void beginVerbatimList() ; public abstract void endVerbatimList() ; public abstract void verbatimLine( String s ) ; public void verbatimList( Enumeration<String> e ) { if ( ! e.hasMoreElements() ) return ; beginVerbatimList() ; for ( ; e.hasMoreElements() ; ) { verbatimLine( e.nextElement() ) ; } endVerbatimList() ; } public abstract void beginAttributeList( ) ; public abstract void endAttributeList( ) ; public abstract void attributeName( String s ) ; public abstract void beginAttributeValue( ) ; public abstract void endAttributeValue( ) ; public String reprAsHex( int v ) { return Utils.asHex( v, 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.Enumeration; public class HelpHTMLAccumulator extends HelpAccumulator{ private boolean isOldHtml ; public HelpHTMLAccumulator( boolean old, String fileName ) { super( fileName ) ; isOldHtml = old ; } private void beginTag( String t, boolean end ) { append( '<' ) ; if ( end ) append( '/' ) ; append( t ) ; } private void endTag( ) { append( '>' ) ; } private void tag( String t, boolean end, String params ) { beginTag( t, end ) ; if ( params != null ) { append( " " ) ; append( params ) ; } endTag() ; } private void tag( String t, boolean end ) { tag( t, end, null ) ; } private void tagged( String t, String s ) { tag( t, false ) ; append( s ) ; tag( t, true ) ; } public void beginHeadTitleBody( String t ) { if ( ! isOldHtml ) { tag( "!doctype", false, "html public \"-//w3c//dtd html 4.0 transitional//en\"" ) ; tag( "html", false ) ; tag( "head", false ) ; tag( "meta", false, "http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"" ) ; tag( "meta", false, "name=\"GENERATOR\" content=\"Simple Stack Machine, " + Config.version() + ", " + Config.versionDate() + "\"" ) ; tag( "title", false ) ; append( t ) ; tag( "title", true ) ; tag( "head", true ) ; } tag( "body", false ) ; } public void endHeadTitleBody() { tag( "body", true ) ; if ( ! isOldHtml ) { tag( "html", true ) ; } } private void beginA( String name, String href ) { beginTag( "a", false ) ; if ( href != null ) define( "href", href ) ; if ( name != null ) define( "name", name ) ; endTag() ; } private void endA() { tag( "a", true ) ; } public void anchor( String a ) { beginA( a, null ) ; endA( ) ; } public void a( String href, String title ) { beginA( null, href ) ; append( title ) ; endA( ) ; } public void anchorA( String href, String title ) { a( "#" + href, title ) ; } private void beginPara( String align ) { beginTag( "p", false ) ; if ( align != null ) define( "align", align ) ; endTag() ; } public void beginPara( ) { beginPara( null ) ; } public void endPara() { tag( "p", true ) ; } public void beginCentered( ) { beginPara( "center" ) ; } public void endCentered() { endPara() ; } public void beginSectionTitle() { tag( "h2", false ) ; } public void endSectionTitle() { tag( "h2", true ) ; } public void beginSubsectionTitle() { tag( "h3", false ) ; } public void endSubsectionTitle() { tag( "h3", true ) ; } public void beginTable( int nCols, int widthPerc, int[] colWidthWeight ) { tag( "table", false, "BORDER COLS=" + nCols + " WIDTH=\"" + (widthPerc == 0 ? 100 : widthPerc) + "%\"" ) ; } public void endTable() { tag( "table", true ) ; } public void beginTableRow( ) { tag( "tr", false ) ; } public void endTableRow() { tag( "tr", true ) ; } public void beginTableData( ) { tag( "td", false ) ; } public void endTableData() { tag( "td", true ) ; } public void beginBlockQuote( ) { tag( "blockquote", false ) ; } public void endBlockQuote() { tag( "blockquote", true ) ; } public void linebreak() { tag( "br", false ) ; } private void font( String f, String s ) { tag( f, false ) ; append( s ) ; tag( f, true ) ; } public void bold( String s ) { font( "b", s ) ; } private void define( String nm, String val ) { append( " " ) ; append( nm ) ; append( "=" ) ; string( val ) ; } public void mathEquationList( Enumeration e, char subscript ) { for ( ; e.hasMoreElements() ; ) { append( ((String)e.nextElement()) ) ; if ( e.hasMoreElements() ) linebreak() ; } } public void beginAttributeList( ) { } public void endAttributeList( ) { } public void attributeName( String s ) { subsectionTitle( s ) ; } public void beginAttributeValue( ) { beginBlockQuote() ; } public void endAttributeValue( ) { endBlockQuote() ; } public void beginVerbatimList() { tag( "pre", false ) ; nl() ; } public void endVerbatimList() { tag( "pre", true ) ; nl() ; } public void verbatimLine( String s ) { append( s ) ; nl() ; } }
\ 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.Enumeration; public class HelpHTMLAccumulator extends HelpAccumulator{ private boolean isOldHtml ; public HelpHTMLAccumulator( boolean old, String fileName ) { super( fileName ) ; isOldHtml = old ; } private void beginTag( String t, boolean end ) { append( '<' ) ; if ( end ) append( '/' ) ; append( t ) ; } private void endTag( ) { append( '>' ) ; } private void tag( String t, boolean end, String params ) { beginTag( t, end ) ; if ( params != null ) { append( " " ) ; append( params ) ; } endTag() ; } private void tag( String t, boolean end ) { tag( t, end, null ) ; } private void tagged( String t, String s ) { tag( t, false ) ; append( s ) ; tag( t, true ) ; } public void beginHeadTitleBody( String t ) { if ( ! isOldHtml ) { tag( "!doctype", false, "html public \"-//w3c//dtd html 4.0 transitional//en\"" ) ; tag( "html", false ) ; tag( "head", false ) ; tag( "meta", false, "http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"" ) ; tag( "meta", false, "name=\"GENERATOR\" content=\"Simple Stack Machine, " + Config.version() + ", " + Config.versionDate() + "\"" ) ; tag( "title", false ) ; append( t ) ; tag( "title", true ) ; tag( "head", true ) ; } tag( "body", false ) ; } public void endHeadTitleBody() { tag( "body", true ) ; if ( ! isOldHtml ) { tag( "html", true ) ; } } private void beginA( String name, String href ) { beginTag( "a", false ) ; if ( href != null ) define( "href", href ) ; if ( name != null ) define( "name", name ) ; endTag() ; } private void endA() { tag( "a", true ) ; } public void anchor( String a ) { beginA( a, null ) ; endA( ) ; } public void a( String href, String title ) { beginA( null, href ) ; append( title ) ; endA( ) ; } public void anchorA( String href, String title ) { a( "#" + href, title ) ; } private void beginPara( String align ) { beginTag( "p", false ) ; if ( align != null ) define( "align", align ) ; endTag() ; } public void beginPara( ) { beginPara( null ) ; } public void endPara() { tag( "p", true ) ; } public void beginCentered( ) { beginPara( "center" ) ; } public void endCentered() { endPara() ; } public void beginSectionTitle() { tag( "h2", false ) ; } public void endSectionTitle() { tag( "h2", true ) ; } public void beginSubsectionTitle() { tag( "h3", false ) ; } public void endSubsectionTitle() { tag( "h3", true ) ; } public void beginTable( int nCols, int widthPerc, int[] colWidthWeight ) { tag( "table", false, "BORDER COLS=" + nCols + " WIDTH=\"" + (widthPerc == 0 ? 100 : widthPerc) + "%\"" ) ; } public void endTable() { tag( "table", true ) ; } public void beginTableRow( ) { tag( "tr", false ) ; } public void endTableRow() { tag( "tr", true ) ; } public void beginTableData( ) { tag( "td", false ) ; } public void endTableData() { tag( "td", true ) ; } public void beginBlockQuote( ) { tag( "blockquote", false ) ; } public void endBlockQuote() { tag( "blockquote", true ) ; } public void linebreak() { tag( "br", false ) ; } private void font( String f, String s ) { tag( f, false ) ; append( s ) ; tag( f, true ) ; } public void bold( String s ) { font( "b", s ) ; } private void define( String nm, String val ) { append( " " ) ; append( nm ) ; append( "=" ) ; string( val ) ; } public void mathEquationList( Enumeration<String> e, char subscript ) { for ( ; e.hasMoreElements() ; ) { append( e.nextElement() ) ; if ( e.hasMoreElements() ) linebreak() ; } } public void beginAttributeList( ) { } public void endAttributeList( ) { } public void attributeName( String s ) { subsectionTitle( s ) ; } public void beginAttributeValue( ) { beginBlockQuote() ; } public void endAttributeValue( ) { endBlockQuote() ; } public void beginVerbatimList() { tag( "pre", false ) ; nl() ; } public void endVerbatimList() { tag( "pre", true ) ; nl() ; } public void verbatimLine( String s ) { append( s ) ; nl() ; } }
\ 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.io.IOException;import java.io.StreamTokenizer;import java.io.StringReader;import java.util.Enumeration; public class HelpLaTeXAccumulator extends HelpAccumulator{ public HelpLaTeXAccumulator( String fileName ) { super( fileName ) ; } private void beginEnv( String t, String param ) { macro( "begin", t ) ; if ( param != null ) bracket( param ) ; } private void beginEnv( String t ) { beginEnv( t, null ) ; } private void endEnv( String t ) { macro( "end", t ) ; } private void beginMath( ) { macro( "(" ) ; } private void endMath() { macro( ")" ) ; } private void beginParen( ) { append( '(' ) ; } private void endParen( ) { append( ')' ) ; } private void beginBracket( ) { append( '{' ) ; } private void endBracket( ) { append( '}' ) ; } private void bracket( String t ) { beginBracket( ) ; append( t ) ; endBracket() ; } private void beginMacro( String t ) { append( '\\' ) ; append( t ) ; beginBracket() ; } private void endMacro( ) { endBracket() ; } private void macro( String t, String a1 ) { append( '\\' ) ; append( t ) ; if ( a1 != null ) bracket( a1 ) ; else append( " " ) ; } private void macro( String t ) { macro( t, null ) ; } public void beginHeadTitleBody( String t ) { } public void endHeadTitleBody() { } public void anchor( String a ) { macro( "label", "ssmanchor:" + a ) ; macro( "Ix", a ) ; } public void a( String href, String title ) { append( title ) ; beginParen() ; macro( "Ref", href ) ; endParen() ; } public void anchorA( String href, String title ) { a( "ssmanchor:" + href, title ) ; } public void beginPara( ) { nl() ; nl() ; } public void endPara() { nl() ; nl() ; } public void beginCentered( ) { beginEnv( "center" ) ; } public void endCentered() { endEnv( "center" ) ; } public void beginSectionTitle() { beginMacro( "Sec" ) ; } public void endSectionTitle() { endMacro() ; } public void beginSubsectionTitle() { beginMacro( "Par" ) ; } public void endSubsectionTitle() { endMacro() ; } public void beginTable( int nCols, int widthPerc, int[] colWidthWeight ) { int perc = Math.min( 99, widthPerc ) ; StringBuffer colFmt = new StringBuffer() ; colFmt.append( "l" ) ; beginEnv( "tabular*", "0." + perc + "\\textwidth" ) ; if ( colWidthWeight == null ) { colFmt.append( "l" + Utils.repeat( "p{0." + (perc / nCols) + "\\textwidth}", nCols ) ) ; } else { int sum = 0 ; for ( int i = 0 ; i < colWidthWeight.length ; i++ ) sum += colWidthWeight[ i ] ; for ( int i = 0 ; i < colWidthWeight.length ; i++ ) colFmt.append( "p{0." + (perc * colWidthWeight[ i ] / sum) + "\\textwidth}" ) ; } bracket( colFmt.toString() ) ; } public void endTable() { endEnv( "tabular*" ) ; } public void beginTableRow( ) { } public void endTableRow() { linebreak() ; } public void beginTableData( ) { append( "& " ) ; macro( "begingroup" ) ; macro( "raggedright" ) ; } public void endTableData() { macro( "endgroup" ) ; } public void beginBlockQuote( ) { } public void endBlockQuote() { } public void linebreak() { append( "\\\\" ) ; nl() ; } public void bold( String s ) { beginBracket() ; macro( "bf" ) ; append( s ) ; endBracket() ; } private final static int MATH_NORMAL = 0 ; private final static int MATH_SUBSCRIPT = 1 ; private void mathMangle( String s, char subscript ) { StreamTokenizer t = new StreamTokenizer( new StringReader( s ) ) ; t.resetSyntax() ; t.wordChars( 'a', 'z' ) ; t.wordChars( 'A', 'Z' ) ; int tok ; int state = MATH_NORMAL ; beginMath() ; try { while ( ( tok = t.nextToken() ) != StreamTokenizer.TT_EOF ) { if ( tok == StreamTokenizer.TT_WORD ) { if ( state == MATH_SUBSCRIPT ) { bracket( t.sval ) ; state = MATH_NORMAL ; } else append( t.sval ) ; } else { if ( tok == subscript ) state = MATH_SUBSCRIPT ; if ( tok == '&' || tok == '%' ) append( '\\' ) ; append( (char)tok ) ; } } } catch ( IOException ex ) { append( ex.toString() ) ; } endMath() ; } public void mathEquationList( Enumeration e, char subscript ) { for ( ; e.hasMoreElements() ; ) { mathMangle( ((String)e.nextElement()), subscript ) ; if ( e.hasMoreElements() ) linebreak() ; } } public void beginAttributeList( ) { beginBracket() ; macro( "renewcommand", "\\arraystretch" ) ; bracket( "1.7" ) ; beginTable( 2, 90, new int[] {1,2} ) ; } public void endAttributeList( ) { endTable() ; endBracket() ; } public void attributeName( String s ) { beginTableRow() ; beginTableData() ; bold( s ) ; endTableData() ; } public void beginAttributeValue( ) { beginTableData() ; beginEnv( "minipage" ) ; append( "[t]" ) ; bracket( "0.6\\textwidth" ) ; } public void endAttributeValue( ) { endEnv( "minipage" ) ; endTableData() ; endTableRow() ; } public void beginVerbatimList() { beginEnv( "Verbatim" ) ; nl() ; } public void endVerbatimList() { endEnv( "Verbatim" ) ; nl() ; } public void verbatimLine( String s ) { append( s ) ; nl() ; } }
\ 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.io.IOException;import java.io.StreamTokenizer;import java.io.StringReader;import java.util.Enumeration; public class HelpLaTeXAccumulator extends HelpAccumulator{ public HelpLaTeXAccumulator( String fileName ) { super( fileName ) ; } private void beginEnv( String t, String param ) { macro( "begin", t ) ; if ( param != null ) bracket( param ) ; } private void beginEnv( String t ) { beginEnv( t, null ) ; } private void endEnv( String t ) { macro( "end", t ) ; } private void beginMath( ) { macro( "(" ) ; } private void endMath() { macro( ")" ) ; } private void beginParen( ) { append( '(' ) ; } private void endParen( ) { append( ')' ) ; } private void beginBracket( ) { append( '{' ) ; } private void endBracket( ) { append( '}' ) ; } private void bracket( String t ) { beginBracket( ) ; append( t ) ; endBracket() ; } private void beginMacro( String t ) { append( '\\' ) ; append( t ) ; beginBracket() ; } private void endMacro( ) { endBracket() ; } private void macro( String t, String a1 ) { append( '\\' ) ; append( t ) ; if ( a1 != null ) bracket( a1 ) ; else append( " " ) ; } private void macro( String t ) { macro( t, null ) ; } public void beginHeadTitleBody( String t ) { } public void endHeadTitleBody() { } public void anchor( String a ) { macro( "label", "ssmanchor:" + a ) ; macro( "Ix", a ) ; } public void a( String href, String title ) { append( title ) ; beginParen() ; macro( "Ref", href ) ; endParen() ; } public void anchorA( String href, String title ) { a( "ssmanchor:" + href, title ) ; } public void beginPara( ) { nl() ; nl() ; } public void endPara() { nl() ; nl() ; } public void beginCentered( ) { beginEnv( "center" ) ; } public void endCentered() { endEnv( "center" ) ; } public void beginSectionTitle() { beginMacro( "Sec" ) ; } public void endSectionTitle() { endMacro() ; } public void beginSubsectionTitle() { beginMacro( "Par" ) ; } public void endSubsectionTitle() { endMacro() ; } public void beginTable( int nCols, int widthPerc, int[] colWidthWeight ) { int perc = Math.min( 99, widthPerc ) ; StringBuffer colFmt = new StringBuffer() ; colFmt.append( "l" ) ; beginEnv( "tabular*", "0." + perc + "\\textwidth" ) ; if ( colWidthWeight == null ) { colFmt.append( "l" + Utils.repeat( "p{0." + (perc / nCols) + "\\textwidth}", nCols ) ) ; } else { int sum = 0 ; for ( int i = 0 ; i < colWidthWeight.length ; i++ ) sum += colWidthWeight[ i ] ; for ( int i = 0 ; i < colWidthWeight.length ; i++ ) colFmt.append( "p{0." + (perc * colWidthWeight[ i ] / sum) + "\\textwidth}" ) ; } bracket( colFmt.toString() ) ; } public void endTable() { endEnv( "tabular*" ) ; } public void beginTableRow( ) { } public void endTableRow() { linebreak() ; } public void beginTableData( ) { append( "& " ) ; macro( "begingroup" ) ; macro( "raggedright" ) ; } public void endTableData() { macro( "endgroup" ) ; } public void beginBlockQuote( ) { } public void endBlockQuote() { } public void linebreak() { append( "\\\\" ) ; nl() ; } public void bold( String s ) { beginBracket() ; macro( "bf" ) ; append( s ) ; endBracket() ; } private final static int MATH_NORMAL = 0 ; private final static int MATH_SUBSCRIPT = 1 ; private void mathMangle( String s, char subscript ) { StreamTokenizer t = new StreamTokenizer( new StringReader( s ) ) ; t.resetSyntax() ; t.wordChars( 'a', 'z' ) ; t.wordChars( 'A', 'Z' ) ; int tok ; int state = MATH_NORMAL ; beginMath() ; try { while ( ( tok = t.nextToken() ) != StreamTokenizer.TT_EOF ) { if ( tok == StreamTokenizer.TT_WORD ) { if ( state == MATH_SUBSCRIPT ) { bracket( t.sval ) ; state = MATH_NORMAL ; } else append( t.sval ) ; } else { if ( tok == subscript ) state = MATH_SUBSCRIPT ; if ( tok == '&' || tok == '%' ) append( '\\' ) ; append( (char)tok ) ; } } } catch ( IOException ex ) { append( ex.toString() ) ; } endMath() ; } public void mathEquationList( Enumeration<String> e, char subscript ) { for ( ; e.hasMoreElements() ; ) { mathMangle( e.nextElement(), subscript ) ; if ( e.hasMoreElements() ) linebreak() ; } } public void beginAttributeList( ) { beginBracket() ; macro( "renewcommand", "\\arraystretch" ) ; bracket( "1.7" ) ; beginTable( 2, 90, new int[] {1,2} ) ; } public void endAttributeList( ) { endTable() ; endBracket() ; } public void attributeName( String s ) { beginTableRow() ; beginTableData() ; bold( s ) ; endTableData() ; } public void beginAttributeValue( ) { beginTableData() ; beginEnv( "minipage" ) ; append( "[t]" ) ; bracket( "0.6\\textwidth" ) ; } public void endAttributeValue( ) { endEnv( "minipage" ) ; endTableData() ; endTableRow() ; } public void beginVerbatimList() { beginEnv( "Verbatim" ) ; nl() ; } public void endVerbatimList() { endEnv( "Verbatim" ) ; nl() ; } public void verbatimLine( String s ) { append( s ) ; nl() ; } }
\ No newline at end of file
......
This diff is collapsed.
/** * Simple Stack Machine * * Written by Atze Dijkstra, atze@cs.uu.nl, * Copyright Utrecht University. * */ package nl.uu.cs.ssm ; import java.util.Vector; public abstract class MetaInstrInstantiator{ protected MetaInstrInstantiator() { } public abstract MetaInstruction instantiate( Instruction instr, Vector args ) ; public static MetaInstrInstantiator newAnnoteInstantiator() { return new MetaInstrInstantiator() { public MetaInstruction instantiate( Instruction instr, Vector args ) { return MetaInstruction.newAnnote( instr, args ) ; } } ; }}
\ 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.Vector; public abstract class MetaInstrInstantiator{ protected MetaInstrInstantiator() { } public abstract MetaInstruction instantiate( Instruction instr, Vector<String> args ) ; public static MetaInstrInstantiator newAnnoteInstantiator() { return new MetaInstrInstantiator() { public MetaInstruction instantiate( Instruction instr, Vector<String> args ) { return MetaInstruction.newAnnote( instr, args ) ; } } ; }}
\ 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.awt.Color;import java.util.Hashtable;import java.util.Vector; 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.awt.Color;import java.util.Hashtable;import java.util.Vector; 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<String> 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 = 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
......
This diff is collapsed.
/* Runner.java Title: Simple Stack Machine Runner Author: atze Description: */ package nl.uu.cs.ssmui; import java.io.IOException;import java.net.URL;import java.util.Enumeration;import java.util.Hashtable;import java.util.Properties;import java.util.Vector; import nl.uu.cs.ssm.HelpAccumulator;import nl.uu.cs.ssm.HelpSupplier;import nl.uu.cs.ssm.Utils; 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 ) { 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 java.io.IOException;import java.net.URL;import java.util.Enumeration;import java.util.Hashtable;import java.util.Properties;import java.util.Vector; import nl.uu.cs.ssm.HelpAccumulator;import nl.uu.cs.ssm.HelpSupplier;import nl.uu.cs.ssm.Utils; 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 ) { Enumeration<String> 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.Enumeration;import java.util.Hashtable;import java.util.Vector; 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
/* Title: Simple Stack Machine Runner Author: atze Description: */ package nl.uu.cs.ssmui; import java.util.Enumeration;import java.util.Hashtable;import java.util.Vector; 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 ; } } protected 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<String> regNames ) { if ( regNames != null ) { labels = new Hashtable<String,Label>() ; for ( ; regNames.hasMoreElements() ; ) { String nm = 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<UnresolvedLabelUsage> 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
......
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