001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.cnd.api.model;
043:
044: import java.util.Collection;
045: import java.util.HashMap;
046: import java.util.Map;
047:
048: /**
049: *
050: * @author Vladimir Kvashin
051: */
052: public interface CsmFunction<T> extends CsmOffsetableDeclaration<T>,
053: CsmScope {
054:
055: public enum OperatorKind {
056: COMMA(",", true), NOT("!", false), NOT_EQ("!=", true), MOD("%",
057: true), MOD_EQ("%=", true), AND("&", true), ADDRESS("&",
058: false), AND_AND("&&", true), AND_EQ("&=", true), FUN_CALL(
059: "()", null), CAST("()", false), MUL("*", true), POINTER(
060: "*", false), MUL_EQ("*=", true), PLUS("+", true), PLUS_EQ(
061: "+=", true), PLUS_UNARY("+", false), PLUS_PLUS("++",
062: false), MINUS("-", true), MINUS_EQ("-=", true), MINUS_UNARY(
063: "-", false), MINUS_MINUS("--", false), ARROW("->", true), ARROW_MBR(
064: "->*", true), DIV("/", true), DIV_EQ("/=", true), LESS(
065: "<", true), LEFT_SHIFT("<<", true), // often as serialize
066: LEFT_SHIFT_EQ("<<=", true), LESS_EQ("<=", true), EQ("=", true), EQ_EQ(
067: "==", true), GREATER(">", true), GREATER_EQ(">=", true), RIGHT_SHIFT(
068: ">>", true), RIGHT_EQ(">>=", true), ARRAY("[]", null), XOR(
069: "^", true), XOR_EQ("^=", true), OR("|", true), OR_EQ(
070: "|=", true), OR_OR("||", true), TILDE("~", false), DELETE(
071: "delete", null), NEW("new", null), CONVERSION("", false), NONE(
072: "", null);
073:
074: private final String img;
075: private final Boolean binary;
076:
077: private OperatorKind(String img, Boolean binary) {
078: this .img = img;
079: this .binary = binary;
080: }
081:
082: public String getImage() {
083: return img;
084: }
085:
086: public Boolean isBinary() {
087: return binary;
088: }
089:
090: private static boolean inited = false;
091: private static Map<String, OperatorKind> kinds = new HashMap<String, OperatorKind>();
092:
093: public static OperatorKind getKindByImage(String image) {
094: if (!inited) {
095: for (OperatorKind kind : OperatorKind.values()) {
096: String img = kind.getImage();
097: if (img.length() > 0) {
098: kinds.put(img, kind);
099: }
100: }
101: inited = true;
102: }
103: OperatorKind kind = kinds.get(image);
104: if (kind == null) {
105: kind = NONE;
106: }
107: return kind;
108: }
109: }
110:
111: /** Gets this function's declaration text */
112: CharSequence getDeclarationText();
113:
114: /**
115: * Gets this function definition
116: * TODO: describe getDefiition==this ...
117: */
118: CsmFunctionDefinition getDefinition();
119:
120: /** Returns this function declaration */
121: CsmFunction getDeclaration();
122:
123: boolean isOperator();
124:
125: OperatorKind getOperatorKind();
126:
127: /**
128: * Returns true if this class is template, otherwise false.
129: * If isTemplate() returns true, this class is an instance of CsmTemplate
130: */
131: boolean isTemplate();
132:
133: boolean isInline();
134:
135: CsmType getReturnType();
136:
137: Collection<CsmParameter> getParameters();
138:
139: /**
140: * Gets this function signature string representation.
141: * Used to identify overrides, etc.
142: */
143: CharSequence getSignature();
144: }
|