Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
preprocessor
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Willi Mutschler
preprocessor
Commits
4213c42b
Commit
4213c42b
authored
7 years ago
by
Houtan Bastani
Browse files
Options
Downloads
Patches
Plain Diff
preprocessor: factorize code that checks for valid symb_id
parent
7c884bca
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
SymbolTable.cc
+5
-10
5 additions, 10 deletions
SymbolTable.cc
SymbolTable.hh
+18
-18
18 additions, 18 deletions
SymbolTable.hh
with
23 additions
and
28 deletions
SymbolTable.cc
+
5
−
10
View file @
4213c42b
...
@@ -156,8 +156,7 @@ SymbolTable::changeType(int id, SymbolType newtype) throw (UnknownSymbolIDExcept
...
@@ -156,8 +156,7 @@ SymbolTable::changeType(int id, SymbolType newtype) throw (UnknownSymbolIDExcept
if
(
frozen
)
if
(
frozen
)
throw
FrozenException
();
throw
FrozenException
();
if
(
id
<
0
||
id
>
symbol_table
.
size
())
validateSymbID
(
id
);
throw
UnknownSymbolIDException
(
id
);
type_table
[
id
]
=
newtype
;
type_table
[
id
]
=
newtype
;
}
}
...
@@ -732,8 +731,8 @@ SymbolTable::getAuxiliaryVarsExprNode(int symb_id) const throw (SearchFailedExce
...
@@ -732,8 +731,8 @@ SymbolTable::getAuxiliaryVarsExprNode(int symb_id) const throw (SearchFailedExce
void
void
SymbolTable
::
markPredetermined
(
int
symb_id
)
throw
(
UnknownSymbolIDException
,
FrozenException
)
SymbolTable
::
markPredetermined
(
int
symb_id
)
throw
(
UnknownSymbolIDException
,
FrozenException
)
{
{
if
(
symb_id
<
0
||
symb_id
>
symbol_table
.
size
())
validateSymbID
(
symb_id
);
throw
UnknownSymbolIDException
(
symb_id
);
if
(
frozen
)
if
(
frozen
)
throw
FrozenException
();
throw
FrozenException
();
...
@@ -745,9 +744,7 @@ SymbolTable::markPredetermined(int symb_id) throw (UnknownSymbolIDException, Fro
...
@@ -745,9 +744,7 @@ SymbolTable::markPredetermined(int symb_id) throw (UnknownSymbolIDException, Fro
bool
bool
SymbolTable
::
isPredetermined
(
int
symb_id
)
const
throw
(
UnknownSymbolIDException
)
SymbolTable
::
isPredetermined
(
int
symb_id
)
const
throw
(
UnknownSymbolIDException
)
{
{
if
(
symb_id
<
0
||
symb_id
>
symbol_table
.
size
())
validateSymbID
(
symb_id
);
throw
UnknownSymbolIDException
(
symb_id
);
return
(
predetermined_variables
.
find
(
symb_id
)
!=
predetermined_variables
.
end
());
return
(
predetermined_variables
.
find
(
symb_id
)
!=
predetermined_variables
.
end
());
}
}
...
@@ -760,9 +757,7 @@ SymbolTable::predeterminedNbr() const
...
@@ -760,9 +757,7 @@ SymbolTable::predeterminedNbr() const
void
void
SymbolTable
::
addObservedVariable
(
int
symb_id
)
throw
(
UnknownSymbolIDException
)
SymbolTable
::
addObservedVariable
(
int
symb_id
)
throw
(
UnknownSymbolIDException
)
{
{
if
(
symb_id
<
0
||
symb_id
>
symbol_table
.
size
())
validateSymbID
(
symb_id
);
throw
UnknownSymbolIDException
(
symb_id
);
assert
(
getType
(
symb_id
)
==
eEndogenous
);
assert
(
getType
(
symb_id
)
==
eEndogenous
);
varobs
.
push_back
(
symb_id
);
varobs
.
push_back
(
symb_id
);
}
}
...
...
This diff is collapsed.
Click to expand it.
SymbolTable.hh
+
18
−
18
View file @
4213c42b
...
@@ -219,6 +219,8 @@ private:
...
@@ -219,6 +219,8 @@ private:
int
addLeadAuxiliaryVarInternal
(
bool
endo
,
int
index
,
expr_t
arg
)
throw
(
FrozenException
);
int
addLeadAuxiliaryVarInternal
(
bool
endo
,
int
index
,
expr_t
arg
)
throw
(
FrozenException
);
//! Factorized code for Json writing
//! Factorized code for Json writing
void
writeJsonVarVector
(
ostream
&
output
,
const
vector
<
int
>
&
varvec
)
const
;
void
writeJsonVarVector
(
ostream
&
output
,
const
vector
<
int
>
&
varvec
)
const
;
//! Factorized code for asserting that 0 <= symb_id <= symbol_table.size()
inline
void
validateSymbID
(
int
symb_id
)
const
throw
(
UnknownSymbolIDException
);
public
:
public
:
//! Add a symbol
//! Add a symbol
/*! Returns the symbol ID */
/*! Returns the symbol ID */
...
@@ -362,6 +364,13 @@ public:
...
@@ -362,6 +364,13 @@ public:
set
<
int
>
getOrigEndogenous
()
const
;
set
<
int
>
getOrigEndogenous
()
const
;
};
};
inline
void
SymbolTable
::
validateSymbID
(
int
symb_id
)
const
throw
(
UnknownSymbolIDException
)
{
if
(
symb_id
<
0
||
symb_id
>
symbol_table
.
size
())
throw
UnknownSymbolIDException
(
symb_id
);
}
inline
bool
inline
bool
SymbolTable
::
exists
(
const
string
&
name
)
const
SymbolTable
::
exists
(
const
string
&
name
)
const
{
{
...
@@ -372,36 +381,28 @@ SymbolTable::exists(const string &name) const
...
@@ -372,36 +381,28 @@ SymbolTable::exists(const string &name) const
inline
string
inline
string
SymbolTable
::
getName
(
int
id
)
const
throw
(
UnknownSymbolIDException
)
SymbolTable
::
getName
(
int
id
)
const
throw
(
UnknownSymbolIDException
)
{
{
if
(
id
<
0
||
id
>
symbol_table
.
size
())
validateSymbID
(
id
);
throw
UnknownSymbolIDException
(
id
);
else
return
name_table
[
id
];
return
name_table
[
id
];
}
}
inline
string
inline
string
SymbolTable
::
getTeXName
(
int
id
)
const
throw
(
UnknownSymbolIDException
)
SymbolTable
::
getTeXName
(
int
id
)
const
throw
(
UnknownSymbolIDException
)
{
{
if
(
id
<
0
||
id
>
symbol_table
.
size
())
validateSymbID
(
id
);
throw
UnknownSymbolIDException
(
id
);
else
return
tex_name_table
[
id
];
return
tex_name_table
[
id
];
}
}
inline
string
inline
string
SymbolTable
::
getLongName
(
int
id
)
const
throw
(
UnknownSymbolIDException
)
SymbolTable
::
getLongName
(
int
id
)
const
throw
(
UnknownSymbolIDException
)
{
{
if
(
id
<
0
||
id
>
symbol_table
.
size
())
validateSymbID
(
id
);
throw
UnknownSymbolIDException
(
id
);
else
return
long_name_table
[
id
];
return
long_name_table
[
id
];
}
}
inline
SymbolType
inline
SymbolType
SymbolTable
::
getType
(
int
id
)
const
throw
(
UnknownSymbolIDException
)
SymbolTable
::
getType
(
int
id
)
const
throw
(
UnknownSymbolIDException
)
{
{
if
(
id
<
0
||
id
>
symbol_table
.
size
())
validateSymbID
(
id
);
throw
UnknownSymbolIDException
(
id
);
else
return
type_table
[
id
];
return
type_table
[
id
];
}
}
...
@@ -427,8 +428,7 @@ SymbolTable::getTypeSpecificID(int id) const throw (UnknownSymbolIDException, No
...
@@ -427,8 +428,7 @@ SymbolTable::getTypeSpecificID(int id) const throw (UnknownSymbolIDException, No
if
(
!
frozen
)
if
(
!
frozen
)
throw
NotYetFrozenException
();
throw
NotYetFrozenException
();
if
(
id
<
0
||
id
>
symbol_table
.
size
())
validateSymbID
(
id
);
throw
UnknownSymbolIDException
(
id
);
return
type_specific_ids
[
id
];
return
type_specific_ids
[
id
];
}
}
...
...
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