Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Scientific Software
Takin
mag-core
Commits
7cc8aedc
Verified
Commit
7cc8aedc
authored
Oct 30, 2020
by
Tobias WEBER
Browse files
small bugfixes
parent
cb5d54c1
Changes
2
Hide whitespace changes
Inline
Side-by-side
tools/scanbrowser/cli/ast.cpp
View file @
7cc8aedc
...
...
@@ -41,7 +41,7 @@ std::shared_ptr<Symbol> CliASTString::Eval(CliParserContext&) const
/**
* recursively evaluate a list and collect symbols into a vector
*/
static
std
::
vector
<
std
::
shared_ptr
<
Symbol
>>
static
std
::
vector
<
std
::
shared_ptr
<
Symbol
>>
list_eval
(
CliParserContext
&
ctx
,
std
::
shared_ptr
<
CliAST
>
left
,
std
::
shared_ptr
<
CliAST
>
right
)
{
std
::
vector
<
std
::
shared_ptr
<
Symbol
>>
vec
;
...
...
@@ -149,7 +149,7 @@ std::shared_ptr<Symbol> CliASTArrayAccess::Eval(CliParserContext& ctx) const
}
else
{
ctx
.
PrintError
(
"Variables of type "
,
Symbol
::
get_type_name
(
*
lefteval
),
ctx
.
PrintError
(
"Variables of type "
,
Symbol
::
get_type_name
(
*
lefteval
),
" do not support element access."
);
return
nullptr
;
}
...
...
@@ -260,7 +260,7 @@ std::shared_ptr<Symbol> CliASTPlus::Eval(CliParserContext& ctx) const
{
if
(
!
m_left
||
!
m_right
)
return
nullptr
;
if
(
auto
lefteval
=
m_left
->
Eval
(
ctx
),
righteval
=
m_right
->
Eval
(
ctx
);
lefteval
&&
righteval
)
return
Symbol
::
add
(
*
lefteval
,
*
righteval
);
...
...
@@ -295,7 +295,7 @@ std::shared_ptr<Symbol> CliASTMult::Eval(CliParserContext& ctx) const
{
if
(
!
m_left
||
!
m_right
)
return
nullptr
;
if
(
auto
lefteval
=
m_left
->
Eval
(
ctx
),
righteval
=
m_right
->
Eval
(
ctx
);
lefteval
&&
righteval
)
return
Symbol
::
mul
(
*
lefteval
,
*
righteval
);
...
...
@@ -310,7 +310,7 @@ std::shared_ptr<Symbol> CliASTDiv::Eval(CliParserContext& ctx) const
{
if
(
!
m_left
||
!
m_right
)
return
nullptr
;
if
(
auto
lefteval
=
m_left
->
Eval
(
ctx
),
righteval
=
m_right
->
Eval
(
ctx
);
lefteval
&&
righteval
)
return
Symbol
::
div
(
*
lefteval
,
*
righteval
);
...
...
@@ -325,7 +325,7 @@ std::shared_ptr<Symbol> CliASTMod::Eval(CliParserContext& ctx) const
{
if
(
!
m_left
||
!
m_right
)
return
nullptr
;
if
(
auto
lefteval
=
m_left
->
Eval
(
ctx
),
righteval
=
m_right
->
Eval
(
ctx
);
lefteval
&&
righteval
)
return
Symbol
::
mod
(
*
lefteval
,
*
righteval
);
...
...
@@ -340,7 +340,7 @@ std::shared_ptr<Symbol> CliASTPow::Eval(CliParserContext& ctx) const
{
if
(
!
m_left
||
!
m_right
)
return
nullptr
;
if
(
auto
lefteval
=
m_left
->
Eval
(
ctx
),
righteval
=
m_right
->
Eval
(
ctx
);
lefteval
&&
righteval
)
return
Symbol
::
pow
(
*
lefteval
,
*
righteval
);
...
...
@@ -446,7 +446,7 @@ std::shared_ptr<Symbol> CliASTCall::Eval(CliParserContext& ctx) const
{
// general function
return
(
*
std
::
get
<
0
>
(
iter
->
second
))(
ctx
,
args
[
0
],
args
[
1
]);
}
else
if
(
auto
iter
=
g_funcs_real_2args
.
find
(
ident
);
else
if
(
auto
iter
=
g_funcs_real_2args
.
find
(
ident
);
iter
!=
g_funcs_real_2args
.
end
()
&&
args
[
0
]
->
GetType
()
==
SymbolType
::
REAL
&&
args
[
1
]
->
GetType
()
==
SymbolType
::
REAL
)
{
// real function
...
...
tools/scanbrowser/cli/cliparser.h
View file @
7cc8aedc
...
...
@@ -290,6 +290,7 @@ protected:
public:
CliAST
(
std
::
shared_ptr
<
CliAST
>
left
=
nullptr
,
std
::
shared_ptr
<
CliAST
>
right
=
nullptr
)
:
m_left
(
left
),
m_right
(
right
)
{}
virtual
~
CliAST
()
{}
void
SetLeft
(
std
::
shared_ptr
<
CliAST
>
left
)
{
m_left
=
left
;
}
void
SetRight
(
std
::
shared_ptr
<
CliAST
>
right
)
{
m_right
=
right
;
}
...
...
@@ -307,6 +308,7 @@ protected:
public:
CliASTReal
(
t_real_cli
val
)
:
m_val
(
val
)
{
}
virtual
~
CliASTReal
()
{}
virtual
void
Print
(
std
::
ostringstream
&
ostr
,
int
indent
=
0
)
const
override
;
virtual
std
::
shared_ptr
<
Symbol
>
Eval
(
CliParserContext
&
ctx
)
const
override
;
...
...
@@ -323,6 +325,7 @@ protected:
public:
CliASTString
(
const
std
::
string
&
val
)
:
m_val
(
val
)
{
}
virtual
~
CliASTString
()
{}
virtual
void
Print
(
std
::
ostringstream
&
ostr
,
int
indent
=
0
)
const
override
;
virtual
std
::
shared_ptr
<
Symbol
>
Eval
(
CliParserContext
&
ctx
)
const
override
;
...
...
@@ -339,6 +342,7 @@ protected:
public:
CliASTIdent
(
const
std
::
string
&
val
)
:
m_val
(
val
)
{
}
virtual
~
CliASTIdent
()
{}
virtual
void
Print
(
std
::
ostringstream
&
ostr
,
int
indent
=
0
)
const
override
;
virtual
std
::
shared_ptr
<
Symbol
>
Eval
(
CliParserContext
&
ctx
)
const
override
;
...
...
@@ -352,6 +356,7 @@ class CliASTAssign : public CliAST
{
public:
using
CliAST
::
CliAST
;
virtual
~
CliASTAssign
()
{}
virtual
void
Print
(
std
::
ostringstream
&
ostr
,
int
indent
=
0
)
const
override
;
virtual
std
::
shared_ptr
<
Symbol
>
Eval
(
CliParserContext
&
ctx
)
const
override
;
...
...
@@ -364,6 +369,7 @@ class CliASTPlus : public CliAST
{
public:
using
CliAST
::
CliAST
;
virtual
~
CliASTPlus
()
{}
virtual
void
Print
(
std
::
ostringstream
&
ostr
,
int
indent
=
0
)
const
override
;
virtual
std
::
shared_ptr
<
Symbol
>
Eval
(
CliParserContext
&
ctx
)
const
override
;
...
...
@@ -376,6 +382,7 @@ class CliASTMinus : public CliAST
{
public:
using
CliAST
::
CliAST
;
virtual
~
CliASTMinus
()
{}
virtual
void
Print
(
std
::
ostringstream
&
ostr
,
int
indent
=
0
)
const
override
;
virtual
std
::
shared_ptr
<
Symbol
>
Eval
(
CliParserContext
&
ctx
)
const
override
;
...
...
@@ -388,6 +395,7 @@ class CliASTMult : public CliAST
{
public:
using
CliAST
::
CliAST
;
virtual
~
CliASTMult
()
{}
virtual
void
Print
(
std
::
ostringstream
&
ostr
,
int
indent
=
0
)
const
override
;
virtual
std
::
shared_ptr
<
Symbol
>
Eval
(
CliParserContext
&
ctx
)
const
override
;
...
...
@@ -400,6 +408,7 @@ class CliASTDiv : public CliAST
{
public:
using
CliAST
::
CliAST
;
virtual
~
CliASTDiv
()
{}
virtual
void
Print
(
std
::
ostringstream
&
ostr
,
int
indent
=
0
)
const
override
;
virtual
std
::
shared_ptr
<
Symbol
>
Eval
(
CliParserContext
&
ctx
)
const
override
;
...
...
@@ -412,6 +421,7 @@ class CliASTMod : public CliAST
{
public:
using
CliAST
::
CliAST
;
virtual
~
CliASTMod
()
{}
virtual
void
Print
(
std
::
ostringstream
&
ostr
,
int
indent
=
0
)
const
override
;
virtual
std
::
shared_ptr
<
Symbol
>
Eval
(
CliParserContext
&
ctx
)
const
override
;
...
...
@@ -424,6 +434,7 @@ class CliASTPow : public CliAST
{
public:
using
CliAST
::
CliAST
;
virtual
~
CliASTPow
()
{}
virtual
void
Print
(
std
::
ostringstream
&
ostr
,
int
indent
=
0
)
const
override
;
virtual
std
::
shared_ptr
<
Symbol
>
Eval
(
CliParserContext
&
ctx
)
const
override
;
...
...
@@ -436,6 +447,7 @@ class CliASTCall : public CliAST
{
public:
using
CliAST
::
CliAST
;
virtual
~
CliASTCall
()
{}
virtual
void
Print
(
std
::
ostringstream
&
ostr
,
int
indent
=
0
)
const
override
;
virtual
std
::
shared_ptr
<
Symbol
>
Eval
(
CliParserContext
&
ctx
)
const
override
;
...
...
@@ -448,6 +460,7 @@ class CliASTExprList : public CliAST
{
public:
using
CliAST
::
CliAST
;
virtual
~
CliASTExprList
()
{}
virtual
void
Print
(
std
::
ostringstream
&
ostr
,
int
indent
=
0
)
const
override
;
virtual
std
::
shared_ptr
<
Symbol
>
Eval
(
CliParserContext
&
ctx
)
const
override
;
...
...
@@ -460,6 +473,7 @@ class CliASTArray : public CliAST
{
public:
using
CliAST
::
CliAST
;
virtual
~
CliASTArray
()
{}
virtual
void
Print
(
std
::
ostringstream
&
ostr
,
int
indent
=
0
)
const
override
;
virtual
std
::
shared_ptr
<
Symbol
>
Eval
(
CliParserContext
&
ctx
)
const
override
;
...
...
@@ -472,6 +486,7 @@ class CliASTArrayAccess : public CliAST
{
public:
using
CliAST
::
CliAST
;
virtual
~
CliASTArrayAccess
()
{}
virtual
void
Print
(
std
::
ostringstream
&
ostr
,
int
indent
=
0
)
const
override
;
virtual
std
::
shared_ptr
<
Symbol
>
Eval
(
CliParserContext
&
ctx
)
const
override
;
...
...
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