@@ -27,9 +27,10 @@ static auto parse_regex(const std::string &pattern,
2727}
2828
2929static auto
30- relative_schema_location_size (const sourcemeta::blaze::Instruction &step)
30+ relative_schema_location_size (const sourcemeta::blaze::Context &context,
31+ const sourcemeta::blaze::Instruction &step)
3132 -> std::size_t {
32- return step.relative_schema_location .size ();
33+ return context. extra [ step. extra_index ] .relative_schema_location .size ();
3334}
3435
3536static auto
@@ -103,7 +104,8 @@ compile_properties(const sourcemeta::blaze::Context &context,
103104 // we prefer to evaluate smaller subschemas first, in the hope of failing
104105 // earlier without spending a lot of time on other subschemas
105106 if (context.tweaks .properties_reorder ) {
106- std::ranges::sort (properties, [](const auto &left, const auto &right) {
107+ std::ranges::sort (properties, [&context](const auto &left,
108+ const auto &right) {
107109 const auto left_size{recursive_template_size (left.second )};
108110 const auto right_size{recursive_template_size (right.second )};
109111 if (left_size == right_size) {
@@ -118,8 +120,9 @@ compile_properties(const sourcemeta::blaze::Context &context,
118120 // If both options have a direct enumeration, we choose
119121 // the one with the shorter relative schema location
120122 return relative_schema_location_size (
121- left.second .at (left_direct_enumeration.value ())) <
123+ context, left.second .at (left_direct_enumeration.value ())) <
122124 relative_schema_location_size (
125+ context,
123126 right.second .at (right_direct_enumeration.value ()));
124127 } else if (left_direct_enumeration.has_value ()) {
125128 return true ;
@@ -994,39 +997,45 @@ auto compiler_draft4_applicator_properties_with_options(
994997 if (context.mode == Mode::FastValidation && track_evaluation &&
995998 substeps.size () == 1 &&
996999 substeps.front ().type == InstructionIndex::AssertionTypeStrict) {
997- children.push_back (rephrase (sourcemeta::blaze::InstructionIndex::
1000+ children.push_back (rephrase (context,
1001+ sourcemeta::blaze::InstructionIndex::
9981002 AssertionPropertyTypeStrictEvaluate,
9991003 substeps.front ()));
10001004 } else if (context.mode == Mode::FastValidation && track_evaluation &&
10011005 substeps.size () == 1 &&
10021006 substeps.front ().type == InstructionIndex::AssertionType) {
10031007 children.push_back (rephrase (
1008+ context,
10041009 sourcemeta::blaze::InstructionIndex::AssertionPropertyTypeEvaluate,
10051010 substeps.front ()));
10061011 } else if (context.mode == Mode::FastValidation && track_evaluation &&
10071012 substeps.size () == 1 &&
10081013 substeps.front ().type ==
10091014 InstructionIndex::AssertionTypeStrictAny) {
1010- children.push_back (rephrase (sourcemeta::blaze::InstructionIndex::
1015+ children.push_back (rephrase (context,
1016+ sourcemeta::blaze::InstructionIndex::
10111017 AssertionPropertyTypeStrictAnyEvaluate,
10121018 substeps.front ()));
10131019
10141020 // NOLINTBEGIN(bugprone-branch-clone)
10151021 } else if (context.mode == Mode::FastValidation && substeps.size () == 1 &&
10161022 substeps.front ().type ==
10171023 InstructionIndex::AssertionPropertyTypeStrict) {
1018- children.push_back (unroll (
1019- substeps.front (), effective_dynamic_context.base_instance_location ));
1024+ children.push_back (
1025+ unroll (context, substeps.front (),
1026+ effective_dynamic_context.base_instance_location ));
10201027 } else if (context.mode == Mode::FastValidation && substeps.size () == 1 &&
10211028 substeps.front ().type ==
10221029 InstructionIndex::AssertionPropertyType) {
1023- children.push_back (unroll (
1024- substeps.front (), effective_dynamic_context.base_instance_location ));
1030+ children.push_back (
1031+ unroll (context, substeps.front (),
1032+ effective_dynamic_context.base_instance_location ));
10251033 } else if (context.mode == Mode::FastValidation && substeps.size () == 1 &&
10261034 substeps.front ().type ==
10271035 InstructionIndex::AssertionPropertyTypeStrictAny) {
1028- children.push_back (unroll (
1029- substeps.front (), effective_dynamic_context.base_instance_location ));
1036+ children.push_back (
1037+ unroll (context, substeps.front (),
1038+ effective_dynamic_context.base_instance_location ));
10301039 // NOLINTEND(bugprone-branch-clone)
10311040
10321041 } else {
@@ -1608,26 +1617,22 @@ auto compiler_draft4_applicator_items_with_options(
16081617 context, schema_context, dynamic_context, ValueNone{},
16091618 std::move (children))};
16101619 if (std::get<ValueTypedHashes>(value_copy).second .first .size () == 3 ) {
1611- return {Instruction{
1612- .type = sourcemeta::blaze::InstructionIndex::
1613- LoopItemsPropertiesExactlyTypeStrictHash3,
1614- .relative_instance_location = current.relative_instance_location ,
1615- .value = std::move (value_copy),
1616- .children = {},
1617- .relative_schema_location = current.relative_schema_location ,
1618- .keyword_location = current.keyword_location ,
1619- .schema_resource = current.schema_resource }};
1620+ return {Instruction{.type = sourcemeta::blaze::InstructionIndex::
1621+ LoopItemsPropertiesExactlyTypeStrictHash3,
1622+ .relative_instance_location =
1623+ current.relative_instance_location ,
1624+ .value = std::move (value_copy),
1625+ .children = {},
1626+ .extra_index = current.extra_index }};
16201627 }
16211628
1622- return {Instruction{
1623- .type = sourcemeta::blaze::InstructionIndex::
1624- LoopItemsPropertiesExactlyTypeStrictHash,
1625- .relative_instance_location = current.relative_instance_location ,
1626- .value = std::move (value_copy),
1627- .children = {},
1628- .relative_schema_location = current.relative_schema_location ,
1629- .keyword_location = current.keyword_location ,
1630- .schema_resource = current.schema_resource }};
1629+ return {Instruction{.type = sourcemeta::blaze::InstructionIndex::
1630+ LoopItemsPropertiesExactlyTypeStrictHash,
1631+ .relative_instance_location =
1632+ current.relative_instance_location ,
1633+ .value = std::move (value_copy),
1634+ .children = {},
1635+ .extra_index = current.extra_index }};
16311636 }
16321637 }
16331638
0 commit comments