LRDE Tiger Compiler
1.34a $Id: 7fef12e1f5fa43449d667a0eec1d837c40fc1202 $
|
#include <function.hh>
Public Member Functions | |
Function (const Record *formals, const Type &result) | |
Construct a Function. | |
virtual | ~Function () |
Destructor. | |
virtual std::ostream & | dump (std::ostream &ostr) const override |
Print function's result's and formals's types. | |
virtual bool | compatible_with (const Type &other) const |
Whether two types are "compatible". | |
Accessors. | |
const Record & | formals_get () const |
Return the type structures of the function's arguments. | |
const Type & | result_get () const |
Return the type structure of the function's result. | |
Accessors. | |
virtual const Type & | actual () const |
Return the actual type held by THIS. |
Protected Attributes | |
const Record * | formals_ |
Formals' types. | |
const Type & | result_ |
Result's type. |
Function types.
Encapsulate the signature of a function, ie the type structures of both function's arguments and its result.
Construct a Function.
formals | type structures of formal arguments. |
result | type structure of what function returns. |
References formals_, and precondition.
|
inlinevirtual |
Destructor.
References formals_.
|
virtualinherited |
Return the actual type held by THIS.
Reimplemented in type::Named.
Referenced by object::TypeChecker::operator()(), and object::DesugarVisitor::recurse_args().
|
virtualinherited |
Whether two types are "compatible".
I.e., whether "a = b", "a <> b", "a := b" are correctly typed with a of type this, and b of type other).
By default two types are compatible (in the sense of "=" and "<>", not wrt an order) only when they are equal.
In the case of assignment, "rec := nil" is valid, but "nil := rec" is not, which suggest that we should have a non commutative assignment specific compatibility check. But since "nil := ..." is incorrect syntactically, that is not needed.
Reimplemented in type::Named, and type::Nil.
|
overridevirtual |
Print function's result's and formals's types.
Implements type::Type.
References formals_, type::hide_actual_types, result_, and misc::xalloc< StoredType >::swap().
|
inline |
Return the type structures of the function's arguments.
References formals_.
|
inline |
Return the type structure of the function's result.
References result_.
|
protected |
Formals' types.
Referenced by dump(), formals_get(), Function(), and ~Function().
|
protected |
Result's type.
Referenced by dump(), and result_get().