Decompiler

public class Decompiler

Abstract class for Fortran, C decompilers.

Fields

EMPTY_CONTEXT

protected static final int EMPTY_CONTEXT

commentChar

protected String commentChar

continuationChar

protected String continuationChar

eolContinuationChar

protected String eolContinuationChar

language

protected int language

maxColumn

protected int maxColumn

posX

protected int posX

posY

protected int posY

printer

protected final Printer printer

showMessages

protected boolean showMessages

To display Tapenade message.

waitingComments

protected TapList<String> waitingComments

waitingCommentsBlock

protected TapList<String> waitingCommentsBlock

Constructors

Decompiler

protected Decompiler(Printer printer, String msgFileName)

Methods

contextMinus

protected int contextMinus(int context, int newContextRk)

contextPlus

protected int contextPlus(int context, int newContextRk)

decompileTree

public void decompileTree(Tree tree, int language, boolean inInclude, boolean dumps)

hasContext

protected boolean hasContext(int context, int newContextRk)

newLine

public void newLine(int indent)

prints a new line.

postDecompile

protected void postDecompile(Tree tree, int indent)

Process annotations of a tree after it has been decompiled. This function uses stack “seenTreesStack” to make sure each tree is postDecompiled only once, in principle on the last call to postDecompile().

Parameters
  • tree – the tree to process.

  • indent – the indentation to use if something has to be printed.

Throws
  • IOException – printer exception

preDecompile

protected void preDecompile(Tree tree, int indent)

Process annotations of a tree before it is decompiled. This function may be called several successive times for the same tree depending on the call order of all the decompile functions above. Only the 1st call will have an effect. The calls to this function are all paired with a corresponding call of the postDecompile(), using the global stack “seenTreesStack”.

Parameters
  • tree – the tree to process.

  • indent – the indentation to use if something has to be printed.

Throws
  • IOException – printer exception

print

protected void print(String word, int indent, String kind)

Prints the word “word” onto the output. If the word is too long, we go to a new line or we may even CUT the word.

Parameters
  • indent – current indentation level, to be used in case the word starts a new line or “continuation line”.

  • kind – the kind of word, that will determine its HTML rendering. It can be one of {“plain”, “string”, “constant”, “keyword”, “funcname”, “typename”, “label”, “modifier”, “vardecl”}.

printString

protected void printString(String word)

reinitialize

protected void reinitialize()

space

protected void space()

Prints one whiteSpace. If there was already a space just before, prints nothing.

tryFlushComments

protected void tryFlushComments(int indent, boolean prefix)

Prints all waiting line-comments, and resets waiting comments to null.

tryFlushCommentsBlock

protected void tryFlushCommentsBlock(int indent, boolean prefix)

Prints all waiting block-comments, and resets waiting comments to null.