Skip to content

Deep SSOT reflect-cpp adoption: --standard-json-schema, shared CLI/JSON enum tables, and symmetric Yul AST JSON - #3

Open
clockblocker wants to merge 2 commits into
adopt-rfl-nlohmann-jsonfrom
adopt-rfl-ssot-schema-and-yul-ast
Open

clockblocker wants to merge 2 commits into
adopt-rfl-nlohmann-jsonfrom
adopt-rfl-ssot-schema-and-yul-ast

Conversation

@clockblocker

Copy link
Copy Markdown
Owner

Summary

Stacked on adopt-rfl-nlohmann-json, this PR deepens reflect-cpp SSOT adoption across two commits:

Commit 1 (2ff4b2b) — Official --standard-json-schema & shared CLI/Standard-JSON enum SSOT

  • Added shared constexpr option/enum tables with zero <rfl/...> leakage into public headers:
    • libsolidity/interface/DebugSettings.h: c_revertStringsTable + allRevertStringsNames()
    • libsolidity/interface/CompilerStack.h: StopAfterParsing + stopAfterFromString(std::string_view)
    • libsolidity/formal/ModelCheckerSettings.h & libsmtutil/SolverInterface.h: validNames() on ModelCheckerEngine, ModelCheckerExtCalls, ModelCheckerInvariants, ModelCheckerTargets, and smtutil::SMTSolverChoice
    • Wired solc/CommandLineParser.cpp help descriptions and --stop-after parsing to the shared tables (keeping CLI --metadata-hash=swarm distinct from Standard JSON "bzzr1").
  • Upgraded standard_json::StandardInput DTO fields to typed rfl::Literal<...> enums (LanguageLiteral, StopAfterLiteral, EvmVersionLiteral, RevertStringsLiteral, ModelChecker{Engine,ExtCalls,Invariant,Solver,Target}Literal) with static_assert size checks against the SSOT tables, and typed sources as std::optional<std::map<std::string, Json>>.
  • Distinguished rfl::ErrorKind::invalid_value (literal value rejection) vs != invalid_value (type mismatch from rfl::nlohmann::Reader::to_basic_type) in formatRflError() to preserve 100% of golden Standard JSON error messages.
  • Exposed StandardCompiler::inputSchema(util::JsonFormat const&) via rfl::json::to_schema<StandardInput, rfl::NoExtraFields>() and wired solc --standard-json-schema (supporting --pretty-json and --json-indent).

Commit 2 (9d85bf3) — Symmetric Yul AST JSON export, import, and schema SSOT (libyul)

  • Added libyul/AsmJsonSchema.h defining the 16 Yul AST JSON DTO structs plus named recursive tagged unions YulExpression (YulIdentifier, YulLiteral, YulFunctionCall) and YulStatement (11 statements) with inline rfl::Literal<"Yul..."> nodeType{} discriminators (zero synthetic __tagged wrappers in $defs).
  • Added ast_json::Nullable<T> (rfl::Reflector -> std::optional<T>) combined with rfl::DefaultVal for YulVariableDeclaration::value and YulAssignment::value so export always emits "value": null, import accepts omitted/null/expression, and schema emits a valid Draft 2020-12 nullable property with "default": null.
  • Unified libyul/AsmJsonConverter.{h,cpp} (rfl::nlohmann::write + AsmJsonConverter::astJsonSchema() with rfl::NoExtraFields, rfl::VariantsAsOneOf) and libyul/AsmJsonImporter.{h,cpp} (rfl::nlohmann::read<YulBlock>) on the single AsmJsonSchema.h definition while keeping public headers free of <rfl/...> and preserving all semantic Yul assertions.
  • Added test/libyul/AsmJson.cpp (YulAsmJson suite) covering all 15 Yul AST node types, wire-format quirks, astJsonSchema() structure/recursion, and negative import assertions.

Verification

  • soltest --run_test=StandardCompiler -- --no-semantic-tests: 66/66 passed (1,877 assertions)
  • soltest --run_test=CommandLineParserTest -- --no-semantic-tests: 21/21 passed (195 assertions)
  • soltest --run_test=CommandLineInterfaceTest -- --no-semantic-tests: 39/39 passed (372 assertions)
  • soltest --run_test=YulAsmJson -- --no-semantic-tests: 4/4 passed (103 assertions)
  • soltest --run_test=YulParser,YulObjectParser,SolidityInlineAssembly -- --no-semantic-tests: 89/89 passed (465 assertions)
  • soltest --run_test="ASTJSON/*" -- --no-semantic-tests: 71/71 passed (71 assertions — byte-for-byte Yul inline assembly compatibility)
  • solc --standard-json-schema --pretty-json validated against test/cmdlineTests/standard_*/input.json: 145/145 valid JSON inputs pass (0 unexpected failures); 24 expected-JSONError inputs rejected directly by schema.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant