microsoft/qdk

Public

mirrored fromhttps://github.com/microsoft/qdkAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v1.1.3

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

compiler/qsc_eval/src/debug.rs

57lines · modecode

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4use qsc_data_structures::span::Span;
5
6use crate::val::FunctorApp;
7use qsc_fir::fir;
8use qsc_fir::fir::{PackageId, StoreItemId};
9use qsc_hir::hir;
10
11#[derive(Clone, Copy, Debug, PartialEq)]
12pub struct Frame {
13 pub span: Span,
14 pub id: StoreItemId,
15 pub caller: PackageId,
16 pub functor: FunctorApp,
17}
18
19#[derive(Debug, Default, Clone, PartialEq)]
20pub struct CallStack {
21 frames: Vec<Frame>,
22}
23
24impl CallStack {
25 #[must_use]
26 pub fn is_empty(&self) -> bool {
27 self.frames.is_empty()
28 }
29
30 #[must_use]
31 pub fn len(&self) -> usize {
32 self.frames.len()
33 }
34
35 #[must_use]
36 pub fn into_frames(self) -> Vec<Frame> {
37 self.frames
38 }
39
40 pub fn push_frame(&mut self, frame: Frame) {
41 self.frames.push(frame);
42 }
43
44 pub fn pop_frame(&mut self) -> Option<Frame> {
45 self.frames.pop()
46 }
47}
48
49#[must_use]
50pub fn map_hir_package_to_fir(package: hir::PackageId) -> fir::PackageId {
51 fir::PackageId::from(<hir::PackageId as Into<usize>>::into(package))
52}
53
54#[must_use]
55pub fn map_fir_package_to_hir(package: fir::PackageId) -> hir::PackageId {
56 hir::PackageId::from(<fir::PackageId as Into<usize>>::into(package))
57}
58