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

Method types. More...

#include <method.hh>

Inheritance diagram for type::Method:
Collaboration diagram for type::Method:

Public Member Functions

 Method (const misc::symbol &name, const Class *owner, const Record *formals, const Type &result, ast::MethodDec *def)
 Construct a FunEntry.
virtual ~Method ()
 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.
misc::symbol name_get () const
 Return the method's name.
const Classowner_get () const
 Return thes method's owner (enclosing class).
const ast::MethodDecdef_get () const
 Return the method's definiton site.
ast::MethodDecdef_get ()
 Return the method's definiton site.
void name_set (const misc::symbol &name)
 Set the method's name.
void def_set (ast::MethodDec *def)
 set the method's definiton site.
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.

Private Types

typedef Function super_type
 A shortcut for the super type of this class.

Private Attributes

misc::symbol name_
 Method's identifier.
const Classowner_
 The Class where this Method is defined.
ast::MethodDecdef_
 Method's definition site.

Detailed Description

Method types.

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

Member Typedef Documentation

A shortcut for the super type of this class.

Constructor & Destructor Documentation

type::Method::Method ( const misc::symbol name,
const Class owner,
const Record formals,
const Type result,
ast::MethodDec def 
)

Construct a FunEntry.

Parameters
nameThe method's identifier.
ownerThe type::Class owning this method.
formalsThe type structures of formal arguments.
resultThe type structure of what method returns.
defThe method's definition site.
type::Method::~Method ( )
virtual

Destructor.

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.

const ast::MethodDec * type::Method::def_get ( ) const
inline

Return the method's definiton site.

References def_.

Referenced by object::DesugarVisitor::dispatch_switch().

ast::MethodDec * type::Method::def_get ( )
inline

Return the method's definiton site.

References def_.

void type::Method::def_set ( ast::MethodDec def)
inline

set the method's definiton site.

References def_.

std::ostream & type::Function::dump ( std::ostream &  ostr) const
overridevirtualinherited

Print function's result's and formals's types.

Implements type::Type.

References type::Function::formals_, type::hide_actual_types, type::Function::result_, and misc::xalloc< StoredType >::swap().

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

Return the type structures of the function's arguments.

References type::Function::formals_.

misc::symbol type::Method::name_get ( ) const
inline

Return the method's name.

References name_.

Referenced by object::DesugarVisitor::dispatch_fun_name(), and object::DesugarVisitor::dispatch_switch().

void type::Method::name_set ( const misc::symbol name)
inline

Set the method's name.

References name_.

const Class * type::Method::owner_get ( ) const
inline

Return thes method's owner (enclosing class).

References owner_.

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

Return the type structure of the function's result.

References type::Function::result_.

Member Data Documentation

ast::MethodDec* type::Method::def_
private

Method's definition site.

Referenced by def_get(), and def_set().

const Record* type::Function::formals_
protectedinherited
misc::symbol type::Method::name_
private

Method's identifier.

Referenced by name_get(), and name_set().

const Class* type::Method::owner_
private

The Class where this Method is defined.

Referenced by owner_get().

const Type& type::Function::result_
protectedinherited

Result's type.

Referenced by type::Function::dump(), and type::Function::result_get().


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