@shapeshift-labs/frontier-lang-parser 0.3.73 → 0.3.74

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/metadata.js CHANGED
@@ -269,6 +269,7 @@ function mergeResourceGraphBlocks(blocks) {
269
269
  pointerEdgeIds: blocks.flatMap((block) => ids(block.graph?.pointerEdges)),
270
270
  memoryAccessIds: blocks.flatMap((block) => ids(block.graph?.memoryAccesses)),
271
271
  abiBoundaryIds: blocks.flatMap((block) => ids(block.graph?.abiBoundaries)),
272
+ synchronizationEdgeIds: blocks.flatMap((block) => ids(block.graph?.synchronizationEdges)),
272
273
  trapIds: blocks.flatMap((block) => ids(block.graph?.traps)),
273
274
  undefinedBehaviorIds: blocks.flatMap((block) => ids(block.graph?.undefinedBehaviors)),
274
275
  conflictIds: blocks.flatMap((block) => ids(block.graph?.conflicts)),
@@ -287,17 +288,16 @@ function mergeResourceGraphBlocks(blocks) {
287
288
  lifetimeRelationCount: sum(blocks, 'lifetimeRelations'),
288
289
  borrowScopeCount: sum(blocks, 'borrowScopes'),
289
290
  unsafeBoundaryCount: sum(blocks, 'unsafeBoundaries'),
290
- memoryRegionCount: sum(blocks, 'memoryRegions'),
291
- dataLayoutCount: sum(blocks, 'dataLayouts'),
292
- pointerEdgeCount: sum(blocks, 'pointerEdges'),
293
- memoryAccessCount: sum(blocks, 'memoryAccesses'),
294
- abiBoundaryCount: sum(blocks, 'abiBoundaries'),
291
+ memoryRegionCount: sum(blocks, 'memoryRegions'), dataLayoutCount: sum(blocks, 'dataLayouts'),
292
+ pointerEdgeCount: sum(blocks, 'pointerEdges'), memoryAccessCount: sum(blocks, 'memoryAccesses'),
293
+ abiBoundaryCount: sum(blocks, 'abiBoundaries'), synchronizationEdgeCount: sum(blocks, 'synchronizationEdges'),
295
294
  trapCount: sum(blocks, 'traps'),
296
295
  undefinedBehaviorCount: sum(blocks, 'undefinedBehaviors'),
297
296
  lowLevelPrimitiveCount: sum(blocks, 'lowLevelPrimitives'),
298
297
  conflictCount: sum(blocks, 'conflicts'),
299
298
  proofObligationCount: sum(blocks, 'proofObligations'),
300
299
  unsafeBoundariesWithoutProof: sum(blocks, 'unsafeBoundariesWithoutProof'),
300
+ synchronizationEdgeWithoutProofCount: sum(blocks, 'synchronizationEdgesWithoutProof'),
301
301
  failClosedTrapCount: sum(blocks, 'failClosedTraps'),
302
302
  trapWithoutProofCount: sum(blocks, 'trapsWithoutProof'),
303
303
  undefinedBehaviorWithoutProofCount: sum(blocks, 'undefinedBehaviorsWithoutProof')
@@ -4,6 +4,7 @@ export function parseLowLevelResourceRecord(kind, common, name, text) {
4
4
  if (kind === 'pointerEdge') return cleanRecord({ ...common, resourceId: word('resource', text) ?? word('resourceId', text), targetResourceId: word('targetResource', text) ?? word('targetResourceId', text) ?? word('target', text), ownerId: word('owner', text) ?? word('ownerId', text), lifetimeRegionId: word('lifetime', text) ?? word('lifetimeRegion', text) ?? word('lifetimeRegionId', text), pointerKind: word('pointerKind', text) ?? word('kind', text) ?? 'pointer', addressSpace: word('addressSpace', text) ?? word('space', text), pointerWidth: number('pointerWidth', text), aliasKind: word('aliasKind', text), mode: word('mode', text), provenance: word('provenance', text), nullable: flag('nullable', text), mutable: flag('mutable', text) });
5
5
  if (kind === 'memoryAccess') return cleanRecord({ ...common, resourceId: word('resource', text) ?? word('resourceId', text), accessKind: word('accessKind', text) ?? word('kind', text) ?? name, operationKind: word('operation', text) ?? word('operationKind', text), memoryOrder: word('memoryOrder', text) ?? word('ordering', text), lockId: word('lock', text) ?? word('lockId', text), synchronizationKey: word('sync', text) ?? word('synchronizationKey', text), reads: list(text, 'read', 'reads'), writes: list(text, 'write', 'writes'), volatile: flag('volatile', text), atomic: flag('atomic', text), proofStatus: word('proofStatus', text) ?? word('status', text) ?? 'missing' });
6
6
  if (kind === 'abiBoundary') return cleanRecord({ ...common, resourceId: word('resource', text) ?? word('resourceId', text), callableId: word('callable', text) ?? word('callableId', text), functionId: word('function', text) ?? word('functionId', text), boundaryKind: word('boundaryKind', text) ?? word('kind', text) ?? 'abi-boundary', abi: word('abi', text), abiKind: word('abiKind', text), callingConvention: word('callingConvention', text) ?? word('convention', text), pointerWidth: number('pointerWidth', text), endian: word('endian', text) ?? word('endianness', text), ffiBoundary: word('ffiBoundary', text), proofStatus: word('proofStatus', text) ?? word('status', text) ?? 'missing' });
7
+ if (kind === 'synchronizationEdge') return cleanRecord({ ...common, resourceId: word('resource', text) ?? word('resourceId', text), fromMemoryAccessId: word('fromAccess', text) ?? word('fromAccessId', text) ?? word('fromMemoryAccess', text) ?? word('fromMemoryAccessId', text) ?? word('from', text), toMemoryAccessId: word('toAccess', text) ?? word('toAccessId', text) ?? word('toMemoryAccess', text) ?? word('toMemoryAccessId', text) ?? word('to', text), edgeKind: word('edgeKind', text) ?? word('synchronizationKind', text) ?? word('syncKind', text) ?? word('kind', text) ?? name, synchronizationKind: word('synchronizationKind', text) ?? word('syncKind', text) ?? word('edgeKind', text) ?? word('kind', text) ?? name, fenceKind: word('fenceKind', text), memoryScope: word('memoryScope', text) ?? word('barrierScope', text) ?? word('scope', text), memoryOrder: word('memoryOrder', text) ?? word('ordering', text), lockId: word('lock', text) ?? word('lockId', text), synchronizationKey: word('sync', text) ?? word('synchronizationKey', text), channelId: word('channel', text) ?? word('channelId', text), actorId: word('actor', text) ?? word('actorId', text), operationKind: word('operation', text) ?? word('operationKind', text), reasonCode: word('reasonCode', text) ?? word('code', text), condition: quoted('condition', text) ?? word('condition', text), status: word('status', text) ?? 'needs-proof', severity: word('severity', text) ?? 'error', proofStatus: word('proofStatus', text) ?? word('status', text) ?? 'missing', message: quoted('message', text), failClosed: common.failClosed ?? true, semanticEquivalenceClaim: false, runtimeEquivalenceClaim: false });
7
8
  if (kind === 'trap') return cleanRecord({ ...common, resourceId: word('resource', text) ?? word('resourceId', text), ownerId: word('owner', text) ?? word('ownerId', text), loanId: word('loan', text) ?? word('loanId', text), pointerEdgeId: word('pointer', text) ?? word('pointerEdge', text) ?? word('pointerEdgeId', text), memoryAccessId: word('memoryAccess', text) ?? word('memoryAccessId', text), unsafeBoundaryId: word('unsafeBoundary', text) ?? word('unsafeBoundaryId', text), operationKind: word('operation', text) ?? word('operationKind', text), instructionId: word('instruction', text) ?? word('instructionId', text), callableId: word('callable', text) ?? word('callableId', text), trapKind: word('trapKind', text) ?? word('kind', text) ?? name, trapCode: word('trapCode', text) ?? word('code', text), reasonCode: word('reasonCode', text) ?? word('code', text), condition: quoted('condition', text) ?? word('condition', text), status: word('status', text) ?? 'needs-proof', severity: word('severity', text) ?? 'error', proofStatus: word('proofStatus', text) ?? word('status', text) ?? 'missing', message: quoted('message', text), failClosed: common.failClosed ?? true, semanticEquivalenceClaim: false, runtimeEquivalenceClaim: false });
8
9
  if (kind === 'undefinedBehavior') return cleanRecord({ ...common, resourceId: word('resource', text) ?? word('resourceId', text), ownerId: word('owner', text) ?? word('ownerId', text), loanId: word('loan', text) ?? word('loanId', text), pointerEdgeId: word('pointer', text) ?? word('pointerEdge', text) ?? word('pointerEdgeId', text), memoryAccessId: word('memoryAccess', text) ?? word('memoryAccessId', text), unsafeBoundaryId: word('unsafeBoundary', text) ?? word('unsafeBoundaryId', text), operationKind: word('operation', text) ?? word('operationKind', text), undefinedBehaviorKind: word('undefinedBehaviorKind', text) ?? word('behaviorKind', text) ?? word('kind', text) ?? name, language: word('language', text), reasonCode: word('reasonCode', text) ?? word('code', text), condition: quoted('condition', text) ?? word('condition', text), status: word('status', text) ?? 'needs-proof', severity: word('severity', text) ?? 'error', proofStatus: word('proofStatus', text) ?? word('status', text) ?? 'missing', message: quoted('message', text), failClosed: common.failClosed ?? true, semanticEquivalenceClaim: false, runtimeEquivalenceClaim: false });
9
10
  return undefined;
@@ -18,6 +18,7 @@ const GROUPS = {
18
18
  pointerEdge: 'pointerEdges',
19
19
  memoryAccess: 'memoryAccesses',
20
20
  abiBoundary: 'abiBoundaries',
21
+ synchronizationEdge: 'synchronizationEdges',
21
22
  trap: 'traps',
22
23
  undefinedBehavior: 'undefinedBehaviors',
23
24
  conflict: 'conflicts',
@@ -54,6 +55,7 @@ export function parseResourceGraphBlock(block) {
54
55
  pointerEdges: [],
55
56
  memoryAccesses: [],
56
57
  abiBoundaries: [],
58
+ synchronizationEdges: [],
57
59
  traps: [],
58
60
  undefinedBehaviors: [],
59
61
  conflicts: [],
@@ -91,10 +93,11 @@ export function parseResourceGraphBlock(block) {
91
93
  trapIds: ids(graph.traps),
92
94
  undefinedBehaviorIds: ids(graph.undefinedBehaviors),
93
95
  failClosedTrapIds: ids(graph.traps.filter((record) => record.failClosed)),
94
- lowLevelPrimitiveIds: ids([...graph.memoryRegions, ...graph.dataLayouts, ...graph.pointerEdges, ...graph.memoryAccesses, ...graph.abiBoundaries, ...graph.traps, ...graph.undefinedBehaviors]),
96
+ synchronizationEdgeIds: ids(graph.synchronizationEdges),
97
+ lowLevelPrimitiveIds: ids([...graph.memoryRegions, ...graph.dataLayouts, ...graph.pointerEdges, ...graph.memoryAccesses, ...graph.abiBoundaries, ...graph.synchronizationEdges, ...graph.traps, ...graph.undefinedBehaviors]),
95
98
  sourcePaths: unique(allRecords(graph).map((record) => record.sourcePath)),
96
99
  evidenceIds: unique([...graph.evidenceIds, ...allRecords(graph).flatMap((record) => record.evidenceIds ?? [])]),
97
- blockerReasonCodes: unique([...graph.conflicts, ...graph.traps, ...graph.undefinedBehaviors].map((record) => record.reasonCode))
100
+ blockerReasonCodes: unique([...graph.conflicts, ...graph.synchronizationEdges, ...graph.traps, ...graph.undefinedBehaviors].map((record) => record.reasonCode))
98
101
  };
99
102
 
100
103
  return {
@@ -168,9 +171,10 @@ function summarize(graph) {
168
171
  pointerEdges: graph.pointerEdges.length,
169
172
  memoryAccesses: graph.memoryAccesses.length,
170
173
  abiBoundaries: graph.abiBoundaries.length,
174
+ synchronizationEdges: graph.synchronizationEdges.length,
171
175
  traps: graph.traps.length,
172
176
  undefinedBehaviors: graph.undefinedBehaviors.length,
173
- lowLevelPrimitives: graph.memoryRegions.length + graph.dataLayouts.length + graph.pointerEdges.length + graph.memoryAccesses.length + graph.abiBoundaries.length + graph.traps.length + graph.undefinedBehaviors.length,
177
+ lowLevelPrimitives: graph.memoryRegions.length + graph.dataLayouts.length + graph.pointerEdges.length + graph.memoryAccesses.length + graph.abiBoundaries.length + graph.synchronizationEdges.length + graph.traps.length + graph.undefinedBehaviors.length,
174
178
  conflicts: graph.conflicts.length,
175
179
  proofObligations: graph.proofObligations.length,
176
180
  unsafeBoundariesWithoutProof: graph.unsafeBoundaries.filter((record) => record.proofStatus !== 'passed').length,
@@ -178,7 +182,8 @@ function summarize(graph) {
178
182
  trapsWithoutProof: graph.traps.filter((record) => record.proofStatus !== 'passed').length,
179
183
  undefinedBehaviorsWithoutProof: graph.undefinedBehaviors.filter((record) => record.proofStatus !== 'passed').length,
180
184
  parseErrors: graph.parser?.errors?.length ?? 0,
181
- reasonCodes: unique([...graph.conflicts, ...graph.traps, ...graph.undefinedBehaviors].map((record) => record.reasonCode))
185
+ synchronizationEdgesWithoutProof: graph.synchronizationEdges.filter((record) => record.proofStatus !== 'passed').length,
186
+ reasonCodes: unique([...graph.conflicts, ...graph.synchronizationEdges, ...graph.traps, ...graph.undefinedBehaviors].map((record) => record.reasonCode))
182
187
  };
183
188
  }
184
189
 
@@ -200,6 +205,7 @@ function allRecords(graph) {
200
205
  ...graph.pointerEdges,
201
206
  ...graph.memoryAccesses,
202
207
  ...graph.abiBoundaries,
208
+ ...graph.synchronizationEdges,
203
209
  ...graph.traps,
204
210
  ...graph.undefinedBehaviors,
205
211
  ...graph.conflicts,
@@ -217,6 +223,7 @@ function normalizeRowKind(kind) {
217
223
  if (kind === 'pointer' || kind === 'ptr' || kind === 'address') return 'pointerEdge';
218
224
  if (kind === 'access' || kind === 'memoryAccess' || kind === 'atomic' || kind === 'volatile') return 'memoryAccess';
219
225
  if (kind === 'abi' || kind === 'abiBoundary' || kind === 'callBoundary') return 'abiBoundary';
226
+ if (kind === 'sync' || kind === 'synchronization' || kind === 'synchronisation' || kind === 'synchronizationEdge' || kind === 'synchronisationEdge' || kind === 'happensBefore' || kind === 'happens-before' || kind === 'hb' || kind === 'fence' || kind === 'fenceEdge' || kind === 'barrier' || kind === 'barrierEdge') return 'synchronizationEdge';
220
227
  if (kind === 'traps') return 'trap';
221
228
  if (kind === 'undefined' || kind === 'ub' || kind === 'undefinedBehavior' || kind === 'undefinedBehaviour') return 'undefinedBehavior';
222
229
  if (kind === 'proof' || kind === 'obligation' || kind === 'proofObligation') return 'proofObligation';
@@ -233,6 +240,7 @@ function recordKind(kind) {
233
240
  if (kind === 'pointerEdge') return 'pointer-edge';
234
241
  if (kind === 'memoryAccess') return 'memory-access';
235
242
  if (kind === 'abiBoundary') return 'abi-boundary';
243
+ if (kind === 'synchronizationEdge') return 'synchronization-edge';
236
244
  if (kind === 'undefinedBehavior') return 'undefined-behavior';
237
245
  if (kind === 'proofObligation') return 'proof-obligation';
238
246
  return kind;
@@ -16,8 +16,8 @@ export const ROW_SYNTAX_CONFIG = Object.freeze({
16
16
  runtimeCapabilities: rowConfig('runtimeCapabilityRow', 'runtime_capability_row', runtimeRows, normalizeRuntimeCapabilityRow),
17
17
  runtimeCapabilityMatrix: rowConfig('runtimeCapabilityRow', 'runtime_capability_row', runtimeRows, normalizeRuntimeCapabilityRow),
18
18
  runtimeHosts: rowConfig('runtimeCapabilityRow', 'runtime_capability_row', runtimeRows, normalizeRuntimeCapabilityRow),
19
- resourceGraph: rowConfig('resourceGraphRow', 'resource_graph_row', words('resource owner loan alias move drop escape lifetime lifetimeRegion life outlives lifetimeRelation lifeRelation borrow borrowScope borrowRegion unsafe unsafeBoundary memory memoryRegion region layout dataLayout pointer ptr address access memoryAccess atomic volatile abi abiBoundary callBoundary trap traps undefined undefinedBehavior undefinedBehaviour ub conflict proof proofObligation obligation'), normalizeResourceGraphRow),
20
- semanticResourceGraph: rowConfig('resourceGraphRow', 'resource_graph_row', words('resource owner loan alias move drop escape lifetime lifetimeRegion life outlives lifetimeRelation lifeRelation borrow borrowScope borrowRegion unsafe unsafeBoundary memory memoryRegion region layout dataLayout pointer ptr address access memoryAccess atomic volatile abi abiBoundary callBoundary trap traps undefined undefinedBehavior undefinedBehaviour ub conflict proof proofObligation obligation'), normalizeResourceGraphRow),
19
+ resourceGraph: rowConfig('resourceGraphRow', 'resource_graph_row', words('resource owner loan alias move drop escape lifetime lifetimeRegion life outlives lifetimeRelation lifeRelation borrow borrowScope borrowRegion unsafe unsafeBoundary memory memoryRegion region layout dataLayout pointer ptr address access memoryAccess atomic volatile abi abiBoundary callBoundary sync synchronization synchronisation synchronizationEdge synchronisationEdge happensBefore hb fence fenceEdge barrier barrierEdge trap traps undefined undefinedBehavior undefinedBehaviour ub conflict proof proofObligation obligation'), normalizeResourceGraphRow),
20
+ semanticResourceGraph: rowConfig('resourceGraphRow', 'resource_graph_row', words('resource owner loan alias move drop escape lifetime lifetimeRegion life outlives lifetimeRelation lifeRelation borrow borrowScope borrowRegion unsafe unsafeBoundary memory memoryRegion region layout dataLayout pointer ptr address access memoryAccess atomic volatile abi abiBoundary callBoundary sync synchronization synchronisation synchronizationEdge synchronisationEdge happensBefore hb fence fenceEdge barrier barrierEdge trap traps undefined undefinedBehavior undefinedBehaviour ub conflict proof proofObligation obligation'), normalizeResourceGraphRow),
21
21
  applicationSurface: rowConfig('applicationSurfaceRow', 'application_surface_row', appRows, normalizeApplicationSurfaceRow),
22
22
  appHost: rowConfig('applicationSurfaceRow', 'application_surface_row', appRows, normalizeApplicationSurfaceRow),
23
23
  plugin: rowConfig('applicationSurfaceRow', 'application_surface_row', appRows, normalizeApplicationSurfaceRow),
@@ -84,6 +84,7 @@ function normalizeResourceGraphRow(rowKind) {
84
84
  if (rowKind === 'pointer' || rowKind === 'ptr' || rowKind === 'address') return 'pointerEdge';
85
85
  if (rowKind === 'access' || rowKind === 'atomic' || rowKind === 'volatile') return 'memoryAccess';
86
86
  if (rowKind === 'abi' || rowKind === 'callBoundary') return 'abiBoundary';
87
+ if (rowKind === 'sync' || rowKind === 'synchronization' || rowKind === 'synchronisation' || rowKind === 'synchronisationEdge' || rowKind === 'happensBefore' || rowKind === 'hb' || rowKind === 'fence' || rowKind === 'fenceEdge' || rowKind === 'barrier' || rowKind === 'barrierEdge') return 'synchronizationEdge';
87
88
  if (rowKind === 'traps') return 'trap';
88
89
  if (rowKind === 'undefined' || rowKind === 'undefinedBehaviour' || rowKind === 'ub') return 'undefinedBehavior';
89
90
  if (rowKind === 'proof' || rowKind === 'proofObligation') return 'obligation';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shapeshift-labs/frontier-lang-parser",
3
- "version": "0.3.73",
3
+ "version": "0.3.74",
4
4
  "description": "Parser for the first Frontier Lang .frontier syntax slice.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",