~ubuntu-branches/debian/sid/eclipse-cdt/sid

« back to all changes in this revision

Viewing changes to results/plugins/org.eclipse.cdt.core.parser.upc/src/org/eclipse/cdt/core/dom/parser/upc/UPCASTNodeFactory.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2011-10-06 21:15:04 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20111006211504-8dutmljjih0zikfv
Tags: 8.0.1-1
* New upstream release.
* Split the JNI packages into a separate architecture dependent
  package and made eclipse-cdt architecture independent.
* Install JNI libraries into multiarch aware location
* Bumped Standards-Version to 3.9.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*******************************************************************************
2
 
 *  Copyright (c) 2006, 2009 IBM Corporation and others.
3
 
 *  All rights reserved. This program and the accompanying materials
4
 
 *  are made available under the terms of the Eclipse Public License v1.0
5
 
 *  which accompanies this distribution, and is available at
6
 
 *  http://www.eclipse.org/legal/epl-v10.html
7
 
 * 
8
 
 *  Contributors:
9
 
 *     IBM Corporation - initial API and implementation
10
 
 *******************************************************************************/
11
 
package org.eclipse.cdt.core.dom.parser.upc;
12
 
 
13
 
import org.eclipse.cdt.core.dom.ast.IASTExpression;
14
 
import org.eclipse.cdt.core.dom.ast.IASTName;
15
 
import org.eclipse.cdt.core.dom.ast.IASTStatement;
16
 
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
17
 
import org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression;
18
 
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
19
 
import org.eclipse.cdt.core.dom.upc.ast.IUPCASTCompositeTypeSpecifier;
20
 
import org.eclipse.cdt.core.dom.upc.ast.IUPCASTElaboratedTypeSpecifier;
21
 
import org.eclipse.cdt.core.dom.upc.ast.IUPCASTEnumerationSpecifier;
22
 
import org.eclipse.cdt.core.dom.upc.ast.IUPCASTForallStatement;
23
 
import org.eclipse.cdt.core.dom.upc.ast.IUPCASTKeywordExpression;
24
 
import org.eclipse.cdt.core.dom.upc.ast.IUPCASTSimpleDeclSpecifier;
25
 
import org.eclipse.cdt.core.dom.upc.ast.IUPCASTSynchronizationStatement;
26
 
import org.eclipse.cdt.core.dom.upc.ast.IUPCASTTypedefNameSpecifier;
27
 
import org.eclipse.cdt.internal.core.dom.parser.c.CNodeFactory;
28
 
import org.eclipse.cdt.internal.core.dom.parser.upc.ast.UPCASTCompositeTypeSpecifier;
29
 
import org.eclipse.cdt.internal.core.dom.parser.upc.ast.UPCASTElaboratedTypeSpecifier;
30
 
import org.eclipse.cdt.internal.core.dom.parser.upc.ast.UPCASTEnumerationSpecifier;
31
 
import org.eclipse.cdt.internal.core.dom.parser.upc.ast.UPCASTForallStatement;
32
 
import org.eclipse.cdt.internal.core.dom.parser.upc.ast.UPCASTKeywordExpression;
33
 
import org.eclipse.cdt.internal.core.dom.parser.upc.ast.UPCASTSimpleDeclSpecifier;
34
 
import org.eclipse.cdt.internal.core.dom.parser.upc.ast.UPCASTSynchronizationStatement;
35
 
import org.eclipse.cdt.internal.core.dom.parser.upc.ast.UPCASTTypeIdSizeofExpression;
36
 
import org.eclipse.cdt.internal.core.dom.parser.upc.ast.UPCASTTypedefNameSpecifier;
37
 
import org.eclipse.cdt.internal.core.dom.parser.upc.ast.UPCASTUnarySizeofExpression;
38
 
 
39
 
 
40
 
/**
41
 
 * Creates AST nodes that are specific to the UPC parser.
42
 
 * 
43
 
 * The methods in ASTNodeFactory that build nodes for declaration
44
 
 * specifiers are overridden here to replace those nodes with the UPC nodes for
45
 
 * declaration specifiers. These UPC specific nodes add support
46
 
 * for 'strict', 'relaxed' and 'shared'.
47
 
 */
48
 
@SuppressWarnings("restriction")
49
 
public class UPCASTNodeFactory extends CNodeFactory implements IUPCNodeFactory {
50
 
 
51
 
        
52
 
        private boolean useUPCSizeofExpressions = false;
53
 
        private int currentUPCSizofExpressionOperator = 0;
54
 
        
55
 
        
56
 
        public void setUseUPCSizeofExpressions(int op) {
57
 
                useUPCSizeofExpressions = true;
58
 
                currentUPCSizofExpressionOperator = op;
59
 
        }
60
 
        
61
 
        public void setUseC99SizeofExpressions() {
62
 
                useUPCSizeofExpressions = false;
63
 
        }
64
 
        
65
 
        
66
 
        
67
 
        @Override
68
 
        public IASTTypeIdExpression newTypeIdExpression(int operator, IASTTypeId typeId) {
69
 
                if(useUPCSizeofExpressions) {
70
 
                        assert operator == IASTTypeIdExpression.op_sizeof;
71
 
                        return new UPCASTTypeIdSizeofExpression(currentUPCSizofExpressionOperator, typeId);
72
 
                }
73
 
                
74
 
                return super.newTypeIdExpression(operator, typeId);
75
 
        }
76
 
        
77
 
 
78
 
        @Override
79
 
        public IASTUnaryExpression newUnaryExpression(int operator, IASTExpression operand) {
80
 
                if(useUPCSizeofExpressions) {
81
 
                        assert operator == IASTUnaryExpression.op_sizeof;
82
 
                        return new UPCASTUnarySizeofExpression(currentUPCSizofExpressionOperator, operand);
83
 
                }
84
 
                
85
 
                return super.newUnaryExpression(operator, operand);
86
 
        }
87
 
        
88
 
 
89
 
        public IUPCASTKeywordExpression newKeywordExpression(int keywordKind) {
90
 
                return new UPCASTKeywordExpression(keywordKind);
91
 
        }
92
 
        
93
 
 
94
 
        public IUPCASTSynchronizationStatement newSyncronizationStatment(IASTExpression barrierExpression, int statmentKind) {
95
 
                return new UPCASTSynchronizationStatement(barrierExpression, statmentKind);
96
 
        }
97
 
        
98
 
 
99
 
        public IUPCASTForallStatement newForallStatement(IASTStatement init, IASTExpression condition,
100
 
                        IASTExpression iterationExpression, IASTStatement body, IASTExpression affinity) {
101
 
                return new UPCASTForallStatement(init, condition, iterationExpression, body, affinity);
102
 
        }
103
 
 
104
 
 
105
 
        @Override
106
 
        public IUPCASTSimpleDeclSpecifier newSimpleDeclSpecifier() {
107
 
                return new UPCASTSimpleDeclSpecifier();
108
 
        }
109
 
        
110
 
 
111
 
        @Override
112
 
        public IUPCASTCompositeTypeSpecifier newCompositeTypeSpecifier(int key, IASTName name) {
113
 
                return new UPCASTCompositeTypeSpecifier(key, name);
114
 
        }
115
 
        
116
 
 
117
 
        @Override
118
 
        public IUPCASTElaboratedTypeSpecifier newElaboratedTypeSpecifier(int kind, IASTName name) {
119
 
                return new UPCASTElaboratedTypeSpecifier(kind, name);
120
 
        }
121
 
        
122
 
 
123
 
        @Override
124
 
        public IUPCASTEnumerationSpecifier newEnumerationSpecifier(IASTName name) {
125
 
                return new UPCASTEnumerationSpecifier(name);
126
 
        }
127
 
        
128
 
 
129
 
        @Override
130
 
        public IUPCASTTypedefNameSpecifier newTypedefNameSpecifier(IASTName name) {
131
 
                return new UPCASTTypedefNameSpecifier(name);
132
 
        }
133
 
 
134
 
}