Skip to content

Commit 4b264c7

Browse files
authored
Update schema_resource_id to directly take resources (#535)
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
1 parent e2fcdfb commit 4b264c7

3 files changed

Lines changed: 13 additions & 13 deletions

File tree

src/compiler/compile.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,9 @@ auto precompile(
7474
-> sourcemeta::blaze::Instructions {
7575
const sourcemeta::core::URI anchor_uri{entry.first.second};
7676
const auto label{sourcemeta::blaze::Evaluator{}.hash(
77-
schema_resource_id(context,
78-
anchor_uri.recompose_without_fragment().value_or("")),
77+
sourcemeta::blaze::schema_resource_id(
78+
context.resources,
79+
anchor_uri.recompose_without_fragment().value_or("")),
7980
std::string{anchor_uri.fragment().value_or("")})};
8081
schema_context.labels.insert(label);
8182

src/compiler/compile_helpers.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,17 @@ inline auto property_relative_dynamic_context() -> DynamicContext {
2929
true};
3030
}
3131

32-
inline auto schema_resource_id(const Context &context,
32+
inline auto schema_resource_id(const std::vector<std::string> &resources,
3333
const std::string &resource) -> std::size_t {
34-
const auto iterator{std::find(context.resources.cbegin(),
35-
context.resources.cend(),
34+
const auto iterator{std::find(resources.cbegin(), resources.cend(),
3635
sourcemeta::core::URI::canonicalize(resource))};
37-
if (iterator == context.resources.cend()) {
36+
if (iterator == resources.cend()) {
3837
assert(resource.empty());
3938
return 0;
4039
}
4140

42-
return 1 + static_cast<std::size_t>(
43-
std::distance(context.resources.cbegin(), iterator));
41+
return 1 +
42+
static_cast<std::size_t>(std::distance(resources.cbegin(), iterator));
4443
}
4544

4645
// Instantiate a value-oriented step with a custom resource
@@ -58,7 +57,7 @@ inline auto make_with_resource(const InstructionIndex type,
5857
{dynamic_context.keyword}),
5958
dynamic_context.base_instance_location,
6059
to_uri(schema_context.relative_pointer, schema_context.base).recompose(),
61-
schema_resource_id(context, resource),
60+
schema_resource_id(context.resources, resource),
6261
value,
6362
{}};
6463
}
@@ -85,7 +84,7 @@ inline auto make(const InstructionIndex type, const Context &context,
8584
{dynamic_context.keyword}),
8685
dynamic_context.base_instance_location,
8786
to_uri(schema_context.relative_pointer, schema_context.base).recompose(),
88-
schema_resource_id(context, schema_context.base.recompose()),
87+
schema_resource_id(context.resources, schema_context.base.recompose()),
8988
std::move(value),
9089
std::move(children)};
9190
}

src/compiler/default_compiler_draft4.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,9 @@ auto compiler_draft4_core_ref(const Context &context,
212212
}
213213

214214
const auto &reference{context.frame.references().at({type, entry.pointer})};
215-
const auto label{
216-
Evaluator{}.hash(schema_resource_id(context, reference.base.value_or("")),
217-
reference.fragment.value_or(""))};
215+
const auto label{Evaluator{}.hash(
216+
schema_resource_id(context.resources, reference.base.value_or("")),
217+
reference.fragment.value_or(""))};
218218

219219
// The label is already registered, so just jump to it
220220
if (schema_context.labels.contains(label) ||

0 commit comments

Comments
 (0)