Skip to content

Commit

Permalink
fix: wasm build condition
Browse files Browse the repository at this point in the history
  • Loading branch information
Chronostasys committed Sep 27, 2023
1 parent b62dc34 commit 70906c7
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/ast/node/string_literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ impl Node for StringNode {

builder.build_store(
len,
builder.int_value(
&PriType::I64,
vm::count_utf8_char(&self.content) as u64,
true,
),
builder.int_value(&PriType::I64, count_utf8_char(&self.content), true),
);
builder.build_store(
byte_len,
Expand All @@ -59,3 +55,13 @@ impl Node for StringNode {
alloca.new_output(tp.tp).set_const().to_result()
}
}

#[cfg(feature = "vm")]
fn count_utf8_char(s: &str) -> u64 {
vm::count_utf8_char(s) as u64
}

#[cfg(not(feature = "vm"))]
fn count_utf8_char(s: &str) -> u64 {
0
}

0 comments on commit 70906c7

Please sign in to comment.