Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
9aa991d6
Commit
9aa991d6
authored
Aug 05, 2010
by
Roberto Raggi
Committed by
Oswald Buddenhagen
Aug 05, 2010
Browse files
Refactored CPlusPlus::Function.
parent
5f440364
Changes
11
Hide whitespace changes
Inline
Side-by-side
src/libs/cplusplus/CppRewriter.cpp
View file @
9aa991d6
...
...
@@ -145,7 +145,7 @@ public:
newArg
->
setName
(
rewrite
->
rewriteName
(
arg
->
name
()));
newArg
->
setType
(
rewrite
->
rewriteType
(
arg
->
type
()));
funTy
->
a
rguments
()
->
enterSymbol
(
newArg
);
funTy
->
a
ddMember
(
newArg
);
}
temps
.
append
(
funTy
);
...
...
src/libs/cplusplus/DeprecatedGenTemplateInstance.cpp
View file @
9aa991d6
...
...
@@ -145,7 +145,7 @@ private:
arg
->
setType
(
q
->
apply
(
originalArgument
->
type
()));
arg
->
setInitializer
(
originalArgument
->
initializer
());
fun
->
a
rguments
()
->
enterSymbol
(
arg
);
fun
->
a
ddMember
(
arg
);
}
_type
.
setType
(
fun
);
...
...
src/libs/cplusplus/LookupContext.cpp
View file @
9aa991d6
...
...
@@ -282,7 +282,7 @@ QList<LookupItem> LookupContext::lookup(const Name *name, Scope *scope) const
}
else
if
(
scope
->
isFunctionScope
())
{
Function
*
fun
=
scope
->
owner
()
->
asFunction
();
bindings
()
->
lookupInScope
(
name
,
fun
->
argument
s
(),
&
candidates
,
/*templateId = */
0
,
/*binding=*/
0
);
bindings
()
->
lookupInScope
(
name
,
fun
->
member
s
(),
&
candidates
,
/*templateId = */
0
,
/*binding=*/
0
);
for
(
TemplateParameters
*
it
=
fun
->
templateParameters
();
it
&&
candidates
.
isEmpty
();
it
=
it
->
previous
())
bindings
()
->
lookupInScope
(
name
,
it
->
scope
(),
&
candidates
,
/* templateId = */
0
,
/*binding=*/
0
);
...
...
src/plugins/cppeditor/cpplocalsymbols.cpp
View file @
9aa991d6
...
...
@@ -134,7 +134,7 @@ protected:
Function
*
fun
=
scope
->
owner
()
->
asFunction
();
if
(
findMember
(
fun
->
members
(),
ast
,
line
,
column
))
return
false
;
else
if
(
findMember
(
fun
->
argument
s
(),
ast
,
line
,
column
))
else
if
(
findMember
(
fun
->
member
s
(),
ast
,
line
,
column
))
return
false
;
}
else
if
(
scope
->
isObjCMethodScope
())
{
ObjCMethod
*
method
=
scope
->
owner
()
->
asObjCMethod
();
...
...
@@ -180,7 +180,7 @@ protected:
Function
*
fun
=
scope
->
owner
()
->
asFunction
();
if
(
findMember
(
fun
->
members
(),
ast
,
line
,
column
))
return
false
;
else
if
(
f
indMember
(
fun
->
argument
s
(),
ast
,
line
,
column
))
else
if
(
f
un
->
block
()
&&
findMember
(
fun
->
block
()
->
member
s
(),
ast
,
line
,
column
))
return
false
;
}
else
if
(
scope
->
isBlockScope
())
{
if
(
findMember
(
scope
,
ast
,
line
,
column
))
...
...
src/plugins/cpptools/cppcodecompletion.cpp
View file @
9aa991d6
...
...
@@ -1080,9 +1080,9 @@ void CppCodeCompletion::globalCompletion(Scope *currentScope)
addCompletionItem
(
scope
->
symbolAt
(
i
));
}
}
else
if
(
scope
->
isFunctionScope
())
{
Scope
*
arguments
=
scope
->
owner
()
->
asFunction
()
->
arguments
()
;
for
(
unsigned
i
=
0
;
i
<
argument
s
->
symbol
Count
();
++
i
)
{
addCompletionItem
(
argument
s
->
symbol
At
(
i
));
Function
*
fun
=
scope
->
owner
()
->
asFunction
();
for
(
unsigned
i
=
0
;
i
<
fun
->
argumentCount
();
++
i
)
{
addCompletionItem
(
fun
->
argumentAt
(
i
));
}
break
;
}
else
{
...
...
src/shared/cplusplus/CheckDeclarator.cpp
View file @
9aa991d6
...
...
@@ -175,7 +175,7 @@ bool CheckDeclarator::visit(FunctionDeclaratorAST *ast)
if
(
ast
->
parameters
)
{
DeclarationListAST
*
parameter_declarations
=
ast
->
parameters
->
parameter_declaration_list
;
for
(
DeclarationListAST
*
decl
=
parameter_declarations
;
decl
;
decl
=
decl
->
next
)
{
semantic
()
->
check
(
decl
->
value
,
fun
->
argument
s
());
semantic
()
->
check
(
decl
->
value
,
fun
->
member
s
());
}
if
(
ast
->
parameters
->
dot_dot_dot_token
)
...
...
src/shared/cplusplus/Scope.cpp
View file @
9aa991d6
...
...
@@ -58,9 +58,9 @@ using namespace CPlusPlus;
Scope
::
Scope
(
ScopedSymbol
*
owner
)
:
_owner
(
owner
),
_symbols
(
0
),
_hash
(
0
),
_allocatedSymbols
(
0
),
_symbolCount
(
-
1
),
_hash
(
0
),
_hashSize
(
0
),
_startOffset
(
0
),
_endOffset
(
0
)
...
...
@@ -168,10 +168,7 @@ bool Scope::isBlockScope() const
bool
Scope
::
isPrototypeScope
()
const
{
Function
*
f
=
0
;
if
(
_owner
&&
0
!=
(
f
=
_owner
->
asFunction
()))
return
f
->
arguments
()
==
this
;
return
false
;
return
isFunctionScope
();
}
bool
Scope
::
isObjCClassScope
()
const
...
...
@@ -190,9 +187,8 @@ bool Scope::isObjCProtocolScope() const
bool
Scope
::
isFunctionScope
()
const
{
Function
*
f
=
0
;
if
(
_owner
&&
0
!=
(
f
=
_owner
->
asFunction
()))
return
f
->
arguments
()
!=
this
;
if
(
_owner
)
return
_owner
->
isFunction
();
return
false
;
}
...
...
src/shared/cplusplus/Scope.h
View file @
9aa991d6
...
...
@@ -161,14 +161,11 @@ private:
enum
{
DefaultInitialSize
=
11
};
ScopedSymbol
*
_owner
;
Symbol
**
_symbols
;
Symbol
**
_hash
;
int
_allocatedSymbols
;
int
_symbolCount
;
Symbol
**
_hash
;
int
_hashSize
;
unsigned
_startOffset
;
unsigned
_endOffset
;
};
...
...
src/shared/cplusplus/Semantic.cpp
View file @
9aa991d6
...
...
@@ -199,7 +199,13 @@ void Semantic::finishFunctionDefinition(FunctionDefinitionAST *ast)
Function
*
fun
=
ast
->
symbol
;
d
->
checkDeclaration
->
check
(
ast
->
ctor_initializer
,
fun
->
scope
());
check
(
ast
->
function_body
,
fun
->
members
());
if
(
ast
->
function_body
)
{
check
(
ast
->
function_body
,
fun
->
members
());
if
(
CompoundStatementAST
*
c
=
ast
->
function_body
->
asCompoundStatement
())
fun
->
setBlock
(
c
->
symbol
);
}
switchMethodKey
(
previousMethodKey
);
switchVisibility
(
previousVisibility
);
...
...
src/shared/cplusplus/Symbols.cpp
View file @
9aa991d6
...
...
@@ -191,14 +191,14 @@ void TypenameArgument::visitSymbol0(SymbolVisitor *visitor)
Function
::
Function
(
TranslationUnit
*
translationUnit
,
unsigned
sourceLocation
,
const
Name
*
name
)
:
ScopedSymbol
(
translationUnit
,
sourceLocation
,
name
),
_templateParameters
(
0
),
_flags
(
0
)
{
_arguments
=
new
Scope
(
this
);
}
_templateParameters
(
0
),
_block
(
0
),
_flags
(
0
)
{
}
Function
::~
Function
()
{
delete
_templateParameters
;
delete
_arguments
;
}
bool
Function
::
isNormal
()
const
...
...
@@ -219,6 +219,12 @@ int Function::methodKey() const
void
Function
::
setMethodKey
(
int
key
)
{
f
.
_methodKey
=
key
;
}
Block
*
Function
::
block
()
const
{
return
_block
;
}
void
Function
::
setBlock
(
Block
*
block
)
{
_block
=
block
;
}
unsigned
Function
::
templateParameterCount
()
const
{
if
(
!
_templateParameters
)
...
...
@@ -255,13 +261,13 @@ bool Function::isEqualTo(const Type *other) const
const
Name
*
l
=
identity
();
const
Name
*
r
=
o
->
identity
();
if
(
l
==
r
||
(
l
&&
l
->
isEqualTo
(
r
)))
{
if
(
_
argument
s
->
symbol
Count
()
!=
o
->
_
argument
s
->
symbol
Count
())
if
(
argumentCount
()
!=
o
->
argumentCount
())
return
false
;
else
if
(
!
_returnType
.
isEqualTo
(
o
->
_returnType
))
return
false
;
for
(
unsigned
i
=
0
;
i
<
_
argument
s
->
symbol
Count
();
++
i
)
{
Symbol
*
l
=
_
argument
s
->
symbol
At
(
i
);
Symbol
*
r
=
o
->
_
argument
s
->
symbol
At
(
i
);
for
(
unsigned
i
=
0
;
i
<
argumentCount
();
++
i
)
{
Symbol
*
l
=
argumentAt
(
i
);
Symbol
*
r
=
o
->
argumentAt
(
i
);
if
(
!
l
->
type
().
isEqualTo
(
r
->
type
()))
return
false
;
}
...
...
@@ -334,17 +340,14 @@ bool Function::hasReturnType() const
unsigned
Function
::
argumentCount
()
const
{
if
(
!
_arguments
)
return
0
;
if
(
_block
)
return
memberCount
()
-
1
;
return
_arguments
->
symbol
Count
();
return
member
Count
();
}
Symbol
*
Function
::
argumentAt
(
unsigned
index
)
const
{
return
_arguments
->
symbolAt
(
index
);
}
Scope
*
Function
::
arguments
()
const
{
return
_arguments
;
}
{
return
memberAt
(
index
);
}
bool
Function
::
hasArguments
()
const
{
...
...
@@ -356,8 +359,8 @@ unsigned Function::minimumArgumentCount() const
{
unsigned
index
=
0
;
for
(;
index
<
_
argument
s
->
symbol
Count
();
++
index
)
{
if
(
Argument
*
arg
=
_
argument
s
->
symbol
At
(
index
)
->
asArgument
())
{
for
(;
index
<
argumentCount
();
++
index
)
{
if
(
Argument
*
arg
=
argumentAt
(
index
)
->
asArgument
())
{
if
(
arg
->
hasInitializer
())
break
;
}
...
...
@@ -405,9 +408,6 @@ void Function::setAmbiguous(bool isAmbiguous)
void
Function
::
visitSymbol0
(
SymbolVisitor
*
visitor
)
{
if
(
visitor
->
visit
(
this
))
{
for
(
unsigned
i
=
0
;
i
<
_arguments
->
symbolCount
();
++
i
)
{
visitSymbol
(
_arguments
->
symbolAt
(
i
),
visitor
);
}
for
(
unsigned
i
=
0
;
i
<
memberCount
();
++
i
)
{
visitSymbol
(
memberAt
(
i
),
visitor
);
}
...
...
src/shared/cplusplus/Symbols.h
View file @
9aa991d6
...
...
@@ -342,6 +342,9 @@ public:
int
methodKey
()
const
;
void
setMethodKey
(
int
key
);
Block
*
block
()
const
;
void
setBlock
(
Block
*
block
);
unsigned
templateParameterCount
()
const
;
// ### remove me
Symbol
*
templateParameterAt
(
unsigned
index
)
const
;
// ### remove me
...
...
@@ -356,7 +359,6 @@ public:
unsigned
argumentCount
()
const
;
Symbol
*
argumentAt
(
unsigned
index
)
const
;
Scope
*
arguments
()
const
;
/** Convenience function that returns whether the function receives any arguments. */
bool
hasArguments
()
const
;
...
...
@@ -408,8 +410,9 @@ protected:
virtual
bool
matchType0
(
const
Type
*
otherType
,
TypeMatcher
*
matcher
)
const
;
private:
TemplateParameters
*
_templateParameters
;
FullySpecifiedType
_returnType
;
TemplateParameters
*
_templateParameters
;
Block
*
_block
;
struct
Flags
{
unsigned
_isVirtual
:
1
;
unsigned
_isVariadic
:
1
;
...
...
@@ -423,7 +426,6 @@ private:
unsigned
_flags
;
Flags
f
;
};
Scope
*
_arguments
;
};
class
CPLUSPLUS_EXPORT
Namespace
:
public
ScopedSymbol
,
public
Type
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment