#include "WfAnalyzer.h"
namespace
{
namespace
{
namespace
{
using
namespace
collections
;
using
namespace
reflection
::
description
;
::
(
*
)
:ownerScope(
)
{
}
::
()
{
}
::
()
{
return
->
() +
L"::"
+
;
}
::
(
*
)
:ownerManager(
)
{
}
::
(
<
>
)
:ownerManager(
0
)
, parentScope(
)
{
}
::
()
{
}
*
::
()
{
*
=
this
;
while
(
scope
)
{
if
(
scope
->
)
{
return
scope
->
;
}
scope
=
scope
->
.
();
}
return
0
;
}
<
>
::
()
{
*
=
this
;
while
(
scope
)
{
if
(
auto
=
scope
->
.
<
>())
{
return
module
;
}
scope
=
scope
->
.
();
}
return
0
;
}
*
::
()
{
auto
=
this
;
while
(
scope
)
{
if
(
scope
->
)
{
return
scope
;
}
scope
=
scope
->
.
();
}
return
nullptr
;
}
::
()
{
if
(
auto
=
.
<
>())
{
return
L"<"
+
module
.
+
L">"
;
}
else
if
(
auto
=
.
<
>())
{
auto
=
decl
.
;
if
(
name
==
L""
)
{
name
=
L"<anonymous>"
;
}
return
() +
L"::"
+
name
;
}
else
if
(!
)
{
return
L""
;
}
else
{
return
() +
L"::<>"
;
}
}
<
>
::
()
{
if
(
auto
=
.
<
>())
{
return
decl
;
}
return
nullptr
;
}
::
(
bool
)
:imported(
)
{
}
::
()
{
}
<
>
::
(
const
&
,
bool
)
{
=
.
().
(
);
if
(
index
== -
1
)
{
<
>
=
new
(
);
newName
;
newName
=
this
;
.
(
,
newName
);
return
newName
;
}
else
{
return
.
()
index
];
}
}
void
::
RemoveNonTypeDescriptorNames
(
*
)
{
FOREACH(Ptr<WfLexicalScopeName>, name, children.Values())
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
.
());
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
name
);)
{
name
RemoveNonTypeDescriptorNames
(
);
}
for
(
=
.
() -
1
;
i
>=
0
;
i
--)
{
auto
=
.
()
i
];
if
(!
subScopeName
)
{
.
(
.
()
i
]);
if
(
subScopeName
)
{
->
.
(
subScopeName
);
}
}
}
.
();
}
::
()
{
if
(
)
{
=
->
();
if
(
parentName
==
L""
)
{
return
;
}
else
{
return
parentName
+
L"::"
+
;
}
}
else
{
return
L""
;
}
}
::
(
bool
)
const
{
,
;
if
(
)
{
typeName
= +
L" of type \""
+
() +
L"\""
;
}
if
(
)
{
result
();
}
else
if
(
)
{
result
=
() +
typeName
;
}
else
if
(
)
{
result
=
L"property \""
+
->
() +
L"\" in \""
+
->
()->
() +
L"\""
+
typeName
;
}
else
if
(
)
{
if
(
->
()
L""
)
{
result
=
L"constructor in \""
+
->
()->
() +
L"\""
+
typeName
;
}
else
{
result
=
L"method \""
+
->
() +
L"\" in \""
+
->
()->
() +
L"\""
+
typeName
;
}
}
else
if
(
)
{
result
=
L"event \""
+
->
() +
L"\" in \""
+
->
()->
() +
L"\""
;
}
else
if
(
)
{
result
=
L"expression"
+
typeName
;
}
else
{
result
=
L"<unknown>"
;
}
if
(
result
.
() >
0
&&
)
{
result = INVLOC.ToUpper(result.Left(1)) + result.Right(result.Length() - 1);
result
=
vl
::
::
().
(
result
.
(
1
)) +
result
.
(
result
.
() -
1
);
}
return
result
;
}
::
(
<
>
)
{
;
result
.
;
return
result
;
}
::
(
<
>
)
{
;
result
.
;
result
.
;
return
result
;
}
::
(
<
>
)
{
;
result
.
;
result
.
;
if
(
.
<
>())
{
result
.
;
}
return
result
;
}
::
(
<
reflection
::
description
::
>
)
{
;
result
.
;
return
result
;
}
::
(
<
reflection
::
description
::
>
)
{
;
result
.
;
result
.
;
return
result
;
}
::
(
reflection
::
description
::
*
)
{
<
>
=
(
->
());
<
>
;
if
(
getterType
)
{
if
(
*
=
->
())
{
setterType
getterType
;
if
(
setter
->
() ==
1
&& !
(
getterType
.
(),
setter
->
(
0
)->
()))
{
setterType
(
setter
->
(
0
)->
());
}
}
else
if
(
->
())
{
auto
=
->
();
if
((
td
->
()
::
) !=
::
)
{
setterType
(
->
());
}
}
}
;
result
.
=
;
result
.
getterType
;
result
.
setterType
;
return
result
;
}
::
(
reflection
::
description
::
*
)
{
;
result
.
=
;
result
.
CreateTypeInfoFromMethodInfo
(
);
return
result
;
}
::
(
reflection
::
description
::
*
)
{
;
result
.
=
;
result
.
(
->
());
return
result
;
}
::
(
reflection
::
description
::
*
)
{
;
result
.
=
;
return
result
;
}
bool
(
*
,
*
)
{
if
(
==
)
return
true
;
if
((
==
nullptr
) ^ (
==
nullptr
))
return
false
;
return
(
,
);
}
bool
::
(
const
&
)
const
{
if
(
.
)
return
false
;
if
(
.
)
return
false
;
if
(
!=
.
)
return
false
;
if
(
!=
.
)
return
false
;
if
(
!=
.
)
return
false
;
if
(
!=
.
)
return
false
;
if
(!
(
.
(),
.
.
()))
return
false
;
if
(!
(
.
(),
.
.
()))
return
false
;
if
(!
(
.
(),
.
.
()))
return
false
;
return
true
;
}
bool
::
(
const
&
)
const
{
return
!(*
this
);
}
::
(
<
parsing
::
tabling
::
>
)
:parsingTable(
)
{
.
({
L"cpp"
,
L"File"
},
<
>::
());
.
({
L"cpp"
,
L"UserImpl"
},
<
void
>::
());
.
({
L"cpp"
,
L"Private"
},
<
void
>::
());
.
({
L"cpp"
,
L"Protected"
},
<
void
>::
());
.
({
L"cpp"
,
L"Friend"
},
<
*>::
());
}
::
()
{
}
::
(
const
&
)
{
if
(
auto
=
(
,
,
,
))
{
.
(
module
);
.
(
);
}
return
++;
}
::
(
<
>
)
{
.
=
;
.
(
);
.
(
L""
);
return
++;
}
::
&
::
()
{
return
;
}
::
&
::
()
{
return
;
}
void
::
(
bool
,
bool
)
{
if
(
)
{
if
(
)
{
RemoveNonTypeDescriptorNames
(
this
);
}
else
{
0
;
.
();
}
}
if
(
)
{
.
();
.
();
=
0
;
}
=
0
;
.
();
.
();
.
();
checkedScopes_DuplicatedSymbol
.
();
.
();
.
();
.
();
.
();
.
();
.
();
baseConstructorCallResolvings
.
();
.
();
.
();
.
();
.
();
.
();
.
();
.
();
.
();
.
();
}
#define EXECUTE_CALLBACK(EXPR) if (callback) callback->EXPR
void
::
(
bool
,
*
)
{
EXECUTE_CALLBACK(OnLoadEnvironment());
(
,
false
);
if
(!
)
{
new
(
true
);
BuildGlobalNameFromTypeDescriptors
(
this
);
}
EXECUTE_CALLBACK(OnInitialize(this));
=
.
();
#define EXIT_IF_ERRORS_EXIST\
do\
{\
if (errors.Count() != errorCount) return;\
}while (0)
EXIT_IF_ERRORS_EXIST;
do
{
if
(
.
() !=
errorCount
)
return
; }
while
(
0
);
FOREACH(Ptr<WfModule>, module, modules)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
module
);)
{
(
this
,
module
);
(
this
,
module
);
}
EXIT_IF_ERRORS_EXIST;
do
{
if
(
.
() !=
errorCount
)
return
; }
while
(
0
);
BuildGlobalNameFromModules
(
this
);
FOREACH(Ptr<WfModule>, module, modules)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
module
);)
{
(
this
,
module
);
}
(
this
,
);
CheckScopes_DuplicatedSymbol
(
this
);
EXIT_IF_ERRORS_EXIST;
do
{
if
(
.
() !=
errorCount
)
return
; }
while
(
0
);
FOREACH(Ptr<WfModule>, module, modules)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
module
);)
{
(
this
,
module
);
}
(
this
);
CheckScopes_CycleDependency
(
this
);
EXIT_IF_ERRORS_EXIST;
do
{
if
(
.
() !=
errorCount
)
return
; }
while
(
0
);
FOREACH(Ptr<WfModule>, module, modules)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
module
);)
{
EXECUTE_CALLBACK(OnValidateModule(module));
(
this
,
module
);
}
#undef EXIT_IF_ERRORS_EXIST
}
#undef EXECUTE_CALLBACK
bool
::
(
*
,
const
&
,
bool
,
collections
::
<
*>&
,
collections
::
<
>&
)
{
if
(
.
(
))
{
return
true
;
}
.
(
);
bool
=
false
;
bool
=
false
;
if
((
->
()
::
) !=
::
)
{
if
(
)
{
auto
=
->
();
=
enumType
->
(
);
if
(
index
!= -
1
)
{
.
(
::
(
<
>(
,
::
)));
return
true
;
}
}
return
false
;
}
{
auto
=
];
=
scopeName
.
().
(
);
if
(
index
!= -
1
)
{
auto
=
scopeName
.
()
index
];
found
=
true
;
foundStaticMember
=
true
;
.
(
::
(
subScopeName
));
}
}
if
(
auto
=
->
(
,
false
))
{
for
(
=
0
;
i
<
group
->
();
i
++)
{
auto
=
group
->
(
i
);
if
(
info
->
())
{
found
=
true
;
foundStaticMember
=
true
;
.
(
::
(
info
));
}
}
}
if
(
foundStaticMember
&&
)
{
return
true
;
}
if
(
auto
=
->
(
,
false
))
{
for
(
=
0
;
i
<
group
->
();
i
++)
{
auto
=
group
->
(
i
);
if
(!
info
->
())
{
found
=
true
;
.
(
::
(
info
));
}
}
}
if
(
auto
=
->
(
,
false
))
{
found
=
true
;
.
(
::
(
info
));
}
if
(
auto
=
->
(
,
false
))
{
found
=
true
;
.
(
::
(
info
));
}
if
(!
found
)
{
=
->
GetBaseTypeDescriptorCount
();
for
(
=
0
;
i
<
count
;
i
++)
{
if
(
(
->
(
i
),
,
,
,
))
{
found
=
true
;
}
}
}
return
found
;
}
class
:
public
,
public
::
{
public
:
;
;
(
const
&
)
:name(
)
{
}
void
(
WfModuleUsingNameFragment
*
)
{
->
.
;
}
void
(
WfModuleUsingWildCardFragment
*
)
{
;
}
static
(
<
>
,
const
&
)
{
(
);
(&
visitor
);
return
visitor
.
;
}
};
bool
::
(
*
,
const
&
,
collections
::
<
>&
)
{
=
.
();
bool
=
false
;
*
=
nullptr
;
while
(
)
{
if
(
->
.
<
>() ||
->
.
<
>())
{
break
;
}
if
(
->
)
{
visibleToNonStatic
=
->
||
->
;
if
(!
firstConfigScope
)
{
firstConfigScope
=
;
}
}
=
->
.
().
(
);
if
(
index
!= -
1
)
{
if
(
->
)
{
if
(
->
.
<
>())
{
FOREACH(Ptr<WfLexicalSymbol>, symbol, scope->symbols.GetByIndex(index))
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
->
.
(
index
));
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
symbol
);)
{
if
(
symbol
.
<
>())
{
auto
=
::
(
symbol
);
if
(!
.
(
result
))
{
.
(
result
);
}
}
else
if
(
symbol
.
<
>()
==
::
)
{
if
(
firstConfigScope
->
)
{
auto
=
::
(
symbol
);
if
(!
.
(
result
))
{
.
(
result
);
}
}
}
}
}
}
else
{
FOREACH(Ptr<WfLexicalSymbol>, symbol, scope->symbols.GetByIndex(index))
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
->
.
(
index
));
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
symbol
);)
{
auto
=
::
(
symbol
);
if
(!
.
(
result
))
{
.
(
result
);
}
}
}
}
if
(
->
)
{
<
*>
;
(
->
,
, !
visibleToNonStatic
,
searchedTypes
,
);
}
=
->
.
();
}
while
(
)
{
if
(
auto
=
->
.
<
>())
{
auto
=
nsDecl
.
()];
=
scopeName
.
().
(
);
if
(
index
!= -
1
)
{
auto
=
scopeName
.
()
index
];
auto
=
::
(
subScopeName
);
if
(!
.
(
result
))
{
.
(
result
);
}
}
=
->
.
();
}
else
{
break
;
}
}
=
.
().
(
);
if
(
index
!= -
1
)
{
auto
=
.
()
index
];
auto
=
::
(
subScopeName
);
if
(!
.
(
result
))
{
.
(
result
);
}
}
if
(
auto
=
->
.
<
>())
{
FOREACH(Ptr<WfModuleUsingPath>, path, module->paths)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
module
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
path
);)
{
auto
=
;
FOREACH(Ptr<WfModuleUsingItem>, item, path->items)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
path
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
item
);)
{
;
FOREACH(Ptr<WfModuleUsingFragment>, fragment, item->fragments)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
item
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
fragment
);)
{
fragmentName
::
(
fragment
,
);
}
=
scopeName
.
().
(
fragmentName
);
if
(
index
== -
1
)
goto
USING_PATH_MATCHING_FAILED;
scopeName
scopeName
.
()
index
];
}
{
auto
=
::
(
scopeName
);
if
(!
.
(
result
))
{
.
(
result
);
}
}
USING_PATH_MATCHING_FAILED:;
}
}
return
.
() >
oldResultCount
;
}
<
>
::
(
*
,
*
)
{
auto
=
(
->
->
.
])
.
([=](
<
>
)
{
return
symbol
;
})
.
();
return
symbol
;
}
void
::
(
parsing
::
*
,
<
>
)
{
if
(!
)
{
<
>();
}
.
(
,
);
}
}
}
}