-
Notifications
You must be signed in to change notification settings - Fork 85
Expand file tree
/
Copy pathYulPath.ts
More file actions
33 lines (23 loc) · 883 Bytes
/
YulPath.ts
File metadata and controls
33 lines (23 loc) · 883 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { NonterminalKind } from '@nomicfoundation/slang/cst';
import { doc } from 'prettier';
import { getNodeMetadata } from '../slang-utils/metadata.js';
import { YulIdentifier } from './YulIdentifier.js';
import type * as ast from '@nomicfoundation/slang/ast';
import type { AstPath, Doc } from 'prettier';
import type { PrintFunction, SlangNode } from '../types.d.ts';
const { join } = doc.builders;
export class YulPath implements SlangNode {
readonly kind = NonterminalKind.YulPath;
comments;
loc;
items: YulIdentifier[];
constructor(ast: ast.YulPath) {
const metadata = getNodeMetadata(ast, true);
this.items = ast.items.map((item) => new YulIdentifier(item));
this.comments = metadata.comments;
this.loc = metadata.loc;
}
print(path: AstPath<YulPath>, print: PrintFunction): Doc {
return join('.', path.map(print, 'items'));
}
}