Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
angle
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
angle
Commits
30a487c7
Commit
30a487c7
authored
May 02, 2012
by
alokp@chromium.org
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor refactoring for Input class. Chnaged a raw array to std::vector.
git-svn-id:
https://angleproject.googlecode.com/svn/trunk@1068
736b8ea6-26fd-11df-bfd4-992fa37f6226
parent
519c32ba
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
13 additions
and
23 deletions
+13
-23
Input.cpp
src/compiler/preprocessor/new/Input.cpp
+5
-12
Input.h
src/compiler/preprocessor/new/Input.h
+2
-5
Lexer.cpp
src/compiler/preprocessor/new/Lexer.cpp
+1
-1
Lexer.h
src/compiler/preprocessor/new/Lexer.h
+1
-1
pp.l
src/compiler/preprocessor/new/pp.l
+2
-2
pp_lex.cpp
src/compiler/preprocessor/new/pp_lex.cpp
+2
-2
No files found.
src/compiler/preprocessor/new/Input.cpp
View file @
30a487c7
...
@@ -12,30 +12,23 @@
...
@@ -12,30 +12,23 @@
namespace
pp
namespace
pp
{
{
Input
::
Input
()
:
mCount
(
0
),
mString
(
0
)
,
mLength
(
0
)
Input
::
Input
()
:
mCount
(
0
),
mString
(
0
)
{
{
}
}
Input
::
Input
(
int
count
,
const
char
*
const
string
[],
const
int
length
[])
:
Input
::
Input
(
int
count
,
const
char
*
const
string
[],
const
int
length
[])
:
mCount
(
count
),
mCount
(
count
),
mString
(
string
),
mString
(
string
)
mLength
(
0
)
{
{
assert
(
mCount
>=
0
);
assert
(
mCount
>=
0
);
mLength
=
mCount
>
0
?
new
int
[
mCount
]
:
0
;
mLength
.
reserve
(
mCount
)
;
for
(
int
i
=
0
;
i
<
mCount
;
++
i
)
for
(
int
i
=
0
;
i
<
mCount
;
++
i
)
{
{
mLength
[
i
]
=
length
?
length
[
i
]
:
-
1
;
int
len
=
length
?
length
[
i
]
:
-
1
;
if
(
mLength
[
i
]
<
0
)
mLength
.
push_back
(
len
<
0
?
strlen
(
mString
[
i
])
:
len
);
mLength
[
i
]
=
strlen
(
mString
[
i
]);
}
}
}
}
Input
::~
Input
()
{
if
(
mLength
)
delete
[]
mLength
;
}
int
Input
::
read
(
char
*
buf
,
int
maxSize
)
int
Input
::
read
(
char
*
buf
,
int
maxSize
)
{
{
int
nRead
=
0
;
int
nRead
=
0
;
...
...
src/compiler/preprocessor/new/Input.h
View file @
30a487c7
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
#ifndef COMPILER_PREPROCESSOR_INPUT_H_
#ifndef COMPILER_PREPROCESSOR_INPUT_H_
#define COMPILER_PREPROCESSOR_INPUT_H_
#define COMPILER_PREPROCESSOR_INPUT_H_
#include
"pp_utils.h"
#include
<vector>
namespace
pp
namespace
pp
{
{
...
@@ -18,7 +18,6 @@ class Input
...
@@ -18,7 +18,6 @@ class Input
public
:
public
:
Input
();
Input
();
Input
(
int
count
,
const
char
*
const
string
[],
const
int
length
[]);
Input
(
int
count
,
const
char
*
const
string
[],
const
int
length
[]);
~
Input
();
int
count
()
const
{
return
mCount
;
}
int
count
()
const
{
return
mCount
;
}
const
char
*
string
(
int
index
)
const
{
return
mString
[
index
];
}
const
char
*
string
(
int
index
)
const
{
return
mString
[
index
];
}
...
@@ -36,12 +35,10 @@ class Input
...
@@ -36,12 +35,10 @@ class Input
const
Location
&
readLoc
()
const
{
return
mReadLoc
;
}
const
Location
&
readLoc
()
const
{
return
mReadLoc
;
}
private
:
private
:
PP_DISALLOW_COPY_AND_ASSIGN
(
Input
);
// Input.
// Input.
int
mCount
;
int
mCount
;
const
char
*
const
*
mString
;
const
char
*
const
*
mString
;
int
*
mLength
;
std
::
vector
<
int
>
mLength
;
Location
mReadLoc
;
Location
mReadLoc
;
};
};
...
...
src/compiler/preprocessor/new/Lexer.cpp
View file @
30a487c7
...
@@ -25,7 +25,7 @@ bool Lexer::init(int count, const char* const string[], const int length[])
...
@@ -25,7 +25,7 @@ bool Lexer::init(int count, const char* const string[], const int length[])
if
(
count
<
0
)
return
false
;
if
(
count
<
0
)
return
false
;
if
((
count
>
0
)
&&
(
string
==
0
))
return
false
;
if
((
count
>
0
)
&&
(
string
==
0
))
return
false
;
mContext
.
input
.
reset
(
new
Input
(
count
,
string
,
length
)
);
mContext
.
input
=
Input
(
count
,
string
,
length
);
return
initLexer
();
return
initLexer
();
}
}
...
...
src/compiler/preprocessor/new/Lexer.h
View file @
30a487c7
...
@@ -22,7 +22,7 @@ class Lexer
...
@@ -22,7 +22,7 @@ class Lexer
public
:
public
:
struct
Context
struct
Context
{
{
std
::
auto_ptr
<
Input
>
input
;
Input
input
;
// The location where yytext points to. Token location should track
// The location where yytext points to. Token location should track
// scanLoc instead of Input::mReadLoc because they may not be the same
// scanLoc instead of Input::mReadLoc because they may not be the same
// if text is buffered up in the lexer input buffer.
// if text is buffered up in the lexer input buffer.
...
...
src/compiler/preprocessor/new/pp.l
View file @
30a487c7
...
@@ -40,7 +40,7 @@ typedef pp::Token::Location YYLTYPE;
...
@@ -40,7 +40,7 @@ typedef pp::Token::Location YYLTYPE;
#define YY_USER_ACTION \
#define YY_USER_ACTION \
do { \
do { \
pp::Input* input =
yyextra->input.get();
\
pp::Input* input =
&yyextra->input;
\
pp::Input::Location* scanLoc = &yyextra->scanLoc; \
pp::Input::Location* scanLoc = &yyextra->scanLoc; \
while (scanLoc->cIndex >= input->length(scanLoc->sIndex)) \
while (scanLoc->cIndex >= input->length(scanLoc->sIndex)) \
{ \
{ \
...
@@ -53,7 +53,7 @@ typedef pp::Token::Location YYLTYPE;
...
@@ -53,7 +53,7 @@ typedef pp::Token::Location YYLTYPE;
} while(0);
} while(0);
#define YY_INPUT(buf, result, maxSize) \
#define YY_INPUT(buf, result, maxSize) \
result = yyextra->input
->
read(buf, maxSize);
result = yyextra->input
.
read(buf, maxSize);
%}
%}
...
...
src/compiler/preprocessor/new/pp_lex.cpp
View file @
30a487c7
...
@@ -531,7 +531,7 @@ typedef pp::Token::Location YYLTYPE;
...
@@ -531,7 +531,7 @@ typedef pp::Token::Location YYLTYPE;
#define YY_USER_ACTION \
#define YY_USER_ACTION \
do { \
do { \
pp::Input* input =
yyextra->input.get();
\
pp::Input* input =
&yyextra->input;
\
pp::Input::Location* scanLoc = &yyextra->scanLoc; \
pp::Input::Location* scanLoc = &yyextra->scanLoc; \
while (scanLoc->cIndex >= input->length(scanLoc->sIndex)) \
while (scanLoc->cIndex >= input->length(scanLoc->sIndex)) \
{ \
{ \
...
@@ -544,7 +544,7 @@ typedef pp::Token::Location YYLTYPE;
...
@@ -544,7 +544,7 @@ typedef pp::Token::Location YYLTYPE;
} while(0);
} while(0);
#define YY_INPUT(buf, result, maxSize) \
#define YY_INPUT(buf, result, maxSize) \
result = yyextra->input
->
read(buf, maxSize);
result = yyextra->input
.
read(buf, maxSize);
#define INITIAL 0
#define INITIAL 0
#define COMMENT 1
#define COMMENT 1
...
...
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