#include "WfAnalyzer.h"
namespace
{
namespace
{
namespace
{
using
namespace
collections
;
using
namespace
reflection
;
using
namespace
reflection
::
description
;
using
namespace
typeimpl
;
*
(
*
)
{
if
(
auto
=
->
())
{
auto
=
description
::
<
>();
for
(
=
0
;
i
<
ctors
->
();
i
++)
{
*
=
ctors
->
(
i
);
if
(
info
->
() ==
1
)
{
*
=
info
->
(
0
)->
();
if
(
parameterType
->
() ==
::
)
{
parameterType
=
parameterType
->
();
if
(
parameterType
->
() ==
::
&&
parameterType
->
() ==
proxyTd
)
{
return
info
;
}
}
}
}
}
return
nullptr
;
}
*
(
const
&
)
{
if
(
.
)
{
return
.
->
();
}
else
if
(
.
)
{
return
.
.
();
}
else
{
return
nullptr
;
}
}
<
>
(
*
,
parsing
::
*
,
<
>
,
<
>&
,
<
<
>>&
,
&
)
{
= -
1
;
<
bool
>
;
<
<
>>
;
FOREACH(Ptr<WfExpression>, argument, arguments)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
argument
);)
{
if
(!
argument
||
IsExpressionDependOnExpectedType
(
,
argument
))
{
resolvables
.
(
false
);
types
.
(
nullptr
);
}
else
{
resolvables
.
(
true
);
types
.
(
(
,
argument
,
nullptr
));
}
}
<
<
parsing
::
>>
,
;
<
<
,
>>
;
*
=
description
::
<
>();
for
(
=
0
;
i
<
.
();
i
++)
{
bool
=
false
;
=
0
;
auto
=
i
];
*
=
(
result
);
if
(
expressionType
->
() ==
::
)
{
*
=
expressionType
->
();
if
(
genericType
->
() !=
::
)
goto
FUNCTION_TYPE_FAILED;
*
=
genericType
->
();
if
(
functionType
->
() !=
::
||
functionType
->
() !=
functionFd
)
goto
FUNCTION_TYPE_FAILED;
if
(
genericType
->
() !=
types
.
() +
1
)
{
functionErrors
.
(
::
FunctionArgumentCountMismatched
(
,
.
(),
result
));
failed
=
true
;
}
else
{
for
(
=
0
;
j
<
types
.
();
j
++)
{
if
(
resolvables
j
] &&
types
j
])
{
*
=
genericType
->
(
j
+
1
);
if
(
(
types
j
].
(),
argumentType
,
false
))
{
if
(!
(
types
j
].
(),
argumentType
))
{
convertCount
++;
}
}
else
{
functionErrors
.
(
::
FunctionArgumentTypeMismatched
(
,
result
,
j
+
1
,
types
j
].
(),
argumentType
));
failed
=
true
;
}
}
}
}
}
else
{
goto
FUNCTION_TYPE_FAILED;
}
goto
FUNCTION_TYPE_FINISHED;
FUNCTION_TYPE_FAILED:
nonFunctionErrors
.
(
::
(
.
(),
result
.
.
()));
failed
=
true
;
FUNCTION_TYPE_FINISHED:
if
(!
failed
)
{
selectedFunctionIndices
.
({
i
,
convertCount
});
}
}
if
(
selectedFunctionIndices
.
() >
1
)
{
=
(
selectedFunctionIndices
)
.Select([](
<
,
>
)
{
return
p
.
;
})
.Min();
for
(
=
selectedFunctionIndices
.
() -
1
;
i
>=
0
;
i
--)
{
if
(
selectedFunctionIndices
i
].
!=
minScore
)
{
selectedFunctionIndices
.
(
i
);
}
}
}
if
(
selectedFunctionIndices
.
() ==
1
)
{
=
selectedFunctionIndices
0
].
;
*
=
(
])->
();
for
(
=
0
;
i
<
types
.
();
i
++)
{
*
=
genericType
->
(
i
+
1
);
if
(
resolvables
i
])
{
=
->
.
().
(
i
].
());
if
(
index
!= -
1
)
{
auto
=
->
.
()
index
];
CHECK_ERROR(resolvingResult.expectedType == nullptr, L"GetExpressionType should not set expectedType if it is null");
do
{
if
(!(
resolvingResult
.
nullptr
))
throw
(
L"GetExpressionType should not set expectedType if it is null"
);}
while
(
0
);
resolvingResult
.
(
argumentType
);
->
.
(
i
].
(),
resolvingResult
);
}
}
else
{
if
(
i
])
{
(
,
i
],
(
argumentType
));
}
}
}
return
(
genericType
->
(
0
));
}
else
{
if
(
selectedFunctionIndices
.
() >
1
)
{
<
>
;
(
overloadedFunctions
,
(
selectedFunctionIndices
)
.Select([&functions](
<
,
>
)
{
return
p
.
];
}));
->
.
(
::
CannotPickOverloadedFunctions
(
,
overloadedFunctions
));
}
if
(
functionErrors
.
() >
0
)
{
(
->
,
functionErrors
,
true
);
}
else
{
(
->
,
nonFunctionErrors
,
true
);
}
return
nullptr
;
}
}
void
(
*
,
<
>
)
{
FOREACH(Ptr<WfDeclaration>, declaration, module->declarations)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
declaration
);)
{
ValidateDeclarationSemantic
(
,
declaration
);
}
}
<
>
(
*
,
<
>
)
{
<
>
;
ValidateExpressionSemantic
(
,
,
0
,
results
);
if
(
results
.
() ==
0
)
return
0
;
for
(
=
results
.
() -
1
;
i
>=
0
;
i
--)
{
auto
&
=
results
i
];
if
(!
result
.
)
{
results
.
(
i
);
}
}
if
(
results
.
() ==
0
)
{
->
.
(
::
(
.
()));
return
0
;
}
else
if
(
results
.
() >
1
)
{
->
.
(
::
(
.
(),
results
,
(
)));
return
0
;
}
auto
=
results
0
];
->
.
(
,
result
);
return
result
.
;
}
reflection
::
description
::
*
(
*
,
<
>
)
{
<
>
;
ValidateExpressionSemantic
(
,
,
0
,
results
);
if
(
results
.
() ==
0
)
return
0
;
for
(
=
results
.
() -
1
;
i
>=
0
;
i
--)
{
auto
&
=
results
i
];
if
(!
result
.
)
{
results
.
(
i
);
}
}
if
(
results
.
() ==
0
)
{
->
.
(
::
(
.
()));
return
0
;
}
else
if
(
results
.
() >
1
)
{
->
.
(
::
(
.
(),
results
,
(
)));
return
0
;
}
auto
=
results
0
];
->
.
(
,
result
);
return
result
.
;
}
void
(
*
,
<
>
,
<
reflection
::
description
::
>
,
bool
,
collections
::
<
>&
)
{
ValidateExpressionSemantic
(
,
,
,
);
if
(
.
() ==
0
)
return
;
<
>
;
*
=
0
;
for
(
=
.
() -
1
;
i
>=
0
;
i
--)
{
auto
&
=
i
];
if
(
result
.
&& !
scopeName
)
{
scopeName
result
.
;
}
if
(
result
.
&& !
eventInfo
)
{
eventInfo
=
result
.
;
}
if
(!
result
.
&& !(
&&
eventInfo
))
{
.
(
i
);
}
}
if
(
.
() ==
0
)
{
if
(
scopeName
)
{
->
.
(
::
(
.
(),
scopeName
));
}
if
(
eventInfo
)
{
->
.
(
::
(
.
(),
eventInfo
));
}
}
if
(
)
{
<
<
>>
;
for
(
=
.
() -
1
;
i
>=
0
;
i
--)
{
auto
&
=
i
];
if
(!
(
result
.
.
(),
.
(),
false
))
{
failedTypes
.
(
result
.
);
.
(
i
);
}
}
if
(
.
() ==
0
)
{
FOREACH(Ptr<ITypeInfo>, type, failedTypes)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
failedTypes
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
type
);)
{
->
.
(
::
ExpressionCannotImplicitlyConvertToType
(
.
(),
type
.
(),
.
()));
}
}
}
}
<
reflection
::
description
::
>
(
*
,
<
>
,
<
reflection
::
description
::
>
)
{
<
>
;
(
,
,
,
false
,
results
);
if
(
results
.
() >
1
)
{
->
.
(
::
(
.
(),
results
,
(
)));
return
;
}
else
if
(
results
.
() ==
1
)
{
auto
=
results
0
];
result
.
;
->
.
(
,
result
);
return
?
:
result
.
;
}
else
{
return
;
}
}
<
reflection
::
description
::
>
GetLeftValueExpressionType
(
*
,
<
>
)
{
<
>
;
(
,
,
nullptr
,
false
,
results
);
if
(
results
.
() >
1
)
{
->
.
(
::
(
.
(),
results
,
(
)));
}
else
if
(
results
.
() ==
1
)
{
if
(
results
0
].
)
{
auto
=
results
0
];
->
.
(
,
result
);
return
result
.
;
}
else
{
->
.
(
::
(
.
(),
results
0
]));
}
}
return
nullptr
;
}
<
reflection
::
description
::
>
GetEnumerableExpressionItemType
(
*
,
<
>
,
<
reflection
::
description
::
>
)
{
<
>
=
(
,
,
);
if
(
collectionType
)
{
if
(
collectionType
()->
(
description
::
<
>()))
{
if
(
collectionType
() ==
::
)
{
*
=
collectionType
();
if
(
genericType
->
() ==
::
&&
genericType
->
() ==
1
)
{
return
(
genericType
->
(
0
));
}
}
return
<
>::
();
}
->
.
(
::
ExpressionIsNotCollection
(
.
(),
collectionType
.
()));
}
return
nullptr
;
}
}
}
}