Skip to content

Commit

Permalink
check if default bank was used before creating new banks
Browse files Browse the repository at this point in the history
  • Loading branch information
hlorenzi committed Oct 6, 2020
1 parent 848666e commit c85b242
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/asm/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,15 @@ impl State
report: diagn::RcReport)
-> Result<(), ()>
{
if self.banks.len() > 0 && self.bankdata[0].cur_bit_offset != 0
{
report.error_span(
"cannot create new bank if the default bank has already been used",
&bank.decl_span.as_ref().unwrap());

return Err(());
}

if bank.output_offset.is_some()
{
for j in 1..self.banks.len()
Expand Down
20 changes: 20 additions & 0 deletions tests/bank_default.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
; :::

#d8 1, 2, 3, 4 ; = 0x01020304

; :::

#d8 1, 2, 3, 4
#bankdef a_new_bank {} ; error: default bank

; :::

#res 4
#bankdef a_new_bank {} ; error: default bank

; :::

x = 0x25
label:
#bankdef a_new_bank {}
; = 0x
Binary file modified web/customasm.gc.wasm
Binary file not shown.

0 comments on commit c85b242

Please sign in to comment.