Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
qt-creator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tobias Hunger
qt-creator
Commits
960716df
Commit
960716df
authored
15 years ago
by
Roberto Raggi
Browse files
Options
Downloads
Patches
Plain Diff
Cleanup
parent
213316f2
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/libs/cplusplus/GenTemplateInstance.cpp
+30
-21
30 additions, 21 deletions
src/libs/cplusplus/GenTemplateInstance.cpp
with
30 additions
and
21 deletions
src/libs/cplusplus/GenTemplateInstance.cpp
+
30
−
21
View file @
960716df
...
...
@@ -47,13 +47,13 @@ namespace {
class
ApplySubstitution
{
public:
ApplySubstitution
(
const
LookupContext
&
context
,
const
GenTemplateInstance
::
Substitution
&
substitution
);
ApplySubstitution
(
const
LookupContext
&
context
,
Symbol
*
symbol
,
const
GenTemplateInstance
::
Substitution
&
substitution
);
~
ApplySubstitution
();
Control
*
control
()
const
{
return
context
.
control
();
}
FullySpecifiedType
operator
()
(
Name
*
name
);
FullySpecifiedType
operator
()
(
const
FullySpecifiedType
&
type
);
FullySpecifiedType
apply
(
Name
*
name
);
FullySpecifiedType
apply
(
const
FullySpecifiedType
&
type
);
int
findSubstitution
(
Identifier
*
id
)
const
;
FullySpecifiedType
applySubstitution
(
int
index
)
const
;
...
...
@@ -107,22 +107,22 @@ private:
virtual
void
visit
(
PointerType
*
ptrTy
)
{
_type
.
setType
(
control
()
->
pointerType
(
operator
()
(
ptrTy
->
elementType
())));
_type
.
setType
(
control
()
->
pointerType
(
q
->
apply
(
ptrTy
->
elementType
())));
}
virtual
void
visit
(
ReferenceType
*
refTy
)
{
_type
.
setType
(
control
()
->
referenceType
(
operator
()
(
refTy
->
elementType
())));
_type
.
setType
(
control
()
->
referenceType
(
q
->
apply
(
refTy
->
elementType
())));
}
virtual
void
visit
(
ArrayType
*
arrayTy
)
{
_type
.
setType
(
control
()
->
arrayType
(
operator
()
(
arrayTy
->
elementType
()),
arrayTy
->
size
()));
_type
.
setType
(
control
()
->
arrayType
(
q
->
apply
(
arrayTy
->
elementType
()),
arrayTy
->
size
()));
}
virtual
void
visit
(
NamedType
*
ty
)
{
FullySpecifiedType
n
=
q
->
operator
()
(
ty
->
name
());
FullySpecifiedType
n
=
q
->
apply
(
ty
->
name
());
_type
.
setType
(
n
.
type
());
}
...
...
@@ -136,14 +136,14 @@ private:
fun
->
setAmbiguous
(
funTy
->
isAmbiguous
());
fun
->
setVariadic
(
funTy
->
isVariadic
());
fun
->
setReturnType
(
q
->
operator
()
(
funTy
->
returnType
()));
fun
->
setReturnType
(
q
->
apply
(
funTy
->
returnType
()));
for
(
unsigned
i
=
0
;
i
<
funTy
->
argumentCount
();
++
i
)
{
Argument
*
originalArgument
=
funTy
->
argumentAt
(
i
)
->
asArgument
();
Argument
*
arg
=
control
()
->
newArgument
(
/*sourceLocation*/
0
,
originalArgument
->
name
());
arg
->
setType
(
q
->
operator
()
(
originalArgument
->
type
()));
arg
->
setType
(
q
->
apply
(
originalArgument
->
type
()));
arg
->
setInitializer
(
originalArgument
->
hasInitializer
());
fun
->
arguments
()
->
enterSymbol
(
arg
);
}
...
...
@@ -199,6 +199,7 @@ private:
private
:
ApplySubstitution
*
q
;
FullySpecifiedType
_type
;
QHash
<
Symbol
*
,
FullySpecifiedType
>
_processed
;
};
class
ApplyToName
:
protected
NameVisitor
...
...
@@ -246,7 +247,7 @@ private:
QVarLengthArray
<
FullySpecifiedType
,
8
>
arguments
(
name
->
templateArgumentCount
());
for
(
unsigned
i
=
0
;
i
<
name
->
templateArgumentCount
();
++
i
)
{
FullySpecifiedType
argTy
=
name
->
templateArgumentAt
(
i
);
arguments
[
i
]
=
q
->
operator
()
(
argTy
);
arguments
[
i
]
=
q
->
apply
(
argTy
);
}
TemplateNameId
*
templId
=
control
()
->
templateNameId
(
name
->
identifier
(),
arguments
.
data
(),
arguments
.
size
());
...
...
@@ -263,7 +264,7 @@ private:
QVarLengthArray
<
FullySpecifiedType
,
8
>
arguments
(
templId
->
templateArgumentCount
());
for
(
unsigned
templateArgIndex
=
0
;
templateArgIndex
<
templId
->
templateArgumentCount
();
++
templateArgIndex
)
{
FullySpecifiedType
argTy
=
templId
->
templateArgumentAt
(
templateArgIndex
);
arguments
[
templateArgIndex
]
=
q
->
operator
()
(
argTy
);
arguments
[
templateArgIndex
]
=
q
->
apply
(
argTy
);
}
n
=
control
()
->
templateNameId
(
templId
->
identifier
(),
arguments
.
data
(),
arguments
.
size
());
...
...
@@ -307,26 +308,34 @@ private:
public
:
// attributes
LookupContext
context
;
Symbol
*
symbol
;
GenTemplateInstance
::
Substitution
substitution
;
private
:
ApplyToType
applyToType
;
ApplyToName
applyToName
;
};
ApplySubstitution
::
ApplySubstitution
(
const
LookupContext
&
context
,
const
GenTemplateInstance
::
Substitution
&
substitution
)
:
context
(
context
),
substitution
(
substitution
),
applyToType
(
this
),
applyToName
(
this
)
ApplySubstitution
::
ApplySubstitution
(
const
LookupContext
&
context
,
Symbol
*
symbol
,
const
GenTemplateInstance
::
Substitution
&
substitution
)
:
context
(
context
),
symbol
(
symbol
),
substitution
(
substitution
),
applyToType
(
this
),
applyToName
(
this
)
{
}
ApplySubstitution
::~
ApplySubstitution
()
{
}
FullySpecifiedType
ApplySubstitution
::
operator
()(
Name
*
name
)
{
return
applyToName
(
name
);
}
FullySpecifiedType
ApplySubstitution
::
apply
(
Name
*
name
)
{
FullySpecifiedType
ty
=
applyToName
(
name
);
return
ty
;
}
FullySpecifiedType
ApplySubstitution
::
operator
()(
const
FullySpecifiedType
&
type
)
{
return
applyToType
(
type
);
}
FullySpecifiedType
ApplySubstitution
::
apply
(
const
FullySpecifiedType
&
type
)
{
FullySpecifiedType
ty
=
applyToType
(
type
);
return
ty
;
}
int
ApplySubstitution
::
findSubstitution
(
Identifier
*
id
)
const
{
...
...
@@ -360,8 +369,8 @@ GenTemplateInstance::GenTemplateInstance(const LookupContext &context, const Sub
FullySpecifiedType
GenTemplateInstance
::
operator
()(
Symbol
*
symbol
)
{
ApplySubstitution
o
(
_context
,
_substitution
);
return
o
(
symbol
->
type
());
ApplySubstitution
o
(
_context
,
symbol
,
_substitution
);
return
o
.
apply
(
symbol
->
type
());
}
Control
*
GenTemplateInstance
::
control
()
const
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment