NAME

Language::Zcode::Translator::Generic

DESCRIPTION

Abstract class that's the parent of all language-specific translators.

A translator has methods to translate Z-code into a given other language.

Methods

(Implement all of these to have a valid language translator.)

program_start

Returns a string that should be at the beginning of the output program. (Empty by default)

program_end

Returns a string that should be at the end of the output program. (Empty by default)

routine_start

Returns a string that should be at the beginning of each output subroutine. Might have side effects (e.g., tell translator to start indenting).

Input: Name of sub, array of initial local variable values (all 0 for v5+)

translate_command(command_hashref)

This is the translation workhorse. Translate a command (a reference to a hash returned by a LZ::Parser::parse routine) to the destination language.

routine_end

Returns a string that should be at the end of each output subroutine. Might have side effects (e.g., tell translator to stop indenting).

packed_address_str(address, type_of_address)

String representing a version-dependent packed address. (Note packing is different for routines and strings in V6/7.)

Calculate actual address if $address is a number. Create a language-dependent multiplication string by calling language-dependent mult_add_str otherwise.

mult_add_str(thing, multiplier, adder)

Create a language-dependent multiplication/addition string thing*multiplier + adder