motoko 3.12.4 → 3.13.0

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/src/ast.ts CHANGED
@@ -19,6 +19,7 @@ export interface Node extends Partial<Source> {
19
19
  parent?: Node | undefined;
20
20
  name: string;
21
21
  type?: string;
22
+ typeRep?: Node,
22
23
  doc?: string;
23
24
  declaration?: Source;
24
25
  args?: AST[];
@@ -64,13 +65,25 @@ export function simplifyAST(ast: CompilerAST, parent?: Node | undefined): AST {
64
65
  }
65
66
  return node;
66
67
  }
68
+ if (ast.name === '@@') {
69
+ type RegionSpan = { name: 'Pos'; args: [string, string] };
70
+ const [file, start, end] = ast.args as [string, RegionSpan, RegionSpan];
71
+ return {
72
+ name: 'Region',
73
+ file,
74
+ start: [+start.args[0], +start.args[1]],
75
+ end: [+end.args[0], +end.args[1]],
76
+ };
77
+ }
67
78
  if (ast.name === ':') {
68
- const [typeAst, type] = ast.args as [CompilerNode, string];
79
+ const [typeAst, type, typeRep] = ast.args as
80
+ [CompilerNode, string, CompilerNode];
69
81
  const node =
70
82
  typeof typeAst === 'string'
71
83
  ? { name: typeAst, parent }
72
84
  : simplifyAST(typeAst, parent);
73
85
  node.type = type;
86
+ node.typeRep = simplifyAST(typeRep, parent);
74
87
  return node;
75
88
  }
76
89
  if (ast.name === '*') {
@@ -90,5 +103,26 @@ export function simplifyAST(ast: CompilerAST, parent?: Node | undefined): AST {
90
103
  enumerable: false,
91
104
  });
92
105
  node.args = simplifyAST(ast.args, node);
106
+ if (parent && ast.name === 'ID') {
107
+ // Inherit properties from parent for convenience.
108
+ Object.defineProperty(node, 'type', {
109
+ get: () => parent.type,
110
+ set: (newType) => parent.type = newType,
111
+ enumerable: true,
112
+ configurable: true,
113
+ });
114
+ Object.defineProperty(node, 'typeRep', {
115
+ get: () => parent.typeRep,
116
+ set: (newTypeRep) => parent.typeRep = newTypeRep,
117
+ enumerable: true,
118
+ configurable: true,
119
+ });
120
+ Object.defineProperty(node, 'doc', {
121
+ get: () => parent.doc,
122
+ set: (newDoc) => parent.doc = newDoc,
123
+ enumerable: true,
124
+ configurable: true,
125
+ });
126
+ }
93
127
  return node;
94
128
  }
package/src/index.ts CHANGED
@@ -207,6 +207,9 @@ export default function wrapMotoko(compiler: Compiler) {
207
207
  setRunStepLimit(limit: number) {
208
208
  invoke('setRunStepLimit', false, [limit]);
209
209
  },
210
+ setTypecheckerCombineSrcs(combineSrcs: boolean) {
211
+ invoke('setTypecheckerCombineSrcs', false, [combineSrcs]);
212
+ },
210
213
  check(path: string): Diagnostic[] {
211
214
  const result = invoke('check', false, [path]);
212
215
  return result.diagnostics;