#include "WfAnalyzer.h"
namespace
{
namespace
{
namespace
{
using
namespace
collections
;
using
namespace
reflection
;
using
namespace
reflection
::
description
;
using
namespace
typeimpl
;
class
ValidateSemanticClassMemberVisitor
:
public
,
public
::
{
public
:
*
;
<
>
;
<
>
;
ValidateSemanticClassMemberVisitor
(
<
>
,
<
>
,
*
)
:td(
)
, classDecl(
)
, manager(
)
{
}
void
(
*
)
override
{
}
void
(
*
)
override
{
ValidateDeclarationSemantic
(
,
);
}
void
(
*
)
override
{
ValidateDeclarationSemantic
(
,
);
}
void
(
*
)
override
{
ValidateDeclarationSemantic
(
,
);
}
void
(
*
)
override
{
ValidateDeclarationSemantic
(
,
);
auto
=
->
];
if
(
auto
=
(
scope
.
(),
->
))
{
if
(
->
.
!=
L""
)
{
auto
=
(
->
.
,
false
)->
(
0
);
if
(!
(
typeInfo
.
(),
getter
->
()) ||
getter
->
() !=
0
)
{
->
.
(
::
PropertyGetterTypeMismatched
(
,
.
()));
}
}
if
(
->
.
!=
L""
)
{
auto
=
(
->
.
,
false
)->
(
0
);
if
(
setter
->
()->
() !=
description
::
<
void
>() ||
setter
->
() !=
1
|| !
(
typeInfo
.
(),
setter
->
(
0
)->
()))
{
->
.
(
::
PropertySetterTypeMismatched
(
,
.
()));
}
}
}
}
static
void
(
*
,
*
,
parsing
::
*
,
*
,
<
<
>>&
)
{
<
>
;
if
(
auto
=
->
())
{
=
ctors
->
();
for
(
=
0
;
i
<
count
;
i
++)
{
auto
=
ctors
->
(
i
);
functions
.
(
::
(
ctor
));
}
}
= -
1
;
(
,
,
nullptr
,
functions
,
,
selectedFunctionIndex
);
if
(
selectedFunctionIndex
!= -
1
)
{
auto
=
functions
selectedFunctionIndex
].
;
auto
=
dynamic_cast
<
*>(
);
->
baseConstructorCallResolvings
.
({
,
}, {
call
,
ctor
});
}
}
void
(
*
)
override
{
ValidateDeclarationSemantic
(
,
);
auto
=
->
].
();
auto
=
scope
->
.
();
<
*>
,
;
{
auto
=
classScope
->
;
=
td
->
GetBaseTypeDescriptorCount
();
for
(
=
0
;
i
<
count
;
i
++)
{
auto
=
td
->
(
i
);
if
(!
baseTypes
.
(
baseTd
))
{
baseTypes
.
(
baseTd
);
}
}
}
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
);)
{
if
(
auto
=
GetScopeNameFromReferenceType
(
classScope
,
call
))
{
if
(
auto
=
scopeName
)
{
if
(
initTypes
.
(
td
))
{
->
.
(
::
DuplicatedBaseConstructorCall
(
call
.
(),
td
));
}
else
if
(
baseTypes
.
(
td
))
{
initTypes
.
(
td
);
(
,
,
call
.
(),
td
,
call
);
}
else
{
->
.
(
::
(
call
.
(),
td
));
}
}
}
}
{
= -
1
;
for
(
=
0
;
i
<
initTypes
.
();
i
++)
{
while
(
baseTypes
++
index
] !=
initTypes
i
])
{
auto
=
baseTypes
index
];
<
<
>>
;
(
,
,
,
td
,
arguments
);
}
}
while
(++
index
<
baseTypes
.
())
{
auto
=
baseTypes
index
];
<
<
>>
;
(
,
,
,
td
,
arguments
);
}
}
ValidateStatementSemantic
(
,
->
);
}
void
(
*
)
override
{
ValidateDeclarationSemantic
(
,
);
ValidateStatementSemantic
(
,
->
);
}
void
(
*
)
override
{
ValidateDeclarationSemantic
(
,
);
}
void
(
*
)
override
{
ValidateDeclarationSemantic
(
,
);
}
void
(
*
)
override
{
ValidateDeclarationSemantic
(
,
);
}
void
(
*
)
override
{
ValidateDeclarationSemantic
(
,
);
}
void
(
*
)
override
{
ValidateDeclarationSemantic
(
,
);
}
static
void
(
<
>
,
<
>
,
<
>
,
*
)
{
ValidateSemanticClassMemberVisitor
(
,
,
);
(&
visitor
);
}
};
class
ExpandVirtualDeclarationVisitor
:
public
,
public
::
{
public
:
*
;
ExpandVirtualDeclarationVisitor
(
*
)
:manager(
)
{
}
void
(
WfStateMachineDeclaration
*
)
override
{
(
,
);
}
};
class
ValidateSemanticDeclarationVisitor
:
public
,
public
::
,
public
::
{
public
:
*
;
ValidateSemanticDeclarationVisitor
(
*
)
:manager(
)
{
}
void
(
<
<
>>&
)
{
FOREACH(Ptr<WfAttribute>, attribute, attributes)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
attribute
);)
{
auto
=
<
,
>(
attribute
.
,
attribute
.
);
=
->
.
().
(
key
);
if
(
index
== -
1
)
{
->
.
(
::
(
attribute
.
()));
}
else
{
auto
=
->
.
()
index
];
if
(
attribute
)
{
ValidateConstantExpression
(
,
attribute
,
expectedType
);
}
else
if
(
expectedType
() !=
description
::
<
void
>())
{
->
.
(
::
(
attribute
.
()));
}
}
}
}
void
(
*
)
override
{
FOREACH(Ptr<WfDeclaration>, declaration, node->declarations)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
->
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
declaration
);)
{
ValidateDeclarationSemantic
(
,
declaration
);
}
}
void
(
*
)
override
{
if
(
->
)
{
ValidateStatementSemantic
(
,
->
);
}
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
);
}
}
void
(
*
)
override
{
auto
=
->
];
auto
=
scope
->
.
]
0
];
symbol
(
,
->
,
symbol
);
if
(
symbol
&& !
symbol
)
{
symbol
(
symbol
.
());
}
}
void
(
*
)
override
{
}
void
(
*
)
override
{
}
void
(
*
)
override
{
}
void
(
*
)
override
{
}
void
(
*
)
override
{
auto
=
->
];
auto
=
->
].
<
>();
if
(
->
==
::
)
{
FOREACH(Ptr<WfType>, baseType, node->baseTypes)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
->
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
baseType
);)
{
auto
=
GetScopeNameFromReferenceType
(
scope
.
(),
baseType
);
auto
=
scopeName
;
auto
=
(
baseTd
);
if
(
ctor
==
nullptr
)
{
->
.
(
::
(
,
baseTd
));
}
}
}
if
(
auto
=
(
->
)
.FindType<
WfStateMachineDeclaration
>()
.First(
nullptr
)
)
{
auto
=
description
::
<
>();
=
td
GetBaseTypeDescriptorCount
();
auto
=
<
>(
0
,
count
)
.
([=](
) {
return
td
(
index
); })
.
([=](
*
) {
return
td
==
smtd
; })
.
(
nullptr
);
if
(!
smbc
)
{
->
.
(
::
StateMachineClassNotInheritFromStateMachine
(
));
}
}
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
);)
{
ValidateClassMemberSemantic
(
,
td
,
,
memberDecl
);
}
}
void
(
*
)
override
{
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
);)
{
(
item
);
}
}
void
(
*
)
override
{
auto
=
->
];
auto
=
->
].
<
>();
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
);)
{
auto
=
td
(
member
.
,
false
)->
()->
();
if
((
memberTd
->
()
::
) !=
::
)
{
->
.
(
::
StructContainsNonValueType
(
member
.
(),
));
}
}
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
);)
{
(
member
);
}
}
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
);)
{
ValidateDeclarationSemantic
(
,
decl
);
}
}
void
(
*
)
override
{
bool
=
->
.
() >
0
;
=
->
.
();
->
((
::
*)
this
);
if
(!
expanded
&&
->
.
() ==
errorCount
)
{
ExpandVirtualDeclarationVisitor
(
);
->
(&
visitor
);
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
,
->
);
}
auto
=
->
];
if
(
parentScope
)
{
parentScope
parentScope
;
}
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
);)
{
ContextFreeDeclarationDesugar
(
,
decl
);
}
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
);)
{
(
,
parentScope
,
decl
,
->
]);
}
->
checkedScopes_DuplicatedSymbol
.
(
parentScope
.
());
->
.
(
parentScope
.
());
if
(!
CheckScopes_DuplicatedSymbol
(
) || !
(
))
{
return
;
}
}
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
);)
{
ValidateDeclarationSemantic
(
,
decl
);
}
}
void
(
WfStateMachineDeclaration
*
)
override
{
bool
=
false
;
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
);)
{
if
(
state
.
==
L""
)
{
foundDefaultState
=
true
;
}
ValidateStatementSemantic
(
,
state
);
}
if
(!
foundDefaultState
)
{
->
.
(
::
(
));
}
}
static
void
(
<
>
,
*
)
{
ValidateSemanticDeclarationVisitor
(
);
(&
visitor
);
visitor
.
(
);
}
};
void
ValidateClassMemberSemantic
(
*
,
<
typeimpl
::
>
,
<
>
,
<
>
)
{
return
ValidateSemanticClassMemberVisitor
::
(
,
,
,
);
}
void
ValidateDeclarationSemantic
(
*
,
<
>
)
{
return
ValidateSemanticDeclarationVisitor
::
(
,
);
}
}
}
}