CDMakeProc.mesa (module for ChipNDale)
Copyright © 1985, 1987 by Xerox Corporation. All rights reserved.
Created by Christian Jacobi, May 9, 1985 1:58:40 pm PDT
Last edited by: Christian Jacobi, January 5, 1987 8:12:40 pm PST
DIRECTORY
CD, Rope;
CDMakeProc: CEDAR DEFINITIONS =
BEGIN
Private interface to split the tool which generates Cedar programs to generate layout
-- Environment
Environment: TYPE = REF EnvironmentRep;
--the environment represents the unfinished Cedar code to be produced
--it is passed through and has all the necessary information about used idendentifiers
--already issued declarations and other crap.
EnvironmentRep: TYPE;
GetEnvironmentProp: PROC [env: Environment, key: REF] RETURNS [REF];
PutEnvironmentProp: PROC [env: Environment, key: REF, val: REF];
-- Registrations
-- For classes defining specific generation of code
-- implementing requests of generation of certain pieces of code
ObjectExpressionProc: TYPE = PROC [env: Environment, x: REF, probablyReUse: BOOLFALSE] RETURNS [Rope.ROPE];
--Type for a procedure which returns an expression creating an object
--env: environment for the code (good declarations which can be used or included
--x: object for which an expression is to be made
--probablyReUse: this object migh be needed again and it would be wise to somehow
-- make a definition
--It is ok to issue a local statement; such a statement would preceed the statement which
--contains the returned expression.
RegisterObjectExpressionProc: PROC [for: REF, ep: ObjectExpressionProc, tech: CD.Technology ← NIL];
--register certain Object classes with a procedure how to make an object of this class
-- Dealing with identifiers
Identifier: PROC [r: Rope.ROPE] RETURNS [Rope.ROPE];
--Makes a valid Cedar identifier
Capital: PROC [r: Rope.ROPE] RETURNS [Rope.ROPE];
--Converts first character to capital
Small: PROC [r: Rope.ROPE] RETURNS [Rope.ROPE];
--Converts first character to small
--well, dealing with local identifiers in the procedure is not yet great
GetGlobalIdent: PROC [env: Environment, whatFor: REF] RETURNS [Rope.ROPE];
--Returns a rope with an identifier for whatFor
--Must not depend on it beeing defined with PlaceDeclarationM1;
--but either PlaceDeclarationM1 or PlaceDeclarationM2 has defined the identifier
--NIL if not declared
ForceGlobalIdent: PROC [env: Environment, proposed: Rope.ROPE, whatFor: REFNIL] RETURNS [Rope.ROPE];
--Returns a new identifier which is unique;
--if whatFor#NIL: GetGlobalIdent will find it
-- the caller must place code to declare that ident
-- using either PlaceDeclarationM1 or PlaceDeclarationM2
MakeLayer: PROC [env: Environment, l: CD.Layer] RETURNS [Rope.ROPE];
--Returns an identifier for this layer
--Places code to initialize identifier globally
-- Places declarations and code into the program to be build
MakePreamble: PROC [env: Environment, module: Rope.ROPE, import: BOOLTRUE];
--Places code to get a DIRECTORY entry for the module package
--import: the package is also IMPORTed
PlaceStatement: PROC [env: Environment, line: Rope.ROPE];
--places statement into the local procedure
PlaceDeclarationM1: PROC [env: Environment, line: Rope.ROPE];
--places declaration into the module, before the main procedures
PlaceDeclarationM2: PROC [env: Environment, line: Rope.ROPE];
--places declaration into the module, just before the statements
PlaceStatementM: PROC [env: Environment, line: Rope.ROPE];
--places statement into the module
--Convert procedures
AtomToRope: PROC [env: Environment, a: ATOM] RETURNS [Rope.ROPE];
RopeToRope: PROC [Rope.ROPE] RETURNS [Rope.ROPE];
PosToRope: PROC [pos: CD.Position] RETURNS [Rope.ROPE];
RectToRope: PROC [rect: CD.Rect] RETURNS [Rope.ROPE];
OrientationToRope: PROC [o: CD.Orientation] RETURNS [Rope.ROPE];
TransformationToRope: PROC [trans: CD.Transformation] RETURNS [Rope.ROPE];
END.