Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ jobs:
python3 -m unittest tools.test_check_case_sources tools.test_case_execution tools.test_case_manifest tools.test_test_contracts tools.test_process_tree tools.test_check_msvc_native

- name: Build release compiler
id: release_build
run: cargo build --locked --release --verbose

- name: Run Rust tests
Expand Down Expand Up @@ -381,7 +382,7 @@ jobs:
--features llvm-target-core64 --jobs 2

- name: Verify bundled Linux CRT matrix
if: ${{ always() }}
if: ${{ !cancelled() && steps.release_build.outcome == 'success' }}
run: |
set -euo pipefail

Expand Down Expand Up @@ -430,7 +431,7 @@ jobs:
aarch64_shared_language_workloads_run_under_qemu --jobs 2

- name: Run RISC-V networking contracts under QEMU
if: ${{ always() }}
if: ${{ !cancelled() && steps.release_build.outcome == 'success' }}
run: |
set -euo pipefail

Expand Down Expand Up @@ -861,7 +862,7 @@ jobs:
env:
WAVE_RUNTIME_ARTIFACT_DIR: ${{ runner.temp }}
run: >-
cargo test --locked --no-fail-fast --test runtime_regressions --test std_io_regressions --test native_providers --test stabilization_17 --test native_boundaries --target aarch64-pc-windows-msvc
cargo test --locked --no-fail-fast --test runtime_regressions --test std_io_regressions --test native_providers --test stabilization_17 --test native_boundaries --test release_constants --target aarch64-pc-windows-msvc
--no-default-features --features llvm-target-aarch64 --jobs 2

- name: Save failed native runtime compiler and fixture
Expand Down Expand Up @@ -1019,7 +1020,7 @@ jobs:
WAVE_RUN_WASM_RUNTIME_TESTS: "1"
run: >-
cargo test --locked --no-default-features --features llvm-target-wasm
--test stabilization_17 webassembly_ --jobs 2
--test stabilization_17 --test release_constants webassembly_ --jobs 2

- name: Build and run browser and WASI modules
run: |
Expand Down
54 changes: 54 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// SPDX-License-Identifier: MPL-2.0
use std::{env, path::Path, process::Command};

fn git(args: &[&str]) -> Option<String> {
let result = Command::new("git").args(args).output().ok()?;
result
.status
.success()
.then(|| String::from_utf8_lossy(&result.stdout).trim().to_owned())
}
fn main() {
println!("cargo:rerun-if-env-changed=WAVE_STD_REVISION");
// Track both detached HEAD and branch ref changes, including worktrees.
for path in [
git(&["rev-parse", "--git-path", "HEAD"]),
git(&["rev-parse", "--git-path", "packed-refs"]),
]
.into_iter()
.flatten()
{
println!("cargo:rerun-if-changed={path}");
}
if let Some(reference) = git(&["symbolic-ref", "-q", "HEAD"]) {
if let Some(path) = git(&["rev-parse", "--git-path", &reference]) {
println!("cargo:rerun-if-changed={path}");
}
}
// Source archives can supply the original immutable commit explicitly.
let revision = env::var("WAVE_STD_REVISION")
.ok()
.or_else(|| {
// Do not accidentally record an enclosing, unrelated repository.
let root = git(&["rev-parse", "--show-toplevel"])?;
if Path::new(&root).canonicalize().ok()?
!= Path::new(&env::var("CARGO_MANIFEST_DIR").ok()?)
.canonicalize()
.ok()?
{
return None;
}
git(&["rev-parse", "--verify", "HEAD"])
})
.unwrap_or_default();
assert!(
revision.is_empty()
|| ((revision.len() == 40 || revision.len() == 64)
&& revision.bytes().all(|c| c.is_ascii_hexdigit())),
"WAVE_STD_REVISION must be a full Git commit ID"
);
if revision.is_empty() {
println!("cargo:warning=No std revision recorded; set WAVE_STD_REVISION when building source archives or use install std --ref");
}
println!("cargo:rustc-env=WAVE_BUNDLED_STD_REVISION={revision}");
}
23 changes: 17 additions & 6 deletions front/hir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub mod async_lower;
pub mod conversions;
mod numeric_checks;
use conversions::{ConversionError, NumericExpressionInfo};
pub use numeric_checks::{integer_literal_float, ConstantValue};
use parser::ast::visit::{walk_expression, walk_node, walk_nodes};

use parser::ast::{ASTNode, Expression, MatchPattern, StatementNode, WaveType};
Expand Down Expand Up @@ -82,6 +83,7 @@ pub struct TypedProgram {
expression_types: Vec<HirExpressionType>,
expected_types: Vec<Option<WaveType>>,
numeric_expressions: Vec<Option<NumericExpressionInfo>>,
constant_values: HashMap<ExpressionId, ConstantValue>,
expression_spans: Vec<Option<error::SourceSpan>>,
variant_constructions: Vec<Option<HirVariantConstruction>>,
pattern_ids: HashMap<usize, PatternId>,
Expand Down Expand Up @@ -196,6 +198,7 @@ impl TypedProgram {
expression_types,
expected_types,
numeric_expressions: Vec::new(),
constant_values: HashMap::new(),
expression_spans,
variant_constructions,
pattern_ids,
Expand All @@ -204,15 +207,23 @@ impl TypedProgram {
pattern_spans,
};
program.numeric_expressions = conversions::build(&program);
if let Err(diagnostic) = numeric_checks::validate(&program) {
return Err(HirLoweringError {
syntax: program.syntax,
diagnostic,
});
}
program.constant_values = match numeric_checks::validate(&program) {
Ok(values) => values,
Err(diagnostic) => {
return Err(HirLoweringError {
syntax: program.syntax,
diagnostic,
})
}
};
Ok(program)
}

pub fn constant_value_of(&self, expression: &Expression) -> Option<&ConstantValue> {
self.expression_id(expression)
.and_then(|id| self.constant_values.get(&id))
}

pub fn numeric_expression(&self, id: ExpressionId) -> Option<&NumericExpressionInfo> {
self.numeric_expressions
.get(id.index())
Expand Down
Loading
Loading