-- SMTypesImpl.mesa
-- lasted edited by Satterthwaite, June 22, 1983 8:57 am

DIRECTORY
  SMTree: TYPE Tree USING [Handle, --Id,-- Link, Name, null, nullHandle, nullName],
  SMTreeOps: TYPE USING [GetName, NthSon, OpName],
  SMTypes: TYPE USING [];
  
SMTypesImpl: CEDAR PROGRAM
    IMPORTS SMTreeOps EXPORTS SMTypes ~{
  OPEN Tree~~SMTree, TreeOps~~SMTreeOps;

  StrucType: PUBLIC PROC[type: Tree.Link] RETURNS[Tree.Handle] ~ {
    RETURN [WITH type SELECT FROM
--    id: Tree.Id => StrucType[id.value],
      node: Tree.Handle => node,
      ENDCASE => (IF type = Tree.null THEN Tree.nullHandle ELSE ERROR)]};
  
  TypeName: PROC[type: Tree.Handle] RETURNS[Tree.Name] ~ {	-- $type node
    t: Tree.Link ~ TreeOps.NthSon[type, 1];
    RETURN [IF t = Tree.nullHandle THEN Tree.nullName ELSE TreeOps.GetName[t]]};
    
 
  Equiv: PUBLIC PROC[type1, type2: Tree.Link] RETURNS[BOOL] ~ {
    s1: Tree.Handle ~ StrucType[type1];
    s2: Tree.Handle ~ StrucType[type2];
    RETURN [s1 = s2 OR (	-- quick check
      SELECT TreeOps.OpName[s1] FROM
	$type => TreeOps.OpName[s2] = $type AND (TypeName[s1] = TypeName[s2]),
	$control => TreeOps.OpName[s2] = $control,
	$typeSTRING => TreeOps.OpName[s2] = $typeSTRING,
	ENDCASE => FALSE)]};	-- for now
          

  Implies: PUBLIC PROC[type1, type2: Tree.Link] RETURNS[BOOL] ~ Equiv;	-- temporary
  
  }.