#include "WfCpp.h"
namespace
{
namespace
{
namespace
{
using
namespace
collections
;
using
namespace
reflection
;
using
namespace
reflection
::
description
;
using
namespace
analyzer
;
class
WfGenerateStatementVisitor
:
public
,
public
::
{
public
:
*
;
<
>
;
stream
::
&
;
;
;
*
;
WfGenerateStatementVisitor
(
*
,
<
>
,
stream
::
&
,
const
&
,
const
&
,
*
)
:config(
)
, functionRecord(
)
, writer(
)
, prefixBlock(
)
, prefix(
)
, returnType(
)
{
}
void
(
<
>
,
=
(
L"\t"
,
false
))
{
(
,
,
,
,
,
,
);
}
void
(
*
)
override
{
.
(
);
.
(
L"break;"
);
}
void
(
*
)
override
{
.
(
);
.
(
L"continue;"
);
}
void
(
*
)
override
{
.
(
);
if
(
->
)
{
.
(
L"return "
);
(
,
,
->
,
);
.
(
L";"
);
}
else
{
.
(
L"return;"
);
}
}
void
(
*
)
override
{
.
(
);
.
(
L"::vl::__vwsn::This("
);
(
,
,
->
,
nullptr
);
.
(
L")->Dispose(true);"
);
}
void
(
WfRaiseExceptionStatement
*
)
override
{
if
(
->
)
{
.
(
);
.
(
L"throw ::vl::Exception("
);
auto
=
->
->
->
.
()];
bool
=
result
.
() ==
description
::
<
>();
if
(!
throwString
)
{
.
(
L"::vl::__vwsn::This("
);
}
(
,
,
->
,
result
.
.
());
if
(!
throwString
)
{
.
(
L".Obj())->GetMessage()"
);
}
.
(
L");"
);
}
else
{
.
(
);
.
(
L"throw;"
);
}
}
void
(
*
)
override
{
.
(
);
while
(
)
{
.
(
L"if ("
);
if
(
->
)
{
auto
=
->
->
->
.
()];
auto
=
->
->
].
();
auto
=
(
scope
,
->
);
.
(
L"auto "
);
.
(
->
(
->
.
));
.
(
L" = "
);
(
,
,
result
.
.
(),
typeInfo
.
(), [&]() {
(
,
,
->
,
nullptr
); },
false
);
}
else
{
(
,
,
->
,
<
bool
>::
().
());
}
.
(
L")"
);
(
->
);
if
(
->
)
{
.
(
);
if
(
auto
=
->
.
<
>())
{
.
(
L"else "
);
=
ifStat
.
();
continue
;
}
else
{
.
(
L"else"
);
(
->
);
}
}
break
;
}
}
void
(
*
)
override
{
.
(
);
.
(
L"while ("
);
(
,
,
->
,
<
bool
>::
().
());
.
(
L")"
);
(
->
);
}
void
(
*
)
override
{
auto
=
L"__vwsne_"
+
(
++);
=
;
if
(
->
)
{
auto
=
L"__vwsnb_"
+
(
++);
tryPrefix
+=
L"\t"
;
.
(
);
.
(
L"{"
);
.
(
tryPrefix
);
.
(
L"auto "
);
.
(
blockName
);
.
(
L" = [&]()"
);
(
,
,
,
->
,
tryPrefix
,
(
L"\t"
,
false
),
);
.
(
tryPrefix
);
.
(
L";"
);
.
(
tryPrefix
);
.
(
L"::vl::__vwsn::RunOnExit<::vl::RemoveCVR<decltype("
);
.
(
blockName
);
.
(
L")>::Type> "
);
.
(
blockName
);
.
(
L"_dtor(&"
);
.
(
blockName
);
.
(
L");"
);
}
=
tryPrefix
+
L"\t"
;
.
(
tryPrefix
);
.
(
L"try"
);
.
(
tryPrefix
);
.
(
L"{"
);
(
,
,
,
->
,
bodyPrefix
,
(
L"\t"
,
false
),
);
.
(
tryPrefix
);
.
(
L"}"
);
.
(
tryPrefix
);
.
(
L"catch(const ::vl::Exception&"
);
if
(
->
)
{
.
(
L" "
);
.
(
exName
);
}
.
(
L")"
);
.
(
tryPrefix
);
.
(
L"{"
);
if
(
->
)
{
.
(
bodyPrefix
);
.
(
L"auto "
);
.
(
->
(
->
.
));
.
(
L" = ::vl::reflection::description::IValueException::Create("
);
.
(
exName
);
.
(
L".Message());"
);
(
,
,
,
->
,
bodyPrefix
,
(
L"\t"
,
false
),
);
}
.
(
tryPrefix
);
.
(
L"}"
);
if
(
->
)
{
.
(
);
.
(
L"}"
);
}
}
void
(
*
)
override
{
.
(
);
.
(
L"{"
);
auto
=
;
if
(
->
.
!=
L""
)
{
auto
=
->
(
->
.
,
L"__vwsnl_"
+
(
++) +
L"_"
);
.
(
->
.
,
name
);
.
(
);
.
(
L"\t{"
);
+=
L"\t"
;
}
FOREACH(Ptr<WfStatement>, statement, node->statements)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
->
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
statement
);)
{
statement
SearchUntilNonVirtualStatement
(
statement
);
if
(
statement
.
<
>())
{
(
statement
);
}
else
{
(
statement
,
::
);
}
}
if
(
->
.
!=
L""
)
{
oldPrefix
;
.
(
);
.
(
L"\t}"
);
.
(
);
.
(
L"\t"
);
.
(
->
.
]);
.
(
L":;"
);
.
(
->
.
);
}
.
(
);
.
(
L"}"
);
}
void
(
*
)
override
{
.
(
);
.
(
L"goto "
);
.
(
->
.
]);
.
(
L";"
);
}
void
(
*
)
override
{
.
(
);
(
,
,
->
,
nullptr
,
false
);
.
(
L";"
);
}
void
(
*
)
override
{
auto
=
->
->
->
.
()];
auto
=
scope
->
.
]
0
].
();
.
(
);
if
(
->
)
{
.
(
L"auto"
);
}
else
{
.
(
->
(
symbol
->
.
()));
}
.
(
L" "
);
.
(
->
(
->
.
));
if
(
->
)
{
.
(
L" = "
);
(
,
,
->
,
symbol
->
.
());
}
.
(
L";"
);
}
void
(
*
)
override
{
->
(
this
);
}
void
(
*
)
override
{
CHECK_FAIL(L"WfGenerateStatementVisitor::Visit(WfCoroutineStatement*)#Internal error, All coroutine statements do not generate C++ code.");
do
{
throw
(
L"WfGenerateStatementVisitor::Visit(WfCoroutineStatement*)#Internal error, All coroutine statements do not generate C++ code."
);}
while
(
0
);
}
void
(
*
)
override
{
CHECK_FAIL(L"WfGenerateStatementVisitor::Visit(WfStateMachineStatement*)#Internal error, All state machine statements do not generate C++ code.");
do
{
throw
(
L"WfGenerateStatementVisitor::Visit(WfStateMachineStatement*)#Internal error, All state machine statements do not generate C++ code."
);}
while
(
0
);
}
};
void
(
*
,
<
>
,
stream
::
&
,
<
>
,
const
&
,
const
&
,
reflection
::
description
::
*
)
{
WfGenerateStatementVisitor
(
,
,
,
,
,
);
(&
visitor
);
}
}
}
}