#include "WfAnalyzer.h"
namespace
{
namespace
{
namespace
{
using
namespace
collections
;
using
namespace
reflection
;
using
namespace
reflection
::
description
;
using
namespace
typeimpl
;
class
CheckCycleDependencyDeclarationVisitor
:
public
empty_visitor
::
,
public
empty_visitor
::
VirtualCseDeclarationVisitor
{
public
:
*
;
*
=
description
::
<
>();
*
=
description
::
<
>();
=
0
;
<
*,
*>
;
<
*,
*>
;
CheckCycleDependencyDeclarationVisitor
(
*
)
:manager(
)
{
}
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
{
FOREACH(Ptr<WfDeclaration>, decl, node->declarations)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
->
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
decl
);)
{
decl
(
this
);
}
}
void
(
*
)
override
{
auto
=
->
];
auto
=
->
].
();
if
(
==
1
)
{
.
(
td
,
);
}
else
if
(
==
2
)
{
=
td
->
();
for
(
=
0
;
i
<
count
;
i
++)
{
auto
=
td
->
(
i
)->
();
if
(
propType
->
() ==
::
)
{
auto
=
propType
->
();
if
(!
.
().
(
propTd
))
continue
;
if
(
td
==
propTd
)
{
<
*>
;
tds
.
(
td
);
->
.
(
::
StructRecursivelyIncludeItself
(
,
tds
));
}
else
if
(
propTd
->
() ==
::
)
{
if
(!
.
(
td
,
propTd
))
{
.
(
td
,
propTd
);
}
}
}
}
}
}
void
(
*
)
override
{
auto
=
->
];
auto
=
->
].
();
if
(
==
1
)
{
.
(
td
,
);
}
else
if
(
==
2
)
{
=
td
->
GetBaseTypeDescriptorCount
();
for
(
=
0
;
i
<
count
;
i
++)
{
auto
=
td
->
(
i
);
bool
=
baseTd
->
() ==
::
;
bool
=
baseTd
->
() ==
::
;
switch
(
->
)
{
case
::
:
{
if
(!
isClass
|| !
baseTd
->
())
{
if
(!
dynamic_cast
<
*>(
baseTd
) &&
baseTd
!=
)
{
->
.
(
::
(
,
baseTd
));
}
}
}
break
;
case
::
:
{
if
(!
isInterface
&&
baseTd
!=
)
{
->
.
(
::
(
,
baseTd
));
}
}
break
;
}
if
(!
.
().
(
baseTd
))
continue
;
if
(
baseTd
==
td
)
{
<
*>
;
tds
.
(
td
);
if
(
isClass
)
{
->
.
(
::
ClassRecursiveInheritance
(
,
tds
));
}
else
if
(
isInterface
)
{
->
.
(
::
InterfaceRecursiveInheritance
(
,
tds
));
}
}
else
if
(
baseTd
->
() ==
td
->
())
{
if
(!
.
(
td
,
baseTd
))
{
.
(
td
,
baseTd
);
}
}
}
}
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
(
this
);
}
}
void
(
)
{
=
;
FOREACH(Ptr<WfModule>, module, manager->GetModules())
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
->
());
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
module
);)
{
FOREACH(Ptr<WfDeclaration>, declaration, module->declarations)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
module
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
declaration
);)
{
declaration
(
this
);
}
}
}
void
()
{
(
1
);
}
void
ExecuteCollectDependencies
()
{
(
2
);
}
};
void
CheckScopes_DuplicatedBaseClass
(
*
,
*
,
*
)
{
<
*>
;
<
*>
;
baseTypes
.
(
);
for
(
=
0
;
i
<
baseTypes
.
();
i
++)
{
auto
=
baseTypes
i
];
=
currentTd
->
GetBaseTypeDescriptorCount
();
for
(
=
0
;
j
<
count
;
j
++)
{
auto
=
currentTd
->
(
j
);
if
(
baseTd
->
() ==
::
&&
baseTd
!=
description
::
<
>())
{
if
(
baseTypes
.
(
baseTd
))
{
if
(!
duplicatedTypes
.
(
baseTd
))
{
duplicatedTypes
.
(
baseTd
);
->
.
(
::
(
,
baseTd
));
}
}
else
{
baseTypes
.
(
baseTd
);
}
}
}
}
}
bool
CheckScopes_CycleDependency
(
*
)
{
=
->
.
();
CheckCycleDependencyDeclarationVisitor
(
);
visitor
.
();
visitor
.
ExecuteCollectDependencies
();
{
;
pop
.
(
visitor
.
.
(),
visitor
.
);
pop
.
();
for
(
=
0
;
i
<
pop
.
.
();
i
++)
{
auto
&
=
pop
.
i
];
if
(
component
.
>
1
)
{
<
*>
;
(
tds
,
(
component
.
,
component
.
+
component
.
)
.
([&](
)
{
return
visitor
.
.
()
nodeIndex
];
})
);
switch
(
tds
0
]->
())
{
case
::
:
->
.
(
::
StructRecursivelyIncludeItself
(
dynamic_cast
<
*>(
visitor
.
tds
0
]]),
tds
));
break
;
case
::
:
->
.
(
::
ClassRecursiveInheritance
(
dynamic_cast
<
*>(
visitor
.
tds
0
]]),
tds
));
break
;
case
::
:
->
.
(
::
InterfaceRecursiveInheritance
(
dynamic_cast
<
*>(
visitor
.
tds
0
]]),
tds
));
break
;
default
:;
}
}
}
}
if
(
errorCount
==
->
.
())
{
for
(
=
0
;
i
<
visitor
.
.
();
i
++)
{
auto
=
visitor
.
.
()
i
];
auto
=
dynamic_cast
<
*>(
visitor
.
.
()
i
]);
if
(
value
&&
value
->
==
::
)
{
CheckScopes_DuplicatedBaseClass
(
,
value
,
key
);
}
}
}
return
errorCount
==
->
.
();
}
}
}
}