C2CNames.mesa
Copyright Ó 1988, 1989, 1990, 1991 by Xerox Corporation. All rights reserved.
Christian Jacobi, February 23, 1988 10:07:50 am PST
Christian Jacobi, October 5, 1990 12:17:32 pm PDT
DIRECTORY
CardTab USING [Ref],
IntCodeDefs USING [LogicalId, VariableId],
IO USING [STREAM],
Rope USING [ROPE],
SymTab USING [Ref];
C2CNames: CEDAR DEFINITIONS =
BEGIN
ROPE: TYPE = Rope.ROPE;
Why naming is a trouble
Names should be unique
Names must not collide with include files
=> there must be simple rules to tell writers of include files.
Names must make sense to the debugger
=> names must contain the LogicalId/VariableId number unclipped
Certain C compilers allow only finite name length
ScanExterns: PUBLIC PROC [stream: IO.STREAM] RETURNS [externs: SymTab.Ref];
Read the externProc file and build tables
AssociateNames: PROC [names, labels: CardTab.Ref, externProcs: SymTab.Ref¬NIL];
Enumerate the name tables and predeclare the found identifiers
IsExtern: PROC [id: IntCodeDefs.LogicalId] RETURNS [BOOL];
Returns whether a LogicalId should be extern
[e.g whether it is mentioned in a externProc file]
TryName: PROC [try: ROPE] RETURNS [ROPE];
Make an identifier denoting an identity invented by C2C
Try using try without adding postfix, but add a postfix if necessary for uniqueness
[e.g. usefull for types]
try is syntactically trusted
InternalName: PROC [class: ROPE¬NIL] RETURNS [ROPE];
Make an identifier denoting an identity invented by C2C
Add postfix for uniqueness
class is syntactically trusted
VarName: PROC [id: IntCodeDefs.VariableId, class: ROPE¬NIL] RETURNS [ROPE];
Make an identifier for a variable
class is ignored if id has an associated name; if non nil it is trusted
LabName: PROC [id: IntCodeDefs.LogicalId, class: ROPE¬NIL] RETURNS [ROPE];
Make an identifier for a label
class is ignored if id has an associated name; if non nil it is trusted
ProgramName: PROC [] RETURNS [ROPE];
Finds or makes a name for the module itself
This name is not necessarily unique or legal C but it does not contain illegal characters.
It must be used with a prefix to guarantee uniqueness.
PreDeclare: PROC [id: ROPE];
Reserves an identifier for this compilation
The same identifier can be reserved repeatedly
Reserve: PROC [r: ROPE] RETURNS [sameRope: ROPE];
Reserves an identifier, so it can't be used otherwise [runtime procedure names, keywords]
Globally for all compilations
END.