fetchValue method

void fetchValue(
  1. SourceTree sourceTree,
  2. Type expectedType,
  3. List<Operation<MappingContext>> operations
)

Implementation

void fetchValue(SourceTree sourceTree, Type expectedType, List<Operation<MappingContext>> operations) {
  // recursion

  if (!isRoot) {
    parent!.fetchValue(sourceTree, expectedType, operations);
  }

  // fetch a stored value

  if (fetchProperty == null) {
    // root, no children...

    if (isRoot) {
      fetchProperty = accessor.makeTransformerProperty(false /* write */);
      type = accessor.type;
    }
    else {
      // inner node or leaf

      fetchProperty = PeekValueProperty(
          index: parent!.stackIndex,
          property: accessor.makeTransformerProperty(false /* read */)
      );
      type = accessor.type;
    }

    // in case of inner nodes take the result and remember it

    if (!isLeaf) {
      // store the intermediate result
      stackIndex = sourceTree.stackSize++; // that's my index
      operations.add(Operation(fetchProperty!, PushValueProperty(index: stackIndex)));
    } // if
  }
}