qsharp-lang 0.1.0-dev.1 → 1.0.5-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/README.md CHANGED
@@ -68,7 +68,3 @@ at <src/vs/base/common/cancellation.ts>. This code uses a simplified version of
68
68
 
69
69
  Node.js tests can be run via `node --test` (see
70
70
  <https://nodejs.org/dist/latest-v18.x/docs/api/test.html#test-runner-execution-model>).
71
-
72
- The test module was also added to Node.js v16.17.0, and Electron 22 (which VS Code plans to move to
73
- in first half of 2023) includes v16.17.1, so v16.17 should be our minimum Node.js
74
- version supported (it shipped in Aug 2022).
@@ -9,6 +9,7 @@ export interface ICompiler {
9
9
  checkCode(code: string): Promise<VSDiagnostic[]>;
10
10
  getHir(code: string): Promise<string>;
11
11
  run(code: string, expr: string, shots: number, eventHandler: IQscEventTarget): Promise<void>;
12
+ getQir(code: string): Promise<string>;
12
13
  checkExerciseSolution(user_code: string, exercise_sources: string[], eventHandler: IQscEventTarget): Promise<boolean>;
13
14
  }
14
15
  export type ICompilerWorker = ICompiler & IServiceProxy;
@@ -20,6 +21,7 @@ export declare class Compiler implements ICompiler {
20
21
  * @deprecated use the language service for errors and other editor features.
21
22
  */
22
23
  checkCode(code: string): Promise<VSDiagnostic[]>;
24
+ getQir(code: string): Promise<string>;
23
25
  getHir(code: string): Promise<string>;
24
26
  run(code: string, expr: string, shots: number, eventHandler: IQscEventTarget): Promise<void>;
25
27
  checkExerciseSolution(user_code: string, exercise_sources: string[], eventHandler: IQscEventTarget): Promise<boolean>;
@@ -18,9 +18,12 @@ export class Compiler {
18
18
  const languageService = new this.wasm.LanguageService((uri, version, errors) => {
19
19
  diags = errors;
20
20
  });
21
- languageService.update_document("code", 1, code, true /* exe */);
21
+ languageService.update_document("code", 1, code);
22
22
  return mapDiagnostics(diags, code);
23
23
  }
24
+ async getQir(code) {
25
+ return this.wasm.get_qir(code);
26
+ }
24
27
  async getHir(code) {
25
28
  return this.wasm.get_hir(code);
26
29
  }
@@ -4,6 +4,7 @@ import { createDispatcher, createProxy, } from "../worker-proxy.js";
4
4
  const requests = {
5
5
  checkCode: "request",
6
6
  getHir: "request",
7
+ getQir: "request",
7
8
  run: "requestWithProgress",
8
9
  checkExerciseSolution: "requestWithProgress",
9
10
  };
@@ -45,26 +45,22 @@ export class QSharpDebugService {
45
45
  async evalNext(bps, eventHandler) {
46
46
  const event_cb = (msg) => onCompilerEvent(msg, eventHandler);
47
47
  const ids = new Uint32Array(bps);
48
- const result = this.debugService.eval_next(event_cb, ids);
49
- return { id: result.id, value: result.value };
48
+ return this.debugService.eval_next(event_cb, ids);
50
49
  }
51
50
  async evalStepIn(bps, eventHandler) {
52
51
  const event_cb = (msg) => onCompilerEvent(msg, eventHandler);
53
52
  const ids = new Uint32Array(bps);
54
- const result = this.debugService.eval_step_in(event_cb, ids);
55
- return { id: result.id, value: result.value };
53
+ return this.debugService.eval_step_in(event_cb, ids);
56
54
  }
57
55
  async evalStepOut(bps, eventHandler) {
58
56
  const event_cb = (msg) => onCompilerEvent(msg, eventHandler);
59
57
  const ids = new Uint32Array(bps);
60
- const result = this.debugService.eval_step_out(event_cb, ids);
61
- return { id: result.id, value: result.value };
58
+ return this.debugService.eval_step_out(event_cb, ids);
62
59
  }
63
60
  async evalContinue(bps, eventHandler) {
64
61
  const event_cb = (msg) => onCompilerEvent(msg, eventHandler);
65
62
  const ids = new Uint32Array(bps);
66
- const result = this.debugService.eval_continue(event_cb, ids);
67
- return { id: result.id, value: result.value };
63
+ return this.debugService.eval_continue(event_cb, ids);
68
64
  }
69
65
  async getBreakpoints(path) {
70
66
  const breakpoint_list = this.debugService.get_breakpoints(path);
@@ -75,35 +71,20 @@ export class QSharpDebugService {
75
71
  positions.push(span.hi);
76
72
  });
77
73
  const positionMap = mapUtf8UnitsToUtf16Units(positions, this.code[path]);
78
- const breakpoint_spans = breakpoint_list.spans.map((span) => {
79
- const result = {};
80
- result.id = span.id;
81
- result.lo = positionMap[span.lo];
82
- result.hi = positionMap[span.hi];
83
- return result;
84
- });
74
+ const breakpoint_spans = breakpoint_list.spans.map((span) => ({
75
+ id: span.id,
76
+ lo: positionMap[span.lo],
77
+ hi: positionMap[span.hi],
78
+ }));
85
79
  return breakpoint_spans;
86
80
  }
87
81
  async captureQuantumState() {
88
82
  const state = this.debugService.capture_quantum_state();
89
- const entries = state.entries.map((entry) => {
90
- const result = {};
91
- result.name = entry.name;
92
- result.value = entry.value;
93
- return result;
94
- });
95
- return entries;
83
+ return state.entries;
96
84
  }
97
85
  async getLocalVariables() {
98
86
  const variable_list = this.debugService.get_locals();
99
- const variables = variable_list.variables.map((variable) => {
100
- const result = {};
101
- result.name = variable.name;
102
- result.value = variable.value;
103
- result.var_type = variable.var_type;
104
- return result;
105
- });
106
- return variables;
87
+ return variable_list.variables;
107
88
  }
108
89
  async dispose() {
109
90
  this.debugService.free();