Traductor e intérprete del lenguaje CL 1.23
TypeTree Class Reference

Árboles específicos para representar tipos de CL. More...

List of all members.

Public Member Functions

TypeTree getChild (int i)
 Sobreescribe el método que obtiene el i-éesimo hijo del nodo actual del TypeTree.

Package Functions

 TypeTree ()
 Constructor por defecto, sin parámetros, de un nodo.
 TypeTree (int type)
 Constructor utilizado para crear un tipo básico (INT o BOOL)
 TypeTree (int type, String text)
 Constructor donde se suministran el tipo y el texto de un token para formar un tipo.
 TypeTree (CL_AST t)
 Constructor de un nodo donde el tipo y el texto del token se extraen de un nodo del AST.
 TypeTree (TypeTree t)
 Constructor de un nodo donde el tipo y el texto del token se extraen de un nodo del TypeTree.
boolean isTypeInt ()
 Es un tipo entero (INT)?
boolean isTypeBool ()
 Es un tipo booleano (BOOL)?
boolean isTypeNumeric ()
 Es un tipo numérico (entero)?
boolean isTypeBasic ()
 Es un tipo básico (entero o booleano)?
boolean isTypeStruct ()
 Es un tipo struct (STRUCT)?
boolean isTypeArray ()
 Es un tipo array (ARRAY)?
boolean isTypeProcedure ()
 Es un bloque tipo procedimiento?
boolean isTypeFunction ()
 Es un bloque tipo función?
boolean isTypeUndefined ()
 Es de tipo indefinido (TypeUndefined)?
boolean isTypeError ()
 Es de tipo error (TypeError)?
void setTypeError ()
 Establece el tipo a tipo error.
TypeTree getFieldNumber (int i)
 Dado un tipo struct, obtiene su i-ésimo campo.
String getFieldNameStruct ()
 Dado un TypeTree que representa un campo de un struct, obtiene el nombre del campo.
TypeTree getFieldTypeStruct ()
 Dado un TypeTree que representa un campo de un struct, obtiene el tipo del campo.
TypeTree searchFieldStruct (String s)
 Dado un struct (parámetro implícito) y el nombre de un campo, obtiene el tipo del campo.
int getNumElemsArray ()
 Dado un tipo array, obtiene su tamaño (número de elementos).
TypeTree getElemTypeArray ()
 Dado un tipo array, obtiene el tipo de los elementos del array.
TypeTree getProcLFormalPars ()
 Obtiene la lista de parámetros formales de un procedimiento (bloque PROCEDURE).
TypeTree getFuncLFormalPars ()
 Obtiene la lista de parámetros formales de una función (bloque FUNCTION).
TypeTree getFuncTypeResult ()
 Obtiene el tipo que devuelve una función.
TypeTree getFormalParamNumber (int i)
 Dada la lista de parámetros formales de un procedimiento o función, obtiene el i-ésimo parámetro formal.
boolean isValFormalParam ()
 Dado un TypeTree correspondiente a un parámetro formal, está pasado por valor?.
boolean isRefFormalParam ()
 Dado un TypeTree correspondiente a un parámetro formal, está pasado por referencia?.
TypeTree getFormalParamType ()
 Dado un TypeTree correspondiente a un parámetro formal, devuelve el tipo del parámetro.

Static Package Functions

static boolean equalFormalParamPassing (TypeTree t1, TypeTree t2)
 Dados dos TypeTree 's correspondientes a dos parámetros formales, determina si tienen el mismo mecanismo de paso.
static boolean equalTypes (TypeTree t1, TypeTree t2)
 Determina si dos tipos (dos TypeTree 's) son estructuralmente iguales.
static TypeTree duplicateType (TypeTree t1)
 Dado un tipo (un TypeTree), construye y devuelve otro tipo identico (estructuralmente igual).

Detailed Description

Árboles específicos para representar tipos de CL.

Se admiten los tipos básicos entero y booleano, los tipos estructurados struct(...) y array(...), y se pueden declarar además procedimientos y funciones.

Los TypeTree's se usan para representar los tipos de los objetos de un programa CL, por ejemplo, usamos un TypeTree para decorar los nodos del AST que son subexpresiones, especificando cuál es su tipo.

Al igual que la clase CL_AST, la clase TypeTree extiende la clase CommonTree, pero sin añadir nueva información en los nodos (nuevos atributos). En cambio sí se definen métodos específicos para trabajar con la estructura e información de los tipos de CL.

ANTLR API Documentation [CommonTree Class]:
http://www.antlr.org/api/Java/classorg_1_1antlr_1_1runtime_1_1tree_1_1_common_tree.html
See also:
CommonTree
Author:
José Miguel Rivero Almeida

Definition at line 59 of file TypeTree.java.


Constructor & Destructor Documentation

TypeTree.TypeTree ( ) [package]

Constructor por defecto, sin parámetros, de un nodo.

En el nodo creado el atributo token se inicializa para representar un tipo indefinido (TypeUndefined, definido en TypeCheck.g)

Definition at line 66 of file TypeTree.java.

Here is the caller graph for this function:

TypeTree.TypeTree ( int  type) [package]

Constructor utilizado para crear un tipo básico (INT o BOOL)

Parameters:
[in]typecódigo (type) del token INT o BOOL

Definition at line 75 of file TypeTree.java.

TypeTree.TypeTree ( int  type,
String  text 
) [package]

Constructor donde se suministran el tipo y el texto de un token para formar un tipo.

No es necesario utilizarlo.

Parameters:
[in]typecódigo (type) del token que se incorpora al nodo
[in]texttexto (text) del token que se incorpora al nodo

Definition at line 87 of file TypeTree.java.

TypeTree.TypeTree ( CL_AST  t) [package]

Constructor de un nodo donde el tipo y el texto del token se extraen de un nodo del AST.

Parameters:
[in]tnodo del CL_AST de donde se toma la información para el nodo creado

Definition at line 96 of file TypeTree.java.

TypeTree.TypeTree ( TypeTree  t) [package]

Constructor de un nodo donde el tipo y el texto del token se extraen de un nodo del TypeTree.

Parameters:
[in]tnodo del TypeTree de donde se toma la información para el nodo creado

Definition at line 105 of file TypeTree.java.


Member Function Documentation

static TypeTree TypeTree.duplicateType ( TypeTree  t1) [static, package]

Dado un tipo (un TypeTree), construye y devuelve otro tipo identico (estructuralmente igual).

Parameters:
[in]t1el primer tipo
Returns:
un TypeTree identico a t1

Definition at line 399 of file TypeTree.java.

Here is the call graph for this function:

static boolean TypeTree.equalFormalParamPassing ( TypeTree  t1,
TypeTree  t2 
) [static, package]

Dados dos TypeTree 's correspondientes a dos parámetros formales, determina si tienen el mismo mecanismo de paso.

Ambos deben ser por valor (VAL) o por referencia (REF).

Returns:
cierto ssi tienen el mismo mecanismo de paso

Definition at line 337 of file TypeTree.java.

static boolean TypeTree.equalTypes ( TypeTree  t1,
TypeTree  t2 
) [static, package]

Determina si dos tipos (dos TypeTree 's) son estructuralmente iguales.

Utiliza el concepto de equivalencia estructural de tipos.

Parameters:
[in]t1el primer tipo
[in]t2el segundo tipo
Returns:
cierto ssi t1 y t2 son estructuralmente iguales

Definition at line 348 of file TypeTree.java.

Here is the call graph for this function:

TypeTree TypeTree.getChild ( int  i)

Sobreescribe el método que obtiene el i-éesimo hijo del nodo actual del TypeTree.

Para evitar tener que hacer castings de la forma: (TypeTree) getChild(i)

Parameters:
[in]inúmero de hijo a obtener, comenzando desde 0
Returns:
El i-ésimo subárbol hijo

Definition at line 200 of file TypeTree.java.

Here is the call graph for this function:

Here is the caller graph for this function:

TypeTree TypeTree.getElemTypeArray ( ) [package]

Dado un tipo array, obtiene el tipo de los elementos del array.

Returns:
el tipo (TypeTree) de los elementos del array, que es el segundo hijo del nodo ARRAY.

Definition at line 264 of file TypeTree.java.

Here is the call graph for this function:

String TypeTree.getFieldNameStruct ( ) [package]

Dado un TypeTree que representa un campo de un struct, obtiene el nombre del campo.

Returns:
el string con el nombre del campo, que se encuentra en el texto del propio nodo IDENT.

Definition at line 220 of file TypeTree.java.

Here is the caller graph for this function:

TypeTree TypeTree.getFieldNumber ( int  i) [package]

Dado un tipo struct, obtiene su i-ésimo campo.

Parameters:
[in]iel número de campo, comenzando desde 0
Returns:
el TypeTree que representa el i-ésimo campo, que incluye tanto el nombre como el tipo del campo.

Definition at line 211 of file TypeTree.java.

Here is the call graph for this function:

TypeTree TypeTree.getFieldTypeStruct ( ) [package]

Dado un TypeTree que representa un campo de un struct, obtiene el tipo del campo.

Returns:
el tipo (TypeTree) de ese campo, que es el primer hijo del nodo actual.

Definition at line 229 of file TypeTree.java.

Here is the call graph for this function:

Here is the caller graph for this function:

TypeTree TypeTree.getFormalParamNumber ( int  i) [package]

Dada la lista de parámetros formales de un procedimiento o función, obtiene el i-ésimo parámetro formal.

Parameters:
[in]iel número de parámetro, comenzando desde 0
Returns:
el i-ésimo parámetro formal de la lista (ListOfFormalParams).

Definition at line 304 of file TypeTree.java.

Here is the call graph for this function:

TypeTree TypeTree.getFormalParamType ( ) [package]

Dado un TypeTree correspondiente a un parámetro formal, devuelve el tipo del parámetro.

Returns:
el tipo (TypeTree) del parámetro.

Definition at line 328 of file TypeTree.java.

Here is the call graph for this function:

TypeTree TypeTree.getFuncLFormalPars ( ) [package]

Obtiene la lista de parámetros formales de una función (bloque FUNCTION).

Returns:
el árbol con la lista completa de parámetros formales (ListOfFormalParams).

Definition at line 283 of file TypeTree.java.

Here is the call graph for this function:

TypeTree TypeTree.getFuncTypeResult ( ) [package]

Obtiene el tipo que devuelve una función.

Returns:
el árbol con el tipo devuelto por la función, que es el segundo hijo del tipo de la función.

Definition at line 292 of file TypeTree.java.

Here is the call graph for this function:

int TypeTree.getNumElemsArray ( ) [package]

Dado un tipo array, obtiene su tamaño (número de elementos).

Returns:
devuelve el número de elementos como un int, no como string, y que encuentra en el primer hijo del nodo ARRAY

Definition at line 255 of file TypeTree.java.

Here is the call graph for this function:

TypeTree TypeTree.getProcLFormalPars ( ) [package]

Obtiene la lista de parámetros formales de un procedimiento (bloque PROCEDURE).

Returns:
el árbol con la lista completa de parámetros formales (ListOfFormalParams).

Definition at line 274 of file TypeTree.java.

Here is the call graph for this function:

boolean TypeTree.isRefFormalParam ( ) [package]

Dado un TypeTree correspondiente a un parámetro formal, está pasado por referencia?.

Returns:
cierto ssi es un parámetro por referencia.

Definition at line 320 of file TypeTree.java.

boolean TypeTree.isTypeArray ( ) [package]

Es un tipo array (ARRAY)?

Definition at line 147 of file TypeTree.java.

boolean TypeTree.isTypeBasic ( ) [package]

Es un tipo básico (entero o booleano)?

Returns:
cierto ssi es un tipo básico

Definition at line 134 of file TypeTree.java.

Here is the call graph for this function:

boolean TypeTree.isTypeBool ( ) [package]

Es un tipo booleano (BOOL)?

Returns:
cierto ssi es un booleano

Definition at line 120 of file TypeTree.java.

Here is the caller graph for this function:

boolean TypeTree.isTypeError ( ) [package]

Es de tipo error (TypeError)?

Returns:
cierto ssi es tipo error

Definition at line 177 of file TypeTree.java.

boolean TypeTree.isTypeFunction ( ) [package]

Es un bloque tipo función?

Returns:
cierto ssi es una FUNCTION

Definition at line 162 of file TypeTree.java.

boolean TypeTree.isTypeInt ( ) [package]

Es un tipo entero (INT)?

Returns:
cierto ssi es un entero

Definition at line 113 of file TypeTree.java.

Here is the caller graph for this function:

boolean TypeTree.isTypeNumeric ( ) [package]

Es un tipo numérico (entero)?

Returns:
cierto ssi es numérico

Definition at line 127 of file TypeTree.java.

Here is the call graph for this function:

boolean TypeTree.isTypeProcedure ( ) [package]

Es un bloque tipo procedimiento?

Returns:
cierto ssi es un PROCEDURE

Definition at line 155 of file TypeTree.java.

boolean TypeTree.isTypeStruct ( ) [package]

Es un tipo struct (STRUCT)?

Definition at line 141 of file TypeTree.java.

boolean TypeTree.isTypeUndefined ( ) [package]

Es de tipo indefinido (TypeUndefined)?

Returns:
cierto ssi es tipo indefinido

Definition at line 170 of file TypeTree.java.

Here is the caller graph for this function:

boolean TypeTree.isValFormalParam ( ) [package]

Dado un TypeTree correspondiente a un parámetro formal, está pasado por valor?.

Returns:
cierto ssi es un parámetro por valor.

Definition at line 312 of file TypeTree.java.

TypeTree TypeTree.searchFieldStruct ( String  s) [package]

Dado un struct (parámetro implícito) y el nombre de un campo, obtiene el tipo del campo.

Parameters:
[in]sel nombre del campo a buscar
Returns:
el tipo (TypeTree) del campo s. Si no lo encuentra devuelve null

Definition at line 239 of file TypeTree.java.

Here is the call graph for this function:

void TypeTree.setTypeError ( ) [package]

Establece el tipo a tipo error.

El tipo error se representa mediante un árbol de un sólo nodo. El tipo del token en el nodo (su type) es modificado a TypeError, token definido en TypeCheck.g, y el texto del token pasa a ser "error"

Definition at line 187 of file TypeTree.java.


The documentation for this class was generated from the following file:
 All Classes Files Functions Variables Enumerations