implement value assignment through TreeMutator

This commit is contained in:
Fischlurch 2016-08-25 18:42:51 +02:00
parent cc91e5bba6
commit 1b6a87324d
3 changed files with 15 additions and 38 deletions

View file

@ -259,8 +259,8 @@ namespace diff{
void
TreeDiffMutatorBinding::__failMismatch (GenNode const& spec, Literal oper)
{
throw error::State(_Fmt("Unable to %s element %s. Current target binding "
"did not match as expected") % oper % spec
throw error::State(_Fmt("Unable to %s element %s. Current shape of target "
"data does not match expectations") % oper % spec
, LUMIERA_ERROR_DIFF_CONFLICT);
}
@ -273,36 +273,13 @@ namespace diff{
void
TreeDiffMutatorBinding::__expect_valid_parent_scope (GenNode::ID const& idi)
{
if (0 == scopeManger_->depth())
throw error::Fatal(_Fmt("Diff application floundered after leaving scope %s; "
"unbalanced nested scopes, diff attempts to pop root.") % idi.getSym()
, LUMIERA_ERROR_DIFF_CONFLICT);
}
/* == Forwarding: mutation primitives == */
bool
TreeDiffMutatorBinding::matchSrc (GenNode const& n)
{
UNIMPLEMENTED("ensure the next source element matches with given spec");
}
void
TreeDiffMutatorBinding::assignElm (GenNode const& n)
{
UNIMPLEMENTED("locate already accepted element and assign given new payload");
}
void
TreeDiffMutatorBinding::open_subScope (GenNode const& n)
{
UNIMPLEMENTED("locate already accepted element and open recursive sub-scope for mutation");
}
void
TreeDiffMutatorBinding::close_subScope()
{
UNIMPLEMENTED("finish and leave sub scope and return to invoking parent scope");
}
/* == Implementation of the list diff application primitives == */
@ -364,7 +341,8 @@ namespace diff{
void
TreeDiffMutatorBinding::set (GenNode const& n)
{
assignElm (n);
if (not treeMutator_->assignElm(n))
__failMismatch (n, "assign");
}
/** open nested scope to apply diff to child object */

View file

@ -327,8 +327,7 @@
if (binding_.isApplicable(spec))
{
Iter target_found = binding_.locate (spec);
return target_found? binding_.assign (*target_found, spec)
: false;
return target_found and binding_.assign (*target_found, spec);
}
else
return PAR::assignElm (spec);
@ -342,8 +341,7 @@
if (binding_.isApplicable(spec))
{
Iter target_found = binding_.locate (spec);
return target_found? binding_.openSub (*target_found, spec.idi, targetBuff)
: false;
return target_found and binding_.openSub (*target_found, spec.idi, targetBuff);
}
else
return PAR::mutateChild (spec, targetBuff);

View file

@ -4243,7 +4243,7 @@
<icon BUILTIN="full-4"/>
<node CREATED="1464305377785" ID="ID_396910166" MODIFIED="1464306126692" TEXT="Vor&#xfc;berlegungen">
<icon BUILTIN="pencil"/>
<node CREATED="1464305417066" FOLDED="true" ID="ID_1059660516" MODIFIED="1464306127933" TEXT="w&#xfc;nschenswert">
<node CREATED="1464305417066" FOLDED="true" ID="ID_1059660516" MODIFIED="1472141092653" TEXT="w&#xfc;nschenswert">
<icon BUILTIN="help"/>
<node CREATED="1464305708891" ID="ID_1184917831" MODIFIED="1464305711647" TEXT="Vorteile">
<node CREATED="1464305431944" ID="ID_426248387" MODIFIED="1464305641440" TEXT="den RecordContentMutator loswerden"/>
@ -4514,7 +4514,7 @@
</node>
<node CREATED="1469544027620" HGAP="38" ID="ID_1475348824" MODIFIED="1469544049582" TEXT="Storage-Probleme" VSHIFT="11">
<icon BUILTIN="messagebox_warning"/>
<node CREATED="1469544055624" ID="ID_390940604" MODIFIED="1469544066153" TEXT="Beobachtung: Template-bloat">
<node CREATED="1469544055624" FOLDED="true" ID="ID_390940604" MODIFIED="1472140990090" TEXT="Beobachtung: Template-bloat">
<icon BUILTIN="stop-sign"/>
<node CREATED="1469544072709" ID="ID_16055877" MODIFIED="1469544083016" TEXT="Ursache: wir generieren die Klasse jedesmal neu"/>
<node CREATED="1469544084220" ID="ID_1247343007" MODIFIED="1469544104909" TEXT="...obwohl keinerlei Bezug zum Target-Typ vorliegt">
@ -4537,7 +4537,7 @@
<arrowlink COLOR="#503382" DESTINATION="ID_48737788" ENDARROW="Default" ENDINCLINATION="8;131;" ID="Arrow_ID_579805576" STARTARROW="None" STARTINCLINATION="535;0;"/>
</node>
</node>
<node CREATED="1469544264955" HGAP="35" ID="ID_366424331" MODIFIED="1469544292540" VSHIFT="16">
<node CREATED="1469544264955" FOLDED="true" HGAP="35" ID="ID_366424331" MODIFIED="1472140986107" VSHIFT="16">
<richcontent TYPE="NODE"><html>
<head>
@ -4656,7 +4656,7 @@
</node>
</node>
</node>
<node CREATED="1469545080826" HGAP="41" ID="ID_268789302" MODIFIED="1469738253120" VSHIFT="17">
<node CREATED="1469545080826" FOLDED="true" HGAP="41" ID="ID_268789302" MODIFIED="1472140983547" VSHIFT="17">
<richcontent TYPE="NODE"><html>
<head>
@ -4828,6 +4828,7 @@
<node CREATED="1472121965308" ID="ID_292673963" MODIFIED="1472121974646" TEXT="Verb delegiert an Mutator-Primitive"/>
<node CREATED="1472121976018" ID="ID_421028989" MODIFIED="1472121995995" TEXT="Fehlerbehandlung anhand R&#xfc;ckgabewert dieser"/>
<node CREATED="1472122015157" ID="ID_151735071" MODIFIED="1472122038334" TEXT="sinnvolle interne Fehler-Funktionen aufbauen"/>
<node CREATED="1472141026525" ID="ID_671819323" MODIFIED="1472141034511" TEXT="Scope-Wechsel"/>
</node>
<node CREATED="1465860740971" ID="ID_1662787747" MODIFIED="1465860752949" TEXT="Unit-Test">
<icon BUILTIN="pencil"/>