next up previous
Next: Set types Up: The Pascal type model Previous: Array types

Record types

Establish a user-defined type[16]:
ATTR OpndTypeList: DefTableKeyList;

SYMBOL Record INHERITS TypeDenotation, OperatorDefs END;

RULE: Record ::=  'record' Fields 'end' COMPUTE
  .Type=NewType();
  Record.GotType=
    AddTypeToBlock(
      .Type,
      PointerTypes,
      SingleDefTableKeyList(Record.Type));
  Record.GotOper=
    ORDER(
      InstClass1(ptrType,.Type,Record.Type),
      ListOperator(newType,NoOprName,Fields.OpndTypeList,voidType));
  Fields.OpndTypeList=SingleDefTableKeyList(.Type);
END;

SYMBOL var_part INHERITS OperatorDefs END;

RULE: var_part ::= 'case' var_sel 'of' Variants COMPUTE
  var_part.GotOper=
    ListOperator(newType,NoOprName,Variants.OpndTypeList,voidType);
  Variants.OpndTypeList=
    ConsDefTableKeyList(
      var_sel CONSTITUENT TypIdUse.Type,
      INCLUDING (Fields.OpndTypeList,Variants.OpndTypeList));
END;

TREE SYMBOL TagIdDef INHERITS TypedDefId END;

RULE: var_sel ::= TagIdDef ':' TypIdUse COMPUTE
  TagIdDef.Type=TypIdUse.Type;
END;

RULE: Variant ::= constants ':' '(' Fields ')' COMPUTE
  Fields.OpndTypeList=INCLUDING Variants.OpndTypeList;
END;
This macro is defined in definitions 4, 10, 13, 15, 16, 18, 21, and 23.
This macro is invoked in definition 1.



2008-08-29