com.github.croesch.micro_debug.commons
Class AbstractCodeContainer

java.lang.Object
  extended by com.github.croesch.micro_debug.commons.AbstractCodeContainer
Direct Known Subclasses:
MemoryInterpreter, MicroControlStore

public abstract class AbstractCodeContainer
extends Object

Represents a code container that is e.g. able to print the code.

Since:
Date: Feb 5, 2012
Author:
croesch

Constructor Summary
AbstractCodeContainer()
           
 
Method Summary
protected  String formatIntToHex(int number, int width)
          Formats the given number to a hexadecimal number and returns an right aligned string with the given width.
protected abstract  int getFirstPossibleCodeAddress()
          Returns the address where the first possible code is stored.
protected abstract  int getLastPossibleCodeAddress()
          Returns the address where the last possible code is stored.
 void printCode()
          Prints the whole code to the user.
 void printCode(int pos1, int pos2)
          Prints the code between the given lines to the user.
 void printCodeAroundLine(int line, int scope)
          Prints the given number lines of code around the given line to the user.
protected abstract  int printCodeLine(int line)
          Prints the line with the given number to the user.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractCodeContainer

public AbstractCodeContainer()
Method Detail

printCode

public final void printCode()
Prints the whole code to the user.

Since:
Date: Jan 22, 2012

printCodeAroundLine

public final void printCodeAroundLine(int line,
                                      int scope)
Prints the given number lines of code around the given line to the user.

Parameters:
line - the line around to print the code
scope - the number of lines to print before and after the given line
Since:
Date: Jan 26, 2012

printCode

public final void printCode(int pos1,
                            int pos2)
Prints the code between the given lines to the user.

Parameters:
pos1 - the first line to print
pos2 - the last line to print
Since:
Date: Jan 26, 2012

getFirstPossibleCodeAddress

protected abstract int getFirstPossibleCodeAddress()
Returns the address where the first possible code is stored.

Returns:
the number of the first code line.
Since:
Date: Jan 26, 2012

getLastPossibleCodeAddress

protected abstract int getLastPossibleCodeAddress()
Returns the address where the last possible code is stored.

Returns:
the number of the last code line.
Since:
Date: Jan 26, 2012

printCodeLine

protected abstract int printCodeLine(int line)
Prints the line with the given number to the user. Returns the number of code lines to skip after this line, in case of reading arguments.

Parameters:
line - the line number of the code instruction to print
Returns:
the number of lines that can be skipped after printing this line
Since:
Date: Jan 22, 2012

formatIntToHex

protected final String formatIntToHex(int number,
                                      int width)
Formats the given number to a hexadecimal number and returns an right aligned string with the given width.

Parameters:
number - the number to format
width - the width the formatted string should at least have
Returns:
the formatted string containing the hexadecimal value of the given number and at least width characters.
Since:
Date: Jan 22, 2012


Copyright © 2012. All Rights Reserved.