本文整理汇总了Java中org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator类的典型用法代码示例。如果您正苦于以下问题:Java IASTFunctionDeclarator类的具体用法?Java IASTFunctionDeclarator怎么用?Java IASTFunctionDeclarator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IASTFunctionDeclarator类属于org.eclipse.cdt.core.dom.ast包,在下文中一共展示了IASTFunctionDeclarator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFunctionBinding
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator; //导入依赖的package包/类
public IBinding getFunctionBinding(IASTFunctionDeclarator node, IASTName name) {
IBinding bnd;
bnd = getBinding(name); // generic getBinding method
if (bnd == null) {
ContainerEntity parent = null;
String behavName = SignatureBuilderVisitor.signatureFromAST(node);
// need to find the parent here (although mkStubKey can do it for us)
// because need to know whether it is a method or a function
QualifiedName qualName = new QualifiedName(name);
if (qualName.isFullyQualified()) {
parent = (ContainerEntity) resolveOrCreate(qualName.nameQualifiers(), /*mayBeNull*/false, /*mustBeClass*/false);
}
else {
parent = context.getTopCppNamespace();
}
if (parent instanceof eu.synectique.verveine.core.gen.famix.Class) {
bnd = mkStubKey( behavName, parent, Method.class);
}
else {
bnd = mkStubKey(behavName, (ContainerEntity) parent, Function.class);
}
}
return bnd;
}
示例2: ensureBehavioural
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator; //导入依赖的package包/类
/**
* Get a behaviouralEntity for the node.
* Tries to recover from the binding or the name (does some name resolution based on fully qualified names).
* If all fails, will create an entity.
*/
public BehaviouralEntity ensureBehavioural(IASTFunctionDeclarator node, IBinding nodeBnd, IASTName nodeName) {
BehaviouralEntity fmx;
// just in case this is a definition and we already processed the declaration
fmx = (BehaviouralEntity) dico.getEntityByKey(nodeBnd);
// try harder
if (fmx == null) {
fmx = ensureBehaviouralFromName(node, nodeBnd, nodeName);
}
return fmx;
}
示例3: ensureBehaviouralFromName
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator; //导入依赖的package包/类
public BehaviouralEntity ensureBehaviouralFromName(IASTFunctionDeclarator node, IBinding bnd, IASTName name) {
String sig;
ContainerEntity parent;
BehaviouralEntity fmx;
// get behavioural name and parent
if (bnd instanceof StubBinding) {
String fullname = ((StubBinding)bnd).getEntityName();
sig = QualifiedName.signatureFromBehaviouralFullname(fullname);
parent = behaviouralParentFromNameOrContext(fullname);
}
else {
sig = SignatureBuilderVisitor.signatureFromAST(node);
parent = behaviouralParentFromBindingOrContext(bnd, name);
}
// last try to recover behavioural ...
fmx = (BehaviouralEntity) findInParent(sig, parent, /*recursive*/false);
// ... create it if failed
if (fmx == null) {
if (isMethodBinding(bnd)) {
fmx = dico.ensureFamixMethod(bnd, new QualifiedName(name).unqualifiedName(), sig, /*owner*/(Type)parent);
}
else { // C function or may be a stub ?
fmx = dico.ensureFamixFunction(bnd, new QualifiedName(name).unqualifiedName(), SignatureBuilderVisitor.signatureFromAST(node), (ContainerEntity)context.top());
}
}
return fmx;
}
示例4: visit
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator; //导入依赖的package包/类
@Override
public int visit(IASTDeclarator node) {
/* ********************************************************************************************
* BE CAREFULL: The order of the tests is important because choices are not mutually exclusive
* ex: ICPPASTFunctionDeclarator is a sub-interface of IASTFunctionDeclarator
* ******************************************************************************************** */
if (node instanceof ICPPASTFunctionDeclarator) {
return this.visit((ICPPASTFunctionDeclarator)node);
}
else if (node instanceof IASTStandardFunctionDeclarator) {
return this.visit((IASTStandardFunctionDeclarator)node);
}
else if (node instanceof ICASTKnRFunctionDeclarator) {
return this.visit((ICASTKnRFunctionDeclarator)node);
}
else if (node instanceof IASTFunctionDeclarator) {
return this.visit((IASTFunctionDeclarator)node);
}
else if (node instanceof IASTFieldDeclarator) { // actually seems to never occur ???
return this.visit((IASTFieldDeclarator)node);
}
/* removed to deal with C attributes: IASTDeclarators
else if (node instanceof ICPPASTDeclarator) {
return this.visit((ICPPASTDeclarator)node);
}
replaced by the following:
*/
else {
return this.visitInternal(node);
}
}
示例5: processFunctionDeclarator
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator; //导入依赖的package包/类
protected void processFunctionDeclarator(IASTFunctionDeclarator node) {
BehaviouralEntity fmx;
super.visit(node); // gets the behavioural
fmx = (BehaviouralEntity) returnedEntity;
if ( (fmx != null) && (! resolver.isConstructor(fmx)) && (! resolver.isDestructor(fmx)) ) {
fmx.setDeclaredType(referredType);
}
}
示例6: visit
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator; //导入依赖的package包/类
@Override
protected int visit(IASTFunctionDeclarator node) {
if (! inCastExpression) {
super.visit(node);
return PROCESS_SKIP;
}
else {
// this is something like a cast to a fonction pointer type
// do not deal with the FunctionDeclarator, but handle its possible parameter type
return PROCESS_CONTINUE;
}
}
示例7: visit
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator; //导入依赖的package包/类
@Override
protected int visit(IASTFunctionDeclarator node) {
if (! inCastExpression) {
super.visit(node);
}
// else this is something like a cast to a function pointer type: do not handle it
return PROCESS_SKIP;
}
示例8: visit
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator; //导入依赖的package包/类
@Override
protected int visit(IASTFunctionDeclarator node) {
// get node name and bnd
super.visit(node);
if (nodeBnd instanceof IVariable) {
// declaration of a function pointer such as var in "int (*var)(int param1, char param2)"
returnedEntity = null;
}
else {
returnedEntity = resolver.ensureBehavioural(node, nodeBnd, nodeName);
}
return PROCESS_SKIP;
}
示例9: signatureFromAST
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator; //导入依赖的package包/类
static public String signatureFromAST(IASTFunctionDeclarator node) {
String behavName;
// for behavioral, we put the full signature in the key to have better chance of recovering it
SignatureBuilderVisitor sigVisitor = new SignatureBuilderVisitor();
node.accept(sigVisitor);
behavName = sigVisitor.getSignature();
return behavName;
}
示例10: visit
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator; //导入依赖的package包/类
@Override
protected int visit(ICPPASTFunctionDeclarator node) {
// compute nodeName and binding
super.visit( (IASTFunctionDeclarator)node);
returnedEntity = (BehaviouralEntity) dico.getEntityByKey(nodeBnd);
// try harder
if (returnedEntity == null) {
returnedEntity = resolver.ensureBehaviouralFromName(node, nodeBnd, nodeName);
}
// Not visiting children, because assuming there is no template inside a method
return PROCESS_SKIP;
}
示例11: visit
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator; //导入依赖的package包/类
@Override
protected int visit(IASTFunctionDeclarator node) {
// get node name and bnd in case we have a function pointer such as var in "int (*var)(int param1, char param2)"
super.visit( node);
if (nodeBnd instanceof IVariable) {
nodeName = node.getNestedDeclarator().getName();
ensureVariableKind(nodeBnd, nodeName);
}
return PROCESS_SKIP;
}
示例12: visitFunctionDeclarator
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator; //导入依赖的package包/类
protected BehaviouralEntity visitFunctionDeclarator(IASTFunctionDeclarator node, IASTNode[] params) {
BehaviouralEntity fmx;
Type classCtxt = null;
if (declarationIsFriend(node)) {
// friend function are outside the scope of the class
// so remove the class from the context stack
classCtxt = (Type) getContext().pop();
}
fmx = resolver.ensureBehavioural(node, nodeBnd, nodeName);
dico.setVisibility(fmx, currentVisibility);
// parent node is a SimpleDeclaration or a FunctionDefinition
IASTFileLocation defLoc = node.getParent().getFileLocation();
dico.addSourceAnchorMulti(fmx, filename, defLoc);
if (resolver.isDestructorBinding(nodeBnd)) {
((Method)fmx).setKind(CDictionary.DESTRUCTOR_KIND_MARKER);
}
if (resolver.isConstructorBinding(nodeBnd)) {
((Method)fmx).setKind(Dictionary.CONSTRUCTOR_KIND_MARKER);
}
fmx.setIsStub(false); // used to say TRUE if could not find a binding. Not too sure ...
visitParameters(params, fmx);
if (declarationIsFriend(node)) {
// friend function are outside the scope of the class
// push back the class in the context stack
getContext().push(classCtxt);
}
return fmx;
}
示例13: declarationIsFriend
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator; //导入依赖的package包/类
protected boolean declarationIsFriend(IASTFunctionDeclarator node) {
IASTNode parentDecl = node.getParent();
if (parentDecl instanceof IASTSimpleDeclaration) {
IASTDeclSpecifier spec = ((IASTSimpleDeclaration)parentDecl).getDeclSpecifier();
if (spec instanceof ICPPASTDeclSpecifier) {
return ((ICPPASTDeclSpecifier) spec).isFriend();
}
}
return false;
}
示例14: visit
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator; //导入依赖的package包/类
@Override
public int visit(IASTDeclarator declarator) {
if (declarator instanceof IASTArrayDeclarator)
visit((IASTArrayDeclarator) declarator);
// else if (declarator instanceof IASTFieldDeclarator)
// visit((IASTFieldDeclarator) declarator);
else if (declarator instanceof IASTFunctionDeclarator)
visit((IASTFunctionDeclarator) declarator);
else if (declarator instanceof ICPPASTDeclarator)
visit((ICPPASTDeclarator) declarator);
else {
// TODO: add attributes
List<IConstructor> pointerOperators = new ArrayList<IConstructor>();
Stream.of(declarator.getPointerOperators()).forEach(it -> {
it.accept(this);
pointerOperators.add(stack.pop());
});
IConstructor nestedDeclarator = null;
if (declarator.getNestedDeclarator() != null) {
declarator.getNestedDeclarator().accept(this);
nestedDeclarator = stack.pop();
}
declarator.getName().accept(this);
IConstructor name = stack.pop();
IConstructor initializer = null;
if (declarator.getInitializer() == null) {
} else {
declarator.getInitializer().accept(this);
initializer = stack.pop();
}
throw new RuntimeException("NYI");
}
return PROCESS_ABORT;
}
示例15: testExample
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator; //导入依赖的package包/类
public void testExample() {
IASTTranslationUnit translationUnit = parseCPP(getCommentAbove());
IASTFunctionDefinition functionDefinition = (IASTFunctionDefinition) translationUnit.getDeclarations()[1];
// f(int y)
assertTrue(functionDefinition.getDeclarator() instanceof IASTFunctionDeclarator);
}