#include "WfCpp.h"
namespace
{
namespace
{
namespace
{
using
namespace
collections
;
using
namespace
parsing
;
using
namespace
analyzer
;
using
namespace
reflection
;
using
namespace
reflection
::
description
;
void
::(
stream
::
& ,
<
> )
{
auto
=
.
()];
.
(
L"\t"
);
if
(
.
<
>())
{
.
(
L"class "
);
}
else
{
.
(
L"struct "
);
}
.
(
info
);
.
(
L";"
);
}
void
::(
stream
::
& ,
<
> )
{
if
(
auto
=
.
<
WfOrderedLambdaExpression
>())
{
auto
=
.
()];
.
(
L"\tstruct "
+
name
);
.
(
L"\t{"
);
if
(
(
,
))
{
.
(
L""
);
}
.
(
L"\t\t"
);
(
,
,
name
);
.
(
L";"
);
.
(
L""
);
.
(
L"\t\t"
);
(
,
ordered
,
L"operator()"
,
true
);
.
(
L" const;"
);
.
(
L"\t};"
);
}
else
if
(
auto
=
.
<
>())
{
auto
=
.
()];
.
(
L"\tstruct "
+
name
);
.
(
L"\t{"
);
if
(
(
,
))
{
.
(
L""
);
}
.
(
L"\t\t"
);
(
,
,
name
);
.
(
L";"
);
.
(
L""
);
.
(
L"\t\t"
);
(
,
funcExpr
,
L"operator()"
,
true
);
.
(
L" const;"
);
.
(
L"\t};"
);
}
}
void
::(
stream
::
& ,
<
> )
{
auto
=
->
.
()];
auto
=
result
.
->
();
auto
=
.
()];
.
(
L"\tclass "
+
name
+
L" : public ::vl::Object, public virtual "
+
(
td
));
.
(
L"\t{"
);
.
(
L"\tpublic:"
);
if
(
(
,
))
{
.
(
L""
);
}
.
(
L"\t\t"
);
(
,
,
name
);
.
(
L";"
);
.
(
L""
);
FOREACH(Ptr<WfDeclaration>, memberDecl, lambda->declarations)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>& = ::
vl
::
collections
::
(
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
> ;
__foreach_iterator__
.
(
memberDecl
);)
{
(
this
,
,
name
,
memberDecl
,
L"\t\t"
,
true
);
}
.
(
L"\t};"
);
}
bool
::
(
stream
::
&
,
<
>
)
{
auto
=
.
()];
FOREACH(Ptr<WfLexicalSymbol>, symbol, info->symbols.Values())
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
info
.
());
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
symbol
);)
{
.
(
L"\t\t"
);
.
(
(
symbol
.
()));
.
(
L" "
);
.
(
(
symbol
));
.
(
L";"
);
}
FOREACH_INDEXER(ITypeDescriptor*, thisType, index, info->thisTypes)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
*>&
= ::
vl
::
collections
::
(
info
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
if
(
bool
=
true
)
for
(
=
0
;
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
*
;
__foreach_iterator__
.
(
thisType
);
index
++)
{
auto
=
<
>(
<
>(
thisType
,
::
));
.
(
L"\t\t"
);
.
(
(
typeInfo
.
()));
.
(
L" "
);
.
(
L"__vwsnthis_"
+
(
index
));
.
(
L";"
);
}
return
info
.
() +
info
.
() >
0
;
}
void
::
(
stream
::
&
,
<
>
,
const
&
)
{
auto
=
.
()];
.
(
);
.
(
L"("
);
=
0
;
FOREACH_INDEXER(Ptr<WfLexicalSymbol>, symbol, index, From(info->symbols.Values()).Concat(info->ctorArgumentSymbols.Values()))
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
(
info
.
()).
(
info
.
()));
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
if
(
bool
=
true
)
for
(
=
0
;
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
symbol
);
index
++)
{
if
(
argumentIndex
++ >
0
)
{
.
(
L", "
);
}
.
(
(
symbol
.
()));
.
(
L" __vwsnctor_"
);
.
(
(
symbol
));
}
FOREACH_INDEXER(ITypeDescriptor*, thisType, index, info->thisTypes)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
*>&
= ::
vl
::
collections
::
(
info
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
if
(
bool
=
true
)
for
(
=
0
;
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
*
;
__foreach_iterator__
.
(
thisType
);
index
++)
{
auto
=
<
>(
<
>(
thisType
,
::
));
if
(
argumentIndex
++ >
0
)
{
.
(
L", "
);
}
.
(
(
typeInfo
.
()));
.
(
L" __vwsnctorthis_"
+
(
index
));
}
.
(
L")"
);
}
void
::
WriteCpp_ClosureCtorInitList
(
stream
::
&
,
<
>
)
{
auto
=
.
()];
FOREACH_INDEXER(Ptr<WfLexicalSymbol>, symbol, index, info->symbols.Values())
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
info
.
());
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
if
(
bool
=
true
)
for
(
=
0
;
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
symbol
);
index
++)
{
if
(
index
>
0
)
{
.
(
L"\t\t, "
);
}
else
{
.
(
L"\t\t:"
);
}
.
(
(
symbol
));
.
(
L"(__vwsnctor_"
);
.
(
(
symbol
));
.
(
L")"
);
}
FOREACH_INDEXER(ITypeDescriptor*, thisType, index, info->thisTypes)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
*>&
= ::
vl
::
collections
::
(
info
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
if
(
bool
=
true
)
for
(
=
0
;
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
*
;
__foreach_iterator__
.
(
thisType
);
index
++)
{
if
(
index
>
0
||
info
.
() >
0
)
{
.
(
L"\t\t, "
);
}
else
{
.
(
L"\t\t:"
);
}
.
(
L"__vwsnthis_"
+
(
index
));
.
(
L"(::vl::__vwsn::This(__vwsnctorthis_"
+
(
index
));
.
(
L"))"
);
}
}
void
::
(
stream
::
&
,
<
>
)
{
if
(
auto
=
.
<
WfOrderedLambdaExpression
>())
{
auto
=
.
()];
.
(
L"\t"
);
(
,
,
name
+
L"::"
+
name
);
.
(
L""
);
WriteCpp_ClosureCtorInitList
(
,
);
.
(
L"\t{"
);
.
(
L"\t}"
);
.
(
L""
);
.
(
L"\t"
);
auto
=
(
,
ordered
,
name
+
L"::operator()"
,
true
);
.
(
L" const"
);
.
(
L"\t{"
);
(
,
ordered
,
L"\t\t"
,
returnType
);
.
(
L"\t}"
);
}
else
if
(
auto
=
.
<
>())
{
auto
=
.
()];
.
(
L"\t"
);
(
,
,
name
+
L"::"
+
name
);
.
(
L""
);
WriteCpp_ClosureCtorInitList
(
,
);
.
(
L"\t{"
);
.
(
L"\t}"
);
.
(
L""
);
.
(
L"\t"
);
auto
=
(
,
funcExpr
,
name
+
L"::operator()"
,
true
);
.
(
L" const"
);
(
,
funcExpr
,
L"\t"
,
returnType
);
}
}
class
WriteCpp_ClassExprImpl_InitFieldVisitor
:
public
empty_visitor
::
{
public
:
*
;
stream
::
&
;
WriteCpp_ClassExprImpl_InitFieldVisitor
(
*
,
stream
::
&
)
:config(
)
, writer(
)
{
}
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
{
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
{
if
(
->
)
{
auto
=
->
->
].
();
auto
=
scope
->
->
.
]
0
];
auto
=
symbol
;
.
(
L"\t\tthis->"
);
.
(
->
(
->
.
));
.
(
L" = "
);
(
,
,
->
,
typeInfo
.
());
.
(
L";"
);
}
}
};
void
::
(
stream
::
&
,
<
>
)
{
auto
=
.
()];
.
(
L"\t"
);
(
,
,
name
+
L"::"
+
name
);
.
(
L""
);
WriteCpp_ClosureCtorInitList
(
,
);
.
(
L"\t{"
);
{
WriteCpp_ClassExprImpl_InitFieldVisitor
(
this
,
);
FOREACH(Ptr<WfDeclaration>, memberDecl, lambda->declarations)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
memberDecl
);)
{
memberDecl
(&
visitor
);
}
}
.
(
L"\t}"
);
.
(
L""
);
=
L"::"
+
+
L"::"
+
name
;
FOREACH(Ptr<WfDeclaration>, memberDecl, lambda->declarations)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
memberDecl
);)
{
if
(
(
this
,
,
nullptr
,
name
,
name
,
classFullName
,
memberDecl
,
L"\t"
))
{
.
(
L""
);
}
}
}
}
}
}