translator_compile Class Reference

#include <compile.h>

Inheritance diagram for translator_compile:

translator List of all members.

Public Member Functions

virtual ~translator_compile ()
 translator_compile (const rcstring &outfile)
scope::pointer program_scope_factory (const rcstring &name)
scope::pointer function_scope_factory (const rcstring &name, bool is_func, bool new_seg)
statement::pointer expression_statement_factory (const expression::pointer &arg)
statement::pointer if_statement_factory (const expression::pointer &condition, const statement::pointer &then_clause, const statement::pointer &else_clause)
statement::pointer while_statement_factory (const expression::pointer &condition, const statement::pointer &body)
statement::pointer until_statement_factory (const statement::pointer &body, const expression::pointer &condition)
statement::pointer infinite_loop_factory (const statement::pointer &body)
statement::pointer writeln_statement_factory (expression_list *arg)
expression::pointer boolean_expression_factory (bool value)
expression::pointer integer_plus_integer_expression_factory (const expression::pointer &lhs, const expression::pointer &rhs)
expression::pointer real_plus_real_expression_factory (const expression::pointer &lhs, const expression::pointer &rhs)
expression::pointer set_union_expression_factory (const expression::pointer &lhs, const expression::pointer &rhs)
expression::pointer integer_minus_integer_expression_factory (const expression::pointer &lhs, const expression::pointer &rhs)
expression::pointer real_minus_real_expression_factory (const expression::pointer &lhs, const expression::pointer &rhs)
expression::pointer set_difference_expression_factory (const expression::pointer &lhs, const expression::pointer &rhs)
expression::pointer set2set_expression_factory (const type::pointer &to, const expression::pointer &from)
expression::pointer integer_times_integer_expression_factory (const expression::pointer &lhs, const expression::pointer &rhs)
expression::pointer real_times_real_expression_factory (const expression::pointer &lhs, const expression::pointer &rhs)
expression::pointer set_intersection_expression_factory (const expression::pointer &lhs, const expression::pointer &rhs)
expression::pointer integer_div_integer_expression_factory (const expression::pointer &lhs, const expression::pointer &rhs)
expression::pointer real_over_real_expression_factory (const expression::pointer &lhs, const expression::pointer &rhs)
expression::pointer assignment_expression_factory (const expression::pointer &lhs, const expression::pointer &rhs)
expression::pointer name_expression_factory (symbol *sp)
expression::pointer integer_expression_factory (const rcstring &value)
expression::pointer real_expression_factory (const rcstring &value)
expression::pointer real_from_integer_expression_factory (const expression::pointer &arg)
expression::pointer string_expression_factory (const rcstring &value)
expression::pointer integer_negate_expression_factory (const expression::pointer &arg)
expression::pointer real_negate_expression_factory (const expression::pointer &arg)
expression::pointer boolean_eq_boolean_expression_factory (const expression::pointer &lhs, const expression::pointer &rhs)
expression::pointer integer_eq_integer_expression_factory (const expression::pointer &lhs, const expression::pointer &rhs)
expression::pointer real_eq_real_expression_factory (const expression::pointer &lhs, const expression::pointer &rhs)
expression::pointer string_eq_string_expression_factory (const expression::pointer &lhs, const expression::pointer &rhs)
expression::pointer boolean_ne_boolean_expression_factory (const expression::pointer &lhs, const expression::pointer &rhs)
expression::pointer integer_ne_integer_expression_factory (const expression::pointer &lhs, const expression::pointer &rhs)
expression::pointer real_ne_real_expression_factory (const expression::pointer &lhs, const expression::pointer &rhs)
expression::pointer string_ne_string_expression_factory (const expression::pointer &lhs, const expression::pointer &rhs)
expression::pointer boolean_lt_boolean_expression_factory (const expression::pointer &lhs, const expression::pointer &rhs)
expression::pointer integer_lt_integer_expression_factory (const expression::pointer &lhs, const expression::pointer &rhs)
expression::pointer real_lt_real_expression_factory (const expression::pointer &lhs, const expression::pointer &rhs)
expression::pointer string_lt_string_expression_factory (const expression::pointer &lhs, const expression::pointer &rhs)
expression::pointer boolean_le_boolean_expression_factory (const expression::pointer &lhs, const expression::pointer &rhs)
expression::pointer integer_le_integer_expression_factory (const expression::pointer &lhs, const expression::pointer &rhs)
expression::pointer real_le_real_expression_factory (const expression::pointer &lhs, const expression::pointer &rhs)
expression::pointer string_le_string_expression_factory (const expression::pointer &lhs, const expression::pointer &rhs)
expression::pointer boolean_gt_boolean_expression_factory (const expression::pointer &lhs, const expression::pointer &rhs)
expression::pointer integer_gt_integer_expression_factory (const expression::pointer &lhs, const expression::pointer &rhs)
expression::pointer real_gt_real_expression_factory (const expression::pointer &lhs, const expression::pointer &rhs)
expression::pointer string_gt_string_expression_factory (const expression::pointer &lhs, const expression::pointer &rhs)
expression::pointer boolean_ge_boolean_expression_factory (const expression::pointer &lhs, const expression::pointer &rhs)
expression::pointer integer_ge_integer_expression_factory (const expression::pointer &lhs, const expression::pointer &rhs)
expression::pointer real_ge_real_expression_factory (const expression::pointer &lhs, const expression::pointer &rhs)
expression::pointer string_ge_string_expression_factory (const expression::pointer &lhs, const expression::pointer &rhs)
bool emit_byte (unsigned char value)
bool emit_word_alignment (unsigned char value=0)
bool emit_odd_alignment (unsigned char value=0)
bool emit_word (unsigned value)
bool emit_big (unsigned value)
bool emit_ldci (int n)
void error (const location &, const char *fmt,...)
void new_segment (const rcstring &name)
int next_procedure_number ()
void procedure_parameter_size (unsigned nbytes)
void procedure_variable_size (unsigned nbytes)
void procedure_enter_ic ()
void procedure_exit_ic ()
void procedure_end (int procedure_number, int lex_level)
void segment_end ()
unsigned get_address () const
void poke (unsigned address, unsigned char value)
int new_jump_table_entry (unsigned address)
unsigned get_segment_number () const
void breakpoint (const location &locn)
void need_segment_31 ()
bool segment_31_needed () const
expression::pointer range_check (const expression::pointer &value, const type::pointer &against)
expression::pointer range_check (const expression::pointer &value, int minimum, int maximum)

Protected Member Functions

void post_order_traversal ()
label::pointer label_factory ()
symbolfunction_symbol_factory (const rcstring &name, const scope::pointer &scp, int lex_level)
expression::pointer dereference_expression_factory (const expression::pointer &arg)
expression::pointer logical_and_expression_factory (const expression::pointer &lhs, const expression::pointer &rhs)
expression::pointer logical_or_expression_factory (const expression::pointer &lhs, const expression::pointer &rhs)
expression::pointer logical_not_expression_factory (const expression::pointer &arg)
expression::pointer sizeof_expression_factory (const type::pointer &arg)
expression::pointer char_expression_factory (const location &locn, unsigned char value)
expression::pointer empty_set_expression_factory (const location &locn, const type::pointer &tp)
expression::pointer set_expression_factory (const expression::pointer &singleton)
expression::pointer set_expression_factory (const expression::pointer &lo, const expression::pointer &hi)
symbolbuiltin_chr_factory ()
symbolbuiltin_dec_factory ()
symbolbuiltin_inc_factory ()
symbolbuiltin_odd_factory ()
symbolbuiltin_ord_factory ()
symbolbuiltin_pred_factory ()
symbolbuiltin_sqr_factory ()
symbolbuiltin_succ_factory ()
symbolbuiltin_time_factory ()
symbol_functionbuiltin_syscall_factory (const rcstring &name, int proc_num)

Private Member Functions

 translator_compile (const translator_compile &)
translator_compileoperator= (const translator_compile &)

Private Attributes

codefilecfp
int number_of_errors
segment_builder_stack segstack
location bpt_locn
bool segment_31_flag

Detailed Description

The translator_compile class is used to represent translation phase from text to UCSD p-System code file.

Definition at line 33 of file compile.h.


Constructor & Destructor Documentation

virtual translator_compile::~translator_compile (  )  [virtual]

The destructor.

translator_compile::translator_compile ( const rcstring outfile  ) 

The default constructor.

translator_compile::translator_compile ( const translator_compile  )  [private]

The copy constructor. Do not use.


Member Function Documentation

scope::pointer translator_compile::program_scope_factory ( const rcstring name  )  [virtual]

The program_scope_factory method is used to create a new program scope instance. It is called by the non-virtual program_scope_factory method.

Implements translator.

scope::pointer translator_compile::function_scope_factory ( const rcstring name,
bool  is_func,
bool  new_seg 
) [virtual]

The function_scope_factory method is used to create a new function scope instance. It is called by the non-virtual function_scope_factory method.

Parameters:
name The name of the function or procedure.
is_func true for functions, false for procedures. This is needed because this information is needed long before the function return type is available.
new_seg The new_seg argument indicates whether this function or procedure starts a new segment (if true) or adds another function to the current segment (if false).

Implements translator.

statement::pointer translator_compile::expression_statement_factory ( const expression::pointer arg  )  [virtual]

The expression_statement_factory method is used to create a new expression statement instance in dynamic memory.

Parameters:
arg The expression to be evaluated as the statement's effect.
Returns:
pointer to a statement in dynamic memory

Reimplemented from translator.

statement::pointer translator_compile::if_statement_factory ( const expression::pointer condition,
const statement::pointer then_clause,
const statement::pointer else_clause 
) [virtual]

The if_statement_factory method is used to create a new not equal to expression object instance.

Parameters:
condition The controlling expression
then_clause The statement to perform if the condition is true
else_clause The statement to perform if the condition is false
Returns:
A pointer to an expression object.

Implements translator.

statement::pointer translator_compile::while_statement_factory ( const expression::pointer condition,
const statement::pointer body 
) [virtual]

The while_statement_factory method is used to create a new while statement object instance.

Parameters:
condition The loop control expression.
body The loop body.
Returns:
A pointer to an statement object.

Implements translator.

statement::pointer translator_compile::until_statement_factory ( const statement::pointer body,
const expression::pointer condition 
) [virtual]

The until_statement_factory method is used to create a new until statement object instance.

Parameters:
body The loop body.
condition The loop control expression.
Returns:
A pointer to an statement object.

Implements translator.

statement::pointer translator_compile::infinite_loop_factory ( const statement::pointer body  )  [virtual]

The infinite_loop_factory method is used to create a new not equal to expression object instance.

Parameters:
body The loop body.
Returns:
A pointer to an statement object.

Implements translator.

statement::pointer translator_compile::writeln_statement_factory ( expression_list arg  )  [virtual]

The writeln_statement_factory method is used to create a new compound statement instance in dynamic memory.

Parameters:
arg The expressions which detail what the writeln statement is to print.
Returns:
pointer to a statement in dynamic memory

Implements translator.

expression::pointer translator_compile::boolean_expression_factory ( bool  value  )  [virtual]

The boolean_expression_factory method is used to create a new string constant expression object instance.

Parameters:
value The value of the boolean.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::integer_plus_integer_expression_factory ( const expression::pointer lhs,
const expression::pointer rhs 
) [virtual]

The integer_plus_integer_expression_factory method is used to create a new addition expression object instance.

Parameters:
lhs The left hand side of the addition.
rhs The right hand side of the addition.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::real_plus_real_expression_factory ( const expression::pointer lhs,
const expression::pointer rhs 
) [virtual]

The real_plus_real_expression_factory method is used to create a new addition expression object instance.

Parameters:
lhs The left hand side of the addition.
rhs The right hand side of the addition.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::set_union_expression_factory ( const expression::pointer lhs,
const expression::pointer rhs 
) [virtual]

The set_union_expression_factory method is used to create a new set union expression object instance.

Parameters:
lhs The left hand side of the union.
rhs The right hand side of the union.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::integer_minus_integer_expression_factory ( const expression::pointer lhs,
const expression::pointer rhs 
) [virtual]

The integer_minus_integer_expression_factory method is used to create a new subtraction expression object instance.

Parameters:
lhs The left hand side of the subtraction.
rhs The right hand side of the subtraction.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::real_minus_real_expression_factory ( const expression::pointer lhs,
const expression::pointer rhs 
) [virtual]

The real_minus_real_expression_factory method is used to create a new subtraction expression object instance.

Parameters:
lhs The left hand side of the subtraction.
rhs The right hand side of the subtraction.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::set_difference_expression_factory ( const expression::pointer lhs,
const expression::pointer rhs 
) [virtual]

The set_difference_expression_factory method is used to create a new set difference expression object instance.

Parameters:
lhs The left hand side of the set difference.
rhs The right hand side of the set difference.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::set2set_expression_factory ( const type::pointer to,
const expression::pointer from 
) [virtual]

The set2set_expression_factory method is used to create a new cast expression to convert one set type to another.

Parameters:
to The type of the resulting expression.
from the expression to be cast
Returns:
pointer to new expression node.

Implements translator.

expression::pointer translator_compile::integer_times_integer_expression_factory ( const expression::pointer lhs,
const expression::pointer rhs 
) [virtual]

The integer_times_integer_expression_factory method is used to create a new integer multiplication expression object instance.

Parameters:
lhs The left hand side of the multiplication.
rhs The right hand side of the multiplication.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::real_times_real_expression_factory ( const expression::pointer lhs,
const expression::pointer rhs 
) [virtual]

The real_times_real_expression_factory method is used to create a new real multiplication expression object instance.

Parameters:
lhs The left hand side of the multiplication.
rhs The right hand side of the multiplication.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::set_intersection_expression_factory ( const expression::pointer lhs,
const expression::pointer rhs 
) [virtual]

The set_intersection_expression_factory method is used to create a new set intersection expression object instance.

Parameters:
lhs The left hand side of the set intersection.
rhs The right hand side of the set intersection.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::integer_div_integer_expression_factory ( const expression::pointer lhs,
const expression::pointer rhs 
) [virtual]

The integer_div_integer_expression_factory method is used to create a new integer div expression object instance.

Parameters:
lhs The left hand side of the integer division.
rhs The right hand side of the integer division.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::real_over_real_expression_factory ( const expression::pointer lhs,
const expression::pointer rhs 
) [virtual]

The real_over_real_expression_factory method is used to create a new real division expression object instance.

Parameters:
lhs The left hand side of the real division.
rhs The right hand side of the real division.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::assignment_expression_factory ( const expression::pointer lhs,
const expression::pointer rhs 
)

The assignment_expression_factory method is used to perform routine checks before calling the lhs->assgnment_expresion_ factory() method. This method is intentionally not virtual.

We ask the left hand side to turn itself into an assignment. We don't do this as a virtual method of this translat base class because the assignment will be specific to the left hand side expression. And the left hand side was manufactured by the derived class, so there is ample opportunity for the derived classes to seize control, if they need to.

Parameters:
lhs The left hand side, the variable to assign into.
rhs The right hand side, the variable to assign into.
Returns:
an expression which perorms the assignment.

Reimplemented from translator.

expression::pointer translator_compile::name_expression_factory ( symbol sp  )  [virtual]

The name_expression_factory method is used to create a new variable reference expression object instance.

Parameters:
sp Symbol corresponding to the name of the expression.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::integer_expression_factory ( const rcstring value  )  [virtual]

The integer_expression_factory method is used to create a new string constant expression object instance.

Parameters:
value The value of the string.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::real_expression_factory ( const rcstring value  )  [virtual]

The real_expression_factory method is used to create a new real constant expression object instance.

Parameters:
value The value of the string.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::real_from_integer_expression_factory ( const expression::pointer arg  )  [virtual]

The real_from_integer_expression_factory method is used to build an implcit real(integer) cast expression node.

Parameters:
arg The integer expression to promote to a real value.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::string_expression_factory ( const rcstring value  )  [virtual]

The real_expression_factory method is used to create a new real constant expression object instance.

Parameters:
value The value of the string.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::integer_negate_expression_factory ( const expression::pointer arg  )  [virtual]

The integer_negate_expression_factory method is used to create a new integer negate expression object instance.

Parameters:
arg The integer expression to be negated.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::real_negate_expression_factory ( const expression::pointer arg  )  [virtual]

The real_negate_expression_factory method is used to create a new real negate expression object instance.

Parameters:
arg The real expression to be negated.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::boolean_eq_boolean_expression_factory ( const expression::pointer lhs,
const expression::pointer rhs 
) [virtual]

The booean_eq_booean_expression_factory method is used to create a new equal to expression object instance.

Parameters:
lhs The left hand side of the equal to.
rhs The right hand side of the equal to.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::integer_eq_integer_expression_factory ( const expression::pointer lhs,
const expression::pointer rhs 
) [virtual]

The integer_eq_integer_expression_factory method is used to create a new equal to expression object instance.

Parameters:
lhs The left hand side of the equal to.
rhs The right hand side of the equal to.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::real_eq_real_expression_factory ( const expression::pointer lhs,
const expression::pointer rhs 
) [virtual]

The real_eq_real_expression_factory method is used to create a new equal to expression object instance.

Parameters:
lhs The left hand side of the equal to.
rhs The right hand side of the equal to.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::string_eq_string_expression_factory ( const expression::pointer lhs,
const expression::pointer rhs 
) [virtual]

The string_eq_string_expression_factory method is used to create a new equal to expression object instance.

Parameters:
lhs The left hand side of the equal to.
rhs The right hand side of the equal to.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::boolean_ne_boolean_expression_factory ( const expression::pointer lhs,
const expression::pointer rhs 
) [virtual]

The booean_ne_boolean_expression_factory method is used to create a new not equal to expression object instance.

Parameters:
lhs The left hand side of the not equal to.
rhs The right hand side of the not equal to.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::integer_ne_integer_expression_factory ( const expression::pointer lhs,
const expression::pointer rhs 
) [virtual]

The integer_ne_integer_expression_factory method is used to create a new not equal to expression object instance.

Parameters:
lhs The left hand side of the not equal to.
rhs The right hand side of the not equal to.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::real_ne_real_expression_factory ( const expression::pointer lhs,
const expression::pointer rhs 
) [virtual]

The integer_ne_integer_expression_factory method is used to create a new not equal to expression object instance.

Parameters:
lhs The left hand side of the not equal to.
rhs The right hand side of the not equal to.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::string_ne_string_expression_factory ( const expression::pointer lhs,
const expression::pointer rhs 
) [virtual]

The integer_ne_integer_expression_factory method is used to create a new not equal to expression object instance.

Parameters:
lhs The left hand side of the not equal to.
rhs The right hand side of the not equal to.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::boolean_lt_boolean_expression_factory ( const expression::pointer lhs,
const expression::pointer rhs 
) [virtual]

The boolean_lt_boolean_expression_factory method is used to create a new less than expression object instance.

Parameters:
lhs The left hand side of the less than.
rhs The right hand side of the less than.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::integer_lt_integer_expression_factory ( const expression::pointer lhs,
const expression::pointer rhs 
) [virtual]

The integer_lt_integer_expression_factory method is used to create a new less than expression object instance.

Parameters:
lhs The left hand side of the less than.
rhs The right hand side of the less than.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::real_lt_real_expression_factory ( const expression::pointer lhs,
const expression::pointer rhs 
) [virtual]

The real_lt_real_expression_factory method is used to create a new less than expression object instance.

Parameters:
lhs The left hand side of the less than.
rhs The right hand side of the less than.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::string_lt_string_expression_factory ( const expression::pointer lhs,
const expression::pointer rhs 
) [virtual]

The string_lt_string_expression_factory method is used to create a new less than expression object instance.

Parameters:
lhs The left hand side of the less than.
rhs The right hand side of the less than.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::boolean_le_boolean_expression_factory ( const expression::pointer lhs,
const expression::pointer rhs 
) [virtual]

The le_expression_factory method is used to create a new less than or equal expression object instance.

Parameters:
lhs The left hand side of the less than or equal.
rhs The right hand side of the less than or equal.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::integer_le_integer_expression_factory ( const expression::pointer lhs,
const expression::pointer rhs 
) [virtual]

The le_expression_factory method is used to create a new less than or equal expression object instance.

Parameters:
lhs The left hand side of the less than or equal.
rhs The right hand side of the less than or equal.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::real_le_real_expression_factory ( const expression::pointer lhs,
const expression::pointer rhs 
) [virtual]

The le_expression_factory method is used to create a new less than or equal expression object instance.

Parameters:
lhs The left hand side of the less than or equal.
rhs The right hand side of the less than or equal.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::string_le_string_expression_factory ( const expression::pointer lhs,
const expression::pointer rhs 
) [virtual]

The le_expression_factory method is used to create a new less than or equal expression object instance.

Parameters:
lhs The left hand side of the less than or equal.
rhs The right hand side of the less than or equal.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::boolean_gt_boolean_expression_factory ( const expression::pointer lhs,
const expression::pointer rhs 
) [virtual]

The boolean_gt_boolean_expression_factory method is used to create a new greater than expression object instance.

Parameters:
lhs The left hand side of the greater than.
rhs The right hand side of the greater than.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::integer_gt_integer_expression_factory ( const expression::pointer lhs,
const expression::pointer rhs 
) [virtual]

The integer_gt_integer_expression_factory method is used to create a new greater than expression object instance.

Parameters:
lhs The left hand side of the greater than.
rhs The right hand side of the greater than.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::real_gt_real_expression_factory ( const expression::pointer lhs,
const expression::pointer rhs 
) [virtual]

The real_gt_real_expression_factory method is used to create a new greater than expression object instance.

Parameters:
lhs The left hand side of the greater than.
rhs The right hand side of the greater than.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::string_gt_string_expression_factory ( const expression::pointer lhs,
const expression::pointer rhs 
) [virtual]

The string_gt_string_expression_factory method is used to create a new greater than expression object instance.

Parameters:
lhs The left hand side of the greater than.
rhs The right hand side of the greater than.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::boolean_ge_boolean_expression_factory ( const expression::pointer lhs,
const expression::pointer rhs 
) [virtual]

The boolean_ge_boolean_expression_factory method is used to create a new greater than or equal expression object instance.

Parameters:
lhs The left hand side of the greater than or equal.
rhs The right hand side of the greater than or equal.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::integer_ge_integer_expression_factory ( const expression::pointer lhs,
const expression::pointer rhs 
) [virtual]

The integer_ge_integer_expression_factory method is used to create a new greater than or equal expression object instance.

Parameters:
lhs The left hand side of the greater than or equal.
rhs The right hand side of the greater than or equal.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::real_ge_real_expression_factory ( const expression::pointer lhs,
const expression::pointer rhs 
) [virtual]

The real_ge_real_expression_factory method is used to create a new greater than or equal expression object instance.

Parameters:
lhs The left hand side of the greater than or equal.
rhs The right hand side of the greater than or equal.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::string_ge_string_expression_factory ( const expression::pointer lhs,
const expression::pointer rhs 
) [virtual]

The string_ge_string_expression_factory method is used to create a new greater than or equal expression object instance.

Parameters:
lhs The left hand side of the greater than or equal.
rhs The right hand side of the greater than or equal.
Returns:
A pointer to an expression object.

Implements translator.

bool translator_compile::emit_byte ( unsigned char  value  ) 

The emit_byte method is used to emit a byte into the current segment's code stream.

Parameters:
value The value of the byte to be written.
Returns:
bool; true if the byte fits, false if we have run out of room in the current segment.

bool translator_compile::emit_word_alignment ( unsigned char  value = 0  ) 

The emit_word_alignment method is used to add a single filler byte, if necessary, so that the next data in the code stream will be word aligned.

bool translator_compile::emit_odd_alignment ( unsigned char  value = 0  ) 

The emit_odd_alignment method is used to add a single filler byte, if necessary, so that the next data in the code stream will not be word aligned.

bool translator_compile::emit_word ( unsigned  value  ) 

The emit_word method is used to emit a two byte word into the current segment's code stream.

Parameters:
value The value of the word to be written.
Returns:
bool; true if the word fits, false if we have run out of room in the current segment.

bool translator_compile::emit_big ( unsigned  value  ) 

The emit_big method is used to emit a two byte "big" into the current segment's code stream if the value is 128 or more, and a single byte "big" if the value is less than 128..

Parameters:
value The value of the word to be written.
Returns:
bool; true if the word fits, false if we have run out of room in the current segment.

bool translator_compile::emit_ldci ( int  n  ) 

The emit_ldci method is used to push a constant integer value onto the stack. It optimizes for space, rather than speed.

Parameters:
n the value of the constant to be pushed
Returns:
bool; true if the word fits, false if we have run out of room in the current segment.

void translator_compile::error ( const location ,
const char *  fmt,
  ... 
)

The error method is used to print error messages using the given location. If there are any errors, the compile will exit with a failure exit status.

Parameters:
fmt The format of the rest of the arguments. See printf(3) for more information.

void translator_compile::new_segment ( const rcstring name  ) 

The new_segment method is used to create a new code segment to hold code. Any emit_byte calls will be delivered into the new segments until (a) a segment procedure happens, or scope_end is called.

int translator_compile::next_procedure_number (  ) 

The next_procedure_number method is used to obtain the next available procedure number, and allocate space in the procedure dictionary for it.

Returns:
int; >0 on success, <0 whe too many procedures

void translator_compile::procedure_parameter_size ( unsigned  nbytes  ) 

The procedure_parameter_size method is used to inform the current segment under construction that the current procedure under construction has the given number of bytes of call parameters.

Parameters:
nbytes The number of bytes of call arguments

void translator_compile::procedure_variable_size ( unsigned  nbytes  ) 

The procedure_variable_size method is used to inform the current segment under construction that the current procedure under construction has the given number of bytes of local variables.

Parameters:
nbytes The number of bytes of call arguments

void translator_compile::procedure_enter_ic (  ) 

The procedure_enter_ic method is used to inform the current segment under construction that the current procedure under construction begins at the current code address (know to the segemnt builder, but not to the caller).

void translator_compile::procedure_exit_ic (  ) 

The procedure_exit_ic method is used to inform the current segment under construction that the current procedure under construction's return code begins at the current code address (know to the segemnt builder, but not to the caller).

void translator_compile::procedure_end ( int  procedure_number,
int  lex_level 
)

The procedure_end method is used to inform the current segment under construction that the current procedure under construction is not complete, and the jumps table and procedure attributes may be written. This also gives a concrete value for the pointer in the procedure dictionary.

Parameters:
procedure_number This is the value previously returned by the next_procedure_number method.
lex_level Um, ...

void translator_compile::segment_end (  ) 

The segment_end method is used to complete the current segment.

unsigned translator_compile::get_address (  )  const

The get_address method is used to obtain the current code address of the current segment. This should only be used by the lable_compile class.

void translator_compile::poke ( unsigned  address,
unsigned char  value 
)

The poke method is used to insert a byte into the code stream, overwriting an existing place-marker byte (jump offset). This shall only be used by the label_compile class.

int translator_compile::new_jump_table_entry ( unsigned  address  ) 

The new_jump_table_index method is used to get another jump table entry for the specified address.

Parameters:
address The destination of the jump table entry (the actual value will be self relative, once the size of the jump table is known).

unsigned translator_compile::get_segment_number (  )  const

The get_segment_number method is used to obtain the number of the curremt segment. This is needed generate correct cross-segment calls.

void translator_compile::breakpoint ( const location locn  ) 

The breakpoint method is used to (conditionally) insert a breakpoint into the code.

Parameters:
locn The location for the breakpoint.

void translator_compile::need_segment_31 (  )  [inline]

The need_segment_31 method is used to have the compiler remember that segment 31 must be loaded, because the compiler will generate code which needs it. (This is the segment which contains code for reading and writing reals.)

Definition at line 449 of file compile.h.

References segment_31_flag.

bool translator_compile::segment_31_needed (  )  const [inline]

The segment_31_needed method is used to determine whether or not code should be generated into the program main procedure to load and unload segment 31.

Definition at line 456 of file compile.h.

References segment_31_flag.

expression::pointer translator_compile::range_check ( const expression::pointer value,
const type::pointer against 
)

The range_check method is used to build a range check expression.

Parameters:
value The value to be checked, and the result of evaluating this expression.
against the type to range check against

expression::pointer translator_compile::range_check ( const expression::pointer value,
int  minimum,
int  maximum 
)

The range_check method is used to build a range check expression.

Parameters:
value The value to be checked, and the result of evaluating this expression.
minimum The minimum acceptable value.
maximum The maximum acceptable value.

void translator_compile::post_order_traversal (  )  [protected, virtual]

The post_order_traversal method is called (by the traversal method) after all of the declarations are traversed. The default implementation does nothing.

Reimplemented from translator.

label::pointer translator_compile::label_factory (  )  [protected, virtual]

The label_factory method is used to create new label instances, so that code jumps can be generated for conditional and loop statements.

Reimplemented from translator.

symbol* translator_compile::function_symbol_factory ( const rcstring name,
const scope::pointer scp,
int  lex_level 
) [protected, virtual]

The function_symbol_factory is used to create translator-specific function objects. They need to be translator specific, because they need to know how to create translator-specific function call expression nodes.

Parameters:
name The name of the function
scp The scope this function defines.
lex_level The function nesting level.
Returns:
pointer to new function symbol in dynamic memory

Implements translator.

expression::pointer translator_compile::dereference_expression_factory ( const expression::pointer arg  )  [protected, virtual]

The dereference_expression_factory method is used to create a new dereference expression object instance.

Parameters:
arg The operand of the dereference.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::logical_and_expression_factory ( const expression::pointer lhs,
const expression::pointer rhs 
) [protected, virtual]

The logical_and_expression_factory method is used to create a new logical and expression object instance.

Parameters:
lhs The left hand side of the logical and.
rhs The right hand side of the logical and.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::logical_or_expression_factory ( const expression::pointer lhs,
const expression::pointer rhs 
) [protected, virtual]

The logical_or_expression_factory method is used to create a new logical or expression object instance.

Parameters:
lhs The left hand side of the logical or.
rhs The right hand side of the logical or.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::logical_not_expression_factory ( const expression::pointer arg  )  [protected, virtual]

The logical_not_expression_factory method is used to create a new negate expression object instance.

Parameters:
arg The expression to be logically negated.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::sizeof_expression_factory ( const type::pointer arg  )  [protected, virtual]

The sizeof_expression_factory method is used by the sizeof_expression method after routine checks.

Parameters:
arg The type we want the size of.
Returns:
An expression with the size as a constant.

Implements translator.

expression::pointer translator_compile::char_expression_factory ( const location locn,
unsigned char  value 
) [protected, virtual]

The char_expression_factory method is used to create a new char constant expression object instance.

Parameters:
locn The location of the constant
value The value of the char.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::empty_set_expression_factory ( const location locn,
const type::pointer tp 
) [protected, virtual]

The empty_set_expression_factory method is used to create a new empty set expression object instance.

Parameters:
locn The source file location of this expression node.
tp The type of the set.
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::set_expression_factory ( const expression::pointer singleton  )  [protected, virtual]

The set_expression_factory method is used to create a new set expression object instance.

Parameters:
singleton The expression to be the whole of the range
Returns:
A pointer to an expression object.

Implements translator.

expression::pointer translator_compile::set_expression_factory ( const expression::pointer lo,
const expression::pointer hi 
) [protected, virtual]

The set_expression_factory method is used to create a new set expression object instance.

Parameters:
lo The expression to be the low side of the range
hi The expression to be the high side of the range
Returns:
A pointer to an expression object.

Implements translator.

symbol* translator_compile::builtin_chr_factory (  )  [protected, virtual]

The builtin_chr_factory method is used to create the translator specific implmentation of the built in "chr" function.

Implements translator.

symbol* translator_compile::builtin_dec_factory (  )  [protected, virtual]

The builtin_dec_factory method is used to create the translator specific implmentation of the built in "dec" function.

Implements translator.

symbol* translator_compile::builtin_inc_factory (  )  [protected, virtual]

The builtin_inc_factory method is used to create the translator specific implmentation of the built in "inc" function.

Implements translator.

symbol* translator_compile::builtin_odd_factory (  )  [protected, virtual]

The builtin_odd_factory method is used to create the translator specific implmentation of the built in "odd" function.

Implements translator.

symbol* translator_compile::builtin_ord_factory (  )  [protected, virtual]

The builtin_ord_factory method is used to create the translator specific implmentation of the built in "ord" function.

Implements translator.

symbol* translator_compile::builtin_pred_factory (  )  [protected, virtual]

The builtin_pred_factory method is used to create the translator specific implmentation of the built in "pred" function.

Implements translator.

symbol* translator_compile::builtin_sqr_factory (  )  [protected, virtual]

The builtin_sqr_factory method is used to create the translator specific implmentation of the built in "sqr" function.

Implements translator.

symbol* translator_compile::builtin_succ_factory (  )  [protected, virtual]

The builtin_succ_factory method is used to create the translator specific implmentation of the built in "succ" function.

Implements translator.

symbol* translator_compile::builtin_time_factory (  )  [protected, virtual]

The builtin_time_factory method is used to create the translator specific implmentation of the built in "time" function.

Implements translator.

symbol_function* translator_compile::builtin_syscall_factory ( const rcstring name,
int  proc_num 
) [protected, virtual]

The builtin_syscall_factory method is used to create a symbol for a segment-zero function or procedure.

Parameters:
name the name of the symbol
proc_num the procedure number within segment zero
Returns:
pointer to dynamically allocated symbol

Implements translator.

translator_compile& translator_compile::operator= ( const translator_compile  )  [private]

The assignment operator. Do not use.


Member Data Documentation

codefile* translator_compile::cfp [private]

The cfp instance variable is used to reember the code file to receive the compiled p-code.

Definition at line 566 of file compile.h.

int translator_compile::number_of_errors [private]

The number_of_errors instance variable is used to remember the number of code geneation errors. If there are any errors, the compile will exit with a failure exit status.

Definition at line 573 of file compile.h.

segment_builder_stack translator_compile::segstack [private]

The segstack instance variable is used to reemmber the push-down stack of segments currently being built.

Definition at line 579 of file compile.h.

location translator_compile::bpt_locn [private]

The bpt_locn instance variable is used to remember the current breakpoint location.

Definition at line 585 of file compile.h.

bool translator_compile::segment_31_flag [private]

The segment_31_flag instance variable is used to remember that segment 31 must be loaded, because the compiler will generate code which needs it. (This is the segment which contains code for reading and writing reals.)

Definition at line 593 of file compile.h.

Referenced by need_segment_31(), and segment_31_needed().


The documentation for this class was generated from the following file:
Generated on Sun Feb 25 01:27:14 2007 for UCSDp-SystemCrossCompiler by  doxygen 1.5.1