Attribute management
AddAttribute:
PROC [aNode: AttributedNode, name:
ATOM, value:
REF];
GetAttribute:
PROC [aTree: Tree, name:
ATOM]
RETURNS [value:
REF];
ReplaceAttribute:
PROC [aNode: AttributedNode, name:
ATOM, value:
REF];
AddTypeCodeAttribute:
PROC [tree:
REF, attributeName:
ATOM, typeCode: TypeCode];
QualifyIdentifierNode:
PROC [tree: Tree, qualifier:
ROPE];
Adds a qualifier attribute to tree, which should be an id node.
PropagateAttribute:
PROC [dstNode:
REF, dstAttributeKey:
ATOM, srcNode: AttributedNode, srcAttributeKey:
ATOM];
Copies the attribute
GetTypeCodeAttribute:
PROC [tree:
REF, attributeName:
ATOM ¬
NIL]
RETURNS [TypeCode];
Default attributeName is $TYPECODE
GetTypeValueAttribute:
PROC [typeGraph: TypeGraph, tree:
REF]
RETURNS [TypeCode];
Looks for $TYPECODE attribute, which must indicate the tree represents a TYPE, and returns the code for the represented type.
TypeGraph management
NewTypeGraph:
PROC
RETURNS [TypeGraph];
NewType:
PROC [typeGraph: TypeGraph, type: Type]
RETURNS [typeCode: TypeCode];
NewDefinitionType:
PROC [typeGraph: TypeGraph, qualifier:
ROPE, shortName:
ROPE, groundType: TypeCode]
RETURNS [TypeCode];
NewInitialType:
PROC [typeGraph: TypeGraph, environmentModule:
ROPE, tree: Tree, groundType: TypeCode]
RETURNS [TypeCode];
NewReferenceType:
PROC [typeGraph: TypeGraph, referentType: TypeCode, class:
ATOM]
RETURNS [TypeCode];
NewTypeType:
PROC [typeGraph: TypeGraph, value: TypeCode]
RETURNS [TypeCode];
TypeFromTypeCode:
PROC [typeGraph: TypeGraph, typeCode: TypeCode]
RETURNS [Type];
UnderType:
PROC [typeGraph: TypeGraph, typeCode: TypeCode]
RETURNS [Type];
Strips off all definition layers.
BaseType:
PROC [typeGraph: TypeGraph, typeCode: TypeCode]
RETURNS [Type];
Strips off all definition and subrange layers.
DIntFromRef:
PROC [ref:
REF]
RETURNS [
DINT];
Good for examining first & last in a subrange type.
FieldProc:
TYPE =
PROC [fieldIndex:
INT, fieldName:
ROPE, fieldTypeCode: TypeCode, tagName:
ROPE, tagTypeCode: TypeCode]
RETURNS [quit:
BOOL ¬
FALSE];
For the union part of a variant record, or the sequence part of a sequence-containing record, the tagName and tagType are supplied; otherwise tagType=nullTypeCode.
EnumerateFields:
PROC [typeGraph: TypeGraph, typeCode: TypeCode, action: FieldProc]
RETURNS [
BOOL];
Enumerates fields of the type. Returns TRUE iff any FieldProc returns TRUE.
QualifyVariant:
PROC [typeGraph: TypeGraph, typeCode: TypeCode, qualifier:
ROPE]
RETURNS [TypeCode];
Qualifies the variant record; qualifier must be a valid tag value.
ComputeExternalTypeRep:
PROC [typeGraph: TypeGraph];
AssertNotVar:
PROC [tree:
REF];
Asserts the $VAR attribute is not present on the tree
GetTypeName:
PROC [context: Context, typeCode: TypeCode, retainInitalValue:
BOOL]
RETURNS [
LIST
OF
REF];
GenSym: PROC [typeGraph: TypeGraph, prefix: ROPE] RETURNS [ROPE];
Symbol table management
NewContext:
PROC [parent: Context]
RETURNS [Context];
AddSymbol:
PROC [context: Context, id:
ROPE, val: SymbolTableEntry];
AddFieldListToContext:
PROC [context: Context, fieldList: FieldList];
LookupSymbol:
PROC [context: Context, id:
ROPE]
RETURNS [SymbolTableEntry];
Root:
PROC [context: Context]
RETURNS [Context];
LookupTypeCode:
PROC [context: Context, id:
ROPE]
RETURNS [TypeCode];
GetConcreteTypeCode:
PROC [context: Context, typeCode: TypeCode]
RETURNS [TypeCode];
Looks up the concrete type (if any) associated with the given opaque code.
ExportType:
PROC [context: Context, concrete, opaque: TypeCode];
Attributed tree support
GetIdentifier:
PROC [tree: Tree]
RETURNS [
ROPE];
GetTypeRange:
PROC [context: Context, tree: Tree]
RETURNS [first, last:
DINT];
Tries to pull the range out of a numeric type tree
GetSimpleConstant:
PROC [context: Context, tree: Tree]
RETURNS [
DINT];
Mostly handles just fixed-point literals, but can do a little constant-folding.
GetRopeLiteral:
PROC [tree: Tree]
RETURNS [
ROPE];
GetNodeName:
PROC [tree: Tree]
RETURNS [
ATOM];
GetNodeNameCode:
PROC [tree: Tree]
RETURNS [MPTree.NodeName];
DoList:
PROC [listOrItem: Tree, action:
PROC [Tree]];
WithId:
PROC [tree: Tree, action:
PROC [id:
ROPE]]
RETURNS [
BOOL];
WithLiteral:
PROC [tree: Tree, action:
PROC [literal:
REF MPLeaves.LTNode]]
RETURNS [
BOOL];
With0:
PROC [tree: Tree, nodeName: MPTree.NodeName, action:
PROC]
RETURNS [
BOOL];
DoWith1: PROC [tree: Tree, action: PROC [REF]];
With1:
PROC [tree: Tree, nodeName: MPTree.NodeName, action:
PROC [
REF]]
RETURNS [
BOOL];
DoWith2: PROC [tree: Tree, action: PROC [REF, REF]];
With2:
PROC [tree: Tree, nodeName: MPTree.NodeName, action:
PROC [
REF,
REF]]
RETURNS [
BOOL];
DoWith3: PROC [tree: Tree, action: PROC [REF, REF, REF]];
With3:
PROC [tree: Tree, nodeName: MPTree.NodeName, action:
PROC [
REF,
REF,
REF]]
RETURNS [
BOOL];
DoWith4: PROC [tree: Tree, action: PROC [REF, REF, REF, REF]];
With4:
PROC [tree: Tree, nodeName: MPTree.NodeName, action:
PROC [
REF,
REF,
REF,
REF]]
RETURNS [
BOOL];
DoWith5: PROC [tree: Tree, action: PROC [REF, REF, REF, REF, REF]];
With5:
PROC [tree: Tree, nodeName: MPTree.NodeName, action:
PROC [
REF,
REF,
REF,
REF,
REF]]
RETURNS [
BOOL];
DoWith6: PROC [tree: Tree, action: PROC [REF, REF, REF, REF, REF, REF]];
With6:
PROC [tree: Tree, nodeName: MPTree.NodeName, action:
PROC [
REF,
REF,
REF,
REF,
REF,
REF]]
RETURNS [
BOOL];