Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Tobias Hunger
qt-creator
Commits
8f84f81e
Commit
8f84f81e
authored
Mar 31, 2009
by
Roberto Raggi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduced startOffset(), endOffset(), getPosition(), getStartPosition(), and getEndPosition().
parent
3b042476
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
0 deletions
+49
-0
src/shared/cplusplus/CheckDeclaration.cpp
src/shared/cplusplus/CheckDeclaration.cpp
+8
-0
src/shared/cplusplus/CheckSpecifier.cpp
src/shared/cplusplus/CheckSpecifier.cpp
+4
-0
src/shared/cplusplus/CheckStatement.cpp
src/shared/cplusplus/CheckStatement.cpp
+2
-0
src/shared/cplusplus/Symbol.cpp
src/shared/cplusplus/Symbol.cpp
+23
-0
src/shared/cplusplus/Symbol.h
src/shared/cplusplus/Symbol.h
+12
-0
No files found.
src/shared/cplusplus/CheckDeclaration.cpp
View file @
8f84f81e
...
...
@@ -55,6 +55,7 @@
#include "CoreTypes.h"
#include "Symbols.h"
#include "Control.h"
#include "Literals.h"
#include <cassert>
CPLUSPLUS_BEGIN_NAMESPACE
...
...
@@ -186,6 +187,9 @@ bool CheckDeclaration::visit(SimpleDeclarationAST *ast)
}
Declaration
*
symbol
=
control
()
->
newDeclaration
(
location
,
name
);
symbol
->
setStartOffset
(
tokenAt
(
ast
->
firstToken
()).
offset
);
symbol
->
setEndOffset
(
tokenAt
(
ast
->
lastToken
()).
offset
);
symbol
->
setType
(
control
()
->
integerType
(
IntegerType
::
Int
));
symbol
->
setType
(
declTy
);
...
...
@@ -259,6 +263,8 @@ bool CheckDeclaration::visit(FunctionDefinitionAST *ast)
}
Function
*
fun
=
funTy
->
asFunctionType
();
fun
->
setStartOffset
(
tokenAt
(
ast
->
firstToken
()).
offset
);
fun
->
setEndOffset
(
tokenAt
(
ast
->
lastToken
()).
offset
);
if
(
ast
->
declarator
)
fun
->
setSourceLocation
(
ast
->
declarator
->
firstToken
());
fun
->
setName
(
name
);
...
...
@@ -335,6 +341,8 @@ bool CheckDeclaration::visit(NamespaceAST *ast)
sourceLocation
=
ast
->
identifier_token
;
Namespace
*
ns
=
control
()
->
newNamespace
(
sourceLocation
,
namespaceName
);
ns
->
setStartOffset
(
tokenAt
(
ast
->
firstToken
()).
offset
);
ns
->
setEndOffset
(
tokenAt
(
ast
->
lastToken
()).
offset
);
ast
->
symbol
=
ns
;
_scope
->
enterSymbol
(
ns
);
semantic
()
->
check
(
ast
->
linkage_body
,
ns
->
members
());
// ### we'll do the merge later.
...
...
src/shared/cplusplus/CheckSpecifier.cpp
View file @
8f84f81e
...
...
@@ -303,6 +303,8 @@ bool CheckSpecifier::visit(ClassSpecifierAST *ast)
Name
*
className
=
semantic
()
->
check
(
ast
->
name
,
_scope
);
Class
*
klass
=
control
()
->
newClass
(
sourceLocation
,
className
);
klass
->
setStartOffset
(
tokenAt
(
ast
->
firstToken
()).
offset
);
klass
->
setEndOffset
(
tokenAt
(
ast
->
lastToken
()).
offset
);
ast
->
symbol
=
klass
;
unsigned
classKey
=
tokenKind
(
ast
->
classkey_token
);
if
(
classKey
==
T_CLASS
)
...
...
@@ -369,6 +371,8 @@ bool CheckSpecifier::visit(EnumSpecifierAST *ast)
Name
*
name
=
semantic
()
->
check
(
ast
->
name
,
_scope
);
Enum
*
e
=
control
()
->
newEnum
(
sourceLocation
,
name
);
e
->
setStartOffset
(
tokenAt
(
ast
->
firstToken
()).
offset
);
e
->
setEndOffset
(
tokenAt
(
ast
->
lastToken
()).
offset
);
e
->
setVisibility
(
semantic
()
->
currentVisibility
());
_scope
->
enterSymbol
(
e
);
_fullySpecifiedType
.
setType
(
e
);
...
...
src/shared/cplusplus/CheckStatement.cpp
View file @
8f84f81e
...
...
@@ -99,6 +99,8 @@ bool CheckStatement::visit(CaseStatementAST *ast)
bool
CheckStatement
::
visit
(
CompoundStatementAST
*
ast
)
{
Block
*
block
=
control
()
->
newBlock
(
ast
->
lbrace_token
);
block
->
setStartOffset
(
tokenAt
(
ast
->
firstToken
()).
offset
);
block
->
setEndOffset
(
tokenAt
(
ast
->
lastToken
()).
offset
);
ast
->
symbol
=
block
;
_scope
->
enterSymbol
(
block
);
Scope
*
previousScope
=
switchScope
(
block
->
members
());
...
...
src/shared/cplusplus/Symbol.cpp
View file @
8f84f81e
...
...
@@ -158,6 +158,8 @@ Symbol::Symbol(TranslationUnit *translationUnit, unsigned sourceLocation, Name *
:
_control
(
translationUnit
->
control
()),
_sourceLocation
(
sourceLocation
),
_sourceOffset
(
0
),
_startOffset
(
0
),
_endOffset
(
0
),
_name
(
0
),
_hashCode
(
0
),
_storage
(
Symbol
::
NoStorage
),
...
...
@@ -245,12 +247,33 @@ StringLiteral *Symbol::fileId() const
return
fileId
;
}
void
Symbol
::
getPosition
(
unsigned
*
line
,
unsigned
*
column
,
StringLiteral
**
fileId
)
{
translationUnit
()
->
getPosition
(
_sourceOffset
,
line
,
column
,
fileId
);
}
void
Symbol
::
getStartPosition
(
unsigned
*
line
,
unsigned
*
column
,
StringLiteral
**
fileId
)
{
translationUnit
()
->
getPosition
(
_startOffset
,
line
,
column
,
fileId
);
}
void
Symbol
::
getEndPosition
(
unsigned
*
line
,
unsigned
*
column
,
StringLiteral
**
fileId
)
{
translationUnit
()
->
getPosition
(
_endOffset
,
line
,
column
,
fileId
);
}
const
char
*
Symbol
::
fileName
()
const
{
return
fileId
()
->
chars
();
}
unsigned
Symbol
::
fileNameLength
()
const
{
return
fileId
()
->
size
();
}
unsigned
Symbol
::
startOffset
()
const
{
return
_startOffset
;
}
void
Symbol
::
setStartOffset
(
unsigned
offset
)
{
_startOffset
=
offset
;
}
unsigned
Symbol
::
endOffset
()
const
{
return
_endOffset
;
}
void
Symbol
::
setEndOffset
(
unsigned
offset
)
{
_endOffset
=
offset
;
}
Name
*
Symbol
::
identity
()
const
{
IdentityForName
id
;
...
...
src/shared/cplusplus/Symbol.h
View file @
8f84f81e
...
...
@@ -109,6 +109,16 @@ public:
/// Returns this Symbol's file name length.
unsigned
fileNameLength
()
const
;
unsigned
startOffset
()
const
;
void
setStartOffset
(
unsigned
offset
);
unsigned
endOffset
()
const
;
void
setEndOffset
(
unsigned
offset
);
void
getPosition
(
unsigned
*
line
,
unsigned
*
column
=
0
,
StringLiteral
**
fileId
=
0
);
void
getStartPosition
(
unsigned
*
line
,
unsigned
*
column
=
0
,
StringLiteral
**
fileId
=
0
);
void
getEndPosition
(
unsigned
*
line
,
unsigned
*
column
=
0
,
StringLiteral
**
fileId
=
0
);
/// Returns this Symbol's name.
Name
*
name
()
const
;
...
...
@@ -250,6 +260,8 @@ private:
Control
*
_control
;
unsigned
_sourceLocation
;
unsigned
_sourceOffset
;
unsigned
_startOffset
;
unsigned
_endOffset
;
Name
*
_name
;
unsigned
_hashCode
;
int
_storage
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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