mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
SyntaxParser: set up a C API to get a hash value indicating the node declaration set
To ensure SwiftSyntax calls a compatible parser library, this patch sets up a C API that returns a constant string calculated during compilation time to indicate the version of syntax node declarations. The same hash will be calculated in the SwiftSyntax (client) side as well by using the same algorithm. During runtime, SwiftSyntax will verify its hash value is identical to the result of calling swiftparse_node_declaration_hash before actual parsing happens. This patch only sets the API up. The actual implementation of the hashing algorithm will come later.
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include "swift/Parse/Parser.h"
|
||||
#include "swift/Parse/SyntaxParseActions.h"
|
||||
#include "swift/Syntax/Serialization/SyntaxSerialization.h"
|
||||
#include "swift/Syntax/SyntaxNodes.h"
|
||||
#include "swift/Subsystems.h"
|
||||
#include <Block.h>
|
||||
|
||||
@@ -230,3 +231,7 @@ swiftparse_parse_string(swiftparse_parser_t c_parser, const char *source) {
|
||||
SynParser *parser = static_cast<SynParser*>(c_parser);
|
||||
return parser->parse(source);
|
||||
}
|
||||
|
||||
const char* swiftparse_syntax_structure_versioning_identifier(void) {
|
||||
return getSyntaxStructureVersioningIdentifier();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user