Skip to main content
summaryrefslogtreecommitdiffstats
blob: 863b3dbd6c12091d1960c5d31481b3d025d17d9c (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/*******************************************************************************
 * Copyright (c) 2005, 2009 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:
 *     Devin Steffler (IBM) - Initial API and implementation
 *     Markus Schorn (Wind River Systems)
 *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;

import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;

/**
 * The CPPImplicitTypedef is used to represent implicit typedefs that exist on the translation
 * unit but are not actually part of the physical AST created by CDT.
 * 
 * An example is the GCC built-in typedef:  typedef char * __builtin_va_list;
 */
public class CPPImplicitTypedef extends CPPTypedef {
    private IType type;
    private char[] name;
    private IScope scope;
    
    public CPPImplicitTypedef(IType type, char[] name, IScope scope) {
        super(null);
        this.type = type;
        this.name = name;
        this.scope = scope;
    }
    
    @Override
	public IType getType() {
        return type;
    }

    @Override
	public String getName() {
        return String.valueOf(name);
    }
    
    @Override
	public char[] getNameCharArray() {
        return name;
    }
    
    @Override
	public IScope getScope() {
        return scope;
    }
    
    @Override
	public boolean isSameType(IType t) {
		if (t == this)
			return true;
		if (t instanceof ITypedef) {
			IType temp = getType();
			if (temp != null)
				return temp.isSameType(((ITypedef) t).getType());
			return false;
		}

		IType temp;
		temp = getType();
		if (temp != null)
			return temp.isSameType(t);
		return false;
	}
    
    @Override
	public Object clone(){
        IType t = null;
        t = (IType) super.clone();
        return t;
    }
    
    /**
     * returns null
     */
    @Override
	public IASTNode[] getDeclarations() {
        return null;
    }
    
    /**
     * returns null
     */
    @Override
	public IASTNode getDefinition() {
        return null;
    }
        
    /**
     * does nothing
     */
    @Override
	public void addDefinition(IASTNode node) {
        // do nothing
    }
    
    /**
     * does nothing
     */
    @Override
	public void addDeclaration(IASTNode node) {
        // do nothing
    }
    
    @Override
	public String[] getQualifiedName() {
        String[] temp = new String[1];
        temp[0] = String.valueOf(name);
        
        return temp;
    }
    

    @Override
	public char[][] getQualifiedNameCharArray() {
        char[][] temp = new char[1][];
        temp[0] = name;
        
        return temp;
    }
    
    /**
     * returns true
     */
    @Override
	public boolean isGloballyQualified() {
        return true;
    }
}

Back to the top