Skip to main content
summaryrefslogtreecommitdiffstats
blob: d7c64d10a27765c0453818f9b24051dbaf2df236 (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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
/*******************************************************************************
 * Copyright (c) 2005 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:
 *     Rational Software - initial implementation
 *******************************************************************************/

package org.eclipse.cdt.core.dom.ast;

import org.eclipse.cdt.core.dom.ast.c.ICASTArrayDesignator;
import org.eclipse.cdt.core.dom.ast.c.ICASTArrayModifier;
import org.eclipse.cdt.core.dom.ast.c.ICASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.c.ICASTDesignatedInitializer;
import org.eclipse.cdt.core.dom.ast.c.ICASTDesignator;
import org.eclipse.cdt.core.dom.ast.c.ICASTFieldDesignator;
import org.eclipse.cdt.core.dom.ast.c.ICASTPointer;
import org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.c.ICASTTypeIdInitializerExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTBinaryExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCastExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeleteExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeConstructorExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeIdExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUnaryExpression;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTTypeIdExpression;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTUnaryExpression;
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.gnu.c.IGCCASTArrayRangeDesignator;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTBinaryExpression;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.parser.GCCKeywords;
import org.eclipse.cdt.core.parser.Keywords;

/**
 * This is a utility class to help convert AST elements to Strings corresponding
 * to the AST element's signature.
 * 
 * @author dsteffle
 */

public class ASTSignatureUtil {
	
	private static final String COMMA_SPACE = ", "; //$NON-NLS-1$
	private static final String EMPTY_STRING = ""; //$NON-NLS-1$
	private static final String SPACE = " "; //$NON-NLS-1$
	private static final String[] EMPTY_STRING_ARRAY = new String[0];
	
	/**
	 * Return's the String representation of a node's type (if available).  This is
	 * currently only being used for testing.
	 * 
	 * TODO Remove this function when done testing if it is no longer needed
	 * 
	 * @param node
	 * @return
	 */
	public static String getNodeSignature(IASTNode node) {
		if (node instanceof IASTDeclarator)
			return getSignature((IASTDeclarator)node);
		if (node instanceof IASTDeclSpecifier)
			return getSignature((IASTDeclSpecifier)node);
		if (node instanceof IASTTypeId)
			return getSignature((IASTTypeId)node);
        if( node instanceof IASTSimpleDeclaration )
        {
            IASTSimpleDeclaration decl = (IASTSimpleDeclaration) node;
            StringBuffer buffer = new StringBuffer( getSignature( decl.getDeclSpecifier()));
            
            IASTDeclarator [] declarators = decl.getDeclarators();
            for( int i = 0; i < declarators.length; ++i )
            {
                buffer.append( SPACE );
                buffer.append( getSignature( declarators[i] ));
                if( declarators[i].getInitializer() != null && declarators[i].getInitializer() instanceof ICPPASTConstructorInitializer )
                    buffer.append( getInitializerString( declarators[i].getInitializer() ));
            }
            buffer.append( ";"); //$NON-NLS-1$
            return buffer.toString();
        }
        if( node instanceof IASTExpression )
        {
            return getExpressionString( (IASTExpression) node );
        }
		
		return EMPTY_STRING;
	}
	
	/**
	 * Returns the parameter signature for an IASTDeclarator as a comma separated list wrapped in parenthesis.
	 * 
	 * This method uses ASTSignatureUtil#getParametersSignatureArray(IASTArray) to build a comma separated list of the 
	 * parameter's signatures and then wraps them in parenthesis.
	 * 
	 * @param decltor
	 * @return the parameter signature for an IASTDeclarator as a comma separated list wrapped in parenthesis
	 */
	// if only function declarator's have parameters then change this to function declarator... should check before starting.. make my life easier!
	public static String getParameterSignature(IASTDeclarator decltor) {
		// should only be working with decltor that has parms
		if (!(decltor instanceof IASTStandardFunctionDeclarator || decltor instanceof ICASTKnRFunctionDeclarator)) return EMPTY_STRING;

		StringBuffer result = new StringBuffer();
		
		String[] parms = getParameterSignatureArray(decltor);
		
		result.append(Keywords.cpLPAREN);
		for(int i=0; i<parms.length; i++) {
			if (parms[i] != null) {
				result.append(parms[i]);
				if (i<parms.length-1) result.append(COMMA_SPACE);
			}
		}
		result.append(Keywords.cpRPAREN);
		
		return result.toString();		
	}

	/**
	 * Returns a String[] corresponding to the signatures of individual parameters for an IASTDeclarator.
	 * 
	 * @param decltor
	 * @return a String[] corresponding to the signatures of individual parameters for an IASTDeclarator
	 */
	public static String[] getParameterSignatureArray(IASTDeclarator decltor) {
//		 should only be working with decltor that has parms
		if (!(decltor instanceof IASTStandardFunctionDeclarator || decltor instanceof ICASTKnRFunctionDeclarator)) return EMPTY_STRING_ARRAY;
		
		String[] result = EMPTY_STRING_ARRAY;
		
		if (decltor instanceof IASTStandardFunctionDeclarator) {
			IASTParameterDeclaration[] parms = null;
			parms = ((IASTStandardFunctionDeclarator)decltor).getParameters();
			
			if (((IASTStandardFunctionDeclarator) decltor).takesVarArgs()) {
				result = new String[parms.length + 1];
				result[parms.length] = "..."; //$NON-NLS-1$
			}
			else {
				result = new String[parms.length];
			}
			
			for(int i=0; i<parms.length; i++) {
				if (parms[i] != null) {
					result[i] = getSignature(parms[i].getDeclarator());
				}
			}
		} else if (decltor instanceof ICASTKnRFunctionDeclarator) {
			IASTName[] names = null;
			names = ((ICASTKnRFunctionDeclarator)decltor).getParameterNames(); // required to get the order the parameters are used
			
			result = new String[names.length];
			
			for(int i=0; i<names.length; i++) {
				if (names[i] != null) {
					final IASTDeclarator declaratorForParameterName = ((ICASTKnRFunctionDeclarator)decltor).getDeclaratorForParameterName(names[i]);
                    if( declaratorForParameterName != null )
                        result[i] = getSignature(declaratorForParameterName);
				}
			}
		}
		
		return result;
	}
	
	private static String getDeclaratorSpecificSignature(IASTDeclarator declarator) {
		StringBuffer result = new StringBuffer();
		IASTPointerOperator[] ops = declarator.getPointerOperators();
		boolean needSpace=false;
		
		if (ops != null && ops.length > 0) {
			for(int i=0; i<ops.length; i++) {
				if (ops[i] != null) {
                    if (needSpace) { result.append(SPACE); }
					if (ops[i] instanceof IASTPointer) {
						result.append(Keywords.cpSTAR); // want to have this before keywords on the pointer
						needSpace=true;
					}
					
					if (ops[i] instanceof IGPPASTPointer) {
						if (((IGPPASTPointer)ops[i]).isRestrict()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.RESTRICT); needSpace=true; }
					}
					
					if (ops[i] instanceof ICASTPointer) {
						if (((ICASTPointer)ops[i]).isRestrict()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.RESTRICT); needSpace=true; }
					}
					
					if (ops[i] instanceof IASTPointer) {
						if (((IASTPointer)ops[i]).isConst()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.CONST); needSpace=true; }
						if (((IASTPointer)ops[i]).isVolatile()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.VOLATILE); needSpace=true; }
					}
					
					if (ops[i] instanceof ICPPASTReferenceOperator) {
						if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.cpAMPER); needSpace=true;
					}
				}
			}
		}
		
		if (declarator instanceof IASTArrayDeclarator) {
			IASTArrayModifier[] mods = ((IASTArrayDeclarator)declarator).getArrayModifiers();
			
			for(int i=0; i<mods.length; i++) {
				if (mods[i] != null) {
					if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.cpLBRACKET);
					if (mods[i] instanceof ICASTArrayModifier) {
						if (((ICASTArrayModifier)mods[i]).isConst()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.CONST); needSpace=true; }
						if (((ICASTArrayModifier)mods[i]).isRestrict()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.RESTRICT); needSpace=true; }
						if (((ICASTArrayModifier)mods[i]).isStatic()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.STATIC); needSpace=true; }
						if (((ICASTArrayModifier)mods[i]).isVolatile()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.VOLATILE); }
					}
					result.append(Keywords.cpRBRACKET);
				}
			}
		}
	
		return result.toString();
	}
	
	private static String getDeclaratorSignature(IASTDeclarator declarator) {
		if (declarator == null) return EMPTY_STRING;
		
		StringBuffer result = new StringBuffer();
		
		result.append(getDeclaratorSpecificSignature(declarator));
		
		if (declarator.getNestedDeclarator() != null) {
			result.append(SPACE);
			result.append(Keywords.cpLPAREN);
			result.append(getDeclaratorSignature(declarator.getNestedDeclarator()));
			result.append(Keywords.cpRPAREN);
		}
		
		// append the parameter's signatures
		result.append(getParameterSignature(declarator));
		
		return result.toString();
	}
	
	/**
	 * This function is used to return the signature of an IASTInitializer.
	 * 
	 * TODO this function is used for testing and probably should not public once 
	 * this Utility class has been finalized as it will likely never be used publicly except for testing
	 * 
	 * @param init
	 * @return the signature of an IASTInitializer
	 */
	public static String getInitializerString(IASTInitializer init) {
		StringBuffer result = new StringBuffer();
		
		if (init instanceof IASTInitializerExpression){
			result.append(getExpressionString(((IASTInitializerExpression)init).getExpression()));
		} else if (init instanceof IASTInitializerList) {
			result.append(Keywords.cpLBRACE);
			IASTInitializer[] inits = ((IASTInitializerList)init).getInitializers();
			for(int i=0; i<inits.length; i++) {
				result.append(getInitializerString(inits[i]));
				if (i<inits.length-1) result.append(COMMA_SPACE);
			}
			result.append(Keywords.cpRBRACE);
		} else if (init instanceof ICASTDesignatedInitializer) {
			ICASTDesignator[] designators = ((ICASTDesignatedInitializer)init).getDesignators();
			for(int i=0; i<designators.length; i++) {
				result.append(getDesignatorSignature(designators[i]));
				if (i<designators.length-1) result.append(COMMA_SPACE);
			}
			result.append(Keywords.cpASSIGN);
			result.append(getInitializerString(((ICASTDesignatedInitializer)init).getOperandInitializer()));
		} else if (init instanceof ICPPASTConstructorInitializer) {
			result.append( "("); //$NON-NLS-1$
            result.append( getExpressionString( ((ICPPASTConstructorInitializer)init).getExpression() ));
            result.append( ")"); //$NON-NLS-1$
		}
		
		return result.toString();
	}
	
	private static String getDesignatorSignature(ICASTDesignator designator) {
		StringBuffer result = new StringBuffer();
		
		if (designator instanceof ICASTArrayDesignator) {
			result.append(Keywords.cpLBRACKET);
			result.append(getExpressionString(((ICASTArrayDesignator)designator).getSubscriptExpression()));
			result.append(Keywords.cpRBRACKET);
		} else if (designator instanceof ICASTFieldDesignator) {
			result.append(Keywords.cpDOT);
			result.append(((ICASTFieldDesignator)designator).getName().toString());
		} else if (designator instanceof IGCCASTArrayRangeDesignator) {
			result.append(Keywords.cpLBRACKET);
			result.append(getExpressionString(((IGCCASTArrayRangeDesignator)designator).getRangeFloor()));
			result.append(SPACE);
			result.append(Keywords.cpELLIPSIS);
			result.append(SPACE);
			result.append(getExpressionString(((IGCCASTArrayRangeDesignator)designator).getRangeCeiling()));
			result.append(Keywords.cpRBRACKET);
		}
		
		return result.toString();
	}
	
	/**
	 * Returns the String signature corresponding to an IASTDeclarator.  This includes the signature
	 * of the parameters which is built via ASTSignatureUtil#getParameterSignature(IASTDeclarator)
	 * if the declarator is for a function.
	 * 
	 * @param declarator
	 * @return the String signature corresponding to an IASTDeclarator
	 */
	public static String getSignature(IASTDeclarator declarator) {
		StringBuffer result = new StringBuffer();
		
		// get the declSpec
		IASTDeclSpecifier declSpec = null;
		
		IASTNode node = declarator.getParent();
		while( node instanceof IASTDeclarator ){
			declarator = (IASTDeclarator) node;
			node = node.getParent();
		}
		
		if( node instanceof IASTParameterDeclaration )
			declSpec = ((IASTParameterDeclaration) node).getDeclSpecifier();
		else if( node instanceof IASTSimpleDeclaration )
			declSpec = ((IASTSimpleDeclaration)node).getDeclSpecifier();
		else if( node instanceof IASTFunctionDefinition )
			declSpec = ((IASTFunctionDefinition)node).getDeclSpecifier();
		else if( node instanceof IASTTypeId )
		    declSpec = ((IASTTypeId)node).getDeclSpecifier();
		
		// append the declSpec's signature to the signature
		String specString = getSignature(declSpec);
		if (specString != null && !specString.equals(EMPTY_STRING))
			result.append(specString);
		
		// append the declarator's signature (without specifier)
		String decltorString = getDeclaratorSignature(declarator);
		if (specString != null && specString.length() > 0 && 
				decltorString != null && decltorString.length() > 0) {
			result.append(SPACE);
		}
		result.append(decltorString);
			
		return result.toString();
	}
	
	/**
	 * Returns the String representation of the signature for the IASTDeclSpecifier.
	 * 
	 * @param declSpec
	 * @return the String representation of the signature for the IASTDeclSpecifier
	 */
	public static String getSignature(IASTDeclSpecifier declSpec) {
		if (declSpec == null) return EMPTY_STRING;
		boolean needSpace=false;
		
		StringBuffer result = new StringBuffer();
		
		if (declSpec.getStorageClass() == ICPPASTDeclSpecifier.sc_mutable) { result.append(Keywords.MUTABLE); needSpace=true; }
		if (declSpec.getStorageClass() == IASTDeclSpecifier.sc_auto) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.AUTO); needSpace=true; }
		if (declSpec.getStorageClass() == IASTDeclSpecifier.sc_extern) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.EXTERN); needSpace=true; }
		if (declSpec.getStorageClass() == IASTDeclSpecifier.sc_register) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.REGISTER); needSpace=true; }
		if (declSpec.getStorageClass() == IASTDeclSpecifier.sc_static) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.STATIC); needSpace=true; }
		if (declSpec.getStorageClass() == IASTDeclSpecifier.sc_typedef) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.TYPEDEF); needSpace=true; }
		
		if (declSpec.isConst()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.CONST); needSpace=true; }
		if (declSpec.isInline()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.INLINE); needSpace=true; }
		if (declSpec.isVolatile()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.VOLATILE); needSpace=true; }
		
		if (declSpec instanceof ICASTDeclSpecifier ) {
			if (((ICASTDeclSpecifier)declSpec).isRestrict()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.RESTRICT); needSpace=true; }
		} else if (declSpec instanceof ICPPASTDeclSpecifier) {
			if (declSpec.getStorageClass() == ICPPASTDeclSpecifier.sc_mutable) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.MUTABLE); needSpace=true; }
			if (((ICPPASTDeclSpecifier)declSpec).isExplicit()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.EXPLICIT); needSpace=true; }
			if (((ICPPASTDeclSpecifier)declSpec).isFriend()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.FRIEND); needSpace=true; }
			if (((ICPPASTDeclSpecifier)declSpec).isVirtual()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.VIRTUAL); needSpace=true; }
		} else if (declSpec instanceof IGPPASTDeclSpecifier) {
			if (((IGPPASTDeclSpecifier)declSpec).isRestrict()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.RESTRICT); needSpace=true; }
		}
		
		// handle complex cases 
		if (declSpec instanceof IASTCompositeTypeSpecifier) {
			// 101114 fix, do not display class, and for consistency don't display struct/union as well
//			if (declSpec instanceof ICPPASTCompositeTypeSpecifier) {
//				switch(((ICPPASTCompositeTypeSpecifier)declSpec).getKey()) {
//					case ICPPASTCompositeTypeSpecifier.k_class:
//						if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.CLASS); needSpace=true;
//						break;
//					case IASTCompositeTypeSpecifier.k_struct:
//						if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.STRUCT); needSpace=true;
//						break;
//					case IASTCompositeTypeSpecifier.k_union:
//						if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.UNION); needSpace=true;
//						break;
//				}
//			} else if (declSpec instanceof ICASTCompositeTypeSpecifier) {
//				switch(((ICASTCompositeTypeSpecifier)declSpec).getKey()) {
//					case IASTCompositeTypeSpecifier.k_struct:
//						if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.STRUCT); needSpace=true;
//						break;
//					case IASTCompositeTypeSpecifier.k_union:
//						if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.UNION); needSpace=true;
//						break;
//				}
//			}
		
			result.append(((IASTCompositeTypeSpecifier)declSpec).getName());
		} else if (declSpec instanceof IASTElaboratedTypeSpecifier) {
//			101114 fix, do not display class, and for consistency don't display struct/union as well
//			switch(((IASTElaboratedTypeSpecifier)declSpec).getKind()) {
//				case ICPPASTElaboratedTypeSpecifier.k_class:
//					if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.CLASS); needSpace=true;
//					break;
//				case IASTElaboratedTypeSpecifier.k_enum:
//					if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.ENUM); needSpace=true;
//					break;
//				case IASTElaboratedTypeSpecifier.k_struct:
//					if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.STRUCT); needSpace=true;
//					break;
//				case IASTElaboratedTypeSpecifier.k_union:
//					if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.UNION); needSpace=true;
//					break;
//			}
			result.append(((IASTElaboratedTypeSpecifier)declSpec).getName());
		} else if (declSpec instanceof IASTEnumerationSpecifier) {
			if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.ENUM); needSpace=true;
		} else if (declSpec instanceof IASTNamedTypeSpecifier) {
			if (needSpace) { result.append(SPACE); needSpace=false; } result.append(((IASTNamedTypeSpecifier)declSpec).getName().toString()); needSpace=true;
		} else if (declSpec instanceof IASTSimpleDeclSpecifier) {
			// handle complex cases
			if (declSpec instanceof IGPPASTSimpleDeclSpecifier) {
				if (((IGPPASTSimpleDeclSpecifier)declSpec).isLongLong()) result.append(Keywords.LONG_LONG);
				if (((IGPPASTSimpleDeclSpecifier)declSpec).isComplex()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.c_COMPLEX); needSpace=true; }
				if (((IGPPASTSimpleDeclSpecifier)declSpec).isImaginary()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.c_IMAGINARY); needSpace=true; }
				
				switch(((IGPPASTSimpleDeclSpecifier)declSpec).getType()) {
					case IGPPASTSimpleDeclSpecifier.t_typeof:
						if (needSpace) { result.append(SPACE); needSpace=false; } result.append(GCCKeywords.TYPEOF); needSpace=true;
						break;
				}
			}
			
			if (declSpec instanceof ICPPASTSimpleDeclSpecifier) {
				switch(((ICPPASTSimpleDeclSpecifier)declSpec).getType()) {
					case ICPPASTSimpleDeclSpecifier.t_bool:
						if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.BOOL); needSpace=true;
						break;
					case ICPPASTSimpleDeclSpecifier.t_wchar_t:
						if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.WCHAR_T); needSpace=true;
						break;
				}
			}
			
			if (declSpec instanceof ICASTSimpleDeclSpecifier) {
				if (((ICASTSimpleDeclSpecifier)declSpec).isLongLong()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.LONG_LONG); needSpace=true; }
				if (((ICASTSimpleDeclSpecifier)declSpec).isComplex()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.c_COMPLEX); needSpace=true; }
				if (((ICASTSimpleDeclSpecifier)declSpec).isImaginary()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.c_IMAGINARY); needSpace=true; }
				
				switch(((ICASTSimpleDeclSpecifier)declSpec).getType()) {
					case ICASTSimpleDeclSpecifier.t_Bool:
						if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.c_BOOL); needSpace=true;
						break;
				}
			}
			
			
			// handle simple cases
			if (((IASTSimpleDeclSpecifier)declSpec).isLong()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.LONG); needSpace=true; }
			if (((IASTSimpleDeclSpecifier)declSpec).isShort()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.SHORT); needSpace=true; }
			if (((IASTSimpleDeclSpecifier)declSpec).isSigned()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.SIGNED); needSpace=true; }
			if (((IASTSimpleDeclSpecifier)declSpec).isUnsigned()) { if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.UNSIGNED); needSpace=true; }
			
			switch(((IASTSimpleDeclSpecifier)declSpec).getType()) {
				case IASTSimpleDeclSpecifier.t_char:
					if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.CHAR); needSpace=true;
					break;
				case IASTSimpleDeclSpecifier.t_double:
					if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.DOUBLE); needSpace=true;
					break;
				case IASTSimpleDeclSpecifier.t_float:
					if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.FLOAT); needSpace=true;
					break;
				case IASTSimpleDeclSpecifier.t_int:
					if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.INT); needSpace=true;
					break;
				case IASTSimpleDeclSpecifier.t_void:
					if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.VOID); needSpace=true;
					break;
			}
		}
		
		return result.toString();
	}
	
	/**
	 * Returns the String representation of the signature for the IASTTypeId.
	 * @param typeId
	 * @return the String representation of the signature for the IASTTypeId
	 */
	public static String getSignature(IASTTypeId typeId) {
		return getSignature(typeId.getAbstractDeclarator());
	}
		
	/**
	 * Return a string representation for the given IASTExpression.  Expressions having an extension kind should
	 * provide their own toString method which will be called by this.
	 * 
	 * @param expression
	 * @return a string representation for the given IASTExpression
	 */
	public static String getExpressionString( IASTExpression expression ){
		if (expression instanceof IASTArraySubscriptExpression)
			return getArraySubscriptExpression((IASTArraySubscriptExpression)expression);
		else if (expression instanceof IASTBinaryExpression)
			return getBinaryExpression( (IASTBinaryExpression)expression );
		else if (expression instanceof IASTCastExpression)
			return getCastExpression((IASTCastExpression)expression);
		else if (expression instanceof IASTConditionalExpression)
			return getConditionalExpression((IASTConditionalExpression)expression);
		else if (expression instanceof IASTExpressionList)
			return getExpressionList((IASTExpressionList)expression);
		else if (expression instanceof IASTFieldReference)
			return getFieldReference((IASTFieldReference)expression);
		else if (expression instanceof IASTFunctionCallExpression)
			return getFunctionCallExpression((IASTFunctionCallExpression)expression);
		else if (expression instanceof IASTIdExpression)
			return getIdExpression((IASTIdExpression)expression);
		else if (expression instanceof IASTLiteralExpression)
			return getLiteralExpression((IASTLiteralExpression)expression);
		else if (expression instanceof IASTTypeIdExpression)
			return getTypeIdExpression( (IASTTypeIdExpression)expression );
		else if (expression instanceof IASTUnaryExpression)
			return getUnaryExpression( (IASTUnaryExpression)expression );
		else if (expression instanceof ICASTTypeIdInitializerExpression)
			return getTypeIdInitializerExpression((ICASTTypeIdInitializerExpression)expression);
		else if (expression instanceof ICPPASTDeleteExpression)
			return getDeleteExpression((ICPPASTDeleteExpression)expression);
		else if (expression instanceof ICPPASTNewExpression)
			return getNewExpression((ICPPASTNewExpression)expression);
		else if (expression instanceof ICPPASTSimpleTypeConstructorExpression)
			return getSimpleTypeConstructorExpression((ICPPASTSimpleTypeConstructorExpression)expression);
		else if (expression instanceof ICPPASTTypenameExpression)
			return getTypenameExpression((ICPPASTTypenameExpression)expression);			
		else if (expression instanceof IGNUASTCompoundStatementExpression)
			return getCompoundStatementExpression((IGNUASTCompoundStatementExpression)expression);

		return getEmptyExpression( expression );
	}
	
	private static String getArraySubscriptExpression(IASTArraySubscriptExpression expression) {
		StringBuffer result = new StringBuffer();
		result.append(getExpressionString(expression.getArrayExpression()));
		result.append(Keywords.cpLBRACKET);
		result.append(getExpressionString(expression.getSubscriptExpression()));
		result.append(Keywords.cpRBRACKET);
		return result.toString();
	}
	
	private static String getCastExpression(IASTCastExpression expression) {
		StringBuffer result = new StringBuffer();
		boolean normalCast = false;
		
		if (expression.getOperator() == IASTCastExpression.op_cast)
			normalCast = true;
		
		if (normalCast) {
			result.append(Keywords.cpLPAREN);
			result.append(getSignature(expression.getTypeId()));
			result.append(Keywords.cpRPAREN);
			result.append(getExpressionString(expression.getOperand()));
		} else {
			result.append(getCastOperatorString(expression));
			result.append(Keywords.cpLT);
			result.append(getSignature(expression.getTypeId()));
			result.append(Keywords.cpGT);
			result.append(Keywords.cpLPAREN);
			result.append(getExpressionString(expression.getOperand()));
			result.append(Keywords.cpRPAREN);
		}
		
		return result.toString();
	}
	
	private static String getFieldReference(IASTFieldReference expression) {
		StringBuffer result = new StringBuffer();
		result.append(getExpressionString(expression.getFieldOwner()));
		if (expression.isPointerDereference())
			result.append(Keywords.cpARROW);
		else
			result.append(Keywords.cpDOT);
		
		result.append(expression.getFieldName().toString());
		return result.toString();
	}
	
	private static String getFunctionCallExpression(IASTFunctionCallExpression expression) {
		StringBuffer result = new StringBuffer();
		result.append(getExpressionString(expression.getFunctionNameExpression()));
		result.append(Keywords.cpLPAREN);
		result.append(getExpressionString(expression.getParameterExpression()));
		result.append(Keywords.cpRPAREN);
		return result.toString();
	}
	
	private static String getTypeIdInitializerExpression(ICASTTypeIdInitializerExpression expression) {
		StringBuffer result = new StringBuffer();
		result.append(Keywords.cpLPAREN);
		result.append(getSignature(expression.getTypeId()));
		result.append(Keywords.cpRPAREN);
		result.append(getInitializerString(expression.getInitializer()));
		return result.toString();
	}
	
	private static String getDeleteExpression(ICPPASTDeleteExpression expression) {
		StringBuffer result = new StringBuffer();
		result.append(Keywords.DELETE);
		result.append(SPACE);
		if (expression.getOperand() != null)
			result.append(getExpressionString(expression.getOperand()));
		return result.toString();
	}
	
	private static String getSimpleTypeConstructorExpression(ICPPASTSimpleTypeConstructorExpression expression) {
		StringBuffer result = new StringBuffer();
		switch (expression.getSimpleType()) {
			case ICPPASTSimpleTypeConstructorExpression.t_bool:
				result.append(Keywords.BOOL);
				break;
			case ICPPASTSimpleTypeConstructorExpression.t_char:
				result.append(Keywords.CHAR);
				break;
			case ICPPASTSimpleTypeConstructorExpression.t_double:
				result.append(Keywords.DOUBLE);
				break;
			case ICPPASTSimpleTypeConstructorExpression.t_float:
				result.append(Keywords.FLOAT);
				break;
			case ICPPASTSimpleTypeConstructorExpression.t_int:
				result.append(Keywords.INT);
				break;
			case ICPPASTSimpleTypeConstructorExpression.t_long:
				result.append(Keywords.LONG);
				break;
			case ICPPASTSimpleTypeConstructorExpression.t_short:
				result.append(Keywords.SHORT);
				break;
			case ICPPASTSimpleTypeConstructorExpression.t_signed:
				result.append(Keywords.SIGNED);
				break;
			case ICPPASTSimpleTypeConstructorExpression.t_unsigned:
				result.append(Keywords.UNSIGNED);
				break;
			case ICPPASTSimpleTypeConstructorExpression.t_void:
				result.append(Keywords.VOID);
				break;
			case ICPPASTSimpleTypeConstructorExpression.t_wchar_t:
				result.append(Keywords.WCHAR_T);
				break;
		}
		result.append(Keywords.cpLPAREN);
		result.append(expression.getInitialValue());
		result.append(Keywords.cpRPAREN);
		return result.toString();
	}
	
	private static String getTypenameExpression(ICPPASTTypenameExpression expression) {
		StringBuffer result = new StringBuffer();
		result.append(Keywords.TYPENAME);
		result.append(SPACE);
		result.append(expression.getName().toString());
		IASTExpression initValue = expression.getInitialValue();
		result.append(Keywords.cpLPAREN);
		if (initValue != null) {
			result.append(getExpressionString(initValue));
		}
		result.append(Keywords.cpRPAREN);
		return result.toString();
	}
	
	private static String getCompoundStatementExpression(IGNUASTCompoundStatementExpression expression) {
		return String.valueOf(Keywords.cpELLIPSIS); // TODO might need to getSignature(IASTStatement) in the future
	}
	
	private static String getTypeIdExpression(IASTTypeIdExpression expression) {
		StringBuffer result = new StringBuffer();
		String operator = getTypeIdExpressionOperator(expression); 
		if (operator != null && !operator.equals(EMPTY_STRING)) result.append(operator);
		
		if (operator != null && !operator.equals(EMPTY_STRING)) { result.append(SPACE); result.append(Keywords.cpLPAREN); }
		result.append(getSignature(expression.getTypeId()));
		if (operator != null && !operator.equals(EMPTY_STRING)) result.append(Keywords.cpRPAREN);
		return result.toString();
	}
	
	private static String getExpressionList(IASTExpressionList expression) {
		StringBuffer result = new StringBuffer();
		IASTExpression[] exps = expression.getExpressions();
		if (exps != null && exps.length>0) {
			for(int i=0; i<exps.length; i++) {
				result.append(getExpressionString(exps[i]));
				if (i < exps.length-1) {
					result.append(COMMA_SPACE);
				}
			}
		}
		return result.toString();
	}
	
	private static String getEmptyExpression( IASTExpression expression ){
		return EMPTY_STRING;
	}
	
	private static String getLiteralExpression( IASTLiteralExpression expression ){
		StringBuffer result = new StringBuffer();
		if (expression.getKind() == IASTLiteralExpression.lk_string_literal) result.append("\""); //$NON-NLS-1$
		result.append(expression.toString());
		if (expression.getKind() == IASTLiteralExpression.lk_string_literal) result.append("\""); //$NON-NLS-1$		
		return result.toString();
	}
	
	private static String getIdExpression( IASTIdExpression expression ){
		return expression.getName().toString();
	}
	private static String getConditionalExpression( IASTConditionalExpression expression ){
		StringBuffer result = new StringBuffer();
		result.append(getExpressionString(expression.getLogicalConditionExpression()));
		result.append(SPACE);
		result.append(Keywords.cpQUESTION);
		result.append(SPACE);
		result.append(getExpressionString(expression.getPositiveResultExpression()));
		result.append(SPACE);
		result.append(Keywords.cpCOLON);
		result.append(SPACE);
		result.append(getExpressionString(expression.getNegativeResultExpression()));
		return result.toString();
	}
	private static String getNewExpression( ICPPASTNewExpression expression ){
		StringBuffer result = new StringBuffer();
		result.append(Keywords.NEW);
		result.append(SPACE);
		if (expression.getNewPlacement() != null) {
			result.append(getExpressionString(expression.getNewPlacement()));
		}
		result.append(getSignature(expression.getTypeId()));
		result.append(Keywords.cpLPAREN);
		result.append(getExpressionString(expression.getNewInitializer()));
		result.append(Keywords.cpRPAREN);
		return result.toString();
	}
	private static String getBinaryExpression( IASTBinaryExpression expression ){
		StringBuffer buffer = new StringBuffer();
		buffer.append( getExpressionString( expression.getOperand1() ) );
		buffer.append(SPACE);
		buffer.append( getBinaryOperatorString( expression ));
		buffer.append(SPACE);
		buffer.append( getExpressionString( expression.getOperand2() ) );
		return buffer.toString();
	}

	private static String getUnaryExpression( IASTUnaryExpression expression ){
		StringBuffer buffer = new StringBuffer();
		boolean postOperator=false;
		boolean primaryBracketed=false;
		
		switch(expression.getOperator()) {
			case IASTUnaryExpression.op_postFixDecr:
			case IASTUnaryExpression.op_postFixIncr:
				postOperator=true;
				break;
			case IASTUnaryExpression.op_bracketedPrimary:
				primaryBracketed=true;
				break;
			default:
				postOperator=false;
				break;
		}
		
		if (!postOperator && !primaryBracketed) buffer.append(getUnaryOperatorString(expression));
		
		// need to add a space to the unary expression if it is a specific operator
		switch(expression.getOperator()) {
			case IASTUnaryExpression.op_sizeof:
			case ICPPASTUnaryExpression.op_throw:
			case ICPPASTUnaryExpression.op_typeid:
				buffer.append(SPACE);
				break;
		}
		
		if (primaryBracketed) buffer.append(Keywords.cpLPAREN);
		buffer.append(getExpressionString(expression.getOperand()));
		if (primaryBracketed) buffer.append(Keywords.cpRPAREN);
		if (postOperator && !primaryBracketed) buffer.append(getUnaryOperatorString(expression));
		
		return buffer.toString();
	}

	/**
	 * Returns the String representation of the IASTCastExpression's operator.
	 * 
	 * @param expression
	 * @return the String representation of the IASTCastExpression's operator
	 */
	public static String getCastOperatorString(IASTCastExpression expression) {
		int op = expression.getOperator();
		String opString = EMPTY_STRING;
		
		if (expression instanceof ICPPASTCastExpression) {
			switch (op) {
				case ICPPASTCastExpression.op_const_cast:
					opString = Keywords.CONST_CAST;
					break;
				case ICPPASTCastExpression.op_dynamic_cast:
					opString = Keywords.DYNAMIC_CAST;
					break;
				case ICPPASTCastExpression.op_reinterpret_cast:
					opString = Keywords.REINTERPRET_CAST;
					break;
				case ICPPASTCastExpression.op_static_cast:
					opString = Keywords.STATIC_CAST;
					break;
				default:
					break;
			}
		}
		
		if (!opString.equals(EMPTY_STRING)) return opString;
		
		switch(op) {
			case IASTCastExpression.op_cast:
				opString = Keywords.CAST;
				break;
		}
		
		return opString;
	}
	
	/**
	 * Returns the String representation of the IASTUnaryExpression's operator.
	 * 
	 * @param ue
	 * @return the String representation of the IASTUnaryExpression's operator
	 */
	public static String getUnaryOperatorString(IASTUnaryExpression ue) {
		int op = ue.getOperator();
		String opString = EMPTY_STRING;
		
		if (ue instanceof ICPPASTUnaryExpression) {
			switch(op) {
				case ICPPASTUnaryExpression.op_throw:
					opString = Keywords.THROW;
					break;
				case ICPPASTUnaryExpression.op_typeid:
					opString = Keywords.TYPEID;
					break;
			}
		} else if (ue instanceof IGNUASTUnaryExpression) {
			switch(op) {
				case IGNUASTUnaryExpression.op_alignOf:
					opString = Keywords.ALIGNOF;
					break;
				case IGNUASTUnaryExpression.op_typeof:
					opString = Keywords.TYPEOF;
					break;
			}
		}
		
		if (!opString.equals(EMPTY_STRING)) return opString;
		
		switch(op) {
			case IASTUnaryExpression.op_amper:
				opString = String.valueOf(Keywords.cpAMPER);
				break;
			case IASTUnaryExpression.op_minus:
				opString = String.valueOf(Keywords.cpMINUS);
				break;
			case IASTUnaryExpression.op_not:
				opString = String.valueOf(Keywords.cpNOT);
				break;
			case IASTUnaryExpression.op_plus:
				opString = String.valueOf(Keywords.cpPLUS);
				break;
			case IASTUnaryExpression.op_postFixDecr:
				opString = String.valueOf(Keywords.cpDECR);
				break;
			case IASTUnaryExpression.op_postFixIncr:
				opString = String.valueOf(Keywords.cpINCR);
				break;
			case IASTUnaryExpression.op_prefixDecr:
				opString = String.valueOf(Keywords.cpDECR);
				break;
			case IASTUnaryExpression.op_prefixIncr:
				opString = String.valueOf(Keywords.cpINCR);
				break;
			case IASTUnaryExpression.op_sizeof:
				opString = Keywords.SIZEOF;
				break;
			case IASTUnaryExpression.op_star:
				opString = String.valueOf(Keywords.cpSTAR);
				break;
			case IASTUnaryExpression.op_tilde:
				opString = String.valueOf(Keywords.cpCOMPL); 
				break;
		}
		
		return opString;
	}
	
	/**
	 * Returns the String representation of the IASTBinaryExpression's operator.
	 * 
	 * @param be
	 * @return the String representation of the IASTBinaryExpression's operator
	 */
	public static String getBinaryOperatorString(IASTBinaryExpression be) {
		int op = be.getOperator();
		String opString = EMPTY_STRING;
		
		if (be instanceof ICPPASTBinaryExpression) {
			switch(op) {
				case ICPPASTBinaryExpression.op_pmarrow:
					opString = String.valueOf(Keywords.cpARROW);
					break;
				case ICPPASTBinaryExpression.op_pmdot:
					opString = String.valueOf(Keywords.cpDOT);
					break;
			}
		} else if (be instanceof IGPPASTBinaryExpression) {
			switch(op) {
				case IGPPASTBinaryExpression.op_max:
					opString = String.valueOf(Keywords.cpMAX);
					break;
				case IGPPASTBinaryExpression.op_min:
					opString = String.valueOf(Keywords.cpMIN);
					break;
			}
		}
		
		if (!opString.equals(EMPTY_STRING)) return opString;
		
		switch(op) {
			case IASTBinaryExpression.op_multiply:
				opString = String.valueOf(Keywords.cpSTAR);
				break;
			case IASTBinaryExpression.op_divide:
				opString = String.valueOf(Keywords.cpDIV);
				break;
			case IASTBinaryExpression.op_modulo:
				opString = String.valueOf(Keywords.cpMOD);
				break;
			case IASTBinaryExpression.op_plus:
				opString = String.valueOf(Keywords.cpPLUS);
				break;
			case IASTBinaryExpression.op_minus:
				opString = String.valueOf(Keywords.cpMINUS);
				break;
			case IASTBinaryExpression.op_shiftLeft:
				opString = String.valueOf(Keywords.cpSHIFTL);
				break;
			case IASTBinaryExpression.op_shiftRight:
				opString = String.valueOf(Keywords.cpSHIFTR);
				break;
			case IASTBinaryExpression.op_lessThan:
				opString = String.valueOf(Keywords.cpLT);
				break;
			case IASTBinaryExpression.op_greaterThan:
				opString = String.valueOf(Keywords.cpGT);
				break;
			case IASTBinaryExpression.op_lessEqual:
				opString = String.valueOf(Keywords.cpLTEQUAL);
				break;
			case IASTBinaryExpression.op_greaterEqual:
				opString = String.valueOf(Keywords.cpGTEQUAL);
				break;
			case IASTBinaryExpression.op_binaryAnd:
				opString = String.valueOf(Keywords.cpAMPER);
				break;
			case IASTBinaryExpression.op_binaryXor:
				opString = String.valueOf(Keywords.cpXOR);
				break;
			case IASTBinaryExpression.op_binaryOr:
				opString = String.valueOf(Keywords.cpBITOR);
				break;
			case IASTBinaryExpression.op_logicalAnd:
				opString = String.valueOf(Keywords.cpAND);
				break;
			case IASTBinaryExpression.op_logicalOr:
				opString = String.valueOf(Keywords.cpOR);
				break;
			case IASTBinaryExpression.op_assign:
				opString = String.valueOf(Keywords.cpASSIGN);
				break;
			case IASTBinaryExpression.op_multiplyAssign:
				opString = String.valueOf(Keywords.cpSTARASSIGN);
				break;
			case IASTBinaryExpression.op_divideAssign:
				opString = String.valueOf(Keywords.cpDIVASSIGN);
				break;
			case IASTBinaryExpression.op_moduloAssign:
				opString = String.valueOf(Keywords.cpMODASSIGN);
				break;
			case IASTBinaryExpression.op_plusAssign:
				opString = String.valueOf(Keywords.cpPLUSASSIGN);
				break;
			case IASTBinaryExpression.op_minusAssign:
				opString = String.valueOf(Keywords.cpMINUSASSIGN);
				break;
			case IASTBinaryExpression.op_shiftLeftAssign:
				opString = String.valueOf(Keywords.cpSHIFTLASSIGN);
				break;
			case IASTBinaryExpression.op_shiftRightAssign:
				opString = String.valueOf(Keywords.cpSHIFTRASSIGN);
				break;
			case IASTBinaryExpression.op_binaryAndAssign:
				opString = String.valueOf(Keywords.cpAMPERASSIGN);
				break;
			case IASTBinaryExpression.op_binaryXorAssign:
				opString = String.valueOf(Keywords.cpXORASSIGN);
				break;
			case IASTBinaryExpression.op_binaryOrAssign:
				opString = String.valueOf(Keywords.cpBITORASSIGN);
				break;
			case IASTBinaryExpression.op_equals:
				opString = String.valueOf(Keywords.cpEQUAL);
				break;
			case IASTBinaryExpression.op_notequals:
				opString = String.valueOf(Keywords.cpNOTEQUAL);
				break;
            case IGPPASTBinaryExpression.op_max:
                opString = String.valueOf(Keywords.cpMAX);
                break;
            case IGPPASTBinaryExpression.op_min:
                opString = String.valueOf(Keywords.cpMIN);
                break;
		}
		
		return opString;
	}
	
	/**
	 * Returns the String representation of the IASTTypeIdExpression's operator.
	 * 
	 * @param expression
	 * @return the String representation of the IASTTypeIdExpression's operator
	 */
	private static String getTypeIdExpressionOperator(IASTTypeIdExpression expression) {
		String result = EMPTY_STRING;
		
		if (expression instanceof IGNUASTTypeIdExpression) {
			switch (expression.getOperator()) {
				case IGNUASTTypeIdExpression.op_alignof:
					result = Keywords.ALIGNOF;
					break;
				case IGNUASTTypeIdExpression.op_typeof:
					result = Keywords.TYPEOF;
					break;
			}
		}
		
		if (expression instanceof ICPPASTTypeIdExpression) {
			switch(expression.getOperator()) {
				case ICPPASTTypeIdExpression.op_typeid:
					result = Keywords.TYPEID;
					break;
			}
		}
		
		if (expression.getOperator() == IASTTypeIdExpression.op_sizeof)
			result = Keywords.SIZEOF;
		
		return result;
	}

}

Back to the top