#include "WfAnalyzer.h"
namespace
{
namespace
{
namespace
{
using
namespace
collections
;
using
namespace
reflection
;
using
namespace
reflection
::
description
;
using
namespace
parsing
;
using
namespace
stream
;
class
SearchUntilNonVirtualStatementVisitor
:
public
empty_visitor
::
{
public
:
<
>
;
SearchUntilNonVirtualStatementVisitor
(
<
>
)
:result(
)
{
}
void
(
*
)
override
{
->
;
(
this
);
}
void
(
*
)
override
{
}
void
(
*
)
override
{
}
};
<
>
SearchUntilNonVirtualStatement
(
<
>
)
{
SearchUntilNonVirtualStatementVisitor
(
);
(&
visitor
);
return
visitor
.
;
}
class
CopyDeclarationWithExpandVirtualVisitor
:
empty_visitor
::
{
public
:
bool
=
false
;
<
<
>>&
;
CopyDeclarationWithExpandVirtualVisitor
(
<
<
>>&
)
:decls(
)
{
}
void
(
*
)
override
{
=
true
;
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
);
}
}
void
(
*
)
override
{
=
true
;
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
);
}
}
static
void
(
<
<
>>&
,
<
>
)
{
CopyDeclarationWithExpandVirtualVisitor
(
);
(&
visitor
);
if
(!
visitor
.
)
{
.
(
);
}
}
};
void
CopyWithExpandVirtualVisitor
::
(
collections
::
<
<
>>&
)
{
if
(
)
{
<
<
>>
;
(
copied
,
);
.
();
FOREACH(Ptr<WfDeclaration>, decl, copied)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
copied
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
decl
);)
{
CopyDeclarationWithExpandVirtualVisitor
::
(
,
decl
);
}
}
}
CopyWithExpandVirtualVisitor
::
CopyWithExpandVirtualVisitor
(
bool
)
:expandVirtualAst(
)
{
}
<
>
CopyWithExpandVirtualVisitor
::
(
*
)
{
if
(!
|| !
->
)
{
return
copy_visitor
::
::
(
);
}
->
(
this
);
return
;
}
<
>
CopyWithExpandVirtualVisitor
::
(
*
)
{
if
(!
|| !
->
)
{
return
copy_visitor
::
::
(
);
}
->
(
this
);
return
;
}
<
>
CopyWithExpandVirtualVisitor
::
(
*
)
{
if
(!
|| !
->
)
{
return
copy_visitor
::
::
(
);
}
->
(
this
);
return
;
}
void
CopyWithExpandVirtualVisitor
::
(
*
)
{
copy_visitor
::
::
(
);
(
.
<
>()
);
}
void
CopyWithExpandVirtualVisitor
::
(
*
)
{
copy_visitor
::
::
(
);
(
.
<
>()
);
}
void
CopyWithExpandVirtualVisitor
::
(
*
)
{
copy_visitor
::
::
(
);
(
.
<
>()
);
}
<
>
(
<
>
)
{
return
CopyWithExpandVirtualVisitor
(
false
).
(
);
}
<
>
(
<
>
,
bool
)
{
return
CopyWithExpandVirtualVisitor
(
).
(
);
}
<
>
(
<
>
,
bool
)
{
return
CopyWithExpandVirtualVisitor
(
).
(
);
}
<
>
(
<
>
,
bool
)
{
return
CopyWithExpandVirtualVisitor
(
).
(
);
}
<
>
(
<
>
,
bool
)
{
return
CopyWithExpandVirtualVisitor
(
).
(
);
}
class
:
public
{
typedef
collections
::
<
*>
;
typedef
collections
::
<
*,
*>
;
typedef
collections
::
<
*,
*>
;
typedef
collections
::
<
*,
*>
;
public
:
;
;
;
;
;
;
;
;
;
(
)
{
return
L"<bind-cache>"
+
(
);
}
(
*
,
bool
)
{
=
.
(
);
if
(
)
{
CHECK_ERROR(index != -1, L"BindContext::GetCachedExpressionIndex(WfExpression*, bool)#Cached expression not exists.");
do
{
if
(!(
index
!= -
1
))
throw
(
L"BindContext::GetCachedExpressionIndex(WfExpression*, bool)#Cached expression not exists."
);}
while
(
0
);
}
return
index
;
}
GetCachedExpressionIndexRecursively
(
*
,
bool
)
{
*
=
;
while
(
true
)
{
=
.
().
(
cache
);
if
(
index
== -
1
)
{
return
(
cache
,
);
}
else
{
cache
=
.
()
index
];
}
}
}
};
struct
{
*
;
*
;
;
;
;
};
struct
{
<
,
<
>>
;
<
,
<
>>
;
<
*,
>
;
};
class
:
public
,
public
::
{
public
:
*
;
&
;
(
*
,
&
)
:manager(
)
, context(
)
{
}
void
(
*
)
{
->
(
this
);
}
void
(
*
,
*
)
{
if
(
.
.
().
(
))
{
CHECK_ERROR(context.observeParents[expr] == parent, L"CreateBindContextVisitor::ObservableDepend assigned different parents to the same expression.");
do
{
if
(!(
.
] ==
))
throw
(
L"CreateBindContextVisitor::ObservableDepend assigned different parents to the same expression."
);}
while
(
0
);
return
;
}
.
.
(
);
.
.
(
,
);
(
,
,
false
);
{
auto
=
;
while
(
true
)
{
=
.
.
().
(
cache
);
if
(
index
== -
1
)
{
index
=
.
.
(
cache
);
if
(
index
== -
1
)
{
.
.
(
cache
);
}
break
;
}
else
{
cache
=
.
.
()
index
];
}
}
}
=
.
.
().
(
);
if
(
index
!= -
1
)
{
FOREACH(WfExpression*, observe, context.exprCauses.GetByIndex(index))
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
*>&
= ::
vl
::
collections
::
(
.
.
(
index
));
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
*
;
__foreach_iterator__
.
(
observe
);)
{
.
.
(
observe
,
);
.
.
(
,
observe
);
}
}
.
.
(
,
);
.
.
(
,
);
}
void
(
*
,
*
,
bool
=
true
)
{
if
(
)
{
(
);
}
=
.
.
().
(
);
if
(
index
!= -
1
)
{
FOREACH(WfExpression*, observe, context.exprCauses.GetByIndex(index))
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
*>&
= ::
vl
::
collections
::
(
.
.
(
index
));
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
*
;
__foreach_iterator__
.
(
observe
);)
{
.
.
(
,
observe
);
.
.
(
observe
,
);
}
}
}
void
(
*
)
override
{
}
void
(
*
)
override
{
}
void
(
*
)
override
{
auto
=
->
];
if
(
result
.
)
{
auto
=
result
.
;
if
(
auto
=
dynamic_cast
<
*>(
scope
->
.
()))
{
auto
=
(
letExpr
->
)
.Where([=](
const
<
>&
)
{
return
letVar
.
==
->
.
;
})
.First();
.
.
(
,
letVar
->value.Obj());
(
,
letVar
->value.Obj(),
false
);
}
else
if
(
auto
=
dynamic_cast
<
*>(
scope
->
.
()))
{
.
.
(
,
observeExpr
->
.
());
(
,
observeExpr
->
.
());
}
}
}
void
(
*
)
override
{
}
void
(
WfOrderedLambdaExpression
*
)
override
{
}
void
(
*
)
override
{
(
->
.
());
auto
=
->
].
();
while
(
scope
)
{
if
(
scope
->
.
<
>())
{
break
;
}
scope
=
scope
->
.
();
}
if
(!
scope
)
{
auto
=
->
];
if
(
memberResult
.
)
{
auto
=
memberResult
.
->
();
auto
=
memberResult
.
->
();
if
(!
ev
)
{
ev
=
td
->
(
memberResult
.
->
() +
L"Changed"
,
true
);
}
if
(
ev
)
{
(
,
->
.
());
.
.
(
,
ev
);
return
;
}
}
}
(
,
->
.
(),
false
);
}
void
(
*
)
override
{
(
,
->
.
());
}
void
(
*
)
override
{
}
void
(
*
)
override
{
}
void
(
*
)
override
{
}
void
(
*
)
override
{
}
void
(
*
)
override
{
(
,
->
.
());
}
void
(
*
)
override
{
(
,
->
.
());
(
,
->
.
());
}
void
(
*
)
override
{
FOREACH(Ptr<WfLetVariable>, var, node->variables)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
->
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
var
);)
{
(
,
var
.
());
}
(
,
->
.
());
}
void
(
*
)
override
{
(
,
->
.
());
(
,
->
.
());
(
,
->
.
());
}
void
(
*
)
override
{
(
,
->
.
());
(
,
->
.
());
}
void
(
*
)
override
{
(
,
->
.
());
(
,
->
.
());
}
void
(
*
)
override
{
auto
=
->
];
bool
= (
result
.
()->
() ==
::
);
FOREACH(Ptr<WfConstructorArgument>, argument, node->arguments)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
->
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
argument
);)
{
if
(!
isStruct
)
{
(
,
argument
.
());
}
(
,
argument
.
());
}
}
void
(
*
)
override
{
(
,
->
.
());
}
void
(
*
)
override
{
(
,
->
.
());
}
void
(
*
)
override
{
(
,
->
.
());
}
void
(
*
)
override
{
}
void
(
WfTypeOfExpressionExpression
*
)
override
{
}
void
(
*
)
override
{
(
,
->
.
());
(
,
->
.
());
}
void
(
*
)
override
{
(
,
->
.
());
(
,
->
.
());
}
void
(
*
)
override
{
(
->
.
());
(
,
->
.
());
(
->
.
());
FOREACH(Ptr<WfExpression>, eventExpr, node->events)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
->
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
eventExpr
);)
{
auto
=
->
eventExpr
.
()];
.
.
(
,
result
.
);
(
eventExpr
.
());
}
}
void
(
*
)
override
{
(
,
->
.
());
FOREACH(Ptr<WfExpression>, 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
{
}
void
(
*
)
override
{
FOREACH(Ptr<WfExpression>, 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
{
}
void
(
*
)
override
{
(
,
->
.
());
}
void
(
*
)
override
{
(
,
->
.
());
}
};
<
>
(
const
&
)
{
auto
=
<
>();
ref
.
;
return
ref
;
}
class
ExpandObserveExpressionVisitor
:
public
CopyWithExpandVirtualVisitor
{
public
:
&
;
ExpandObserveExpressionVisitor
(
&
)
:
CopyWithExpandVirtualVisitor
(
true
)
, context(
)
{
}
vl
::
<
>
(
vl
::
<
>
)
override
{
return
(
.
(),
);
}
static
<
>
(
*
,
&
,
bool
=
true
)
{
if
(!
)
{
return
nullptr
;
}
{
=
.
GetCachedExpressionIndexRecursively
(
,
false
);
if
(
index
!= -
1
)
{
if
(
)
{
return
(
.
(
index
));
}
else
{
=
.
index
];
}
}
}
ExpandObserveExpressionVisitor
(
);
->
(&
visitor
);
return
visitor
.
.
<
>();
}
void
(
*
)
override
{
auto
=
<
>();
FOREACH(Ptr<WfLetVariable>, var, node->variables)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
<
>>&
= ::
vl
::
collections
::
(
->
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
<
>
;
__foreach_iterator__
.
(
var
);)
{
if
(
.
GetCachedExpressionIndexRecursively
(
var
.
(),
false
) == -
1
)
{
auto
=
<
>();
letVar
.
var
.
;
letVar
(
var
.
(),
);
letExpr
.
(
letVar
);
}
}
if
(
letExpr
.
() ==
0
)
{
(
->
.
(),
);
}
else
{
letExpr
(
->
.
(),
);
letExpr
;
}
}
void
(
*
)
override
{
if
(
->
==
::
)
{
auto
=
<
>();
expr
(
->
);
expr
.
->
.
<
>()
.
;
expr
;
}
else
{
(
->
);
}
}
};
<
>
(
*
)
{
auto
=
->
()->
();
if
(
->
()==
::
&&
valueType
!=
nullptr
)
{
switch
(
(
))
{
case
::
:
{
auto
=
<
>();
intExpr
.
=
L"0"
;
auto
=
<
>();
inferExpr
=
::
;
inferExpr
intExpr
;
inferExpr
(
CreateTypeInfoFromTypeFlag
(
::
).
());
auto
=
<
>();
castExpr
=
::
;
castExpr
inferExpr
;
castExpr
(
);
return
castExpr
;
}
case
::
:
{
auto
=
<
>();
return
stringExpr
;
}
break
;
case
::
:
if
(
->
()->
() ==
nullptr
)
{
auto
=
<
>();
auto
=
<
>();
castExpr
=
::
;
castExpr
ctorExpr
;
castExpr
(
);
return
castExpr
;
}
default
:
{
auto
=
->
();
if
(
td
==
description
::
<
bool
>())
{
auto
=
<
>();
expr
=
::
;
return
expr
;
}
if
(
td
==
description
::
<
>())
{
auto
=
<
>();
return
expr
;
}
else
if
(
td
==
description
::
<
float
>()
||
td
==
description
::
<
double
>())
{
auto
=
<
>();
valueExpr
.
=
L"0"
;
auto
=
<
>();
inferExpr
valueExpr
;
inferExpr
(
);
return
inferExpr
;
}
else
if
(
td
==
description
::
<
>()
||
td
==
description
::
<
>()
||
td
==
description
::
<
>()
||
td
==
description
::
<
>()
||
td
==
description
::
<
>()
||
td
==
description
::
<
>()
||
td
==
description
::
<
>()
||
td
==
description
::
<
>())
{
auto
=
<
>();
valueExpr
.
=
L"0"
;
auto
=
<
>();
inferExpr
valueExpr
;
inferExpr
(
);
return
inferExpr
;
}
else
{
CHECK_FAIL(L"All serializable types should have been handled!");
do
{
throw
(
L"All serializable types should have been handled!"
);}
while
(
0
);
}
}
}
}
else
{
auto
=
<
>();
nullExpr
=
::
;
auto
=
<
>();
inferExpr
nullExpr
;
inferExpr
(
);
return
inferExpr
;
}
}
<
>
(
const
&
,
*
,
<
>
=
nullptr
)
{
auto
=
<
>();
decl
.
;
decl
(
);
decl
?
:
(
);
return
decl
;
}
<
>
CreateWritableVariableStatement
(
const
&
,
*
,
<
>
=
nullptr
)
{
auto
=
<
>();
stat
(
,
,
);
return
stat
;
}
<
>
(
<
>
)
{
<
>();
=
::
;
return
;
}
<
>
(
<
>
)
{
<
>();
=
::
;
return
;
}
<
>
(
*
,
*
,
,
&
)
{
auto
=
.
(
.
GetCachedExpressionIndexRecursively
(
.
],
true
));
if
(
auto
=
dynamic_cast
<
*>(
))
{
if
(
observeExpr
->
==
::
)
{
auto
=
<
>();
expr
(
cacheName
);
expr
.
observeExpr
->
].
<
>()
.
;
return
expr
;
}
else
{
return
ExpandObserveExpressionVisitor
::
(
observeExpr
->
].
(),
);
}
}
else
{
auto
=
.
]
0
]->
();
auto
=
<
>();
expr
(
cacheName
);
expr
.
eventName
;
return
expr
;
}
}
void
CreateBindAttachStatement
(
<
>
,
*
,
*
,
&
,
&
)
{
FOREACH(CallbackInfo, callbackInfo, info.observeCallbackInfos[observe])
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
>&
= ::
vl
::
collections
::
(
.
]);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
;
__foreach_iterator__
.
(
callbackInfo
);)
{
auto
=
<
>();
attach
(
,
,
callbackInfo
.
,
);
attach
(
callbackInfo
.
);
auto
=
<
>();
nullExpr
=
::
;
auto
=
<
>();
protect
attach
;
protect
nullExpr
;
protect
=
::
;
auto
=
<
>();
assign
=
::
;
assign
(
callbackInfo
.
);
assign
protect
;
auto
=
<
>();
stat
assign
;
.
(
stat
);
}
}
void
CreateBindDetachStatement
(
<
>
,
*
,
*
,
&
,
&
)
{
FOREACH(CallbackInfo, callbackInfo, info.observeCallbackInfos[observe])
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
>&
= ::
vl
::
collections
::
(
.
]);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
;
__foreach_iterator__
.
(
callbackInfo
);)
{
auto
=
<
>();
testNull
(
callbackInfo
.
);
testNull
=
::
;
auto
=
<
>();
ifStat
testNull
;
auto
=
<
>();
ifStat
trueBlock
;
.
(
ifStat
);
{
auto
=
<
>();
detach
(
,
,
callbackInfo
.
,
);
detach
(
callbackInfo
.
);
auto
=
<
>();
stat
detach
;
trueBlock
.
(
stat
);
}
{
auto
=
<
>();
nullExpr
=
::
;
auto
=
<
>();
assignExpr
(
callbackInfo
.
);
assignExpr
nullExpr
;
assignExpr
=
::
;
auto
=
<
>();
stat
assignExpr
;
trueBlock
.
(
stat
);
}
}
}
void
CreateBindCacheAssignStatement
(
*
,
<
>
,
*
,
&
)
{
auto
=
.
];
auto
=
.
(
.
GetCachedExpressionIndexRecursively
(
parent
,
true
));
auto
=
<
>();
protect
ExpandObserveExpressionVisitor
::
(
parent
,
,
false
);
protect
(
->
parent
].
.
());
protect
=
::
;
auto
=
<
>();
assign
=
::
;
assign
(
cacheName
);
assign
protect
;
auto
=
<
>();
stat
assign
;
.
(
stat
);
}
<
>
(
*
,
&
,
&
)
{
auto
=
<
>();
func
.
=
L"Open"
;
func
=
::
;
{
auto
=
<
bool
>::
();
func
(
typeInfo
.
());
}
auto
=
<
>();
func
block
;
{
auto
=
<
>();
block
.
(
ifStat
);
{
auto
=
<
>();
notExpr
=
::
;
notExpr
=
(
L"<bind-opened>"
);
ifStat
notExpr
;
}
auto
=
<
>();
ifStat
ifBlock
;
{
auto
=
<
>();
literal
=
::
;
auto
=
<
>();
assign
=
::
;
assign
=
(
L"<bind-opened>"
);
assign
literal
;
auto
=
<
>();
stat
assign
;
ifBlock
.
(
stat
);
}
{
<
>
;
<
*>
;
(
observes
,
.
.
());
<
*>
;
while
(
observes
.
() >
0
)
{
(
freeObserves
,
(
observes
)
.Where([&](
*
)
{
return
!
.
.
().
(
observe
) ||
(
.
observe
])
.
([&](
*
)
{
return
!
observes
.
(
depended
);
});
})
);
FOREACH(WfExpression*, observe, context.orderedObserves)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
*>&
= ::
vl
::
collections
::
(
.
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
*
;
__foreach_iterator__
.
(
observe
);)
{
if
(
freeObserves
.
(
observe
))
{
auto
=
.
GetCachedExpressionIndexRecursively
(
.
observe
],
true
);
if
(!
assignedParents
.
(
parent
))
{
assignedParents
.
(
parent
);
CreateBindCacheAssignStatement
(
,
ifBlock
,
observe
,
);
}
}
}
FOREACH(WfExpression*, observe, freeObserves)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
*>&
= ::
vl
::
collections
::
(
freeObserves
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
*
;
__foreach_iterator__
.
(
observe
);)
{
observes
.
(
observe
);
}
freeObserves
.
();
}
}
{
FOREACH(WfExpression*, observe, context.orderedObserves)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
*>&
= ::
vl
::
collections
::
(
.
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
*
;
__foreach_iterator__
.
(
observe
);)
{
CreateBindAttachStatement
(
ifBlock
,
,
observe
,
,
);
}
}
{
auto
=
<
>();
literal
=
::
;
auto
=
<
>();
returnStat
literal
;
ifBlock
.
(
returnStat
);
}
}
{
auto
=
<
>();
literal
=
::
;
auto
=
<
>();
returnStat
literal
;
block
.
(
returnStat
);
}
return
func
;
}
<
>
(
&
)
{
auto
=
<
>();
func
.
=
L"Update"
;
func
=
::
;
{
auto
=
<
bool
>::
();
func
(
typeInfo
.
());
}
auto
=
<
>();
func
block
;
{
auto
=
<
>();
block
.
(
ifStat
);
{
auto
=
<
>();
notExpr
=
::
;
notExpr
=
(
L"<bind-closed>"
);
auto
=
<
>();
andExpr
=
::
;
andExpr
=
(
L"<bind-opened>"
);
andExpr
notExpr
;
ifStat
andExpr
;
}
auto
=
<
>();
ifStat
ifBlock
;
{
auto
=
(
L"<bind-activator>"
);
auto
=
<
>();
call
=
ref
;
auto
=
<
>();
stat
call
;
ifBlock
.
(
stat
);
}
{
auto
=
<
>();
literal
=
::
;
auto
=
<
>();
returnStat
literal
;
ifBlock
.
(
returnStat
);
}
}
{
auto
=
<
>();
literal
=
::
;
auto
=
<
>();
returnStat
literal
;
block
.
(
returnStat
);
}
return
func
;
}
<
>
(
*
,
&
,
&
)
{
auto
=
<
>();
func
.
=
L"Close"
;
func
=
::
;
{
auto
=
<
bool
>::
();
func
(
typeInfo
.
());
}
auto
=
<
>();
func
block
;
{
auto
=
<
>();
block
.
(
ifStat
);
{
auto
=
<
>();
notExpr
=
::
;
notExpr
=
(
L"<bind-closed>"
);
ifStat
notExpr
;
}
auto
=
<
>();
ifStat
ifBlock
;
{
auto
=
<
>();
literal
=
::
;
auto
=
<
>();
assign
=
::
;
assign
=
(
L"<bind-closed>"
);
assign
literal
;
auto
=
<
>();
stat
assign
;
ifBlock
.
(
stat
);
}
FOREACH(WfExpression*, observe, context.orderedObserves)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
*>&
= ::
vl
::
collections
::
(
.
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
*
;
__foreach_iterator__
.
(
observe
);)
{
CreateBindDetachStatement
(
ifBlock
,
,
observe
,
,
);
}
for
(
=
0
;
i
<
.
.
();
i
++)
{
auto
=
.
(
i
);
auto
=
->
.
i
]].
;
auto
=
<
>();
assign
=
::
;
assign
(
cacheName
);
assign
(
type
.
());
auto
=
<
>();
stat
assign
;
ifBlock
.
(
stat
);
}
for
(
=
0
;
i
<
.
.
();
i
++)
{
auto
=
.
.
()
i
];
auto
=
.
.
()
i
];
auto
=
<
>();
assign
=
::
;
assign
(
cacheName
);
assign
(
result
.
());
auto
=
<
>();
stat
assign
;
ifBlock
.
(
stat
);
}
{
auto
=
<
>();
literal
=
::
;
auto
=
<
>();
returnStat
literal
;
ifBlock
.
(
returnStat
);
}
}
{
auto
=
<
>();
literal
=
::
;
auto
=
<
>();
returnStat
literal
;
block
.
(
returnStat
);
}
return
func
;
}
void
(
*
,
*
)
{
;
(
,
context
).
(
->
.
());
;
auto
=
<
>();
->
newSubscription
;
{
auto
=
<
<
>>::
();
newSubscription
(
typeInfo
.
());
}
{
<
*>
;
auto
= [](
*
)
{
return
([&](
&
)
{
(
observe
,
::
,
writer
);
});
};
FOREACH_INDEXER(WfExpression*, parent, index, context.cachedExprs)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
*>&
= ::
vl
::
collections
::
(
context
.
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
if
(
bool
=
true
)
for
(
=
0
;
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
*
;
__foreach_iterator__
.
(
parent
);
index
++)
{
=
context
.
(
index
);
{
auto
=
->
parent
].
;
newSubscription
.
(
(
(
cacheName
,
elementType
.
())));
}
}
FOREACH_INDEXER(WfExpression*, observe, observeIndex, context.orderedObserves)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
*>&
= ::
vl
::
collections
::
(
context
.
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
if
(
bool
=
true
)
for
(
=
0
;
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
*
;
__foreach_iterator__
.
(
observe
);
observeIndex
++)
{
const
auto
&
=
context
.
observe
];
FOREACH_INDEXER(IEventInfo*, ev, eventIndex, events)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
*>&
= ::
vl
::
collections
::
(
events
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
if
(
bool
=
true
)
for
(
=
0
;
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
*
;
__foreach_iterator__
.
(
ev
);
eventIndex
++)
{
=
L"<bind-handler>"
+
(
observeIndex
) +
L"_"
+
(
eventIndex
);
{
auto
=
<
<
>>::
();
bcInfo
.
.
(
handlerName
,
elementType
);
newSubscription
.
(
(
(
handlerName
,
elementType
.
())));
}
=
L"<bind-callback>"
+
(
observeIndex
) +
L"_"
+
(
eventIndex
);
{
auto
=
(
ev
->
());
bcInfo
.
.
(
callbackName
,
elementType
);
}
;
callbackInfo
.
=
observe
;
callbackInfo
.
=
ev
;
callbackInfo
.
=
eventIndex
;
callbackInfo
.
callbackName
;
callbackInfo
.
handlerName
;
bcInfo
.
.
(
observe
,
callbackInfo
);
}
}
newSubscription
.
(
(
(
L"<bind-opened>"
,
<
bool
>::
().
())));
newSubscription
.
(
(
(
L"<bind-closed>"
,
<
bool
>::
().
())));
{
auto
=
<
>();
func
.
=
L"<bind-activator>"
;
func
=
::
;
func
(
<
void
>::
().
());
auto
=
<
>();
func
block
;
{
auto
=
<
>();
var
.
=
L"<bind-activator-result>"
;
var
ExpandObserveExpressionVisitor
::
(
->
.
(),
context
);
auto
=
<
>();
varStat
var
;
block
.
(
varStat
);
}
{
auto
=
<
>();
call
=
(
L"ValueChanged"
);
call
.
(
(
L"<bind-activator-result>"
));
auto
=
<
>();
stat
call
;
block
.
(
stat
);
}
newSubscription
.
(
(
func
));
}
FOREACH(WfExpression*, observe, context.orderedObserves)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
*>&
= ::
vl
::
collections
::
(
context
.
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
*
;
__foreach_iterator__
.
(
observe
);)
{
FOREACH(CallbackInfo, callbackInfo, bcInfo.observeCallbackInfos[observe])
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
>&
= ::
vl
::
collections
::
(
bcInfo
.
observe
]);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
;
__foreach_iterator__
.
(
callbackInfo
);)
{
auto
=
<
>();
func
.
callbackInfo
.
;
func
=
::
;
{
auto
=
bcInfo
.
callbackInfo
.
]
();
func
(
genericType
->
(
0
));
=
genericType
->
();
for
(
=
1
;
i
<
count
;
i
++)
{
auto
=
<
>();
arg
.
=
L"<bind-callback-argument>"
+
(
i
-
1
);
arg
(
genericType
->
(
i
));
func
.
(
arg
);
}
}
auto
=
<
>();
func
block
;
{
<
*>
;
affected
.
(
observe
);
for
(
=
0
;
i
<
affected
.
();
i
++)
{
auto
=
affected
i
];
=
context
.
.
().
(
current
);
if
(
dependencyIndex
!= -
1
)
{
FOREACH(WfExpression*, affectedObserve, context.observeAffects.GetByIndex(dependencyIndex))
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
*>&
= ::
vl
::
collections
::
(
context
.
.
(
dependencyIndex
));
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
*
;
__foreach_iterator__
.
(
affectedObserve
);)
{
if
(
affectedObserve
&& !
affected
.
(
affectedObserve
))
{
affected
.
(
affectedObserve
);
}
}
}
}
affected
.
(
observe
);
FOREACH(WfExpression*, affectedObserve, From(affected).Reverse())
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
*>&
= ::
vl
::
collections
::
(
(
affected
).Reverse());
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
*
;
__foreach_iterator__
.
(
affectedObserve
);)
{
CreateBindDetachStatement
(
block
,
,
affectedObserve
,
context
,
bcInfo
);
}
{
<
>
;
FOREACH(WfExpression*, affectedObserve, affected)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
*>&
= ::
vl
::
collections
::
(
affected
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
*
;
__foreach_iterator__
.
(
affectedObserve
);)
{
auto
=
context
.
GetCachedExpressionIndexRecursively
(
context
.
affectedObserve
],
true
);
if
(!
assignedParents
.
(
parent
))
{
assignedParents
.
(
parent
);
CreateBindCacheAssignStatement
(
,
block
,
affectedObserve
,
context
);
}
}
}
FOREACH(WfExpression*, affectedObserve, affected)
if
(
bool
=
true
)
for
(
const
::
vl
::
collections
::
<
*>&
= ::
vl
::
collections
::
(
affected
);
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
for
(
*
;
__foreach_iterator__
.
(
affectedObserve
);)
{
CreateBindAttachStatement
(
block
,
,
affectedObserve
,
context
,
bcInfo
);
}
}
{
auto
=
(
L"<bind-activator>"
);
auto
=
<
>();
call
=
ref
;
auto
=
<
>();
stat
call
;
block
.
(
stat
);
}
newSubscription
.
(
(
func
));
}
}
}
newSubscription
.
(
(
(
,
context
,
bcInfo
)));
newSubscription
.
(
(
(
bcInfo
)));
newSubscription
.
(
(
(
,
context
,
bcInfo
)));
}
}
}
}