File: LTIStringCST.m

package info (click to toggle)
tom 1.1.1-2
  • links: PTS
  • area: main
  • in suites: potato
  • size: 6,340 kB
  • ctags: 2,244
  • sloc: objc: 27,863; ansic: 9,804; sh: 7,411; yacc: 3,377; lex: 966; asm: 208; makefile: 62; cpp: 10
file content (96 lines) | stat: -rw-r--r-- 1,749 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
   Written by Pieter J. Schoenmakers <tiggr@ics.ele.tue.nl>

   Copyright (C) 1996 Pieter J. Schoenmakers.

   This file is part of TOM.  TOM is distributed under the terms of the
   TOM License, a copy of which can be found in the TOM distribution; see
   the file LICENSE.

   $Id: LTIStringCST.m,v 1.9 1998/01/05 00:57:16 tiggr Exp $  */

#define LTISTRINGCST_DECLARE_PRIVATE_METHODS
#import "LTIStringCST.h"

static TLVector *all_strings;

static TLDictionary *strings;

@implementation LTTStringCST (Semantics)

+(id) semanticsForString: (LTTStringCST *) s
{
  return [[CO_LTIStringCST gcAlloc] initWithStructure: s];
}

@end

@implementation LTIStringCST

+(TLVector *) allStrings
{
  return all_strings;
}

+initialize
{
  if (!all_strings)
    {
      all_strings = [TLVector vector];
      [all_strings gcLock];
      strings = [TLDictionary dictionary];
      [strings gcLock];
    }
  return self;
}

+(LTIStringCST *) stringForString: (id <TLString>) string
{
  return [strings objectForKey: string];
}

+(id <TLEnumerator>) strings
{
  return [strings valueEnumerator];
}

+(void) sufferAmnesia
{
  strings = nil;
  all_strings = nil;
  [self initialize];
}

-(LTTStringCST *) structure
{
  return structure;
}

-(void) gcReference
{
  MARK (structure);

  [super gcReference];
}

-initWithStructure: (LTTStringCST *) str
{
  if (![super init])
    return nil;

  structure = str;

  [all_strings addElement: self];
  if (![strings objectForKey: [structure string]])
    [strings setObject: self forKey: [structure string]];

  return self;
}

-(void) print: (id <TLMutableStream>) stream quoted: (BOOL) qp
{
  formac (stream, @"#<%s %p %@ %@>", class_get_class_name (isa), self,
	  [structure lttName], [structure string]);
}

@end