qsharp-lang 1.0.27-dev → 1.0.29-dev

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/main.js CHANGED
@@ -31,6 +31,15 @@ export function getCompiler() {
31
31
  }
32
32
  return new Compiler(wasm);
33
33
  }
34
+ export function getProjectLoader(readFile, loadDirectory, getManifest) {
35
+ if (!wasm) {
36
+ wasm = require("../lib/node/qsc_wasm.cjs");
37
+ // Set up logging and telemetry as soon as possible after instantiating
38
+ wasm.initLogging(log.logWithLevel, log.getLogLevel());
39
+ log.onLevelChanged = (level) => wasm?.setLogLevel(level);
40
+ }
41
+ return new wasm.ProjectLoader(readFile, loadDirectory, getManifest);
42
+ }
34
43
  export function getCompilerWorker() {
35
44
  const thisDir = dirname(fileURLToPath(import.meta.url));
36
45
  const worker = new Worker(join(thisDir, "./compiler/worker-node.js"), {
@@ -62,10 +71,10 @@ export function getDebugServiceWorker() {
62
71
  worker.addListener("message", proxy.onMsgFromWorker);
63
72
  return proxy;
64
73
  }
65
- export function getLanguageService() {
74
+ export function getLanguageService(readFile, listDir, getManifest) {
66
75
  if (!wasm)
67
76
  wasm = require("../lib/node/qsc_wasm.cjs");
68
- return new QSharpLanguageService(wasm);
77
+ return new QSharpLanguageService(wasm, readFile, listDir, getManifest);
69
78
  }
70
79
  export function getLanguageServiceWorker() {
71
80
  const thisDir = dirname(fileURLToPath(import.meta.url));
@@ -17,7 +17,7 @@ export default [
17
17
  {
18
18
  "title": "Bell States",
19
19
  "shots": 100,
20
- "code": "/// # Sample\n/// Bell States\n///\n/// # Description\n/// Bell states or EPR pairs are specific quantum states of two qubits\n/// that represent the simplest (and maximal) examples of quantum entanglement.\n///\n/// This Q# program implements the four different Bell states.\nnamespace Sample {\n open Microsoft.Quantum.Diagnostics;\n open Microsoft.Quantum.Measurement;\n\n @EntryPoint()\n operation BellStates() : (Result, Result)[] {\n // Allocate the two qubits that will be used to create a Bell state.\n use register = Qubit[2];\n\n // This array contains a label and a preparation operation for each one\n // of the four Bell states.\n let bellStateTuples = [\n (\"|Φ+〉\", PreparePhiPlus),\n (\"|Φ-〉\", PreparePhiMinus),\n (\"|Ψ+〉\", PreparePsiPlus),\n (\"|Ψ-〉\", PreparePsiMinus)\n ];\n\n // Prepare all Bell states, show them using the `DumpMachine` operation\n // and measure the Bell state qubits.\n mutable measurements = [];\n for (label, prepare) in bellStateTuples {\n prepare(register);\n Message($\"Bell state {label}:\");\n DumpMachine();\n set measurements += [(M(register[0]), M(register[1]))];\n ResetAll(register);\n }\n return measurements;\n }\n\n operation PreparePhiPlus(register : Qubit[]) : Unit {\n ResetAll(register); // |00〉\n H(register[0]); // |+0〉\n CNOT(register[0], register[1]); // 1/sqrt(2)(|00〉 + |11〉)\n }\n\n operation PreparePhiMinus(register : Qubit[]) : Unit {\n ResetAll(register); // |00〉\n H(register[0]); // |+0〉\n Z(register[0]); // |-0〉\n CNOT(register[0], register[1]); // 1/sqrt(2)(|00〉 - |11〉)\n }\n\n operation PreparePsiPlus(register : Qubit[]) : Unit {\n ResetAll(register); // |00〉\n H(register[0]); // |+0〉\n X(register[1]); // |+1〉\n CNOT(register[0], register[1]); // 1/sqrt(2)(|01〉 + |10〉)\n }\n\n operation PreparePsiMinus(register : Qubit[]) : Unit {\n ResetAll(register); // |00〉\n H(register[0]); // |+0〉\n Z(register[0]); // |-0〉\n X(register[1]); // |-1〉\n CNOT(register[0], register[1]); // 1/sqrt(2)(|01〉 - |10〉)\n }\n}\n"
20
+ "code": "/// # Sample\n/// Bell States\n///\n/// # Description\n/// Bell states or EPR pairs are specific quantum states of two qubits\n/// that represent the simplest (and maximal) examples of quantum entanglement.\n///\n/// This Q# program implements the four different Bell states.\nnamespace Sample {\n open Microsoft.Quantum.Diagnostics;\n open Microsoft.Quantum.Measurement;\n\n @EntryPoint()\n operation BellStates() : (Result, Result)[] {\n // Allocate the two qubits that will be used to create a Bell state.\n use register = Qubit[2];\n\n // This array contains a label and a preparation operation for each one\n // of the four Bell states.\n let bellStateTuples = [\n (\"|Φ+〉\", PreparePhiPlus),\n (\"|Φ-〉\", PreparePhiMinus),\n (\"|Ψ+〉\", PreparePsiPlus),\n (\"|Ψ-〉\", PreparePsiMinus)\n ];\n\n // Prepare all Bell states, show them using the `DumpMachine` operation\n // and measure the Bell state qubits.\n mutable measurements = [];\n for (label, prepare) in bellStateTuples {\n prepare(register);\n Message($\"Bell state {label}:\");\n DumpMachine();\n set measurements += [(MResetZ(register[0]), MResetZ(register[1]))];\n }\n return measurements;\n }\n\n operation PreparePhiPlus(register : Qubit[]) : Unit {\n ResetAll(register); // |00〉\n H(register[0]); // |+0〉\n CNOT(register[0], register[1]); // 1/sqrt(2)(|00〉 + |11〉)\n }\n\n operation PreparePhiMinus(register : Qubit[]) : Unit {\n ResetAll(register); // |00〉\n H(register[0]); // |+0〉\n Z(register[0]); // |-0〉\n CNOT(register[0], register[1]); // 1/sqrt(2)(|00〉 - |11〉)\n }\n\n operation PreparePsiPlus(register : Qubit[]) : Unit {\n ResetAll(register); // |00〉\n H(register[0]); // |+0〉\n X(register[1]); // |+1〉\n CNOT(register[0], register[1]); // 1/sqrt(2)(|01〉 + |10〉)\n }\n\n operation PreparePsiMinus(register : Qubit[]) : Unit {\n ResetAll(register); // |00〉\n H(register[0]); // |+0〉\n Z(register[0]); // |-0〉\n X(register[1]); // |-1〉\n CNOT(register[0], register[1]); // 1/sqrt(2)(|01〉 - |10〉)\n }\n}\n"
21
21
  },
22
22
  {
23
23
  "title": "Teleportation",
@@ -32,7 +32,7 @@ export default [
32
32
  {
33
33
  "title": "Random Number Generator",
34
34
  "shots": 1000,
35
- "code": "/// # Sample\n/// Quantum Random Number Generator\n///\n/// # Description\n/// This program implements a quantum random number generator by setting qubits\n/// in superposition and then using the measurement results as random bits.\nnamespace Sample {\n open Microsoft.Quantum.Measurement;\n open Microsoft.Quantum.Intrinsic;\n\n @EntryPoint()\n operation Main() : Result[] {\n // Generate 5-bit random number.\n let nBits = 5;\n return GenerateNRandomBits(nBits);\n }\n\n /// # Summary\n /// Generates N random bits.\n operation GenerateNRandomBits(nBits : Int) : Result[] {\n // Allocate N qubits.\n use register = Qubit[nBits];\n\n // Set the qubits into superposition of 0 and 1 using the Hadamard\n // operation `H`.\n for qubit in register {\n H(qubit);\n }\n\n // At this point each has 50% chance of being measured in the |0〉 state\n // and 50% chance of being measured in the |1〉 state.\n // Measure each qubit and reset them all so they can be safely\n // deallocated.\n let results = MeasureEachZ(register);\n ResetAll(register);\n return results;\n }\n}\n"
35
+ "code": "/// # Sample\n/// Quantum Random Number Generator\n///\n/// # Description\n/// This program implements a quantum random number generator by setting qubits\n/// in superposition and then using the measurement results as random bits.\nnamespace Sample {\n open Microsoft.Quantum.Measurement;\n open Microsoft.Quantum.Intrinsic;\n\n @EntryPoint()\n operation Main() : Result[] {\n // Generate 5-bit random number.\n let nBits = 5;\n return GenerateNRandomBits(nBits);\n }\n\n /// # Summary\n /// Generates N random bits.\n operation GenerateNRandomBits(nBits : Int) : Result[] {\n // Allocate N qubits.\n use register = Qubit[nBits];\n\n // Set the qubits into superposition of 0 and 1 using the Hadamard\n // operation `H`.\n for qubit in register {\n H(qubit);\n }\n\n // At this point each has 50% chance of being measured in the |0〉 state\n // and 50% chance of being measured in the |1〉 state.\n // Measure each qubit and reset them all so they can be safely\n // deallocated.\n let results = MResetEachZ(register);\n return results;\n }\n}\n"
36
36
  },
37
37
  {
38
38
  "title": "Random Number Generator (Advanced)",
@@ -42,7 +42,7 @@ export default [
42
42
  {
43
43
  "title": "Deutsch-Jozsa",
44
44
  "shots": 1,
45
- "code": "/// # Sample\n/// Deutsch–Jozsa algorithm\n///\n/// # Description\n/// Deutsch–Jozsa is a quantum algorithm that determines whether a given Boolean\n/// function 𝑓 is constant (0 on all inputs or 1 on all inputs) or balanced\n/// (1 for exactly half of the input domain and 0 for the other half).\n///\n/// This Q# program implements the Deutsch–Jozsa algorithm.\nnamespace Sample {\n open Microsoft.Quantum.Measurement;\n\n @EntryPoint()\n operation Main() : (Result[], Result[]) {\n // A Boolean function is a function that maps bitstrings to a bit:\n // 𝑓 : {0, 1}^n → {0, 1}.\n\n // We say that 𝑓 is constant if 𝑓(𝑥⃗) = 𝑓(𝑦⃗) for all bitstrings 𝑥⃗ and\n // 𝑦⃗, and that 𝑓 is balanced if 𝑓 evaluates to true for exactly half of\n // its inputs.\n\n // If we are given a function 𝑓 as a quantum operation 𝑈 |𝑥〉|𝑦〉 =\n // |𝑥〉|𝑦 ⊕ 𝑓(𝑥)〉, and are promised that 𝑓 is either constant or is\n // balanced, then the Deutsch–Jozsa algorithm decides between these\n // cases with a single application of 𝑈.\n\n // Here, we demonstrate the use of the Deutsch-Jozsa algorithm by\n // determining the type (constant or balanced) of a couple of functions.\n let balancedResults = DeutschJozsa(SimpleBalancedBoolF, 5);\n let constantResults = DeutschJozsa(SimpleConstantBoolF, 5);\n return (balancedResults, constantResults);\n }\n\n /// # Summary\n /// This operation implements the DeutschJozsa algorithm.\n /// It returns the query register measurement results. If all the measurement\n /// results are `Zero`, the function is constant. If at least one measurement\n /// result is `One`, the function is balanced.\n /// It is assumed that the function is either constant or balanced.\n ///\n /// # Input\n /// ## Uf\n /// A quantum operation that implements |𝑥〉|𝑦〉 ↦ |𝑥〉|𝑦 ⊕ 𝑓(𝑥)〉, where 𝑓 is a\n /// Boolean function, 𝑥 is an 𝑛 bit register and 𝑦 is a single qubit.\n /// ## n\n /// The number of bits in the input register |𝑥〉.\n ///\n /// # Output\n /// An array of measurement results for the query reguster.\n /// All `Zero` measurement results indicate that the function is constant.\n /// At least one `One` measurement result in the array indicates that the\n /// function is balanced.\n ///\n /// # See Also\n /// - For details see Section 1.4.3 of Nielsen & Chuang.\n ///\n /// # References\n /// - [ *Michael A. Nielsen , Isaac L. Chuang*,\n /// Quantum Computation and Quantum Information ]\n /// (http://doi.org/10.1017/CBO9780511976667)\n operation DeutschJozsa(Uf : ((Qubit[], Qubit) => Unit), n : Int) : Result[] {\n // We allocate n + 1 clean qubits. Note that the function `Uf` is defined\n // on inputs of the form (x, y), where x has n bits and y has 1 bit.\n use queryRegister = Qubit[n];\n use target = Qubit();\n\n // The last qubit needs to be flipped so that the function will actually\n // be computed into the phase when Uf is applied.\n X(target);\n\n // Now, a Hadamard transform is applied to each of the qubits.\n H(target);\n // We use a within-apply block to ensure that the Hadamard transform is\n // correctly inverted on the |𝑥〉 register.\n within {\n for q in queryRegister {\n H(q);\n }\n } apply {\n // We apply Uf to the n+1 qubits, computing |𝑥, 𝑦〉 ↦ |𝑥, 𝑦 ⊕ 𝑓(𝑥)〉.\n Uf(queryRegister, target);\n }\n\n // Measure the query register and reset all qubits so they can be safely\n // deallocated.\n let results = MeasureEachZ(queryRegister);\n ResetAll(queryRegister);\n Reset(target);\n return results;\n }\n\n // Simple constant Boolean function\n operation SimpleConstantBoolF(args : Qubit[], target : Qubit) : Unit {\n X(target);\n }\n\n // Simple balanced Boolean function\n operation SimpleBalancedBoolF(args : Qubit[], target : Qubit) : Unit {\n CX(args[0], target);\n }\n}\n\n"
45
+ "code": "/// # Sample\n/// Deutsch–Jozsa algorithm\n///\n/// # Description\n/// Deutsch–Jozsa is a quantum algorithm that determines whether a given Boolean\n/// function 𝑓 is constant (0 on all inputs or 1 on all inputs) or balanced\n/// (1 for exactly half of the input domain and 0 for the other half).\n///\n/// This Q# program implements the Deutsch–Jozsa algorithm.\nnamespace Sample {\n open Microsoft.Quantum.Measurement;\n\n @EntryPoint()\n operation Main() : (Result[], Result[]) {\n // A Boolean function is a function that maps bitstrings to a bit:\n // 𝑓 : {0, 1}^n → {0, 1}.\n\n // We say that 𝑓 is constant if 𝑓(𝑥⃗) = 𝑓(𝑦⃗) for all bitstrings 𝑥⃗ and\n // 𝑦⃗, and that 𝑓 is balanced if 𝑓 evaluates to true for exactly half of\n // its inputs.\n\n // If we are given a function 𝑓 as a quantum operation 𝑈 |𝑥〉|𝑦〉 =\n // |𝑥〉|𝑦 ⊕ 𝑓(𝑥)〉, and are promised that 𝑓 is either constant or is\n // balanced, then the Deutsch–Jozsa algorithm decides between these\n // cases with a single application of 𝑈.\n\n // Here, we demonstrate the use of the Deutsch-Jozsa algorithm by\n // determining the type (constant or balanced) of a couple of functions.\n let balancedResults = DeutschJozsa(SimpleBalancedBoolF, 5);\n let constantResults = DeutschJozsa(SimpleConstantBoolF, 5);\n return (balancedResults, constantResults);\n }\n\n /// # Summary\n /// This operation implements the DeutschJozsa algorithm.\n /// It returns the query register measurement results. If all the measurement\n /// results are `Zero`, the function is constant. If at least one measurement\n /// result is `One`, the function is balanced.\n /// It is assumed that the function is either constant or balanced.\n ///\n /// # Input\n /// ## Uf\n /// A quantum operation that implements |𝑥〉|𝑦〉 ↦ |𝑥〉|𝑦 ⊕ 𝑓(𝑥)〉, where 𝑓 is a\n /// Boolean function, 𝑥 is an 𝑛 bit register and 𝑦 is a single qubit.\n /// ## n\n /// The number of bits in the input register |𝑥〉.\n ///\n /// # Output\n /// An array of measurement results for the query reguster.\n /// All `Zero` measurement results indicate that the function is constant.\n /// At least one `One` measurement result in the array indicates that the\n /// function is balanced.\n ///\n /// # See Also\n /// - For details see Section 1.4.3 of Nielsen & Chuang.\n ///\n /// # References\n /// - [ *Michael A. Nielsen , Isaac L. Chuang*,\n /// Quantum Computation and Quantum Information ]\n /// (http://doi.org/10.1017/CBO9780511976667)\n operation DeutschJozsa(Uf : ((Qubit[], Qubit) => Unit), n : Int) : Result[] {\n // We allocate n + 1 clean qubits. Note that the function `Uf` is defined\n // on inputs of the form (x, y), where x has n bits and y has 1 bit.\n use queryRegister = Qubit[n];\n use target = Qubit();\n\n // The last qubit needs to be flipped so that the function will actually\n // be computed into the phase when Uf is applied.\n X(target);\n\n // Now, a Hadamard transform is applied to each of the qubits.\n H(target);\n // We use a within-apply block to ensure that the Hadamard transform is\n // correctly inverted on the |𝑥〉 register.\n within {\n for q in queryRegister {\n H(q);\n }\n } apply {\n // We apply Uf to the n+1 qubits, computing |𝑥, 𝑦〉 ↦ |𝑥, 𝑦 ⊕ 𝑓(𝑥)〉.\n Uf(queryRegister, target);\n }\n\n // Measure the query register and reset all qubits so they can be safely\n // deallocated.\n let results = MResetEachZ(queryRegister);\n Reset(target);\n return results;\n }\n\n // Simple constant Boolean function\n operation SimpleConstantBoolF(args : Qubit[], target : Qubit) : Unit {\n X(target);\n }\n\n // Simple balanced Boolean function\n operation SimpleBalancedBoolF(args : Qubit[], target : Qubit) : Unit {\n CX(args[0], target);\n }\n}\n\n"
46
46
  },
47
47
  {
48
48
  "title": "Deutsch-Jozsa (Advanced)",
@@ -1,7 +1,7 @@
1
1
  let imports = {};
2
2
  imports['__wbindgen_placeholder__'] = module.exports;
3
3
  let wasm;
4
- const { TextDecoder, TextEncoder } = require(`util`);
4
+ const { TextEncoder, TextDecoder } = require(`util`);
5
5
 
6
6
  const heap = new Array(128).fill(undefined);
7
7
 
@@ -9,32 +9,7 @@ heap.push(undefined, null, true, false);
9
9
 
10
10
  function getObject(idx) { return heap[idx]; }
11
11
 
12
- let heap_next = heap.length;
13
-
14
- function dropObject(idx) {
15
- if (idx < 132) return;
16
- heap[idx] = heap_next;
17
- heap_next = idx;
18
- }
19
-
20
- function takeObject(idx) {
21
- const ret = getObject(idx);
22
- dropObject(idx);
23
- return ret;
24
- }
25
-
26
- function addHeapObject(obj) {
27
- if (heap_next === heap.length) heap.push(heap.length + 1);
28
- const idx = heap_next;
29
- heap_next = heap[idx];
30
-
31
- heap[idx] = obj;
32
- return idx;
33
- }
34
-
35
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
36
-
37
- cachedTextDecoder.decode();
12
+ let WASM_VECTOR_LEN = 0;
38
13
 
39
14
  let cachedUint8Memory0 = null;
40
15
 
@@ -45,13 +20,6 @@ function getUint8Memory0() {
45
20
  return cachedUint8Memory0;
46
21
  }
47
22
 
48
- function getStringFromWasm0(ptr, len) {
49
- ptr = ptr >>> 0;
50
- return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
51
- }
52
-
53
- let WASM_VECTOR_LEN = 0;
54
-
55
23
  let cachedTextEncoder = new TextEncoder('utf-8');
56
24
 
57
25
  const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
@@ -127,6 +95,38 @@ function getFloat64Memory0() {
127
95
  return cachedFloat64Memory0;
128
96
  }
129
97
 
98
+ let heap_next = heap.length;
99
+
100
+ function dropObject(idx) {
101
+ if (idx < 132) return;
102
+ heap[idx] = heap_next;
103
+ heap_next = idx;
104
+ }
105
+
106
+ function takeObject(idx) {
107
+ const ret = getObject(idx);
108
+ dropObject(idx);
109
+ return ret;
110
+ }
111
+
112
+ function addHeapObject(obj) {
113
+ if (heap_next === heap.length) heap.push(heap.length + 1);
114
+ const idx = heap_next;
115
+ heap_next = heap[idx];
116
+
117
+ heap[idx] = obj;
118
+ return idx;
119
+ }
120
+
121
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
122
+
123
+ cachedTextDecoder.decode();
124
+
125
+ function getStringFromWasm0(ptr, len) {
126
+ ptr = ptr >>> 0;
127
+ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
128
+ }
129
+
130
130
  function debugString(val) {
131
131
  // primitive types
132
132
  const type = typeof val;
@@ -192,12 +192,32 @@ function debugString(val) {
192
192
  return className;
193
193
  }
194
194
 
195
- let stack_pointer = 128;
195
+ function makeMutClosure(arg0, arg1, dtor, f) {
196
+ const state = { a: arg0, b: arg1, cnt: 1, dtor };
197
+ const real = (...args) => {
198
+ // First up with a closure we increment the internal reference
199
+ // count. This ensures that the Rust closure environment won't
200
+ // be deallocated while we're invoking it.
201
+ state.cnt++;
202
+ const a = state.a;
203
+ state.a = 0;
204
+ try {
205
+ return f(a, state.b, ...args);
206
+ } finally {
207
+ if (--state.cnt === 0) {
208
+ wasm.__wbindgen_export_2.get(state.dtor)(a, state.b);
196
209
 
197
- function addBorrowedObject(obj) {
198
- if (stack_pointer == 1) throw new Error('out of js stack');
199
- heap[--stack_pointer] = obj;
200
- return stack_pointer;
210
+ } else {
211
+ state.a = a;
212
+ }
213
+ }
214
+ };
215
+ real.original = state;
216
+
217
+ return real;
218
+ }
219
+ function __wbg_adapter_44(arg0, arg1, arg2) {
220
+ wasm.__wbindgen_export_3(arg0, arg1, addHeapObject(arg2));
201
221
  }
202
222
 
203
223
  let cachedUint32Memory0 = null;
@@ -209,13 +229,6 @@ function getUint32Memory0() {
209
229
  return cachedUint32Memory0;
210
230
  }
211
231
 
212
- function passArray32ToWasm0(arg, malloc) {
213
- const ptr = malloc(arg.length * 4, 4) >>> 0;
214
- getUint32Memory0().set(arg, ptr / 4);
215
- WASM_VECTOR_LEN = arg.length;
216
- return ptr;
217
- }
218
-
219
232
  function passArrayJsValueToWasm0(array, malloc) {
220
233
  const ptr = malloc(array.length * 4, 4) >>> 0;
221
234
  const mem = getUint32Memory0();
@@ -226,6 +239,21 @@ function passArrayJsValueToWasm0(array, malloc) {
226
239
  return ptr;
227
240
  }
228
241
 
242
+ let stack_pointer = 128;
243
+
244
+ function addBorrowedObject(obj) {
245
+ if (stack_pointer == 1) throw new Error('out of js stack');
246
+ heap[--stack_pointer] = obj;
247
+ return stack_pointer;
248
+ }
249
+
250
+ function passArray32ToWasm0(arg, malloc) {
251
+ const ptr = malloc(arg.length * 4, 4) >>> 0;
252
+ getUint32Memory0().set(arg, ptr / 4);
253
+ WASM_VECTOR_LEN = arg.length;
254
+ return ptr;
255
+ }
256
+
229
257
  function getArrayJsValueFromWasm0(ptr, len) {
230
258
  ptr = ptr >>> 0;
231
259
  const mem = getUint32Memory0();
@@ -277,20 +305,20 @@ module.exports.git_hash = function() {
277
305
  return getStringFromWasm0(r0, r1);
278
306
  } finally {
279
307
  wasm.__wbindgen_add_to_stack_pointer(16);
280
- wasm.__wbindgen_export_2(deferred1_0, deferred1_1, 1);
308
+ wasm.__wbindgen_export_4(deferred1_0, deferred1_1, 1);
281
309
  }
282
310
  };
283
311
 
284
312
  /**
285
- * @param {string} code
313
+ * @param {(Array<any>)[]} sources
286
314
  * @returns {string}
287
315
  */
288
- module.exports.get_qir = function(code) {
316
+ module.exports.get_qir = function(sources) {
289
317
  let deferred3_0;
290
318
  let deferred3_1;
291
319
  try {
292
320
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
293
- const ptr0 = passStringToWasm0(code, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
321
+ const ptr0 = passArrayJsValueToWasm0(sources, wasm.__wbindgen_export_0);
294
322
  const len0 = WASM_VECTOR_LEN;
295
323
  wasm.get_qir(retptr, ptr0, len0);
296
324
  var r0 = getInt32Memory0()[retptr / 4 + 0];
@@ -308,21 +336,21 @@ module.exports.get_qir = function(code) {
308
336
  return getStringFromWasm0(ptr2, len2);
309
337
  } finally {
310
338
  wasm.__wbindgen_add_to_stack_pointer(16);
311
- wasm.__wbindgen_export_2(deferred3_0, deferred3_1, 1);
339
+ wasm.__wbindgen_export_4(deferred3_0, deferred3_1, 1);
312
340
  }
313
341
  };
314
342
 
315
343
  /**
316
- * @param {string} code
344
+ * @param {(Array<any>)[]} sources
317
345
  * @param {string} params
318
346
  * @returns {string}
319
347
  */
320
- module.exports.get_estimates = function(code, params) {
348
+ module.exports.get_estimates = function(sources, params) {
321
349
  let deferred4_0;
322
350
  let deferred4_1;
323
351
  try {
324
352
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
325
- const ptr0 = passStringToWasm0(code, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
353
+ const ptr0 = passArrayJsValueToWasm0(sources, wasm.__wbindgen_export_0);
326
354
  const len0 = WASM_VECTOR_LEN;
327
355
  const ptr1 = passStringToWasm0(params, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
328
356
  const len1 = WASM_VECTOR_LEN;
@@ -342,7 +370,7 @@ module.exports.get_estimates = function(code, params) {
342
370
  return getStringFromWasm0(ptr3, len3);
343
371
  } finally {
344
372
  wasm.__wbindgen_add_to_stack_pointer(16);
345
- wasm.__wbindgen_export_2(deferred4_0, deferred4_1, 1);
373
+ wasm.__wbindgen_export_4(deferred4_0, deferred4_1, 1);
346
374
  }
347
375
  };
348
376
 
@@ -361,7 +389,7 @@ module.exports.get_library_source_content = function(name) {
361
389
  let v2;
362
390
  if (r0 !== 0) {
363
391
  v2 = getStringFromWasm0(r0, r1).slice();
364
- wasm.__wbindgen_export_2(r0, r1 * 1);
392
+ wasm.__wbindgen_export_4(r0, r1 * 1);
365
393
  }
366
394
  return v2;
367
395
  } finally {
@@ -388,21 +416,21 @@ module.exports.get_hir = function(code) {
388
416
  return getStringFromWasm0(r0, r1);
389
417
  } finally {
390
418
  wasm.__wbindgen_add_to_stack_pointer(16);
391
- wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
419
+ wasm.__wbindgen_export_4(deferred2_0, deferred2_1, 1);
392
420
  }
393
421
  };
394
422
 
395
423
  /**
396
- * @param {string} code
424
+ * @param {(Array<any>)[]} sources
397
425
  * @param {string} expr
398
426
  * @param {Function} event_cb
399
427
  * @param {number} shots
400
428
  * @returns {boolean}
401
429
  */
402
- module.exports.run = function(code, expr, event_cb, shots) {
430
+ module.exports.run = function(sources, expr, event_cb, shots) {
403
431
  try {
404
432
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
405
- const ptr0 = passStringToWasm0(code, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
433
+ const ptr0 = passArrayJsValueToWasm0(sources, wasm.__wbindgen_export_0);
406
434
  const len0 = WASM_VECTOR_LEN;
407
435
  const ptr1 = passStringToWasm0(expr, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
408
436
  const len1 = WASM_VECTOR_LEN;
@@ -441,9 +469,13 @@ function handleError(f, args) {
441
469
  try {
442
470
  return f.apply(this, args);
443
471
  } catch (e) {
444
- wasm.__wbindgen_export_3(addHeapObject(e));
472
+ wasm.__wbindgen_export_5(addHeapObject(e));
445
473
  }
446
474
  }
475
+ function __wbg_adapter_145(arg0, arg1, arg2, arg3) {
476
+ wasm.__wbindgen_export_6(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
477
+ }
478
+
447
479
  /**
448
480
  */
449
481
  module.exports.StepResultId = Object.freeze({ BreakpointHit:0,"0":"BreakpointHit",Next:1,"1":"Next",StepIn:2,"2":"StepIn",StepOut:3,"3":"StepOut",Return:4,"4":"Return", });
@@ -477,34 +509,31 @@ class DebugService {
477
509
  return DebugService.__wrap(ret);
478
510
  }
479
511
  /**
480
- * @param {string} path
481
- * @param {string} source
512
+ * @param {(Array<any>)[]} sources
482
513
  * @param {string} target_profile
483
514
  * @param {string | undefined} entry
484
515
  * @returns {string}
485
516
  */
486
- load_source(path, source, target_profile, entry) {
487
- let deferred5_0;
488
- let deferred5_1;
517
+ load_source(sources, target_profile, entry) {
518
+ let deferred4_0;
519
+ let deferred4_1;
489
520
  try {
490
521
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
491
- const ptr0 = passStringToWasm0(path, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
522
+ const ptr0 = passArrayJsValueToWasm0(sources, wasm.__wbindgen_export_0);
492
523
  const len0 = WASM_VECTOR_LEN;
493
- const ptr1 = passStringToWasm0(source, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
524
+ const ptr1 = passStringToWasm0(target_profile, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
494
525
  const len1 = WASM_VECTOR_LEN;
495
- const ptr2 = passStringToWasm0(target_profile, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
496
- const len2 = WASM_VECTOR_LEN;
497
- var ptr3 = isLikeNone(entry) ? 0 : passStringToWasm0(entry, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
498
- var len3 = WASM_VECTOR_LEN;
499
- wasm.debugservice_load_source(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
526
+ var ptr2 = isLikeNone(entry) ? 0 : passStringToWasm0(entry, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
527
+ var len2 = WASM_VECTOR_LEN;
528
+ wasm.debugservice_load_source(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
500
529
  var r0 = getInt32Memory0()[retptr / 4 + 0];
501
530
  var r1 = getInt32Memory0()[retptr / 4 + 1];
502
- deferred5_0 = r0;
503
- deferred5_1 = r1;
531
+ deferred4_0 = r0;
532
+ deferred4_1 = r1;
504
533
  return getStringFromWasm0(r0, r1);
505
534
  } finally {
506
535
  wasm.__wbindgen_add_to_stack_pointer(16);
507
- wasm.__wbindgen_export_2(deferred5_0, deferred5_1, 1);
536
+ wasm.__wbindgen_export_4(deferred4_0, deferred4_1, 1);
508
537
  }
509
538
  }
510
539
  /**
@@ -656,13 +685,28 @@ class LanguageService {
656
685
  wasm.__wbg_languageservice_free(ptr);
657
686
  }
658
687
  /**
659
- * @param {(uri: string, version: number | undefined, diagnostics: VSDiagnostic[]) => void} diagnostics_callback
660
688
  */
661
- constructor(diagnostics_callback) {
662
- const ret = wasm.languageservice_new(addHeapObject(diagnostics_callback));
689
+ constructor() {
690
+ const ret = wasm.languageservice_new();
663
691
  return LanguageService.__wrap(ret);
664
692
  }
665
693
  /**
694
+ * @param {(uri: string, version: number | undefined, diagnostics: VSDiagnostic[]) => void} diagnostics_callback
695
+ * @param {(uri: string) => Promise<string | null>} read_file
696
+ * @param {(uri: string) => Promise<[string, number][]>} list_directory
697
+ * @param {(uri: string) => Promise<{ manifestDirectory: string }| null>} get_manifest
698
+ * @returns {Promise<any>}
699
+ */
700
+ start_background_work(diagnostics_callback, read_file, list_directory, get_manifest) {
701
+ const ret = wasm.languageservice_start_background_work(this.__wbg_ptr, addHeapObject(diagnostics_callback), addHeapObject(read_file), addHeapObject(list_directory), addHeapObject(get_manifest));
702
+ return takeObject(ret);
703
+ }
704
+ /**
705
+ */
706
+ stop_background_work() {
707
+ wasm.languageservice_stop_background_work(this.__wbg_ptr);
708
+ }
709
+ /**
666
710
  * @param {IWorkspaceConfiguration} config
667
711
  */
668
712
  update_configuration(config) {
@@ -748,7 +792,7 @@ class LanguageService {
748
792
  var r0 = getInt32Memory0()[retptr / 4 + 0];
749
793
  var r1 = getInt32Memory0()[retptr / 4 + 1];
750
794
  var v2 = getArrayJsValueFromWasm0(r0, r1).slice();
751
- wasm.__wbindgen_export_2(r0, r1 * 4);
795
+ wasm.__wbindgen_export_4(r0, r1 * 4);
752
796
  return v2;
753
797
  } finally {
754
798
  wasm.__wbindgen_add_to_stack_pointer(16);
@@ -803,11 +847,81 @@ class LanguageService {
803
847
  }
804
848
  }
805
849
  module.exports.LanguageService = LanguageService;
850
+ /**
851
+ * a minimal implementation for interacting with async JS filesystem callbacks to
852
+ * load project files
853
+ */
854
+ class ProjectLoader {
855
+
856
+ static __wrap(ptr) {
857
+ ptr = ptr >>> 0;
858
+ const obj = Object.create(ProjectLoader.prototype);
859
+ obj.__wbg_ptr = ptr;
860
+
861
+ return obj;
862
+ }
863
+
864
+ __destroy_into_raw() {
865
+ const ptr = this.__wbg_ptr;
866
+ this.__wbg_ptr = 0;
867
+
868
+ return ptr;
869
+ }
870
+
871
+ free() {
872
+ const ptr = this.__destroy_into_raw();
873
+ wasm.__wbg_projectloader_free(ptr);
874
+ }
875
+ /**
876
+ * @param {(uri: string) => Promise<string | null>} read_file
877
+ * @param {(uri: string) => Promise<[string, number][]>} list_directory
878
+ * @param {(uri: string) => Promise<{ manifestDirectory: string }| null>} get_manifest
879
+ */
880
+ constructor(read_file, list_directory, get_manifest) {
881
+ const ret = wasm.projectloader_new(addHeapObject(read_file), addHeapObject(list_directory), addHeapObject(get_manifest));
882
+ return ProjectLoader.__wrap(ret);
883
+ }
884
+ /**
885
+ * @param {{ manifestDirectory: string }} manifest
886
+ * @returns {Promise<[string, string][]>}
887
+ */
888
+ load_project(manifest) {
889
+ const ret = wasm.projectloader_load_project(this.__wbg_ptr, addHeapObject(manifest));
890
+ return takeObject(ret);
891
+ }
892
+ }
893
+ module.exports.ProjectLoader = ProjectLoader;
894
+
895
+ module.exports.__wbindgen_string_get = function(arg0, arg1) {
896
+ const obj = getObject(arg1);
897
+ const ret = typeof(obj) === 'string' ? obj : undefined;
898
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
899
+ var len1 = WASM_VECTOR_LEN;
900
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
901
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
902
+ };
903
+
904
+ module.exports.__wbindgen_number_get = function(arg0, arg1) {
905
+ const obj = getObject(arg1);
906
+ const ret = typeof(obj) === 'number' ? obj : undefined;
907
+ getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
908
+ getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
909
+ };
806
910
 
807
911
  module.exports.__wbindgen_object_drop_ref = function(arg0) {
808
912
  takeObject(arg0);
809
913
  };
810
914
 
915
+ module.exports.__wbindgen_cb_drop = function(arg0) {
916
+ const obj = takeObject(arg0).original;
917
+ if (obj.cnt-- == 1) {
918
+ obj.a = 0;
919
+ return true;
920
+ }
921
+ const ret = false;
922
+ return ret;
923
+ };
924
+
811
925
  module.exports.__wbindgen_bigint_from_u64 = function(arg0) {
812
926
  const ret = BigInt.asUintN(64, arg0);
813
927
  return addHeapObject(ret);
@@ -834,15 +948,6 @@ module.exports.__wbindgen_in = function(arg0, arg1) {
834
948
  return ret;
835
949
  };
836
950
 
837
- module.exports.__wbindgen_string_get = function(arg0, arg1) {
838
- const obj = getObject(arg1);
839
- const ret = typeof(obj) === 'string' ? obj : undefined;
840
- var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
841
- var len1 = WASM_VECTOR_LEN;
842
- getInt32Memory0()[arg0 / 4 + 1] = len1;
843
- getInt32Memory0()[arg0 / 4 + 0] = ptr1;
844
- };
845
-
846
951
  module.exports.__wbindgen_number_new = function(arg0) {
847
952
  const ret = arg0;
848
953
  return addHeapObject(ret);
@@ -866,11 +971,21 @@ module.exports.__wbg_stack_3090cd8fd3702c6e = function(arg0, arg1) {
866
971
  getInt32Memory0()[arg0 / 4 + 0] = ptr1;
867
972
  };
868
973
 
974
+ module.exports.__wbindgen_is_null = function(arg0) {
975
+ const ret = getObject(arg0) === null;
976
+ return ret;
977
+ };
978
+
869
979
  module.exports.__wbindgen_is_function = function(arg0) {
870
980
  const ret = typeof(getObject(arg0)) === 'function';
871
981
  return ret;
872
982
  };
873
983
 
984
+ module.exports.__wbindgen_typeof = function(arg0) {
985
+ const ret = typeof getObject(arg0);
986
+ return addHeapObject(ret);
987
+ };
988
+
874
989
  module.exports.__wbindgen_object_clone_ref = function(arg0) {
875
990
  const ret = getObject(arg0);
876
991
  return addHeapObject(ret);
@@ -887,13 +1002,6 @@ module.exports.__wbindgen_boolean_get = function(arg0) {
887
1002
  return ret;
888
1003
  };
889
1004
 
890
- module.exports.__wbindgen_number_get = function(arg0, arg1) {
891
- const obj = getObject(arg1);
892
- const ret = typeof(obj) === 'number' ? obj : undefined;
893
- getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
894
- getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
895
- };
896
-
897
1005
  module.exports.__wbg_getwithrefkey_d1f0d12f1f1b63ea = function(arg0, arg1) {
898
1006
  const ret = getObject(arg0)[getObject(arg1)];
899
1007
  return addHeapObject(ret);
@@ -1015,6 +1123,11 @@ module.exports.__wbg_isArray_4c24b343cb13cfb1 = function(arg0) {
1015
1123
  return ret;
1016
1124
  };
1017
1125
 
1126
+ module.exports.__wbg_push_ca1c26067ef907ac = function(arg0, arg1) {
1127
+ const ret = getObject(arg0).push(getObject(arg1));
1128
+ return ret;
1129
+ };
1130
+
1018
1131
  module.exports.__wbg_instanceof_ArrayBuffer_39ac22089b74fddb = function(arg0) {
1019
1132
  let result;
1020
1133
  try {
@@ -1046,6 +1159,40 @@ module.exports.__wbg_buffer_085ec1f694018c4f = function(arg0) {
1046
1159
  return addHeapObject(ret);
1047
1160
  };
1048
1161
 
1162
+ module.exports.__wbg_new_43f1b47c28813cbd = function(arg0, arg1) {
1163
+ try {
1164
+ var state0 = {a: arg0, b: arg1};
1165
+ var cb0 = (arg0, arg1) => {
1166
+ const a = state0.a;
1167
+ state0.a = 0;
1168
+ try {
1169
+ return __wbg_adapter_145(a, state0.b, arg0, arg1);
1170
+ } finally {
1171
+ state0.a = a;
1172
+ }
1173
+ };
1174
+ const ret = new Promise(cb0);
1175
+ return addHeapObject(ret);
1176
+ } finally {
1177
+ state0.a = state0.b = 0;
1178
+ }
1179
+ };
1180
+
1181
+ module.exports.__wbg_resolve_53698b95aaf7fcf8 = function(arg0) {
1182
+ const ret = Promise.resolve(getObject(arg0));
1183
+ return addHeapObject(ret);
1184
+ };
1185
+
1186
+ module.exports.__wbg_then_f7e06ee3c11698eb = function(arg0, arg1) {
1187
+ const ret = getObject(arg0).then(getObject(arg1));
1188
+ return addHeapObject(ret);
1189
+ };
1190
+
1191
+ module.exports.__wbg_then_b2267541e2a73865 = function(arg0, arg1, arg2) {
1192
+ const ret = getObject(arg0).then(getObject(arg1), getObject(arg2));
1193
+ return addHeapObject(ret);
1194
+ };
1195
+
1049
1196
  module.exports.__wbg_self_1ff1d729e9aae938 = function() { return handleError(function () {
1050
1197
  const ret = self.self;
1051
1198
  return addHeapObject(ret);
@@ -1123,6 +1270,11 @@ module.exports.__wbindgen_memory = function() {
1123
1270
  return addHeapObject(ret);
1124
1271
  };
1125
1272
 
1273
+ module.exports.__wbindgen_closure_wrapper536 = function(arg0, arg1, arg2) {
1274
+ const ret = makeMutClosure(arg0, arg1, 156, __wbg_adapter_44);
1275
+ return addHeapObject(ret);
1276
+ };
1277
+
1126
1278
  const path = require('path').join(__dirname, 'qsc_wasm_bg.wasm');
1127
1279
  const bytes = require('fs').readFileSync(path);
1128
1280