Next: Determining the types yielded
Up: Associating types with identifiers
Previous: Analyze specifiers
Analyze declarators
New types are created in declarator contexts.
In each case, the new type is related to an existing type that is obtained
from the parent of the context.
Relationships among types[47]
:
ATTR ExistingType, TotalType: DefTableKey;
CLASS SYMBOL Declarator INHERITS TypeDenotation, OperatorDefs COMPUTE
INH.ExistingType=INCLUDING (Declarator.Type, Declaration.Type);
END;
CLASS SYMBOL DeclaredId COMPUTE
SYNT.TotalType=INCLUDING (Declarator.Type, Declaration.Type);
END;
TREE SYMBOL MemberIdDef INHERITS DeclaredId END;
TREE SYMBOL IdDef INHERITS DeclaredId END;
CLASS SYMBOL PointerDeclarator INHERITS Declarator COMPUTE
SYNT.GotType=
AddTypeToBlock(
THIS.Type,
PointerTypes, /* FIXME: Pointer types have extra qualifiers */
SingleDefTableKeyList(THIS.ExistingType));
SYNT.GotOper=InstClass1(TypeIs_Pointer,THIS.Type,THIS.ExistingType);
END;
TREE SYMBOL pointer_declarator INHERITS PointerDeclarator END;
TREE SYMBOL member_pointer_declarator INHERITS PointerDeclarator END;
TREE SYMBOL pointer_abstract_declarator INHERITS PointerDeclarator END;
ATTR Pointer: DefTableKey;
CLASS SYMBOL ArrayDeclarator INHERITS Declarator COMPUTE
SYNT.Pointer=NewType();
SYNT.GotType=
ORDER(
AddTypeToBlock(
THIS.Pointer,
PointerTypes, /* FIXME: This doesn't account for array size */
SingleDefTableKeyList(THIS.ExistingType)),
AddTypeToBlock(
THIS.Type,
ArrayTypes, /* FIXME: This doesn't account for array size */
SingleDefTableKeyList(THIS.ExistingType)));
SYNT.GotOper=
InstClass2(TypeIs_Array,THIS.Type,THIS.ExistingType,THIS.Pointer);
END;
TREE SYMBOL array_declarator INHERITS ArrayDeclarator END;
TREE SYMBOL member_array_declarator INHERITS ArrayDeclarator END;
TREE SYMBOL array_abstract_declarator INHERITS ArrayDeclarator END;
CLASS SYMBOL FunctionDeclarator INHERITS Declarator COMPUTE
SYNT.Pointer=NewType();
SYNT.GotType=
ORDER(
AddTypeToBlock(
THIS.Pointer,
PointerTypes,
SingleDefTableKeyList(THIS.Type)),
AddTypeToBlock(
THIS.Type,
FunctionTypes,
ConsDefTableKeyList(
THIS.ExistingType,
CONSTITUENT OpndTypeListRoot.OpndTypeList
SHIELD (Declarator, OpndTypeListRoot))));
END;
TREE SYMBOL parameter_type_list INHERITS OpndTypeListRoot END;
TREE SYMBOL parameters INHERITS OpndTypeListRoot END;
TREE SYMBOL ParameterType INHERITS OpndTypeListElem END;
TREE SYMBOL parameter_id INHERITS OpndTypeListElem END;
TREE SYMBOL DotDotDot INHERITS OpndTypeListElem END;
TREE SYMBOL parameter_id INHERITS TypeDefUseId, ChkTypeDefUseId END;
TREE SYMBOL ParameterTypeId INHERITS TypeDefDefId END;
RULE: DotDotDot ::= '...' COMPUTE
DotDotDot.Type=VarArgType;
END;
RULE: ParameterTypeId ::= ParameterDecl COMPUTE
ParameterTypeId.Key=ParameterDecl.Key;
ParameterTypeId.Type=ParameterDecl.TotalType;
END;
RULE: ParameterType ::= parameter_declaration COMPUTE
ParameterType.Type=parameter_declaration.TotalType;
END;
TREE SYMBOL function_declarator INHERITS FunctionDeclarator END;
RULE: function_declarator ::= declarator '(' parameter_type_list ')' COMPUTE
function_declarator.GotOper=
ORDER(
InstClass1(
TypeIs_Function,
function_declarator.Type,
function_declarator.Pointer),
ListOperator(
function_declarator.Type,
NoOprName,
parameter_type_list.OpndTypeList,
function_declarator.ExistingType));
END;
RULE: function_declarator ::= declarator '(' parameters ')' COMPUTE
function_declarator.GotOper=
ORDER(
InstClass1(
TypeIs_Function,
function_declarator.Type,
function_declarator.Pointer),
ListOperator(
function_declarator.Type,
NoOprName,
parameters.OpndTypeList,
function_declarator.ExistingType));
END;
TREE SYMBOL function_abstract_declarator INHERITS FunctionDeclarator END;
RULE: function_abstract_declarator ::= '(' parameter_type_list ')' COMPUTE
function_abstract_declarator.GotOper=
ORDER(
InstClass1(
TypeIs_Function,
function_abstract_declarator.Type,
function_abstract_declarator.Pointer),
ListOperator(
function_abstract_declarator.Type,
NoOprName,
parameter_type_list.OpndTypeList,
function_abstract_declarator.ExistingType));
END;
RULE: function_abstract_declarator ::=
abstract_declarator '(' parameter_type_list ')' COMPUTE
function_abstract_declarator.GotOper=
ORDER(
InstClass1(
TypeIs_Function,
function_abstract_declarator.Type,
function_abstract_declarator.Pointer),
ListOperator(
function_abstract_declarator.Type,
NoOprName,
parameter_type_list.OpndTypeList,
function_abstract_declarator.ExistingType));
END;
TREE SYMBOL member_function_declarator INHERITS FunctionDeclarator END;
RULE: member_function_declarator ::=
member_declarator '(' parameter_type_list ')' COMPUTE
member_function_declarator.GotOper=
ORDER(
InstClass1(
TypeIs_Function,
member_function_declarator.Type,
member_function_declarator.Pointer),
ListOperator(
member_function_declarator.Type,
NoOprName,
parameter_type_list.OpndTypeList,
member_function_declarator.ExistingType));
END;
RULE: declarator ::= TypeIdDef COMPUTE
TypeIdDef.Type=INCLUDING (Declarator.Type, Declaration.Type);
END;
RULE: type_name ::= Specifiers COMPUTE
type_name.TotalType=Specifiers.Type;
END;
RULE: type_name ::= Specifiers abstract_declarator COMPUTE
type_name.TotalType=abstract_declarator.TotalType;
END;
RULE: abstract_declarator ::= pointer_abstract_declarator COMPUTE
abstract_declarator.TotalType=pointer_abstract_declarator.TotalType;
END;
RULE: abstract_declarator ::= array_abstract_declarator COMPUTE
abstract_declarator.TotalType=array_abstract_declarator.TotalType;
END;
RULE: abstract_declarator ::= function_abstract_declarator COMPUTE
abstract_declarator.TotalType=function_abstract_declarator.TotalType;
END;
RULE: pointer_abstract_declarator ::= '*' Specifiers COMPUTE
pointer_abstract_declarator.TotalType=pointer_abstract_declarator.Type;
END;
RULE: pointer_abstract_declarator ::=
'*' Specifiers abstract_declarator COMPUTE
pointer_abstract_declarator.TotalType=abstract_declarator.TotalType;
END;
RULE: array_abstract_declarator ::= '[' constant_expression ']' COMPUTE
array_abstract_declarator.TotalType=array_abstract_declarator.Type;
END;
RULE: array_abstract_declarator ::=
abstract_declarator '[' constant_expression ']' COMPUTE
array_abstract_declarator.TotalType=abstract_declarator.TotalType;
END;
RULE: function_abstract_declarator ::= '(' parameter_type_list ')' COMPUTE
function_abstract_declarator.TotalType=function_abstract_declarator.Type;
END;
RULE: function_abstract_declarator ::=
abstract_declarator '(' parameter_type_list ')' COMPUTE
function_abstract_declarator.TotalType=abstract_declarator.TotalType;
END;
RULE: declarator ::= TypeIdDef COMPUTE
declarator.TotalType=TypeIdDef.Type;
END;
RULE: declarator ::= IdDef COMPUTE
declarator.TotalType=IdDef.Type;
END;
RULE: declarator ::= pointer_declarator COMPUTE
declarator.TotalType=pointer_declarator.TotalType;
END;
RULE: declarator ::= array_declarator COMPUTE
declarator.TotalType=array_declarator.TotalType;
END;
RULE: declarator ::= function_declarator COMPUTE
declarator.TotalType=function_declarator.TotalType;
END;
RULE: pointer_declarator ::= '*' Specifiers declarator COMPUTE
pointer_declarator.TotalType=declarator.TotalType;
END;
RULE: array_declarator ::= declarator '[' constant_expression ']' COMPUTE
array_declarator.TotalType=declarator.TotalType;
END;
RULE: function_declarator ::= declarator '(' parameter_type_list ')' COMPUTE
function_declarator.TotalType=declarator.TotalType;
END;
RULE: function_declarator ::= declarator '(' parameters ')' COMPUTE
function_declarator.TotalType=declarator.TotalType;
END;
RULE: parameter_declaration ::= Specifiers ParameterDecl COMPUTE
parameter_declaration.TotalType=ParameterDecl.TotalType;
END;
RULE: parameter_declaration ::= Specifiers abstract_declarator COMPUTE
parameter_declaration.TotalType=abstract_declarator.TotalType;
END;
RULE: parameter_declaration ::= Specifiers COMPUTE
parameter_declaration.TotalType=Specifiers.Type;
END;
RULE: ParameterDecl ::= declarator COMPUTE
ParameterDecl.TotalType=declarator.TotalType;
END;
This macro is defined in definitions 47.
This macro is invoked in definition 1.
Define keys, properties, and access functions[48]
:
PointerTypes;
ArrayTypes;
FunctionTypes;
This macro is defined in definitions 48.
This macro is invoked in definition 2.
$/Type/StructEquiv.fw
This macro is defined in definitions 29, 49, 50, and 51.
This macro is invoked in definition 3.
Next: Determining the types yielded
Up: Associating types with identifiers
Previous: Analyze specifiers
2008-08-30