Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 68c4b11b027bfeccbd8f803c51e9ab0800663107 (plain) (blame)
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
/*******************************************************************************
 * Copyright (c) 2006, 2008 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.cdt.core.dom.lrparser.action.c99;


import org.eclipse.cdt.core.dom.lrparser.action.FunctionalMap;

/**
 * A facade for a FunctionalMap that is used just to track typedef
 * declarations.
 * 
 * This class acts like a set. No information needs to be associated
 * with a typedef declaration, all we need to know is if the identifier
 * has been declared as a typedef.
 * 
 * @author Mike Kucera
 */
public class TypedefSymbolTable {
	
	/**
	 * Start with EMPTY_TABLE and build up a symbol table using add().
	 */
	public static final TypedefSymbolTable EMPTY_TABLE = new TypedefSymbolTable();
	
	
	// the map we are providing a facade for
	private final FunctionalMap<String,Object> map;
	
	
	/**
	 * Constructors are private, start with EMPTY_TABLE 
	 * and build it up using insert().
	 */
	private TypedefSymbolTable() {
		map = FunctionalMap.emptyMap();
	}
	
	private TypedefSymbolTable(FunctionalMap<String,Object> newRoot) {
		map = newRoot;
	}
	

	public TypedefSymbolTable add(String typedefIdent) {
		return new TypedefSymbolTable(map.insert(typedefIdent, null));
	}


	public boolean contains(String typedef) {
		return map.containsKey(typedef);
	}
	
	public int size() {
		return map.size();
	}
	
	public boolean isEmpty() {
		return map.size() == 0;
	}
	
	@Override public String toString() {
		return map.toString();
	}
	
	
}

Back to the top