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
9
* IBM Corporation - initial API and implementation
10
*******************************************************************************/
11
package org.eclipse.cdt.core.dom.parser.upc;
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;
41
* Creates AST nodes that are specific to the UPC parser.
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'.
48
@SuppressWarnings("restriction")
49
public class UPCASTNodeFactory extends CNodeFactory implements IUPCNodeFactory {
52
private boolean useUPCSizeofExpressions = false;
53
private int currentUPCSizofExpressionOperator = 0;
56
public void setUseUPCSizeofExpressions(int op) {
57
useUPCSizeofExpressions = true;
58
currentUPCSizofExpressionOperator = op;
61
public void setUseC99SizeofExpressions() {
62
useUPCSizeofExpressions = false;
68
public IASTTypeIdExpression newTypeIdExpression(int operator, IASTTypeId typeId) {
69
if(useUPCSizeofExpressions) {
70
assert operator == IASTTypeIdExpression.op_sizeof;
71
return new UPCASTTypeIdSizeofExpression(currentUPCSizofExpressionOperator, typeId);
74
return super.newTypeIdExpression(operator, typeId);
79
public IASTUnaryExpression newUnaryExpression(int operator, IASTExpression operand) {
80
if(useUPCSizeofExpressions) {
81
assert operator == IASTUnaryExpression.op_sizeof;
82
return new UPCASTUnarySizeofExpression(currentUPCSizofExpressionOperator, operand);
85
return super.newUnaryExpression(operator, operand);
89
public IUPCASTKeywordExpression newKeywordExpression(int keywordKind) {
90
return new UPCASTKeywordExpression(keywordKind);
94
public IUPCASTSynchronizationStatement newSyncronizationStatment(IASTExpression barrierExpression, int statmentKind) {
95
return new UPCASTSynchronizationStatement(barrierExpression, statmentKind);
99
public IUPCASTForallStatement newForallStatement(IASTStatement init, IASTExpression condition,
100
IASTExpression iterationExpression, IASTStatement body, IASTExpression affinity) {
101
return new UPCASTForallStatement(init, condition, iterationExpression, body, affinity);
106
public IUPCASTSimpleDeclSpecifier newSimpleDeclSpecifier() {
107
return new UPCASTSimpleDeclSpecifier();
112
public IUPCASTCompositeTypeSpecifier newCompositeTypeSpecifier(int key, IASTName name) {
113
return new UPCASTCompositeTypeSpecifier(key, name);
118
public IUPCASTElaboratedTypeSpecifier newElaboratedTypeSpecifier(int kind, IASTName name) {
119
return new UPCASTElaboratedTypeSpecifier(kind, name);
124
public IUPCASTEnumerationSpecifier newEnumerationSpecifier(IASTName name) {
125
return new UPCASTEnumerationSpecifier(name);
130
public IUPCASTTypedefNameSpecifier newTypedefNameSpecifier(IASTName name) {
131
return new UPCASTTypedefNameSpecifier(name);