LRDE Tiger Compiler  1.34a $Id: 7fef12e1f5fa43449d667a0eec1d837c40fc1202 $
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
type::Function Class Reference

Function types. More...

#include <function.hh>

Inheritance diagram for type::Function:
Collaboration diagram for type::Function:

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 Recordformals_get () const
 Return the type structures of the function's arguments.
const Typeresult_get () const
 Return the type structure of the function's result.
Accessors.
virtual const Typeactual () const
 Return the actual type held by THIS.

Protected Attributes

const Recordformals_
 Formals' types.
const Typeresult_
 Result's type.

Detailed Description

Function types.

Encapsulate the signature of a function, ie the type structures of both function's arguments and its result.

Constructor & Destructor Documentation

type::Function::Function ( const Record formals,
const Type result 
)
inline

Construct a Function.

Parameters
formalstype structures of formal arguments.
resulttype structure of what function returns.

References formals_, and precondition.

type::Function::~Function ( )
inlinevirtual

Destructor.

References formals_.

Member Function Documentation

const Type & type::Type::actual ( ) const
virtualinherited

Return the actual type held by THIS.

Reimplemented in type::Named.

Referenced by object::TypeChecker::operator()(), and object::DesugarVisitor::recurse_args().

bool type::Type::compatible_with ( const Type other) const
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.

std::ostream & type::Function::dump ( std::ostream &  ostr) const
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().

const Record & type::Function::formals_get ( ) const
inline

Return the type structures of the function's arguments.

References formals_.

const Type & type::Function::result_get ( ) const
inline

Return the type structure of the function's result.

References result_.

Member Data Documentation

const Record* type::Function::formals_
protected

Formals' types.

Referenced by dump(), formals_get(), Function(), and ~Function().

const Type& type::Function::result_
protected

Result's type.

Referenced by dump(), and result_get().


The documentation for this class was generated from the following files: