#include "WfAnalyzer.h"
namespace
{
namespace
{
namespace
{
using
namespace
collections
;
using
namespace
parsing
;
using
namespace
reflection
::
description
;
class
ValidateStructureDeclarationVisitor
:
public
,
public
::
,
public
::
,
public
::
{
public
:
*
;
*
;
*
;
ValidateStructureDeclarationVisitor
(
*
,
*
,
*
)
:manager(
)
, classDecl(
)
, surroundingLambda(
)
{
}
void
(
*
)
override
{
if
(
dynamic_cast
<
*>(
))
{
->
.
(
::
WrongDeclarationInInterfaceConstructor
(
));
}
if
(
->
)
{
->
.
(
::
(
));
}
for
(
=
0
;
i
<
->
.
();
i
++)
{
ValidateDeclarationStructure
(
,
->
i
]);
}
}
void
(
*
)
override
{
if
(
&&
->
)
{
switch
(
->
)
{
case
::
:
{
switch
(
->
)
{
case
::
:
case
::
:
if
(!
->
)
{
->
.
(
::
FunctionShouldHaveImplementation
(
));
}
break
;
case
::
:
->
.
(
::
OverrideShouldImplementInterfaceMethod
(
));
break
;
}
}
break
;
case
::
:
{
switch
(
->
)
{
case
::
:
if
(
->
)
{
->
.
(
::
InterfaceMethodShouldNotHaveImplementation
(
));
}
break
;
case
::
:
if
(!
->
)
{
->
.
(
::
FunctionShouldHaveImplementation
(
));
}
break
;
case
::
:
->
.
(
::
OverrideShouldImplementInterfaceMethod
(
));
break
;
}
}
break
;
}
}
else
{
if
(
dynamic_cast
<
*>(
))
{
switch
(
->
)
{
case
::
:
break
;
case
::
:
->
.
(
::
FunctionInNewTypeExpressionCannotBeStatic
(
));
break
;
case
::
:
break
;
}
}
if
(!
->
)
{
->
.
(
::
FunctionShouldHaveImplementation
(
));
}
}
if
(
->
==
::
)
{
if
(!
dynamic_cast
<
*>(
))
{
->
.
(
::
(
));
}
}
(
,
->
,
::
);
FOREACH(Ptr<WfFunctionArgument>, argument, node->arguments)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
->
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
argument
);)
{
(
,
argument
);
}
if
(
->
)
{
;
ValidateStatementStructure
(
, &
context
,
->
);
}
}
void
(
*
)
override
{
if
(
&&
->
)
{
switch
(
->
)
{
case
::
:
break
;
case
::
:
case
::
:
->
.
(
::
(
));
break
;
}
}
if
(
->
)
{
(
,
->
);
}
else
if
(
)
{
->
.
(
::
(
));
}
;
ValidateExpressionStructure
(
, &
context
,
->
);
}
void
(
*
)
override
{
if
(
&&
->
)
{
switch
(
->
)
{
case
::
:
break
;
case
::
:
case
::
:
->
.
(
::
(
));
break
;
}
FOREACH(Ptr<WfType>, argument, node->arguments)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
->
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
argument
);)
{
(
,
argument
);
}
}
else
if
(
dynamic_cast
<
*>(
))
{
->
.
(
::
WrongDeclarationInInterfaceConstructor
(
));
}
else
{
->
.
(
::
(
));
}
}
class
:
public
empty_visitor
::
,
public
empty_visitor
::
VirtualCseDeclarationVisitor
{
public
:
*
;
*
;
*
;
<
>
;
<
>
;
<
>
;
bool
=
false
;
bool
=
false
;
bool
=
false
;
(
*
,
*
,
*
)
:manager(
)
, classDecl(
)
, propDecl(
)
{
}
void
(
*
)
override
{
FOREACH(Ptr<WfDeclaration>, decl, node->expandedDeclarations)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
->
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
decl
);)
{
(
decl
);
}
}
void
(
*
)
override
{
->
((
::
*)
this
);
}
void
(
<
>
)
{
(
this
);
if
(!
&&
.
==
->
.
)
{
if
(
)
{
=
true
;
->
.
(
::
(
,
));
}
else
{
;
}
}
if
(!
&&
->
.
!=
L""
&&
.
==
->
.
)
{
if
(
)
{
=
true
;
->
.
(
::
(
,
));
}
else
{
;
}
}
if
(!
&&
->
.
!=
L""
&&
.
==
->
.
)
{
if
(
)
{
=
true
;
->
.
(
::
(
,
));
}
else
{
;
}
}
}
};
void
(
*
)
override
{
if
(
&&
->
)
{
switch
(
->
)
{
case
::
:
break
;
case
::
:
case
::
:
->
.
(
::
(
));
break
;
}
(
,
->
);
FindPropertyRelatedDeclVisitor
(
,
,
);
FOREACH(Ptr<WfDeclaration>, memberDecl, classDecl->declarations)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
->
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
memberDecl
);)
{
visitor
.
(
memberDecl
);
}
if
(!
visitor
.
||
visitor
.
==
::
|| !
visitor
.
.
<
>())
{
->
.
(
::
(
,
));
}
if
(
->
.
!=
L""
&& (!
visitor
.
||
visitor
.
==
::
|| !
visitor
.
.
<
>()))
{
->
.
(
::
(
,
));
}
if
(
->
.
!=
L""
&& (!
visitor
.
||
visitor
.
==
::
|| !
visitor
.
.
<
>()))
{
->
.
(
::
(
,
));
}
}
else
if
(
dynamic_cast
<
*>(
))
{
->
.
(
::
WrongDeclarationInInterfaceConstructor
(
));
}
else
{
->
.
(
::
(
));
}
}
void
(
*
)
override
{
if
(
&&
->
)
{
switch
(
->
)
{
case
::
:
break
;
case
::
:
case
::
:
->
.
(
::
(
));
break
;
}
if
(
->
!=
::
)
{
->
.
(
::
(
));
}
FOREACH(Ptr<WfBaseConstructorCall>, call, node->baseConstructorCalls)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
->
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
call
);)
{
(
,
call
,
::
,
);
FOREACH(Ptr<WfExpression>, argument, call->arguments)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
call
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
argument
);)
{
;
ValidateExpressionStructure
(
, &
context
,
argument
);
}
}
{
;
ValidateStatementStructure
(
, &
context
,
->
);
}
}
else
{
->
.
(
::
(
));
}
}
void
(
*
)
override
{
if
(
&&
->
)
{
switch
(
->
)
{
case
::
:
break
;
case
::
:
case
::
:
->
.
(
::
(
));
break
;
}
if
(
->
!=
::
)
{
->
.
(
::
(
));
}
;
ValidateStatementStructure
(
, &
context
,
->
);
}
else
{
->
.
(
::
(
));
}
}
class
:
public
empty_visitor
::
,
public
empty_visitor
::
VirtualCseDeclarationVisitor
{
public
:
*
=
nullptr
;
void
(
*
)
override
{
FOREACH(Ptr<WfDeclaration>, decl, node->expandedDeclarations)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
->
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
decl
);)
{
decl
(
this
);
}
}
void
(
*
)
override
{
->
((
::
*)
this
);
}
void
(
*
)
override
{
=
;
}
};
class
:
public
empty_visitor
::
,
public
empty_visitor
::
VirtualCseDeclarationVisitor
{
public
:
*
;
*
;
*
=
nullptr
;
(
*
,
*
)
:manager(
)
, classDecl(
)
{
}
void
(
*
)
override
{
FOREACH(Ptr<WfDeclaration>, decl, node->expandedDeclarations)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
->
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
decl
);)
{
decl
(
this
);
}
}
void
(
*
)
override
{
->
((
::
*)
this
);
}
void
(
*
)
override
{
if
(!
)
{
=
;
}
else
{
->
.
(
::
(
,
));
}
}
};
void
(
*
)
override
{
if
(
&&
->
)
{
switch
(
->
)
{
case
::
:
break
;
case
::
:
case
::
:
->
.
(
::
(
));
break
;
}
}
else
if
(
dynamic_cast
<
*>(
))
{
->
.
(
::
WrongDeclarationInInterfaceConstructor
(
));
}
switch
(
->
)
{
case
::
:
{
if
(
->
!=
::
)
{
->
.
(
::
ClassWithInterfaceConstructor
(
));
}
{
;
FOREACH(Ptr<WfDeclaration>, memberDecl, node->declarations)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
->
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
memberDecl
);)
{
memberDecl
(&
visitor
);
}
if
(!
visitor
.
)
{
auto
=
<
>();
->
.
(
ctor
);
ctor
->
;
ctor
<
>();
ctor
->
;
ctor
=
::
;
ctor
=
::
;
auto
=
<
>();
ctor
stat
;
stat
->
;
}
}
}
break
;
case
::
:
break
;
}
FOREACH(Ptr<WfType>, type, node->baseTypes)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
->
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
type
);)
{
(
,
type
,
::
,
);
}
{
(
,
);
bool
=
false
;
FOREACH(Ptr<WfDeclaration>, memberDecl, node->declarations)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
->
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
memberDecl
);)
{
if
(
auto
=
memberDecl
.
<
WfStateMachineDeclaration
>())
{
if
(!
hasStateMachine
)
{
hasStateMachine
=
true
;
}
else
{
->
.
(
::
(
smDecl
.
()));
}
}
ValidateDeclarationStructure
(
,
memberDecl
,
);
memberDecl
(&
visitor
);
}
}
}
void
(
*
)
override
{
if
(
&&
->
)
{
switch
(
->
)
{
case
::
:
break
;
case
::
:
case
::
:
->
.
(
::
(
));
break
;
}
}
else
if
(
dynamic_cast
<
*>(
))
{
->
.
(
::
WrongDeclarationInInterfaceConstructor
(
));
}
=
0
;
bool
=
false
;
<
>
;
FOREACH(Ptr<WfEnumItem>, item, node->items)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
->
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
item
);)
{
switch
(
item
)
{
case
::
:
{
= -
1
;
TypedValueSerializerProvider
<
>::
(
item
.
,
value
);
if
(!
reportedNotConsecutive
&&
value
!=
current
)
{
reportedNotConsecutive
=
true
;
switch
(
->
)
{
case
::
:
->
.
(
::
EnumValuesNotConsecutiveFromZero
(
));
break
;
case
::
:
->
.
(
::
FlagValuesNotConsecutiveFromZero
(
));
break
;
}
}
switch
(
->
)
{
case
::
:
current
++;
break
;
case
::
:
current
=
current
==
0
?
1
:
current
*
2
;
break
;
}
}
break
;
case
::
:
FOREACH(Ptr<WfEnumItemIntersection>, enumInt, item->intersections)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
item
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
enumInt
);)
{
if
(!
discoveredItems
.
(
enumInt
.
))
{
->
.
(
::
(
enumInt
.
(),
));
}
}
break
;
}
if
(
discoveredItems
.
(
item
.
))
{
->
.
(
::
(
item
.
(),
));
}
else
{
discoveredItems
.
(
item
.
);
}
}
}
void
(
*
)
override
{
if
(
&&
->
)
{
switch
(
->
)
{
case
::
:
break
;
case
::
:
case
::
:
->
.
(
::
(
));
break
;
}
}
else
if
(
dynamic_cast
<
*>(
))
{
->
.
(
::
WrongDeclarationInInterfaceConstructor
(
));
}
<
>
;
FOREACH(Ptr<WfStructMember>, member, node->members)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
->
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
member
);)
{
if
(
discoveredItems
.
(
member
.
))
{
->
.
(
::
(
member
.
(),
));
}
else
{
discoveredItems
.
(
member
.
);
}
}
}
void
(
*
)
override
{
->
(
static_cast
<
::
*>(
this
));
FOREACH(Ptr<WfDeclaration>, decl, node->expandedDeclarations)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
->
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
decl
);)
{
decl
(
this
);
}
}
void
(
WfAutoPropertyDeclaration
*
)
override
{
switch
(
->
)
{
case
::
:
if
(
dynamic_cast
<
*>(
))
{
->
.
(
::
AutoPropertyCannotBeNormalOutsideOfClass
(
));
}
break
;
case
::
:
->
.
(
::
AutoPropertyCannotBeStatic
(
));
break
;
case
::
:
if
(!
dynamic_cast
<
*>(
))
{
->
.
(
::
OverrideShouldImplementInterfaceMethod
(
));
}
break
;
}
if
(
)
{
switch
(
->
)
{
case
::
:
if
(!
->
)
{
->
.
(
::
AutoPropertyShouldBeInitialized
(
));
}
break
;
case
::
:
if
(
->
)
{
->
.
(
::
AutoPropertyCannotBeInitializedInInterface
(
,
));
}
break
;
}
}
else
if
(
dynamic_cast
<
*>(
))
{
if
(!
->
)
{
->
.
(
::
AutoPropertyShouldBeInitialized
(
));
}
}
else
{
->
.
(
::
(
));
}
(
,
->
);
if
(
->
)
{
;
ValidateExpressionStructure
(
, &
context
,
->
);
}
}
void
(
WfCastResultInterfaceDeclaration
*
)
override
{
}
void
(
*
)
override
{
->
(
static_cast
<
::
*>(
this
));
}
void
(
WfStateMachineDeclaration
*
)
override
{
if
(
)
{
FOREACH(Ptr<WfStateDeclaration>, state, node->states)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
->
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
state
);)
{
;
context
.
=
state
.
();
ValidateStatementStructure
(
, &
context
,
state
);
}
}
else
{
->
.
(
::
(
));
}
}
static
void
(
<
>
,
*
,
*
,
*
)
{
ValidateStructureDeclarationVisitor
(
,
,
);
(&
visitor
);
}
};
void
ValidateDeclarationStructure
(
*
,
<
>
,
*
,
*
)
{
ValidateStructureDeclarationVisitor
::
(
,
,
,
);
}
}
}
}