-
-
Notifications
You must be signed in to change notification settings - Fork 0
Upgrade Core and Blaze #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| vendorpull https://github.com/sourcemeta/vendorpull 1dcbac42809cf87cb5b045106b863e17ad84ba02 | ||
| core https://github.com/sourcemeta/core b6640a840bf149edca223c9129a71d64474e12fc | ||
| core https://github.com/sourcemeta/core c43332629d71475f44d212f140effbf0a46c1492 | ||
| blaze https://github.com/sourcemeta/blaze b97dc7b6dca47917f40ff465efa5e068e16e8534 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| if(NOT Blaze_FOUND) | ||
| if(CODEGEN_INSTALL) | ||
| set(SOURCEMETA_BLAZE_INSTALL ON CACHE BOOL "enable installation") | ||
| else() | ||
| set(SOURCEMETA_BLAZE_INSTALL OFF CACHE BOOL "disable installation") | ||
| endif() | ||
|
|
||
| add_subdirectory("${PROJECT_SOURCE_DIR}/vendor/blaze") | ||
| include(Sourcemeta) | ||
| set(Blaze_FOUND ON) | ||
| endif() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,53 @@ | ||
| #include <sourcemeta/blaze/alterschema.h> | ||
| #include <sourcemeta/codegen/ir.h> | ||
| #include <sourcemeta/core/alterschema.h> | ||
|
|
||
| #include <algorithm> // std::ranges::sort | ||
| #include <cassert> // assert | ||
| #include <unordered_set> // std::unordered_set | ||
|
|
||
| #include "ir_default_compiler.h" | ||
|
|
||
| namespace { | ||
|
|
||
| auto is_validation_subschema( | ||
| const sourcemeta::core::SchemaFrame &frame, | ||
| const sourcemeta::core::SchemaFrame::Location &location, | ||
| const sourcemeta::core::SchemaWalker &walker, | ||
| const sourcemeta::core::SchemaResolver &resolver) -> bool { | ||
| if (!location.parent.has_value()) { | ||
| return false; | ||
| } | ||
|
|
||
| const auto &parent{location.parent.value()}; | ||
| if (parent.size() >= location.pointer.size()) { | ||
| return false; | ||
| } | ||
|
|
||
| const auto &keyword_token{location.pointer.at(parent.size())}; | ||
| if (!keyword_token.is_property()) { | ||
| return false; | ||
| } | ||
|
|
||
| const auto parent_location{frame.traverse(parent)}; | ||
| if (!parent_location.has_value()) { | ||
| return false; | ||
| } | ||
|
|
||
| const auto vocabularies{ | ||
| frame.vocabularies(parent_location.value().get(), resolver)}; | ||
| const auto &walker_result{walker(keyword_token.to_property(), vocabularies)}; | ||
| using Type = sourcemeta::core::SchemaKeywordType; | ||
| if (walker_result.type == Type::ApplicatorValueTraverseAnyPropertyKey || | ||
| walker_result.type == Type::ApplicatorValueTraverseAnyItem) { | ||
| return true; | ||
| } | ||
|
|
||
| return is_validation_subschema(frame, parent_location.value().get(), walker, | ||
| resolver); | ||
| } | ||
|
|
||
| } // anonymous namespace | ||
|
|
||
| namespace sourcemeta::codegen { | ||
|
|
||
| auto compile(const sourcemeta::core::JSON &input, | ||
|
|
@@ -25,9 +66,9 @@ auto compile(const sourcemeta::core::JSON &input, | |
| // (2) Canonicalize the schema for easier analysis | ||
| // -------------------------------------------------------------------------- | ||
|
|
||
| sourcemeta::core::SchemaTransformer canonicalizer; | ||
| sourcemeta::core::add(canonicalizer, | ||
| sourcemeta::core::AlterSchemaMode::Canonicalizer); | ||
| sourcemeta::blaze::SchemaTransformer canonicalizer; | ||
| sourcemeta::blaze::add(canonicalizer, | ||
| sourcemeta::blaze::AlterSchemaMode::Canonicalizer); | ||
| [[maybe_unused]] const auto canonicalized{canonicalizer.apply( | ||
| schema, walker, resolver, | ||
| [](const auto &, const auto, const auto, const auto &, | ||
|
|
@@ -67,6 +108,12 @@ auto compile(const sourcemeta::core::JSON &input, | |
| continue; | ||
| } | ||
|
|
||
| // Skip subschemas under validation-only keywords that do not contribute | ||
| // to the type structure (like `contains`) | ||
| if (is_validation_subschema(frame, location, walker, resolver)) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: Skipping all descendants under Prompt for AI agents |
||
| continue; | ||
| } | ||
|
|
||
| const auto &subschema{sourcemeta::core::get(schema, location.pointer)}; | ||
| result.push_back(compiler(schema, frame, location, resolver, subschema)); | ||
| } | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FindBlaze.cmakesetsSOURCEMETA_BLAZE_INSTALL, but the vendored Blaze CMake usesBLAZE_INSTALLto gate install rules/components; this looks likeCODEGEN_INSTALLmay not actually control Blaze’s install behavior as intended.Severity: medium
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.