@@ -386,7 +386,7 @@ define private %Stack @reset(%Stack %oldStack) {
386
386
ret %Stack %stack
387
387
}
388
388
389
- define private void @updatePrompts (%Stack %stack ) {
389
+ define private void @revalidate (%Stack %stack ) {
390
390
%prompt_pointer = getelementptr %StackValue , %Stack %stack , i64 0 , i32 3
391
391
%prompt = load %Prompt , ptr %prompt_pointer
392
392
%stack_pointer = getelementptr %PromptValue , %Prompt %prompt , i64 0 , i32 1
@@ -402,42 +402,52 @@ continue:
402
402
br i1 %isOccupied , label %displace , label %update
403
403
404
404
displace:
405
- call void @displace (%Stack %promptStack , %Stack %promptStack )
405
+ call void @invalidate (%Stack %promptStack , %Stack %promptStack )
406
406
br label %update
407
407
408
408
update:
409
409
store %Stack %stack , ptr %stack_pointer
410
410
411
411
%next_pointer = getelementptr %StackValue , %Stack %stack , i64 0 , i32 4
412
412
%next = load %Stack , ptr %next_pointer
413
- tail call void @updatePrompts (%Stack %next )
413
+ tail call void @revalidate (%Stack %next )
414
414
ret void
415
415
}
416
416
417
- define private void @displace (%Stack %stack , %Stack %end ) {
417
+ ; This panics if we invalidate the meta stack
418
+ define private void @invalidate (%Stack %stack , %Stack %end ) {
418
419
%prompt_pointer = getelementptr %StackValue , %Stack %stack , i64 0 , i32 3
419
420
%next_pointer = getelementptr %StackValue , %Stack %stack , i64 0 , i32 4
420
421
%prompt = load %Prompt , ptr %prompt_pointer
421
422
%stack_pointer = getelementptr %PromptValue , %Prompt %prompt , i64 0 , i32 1
422
423
store %Stack null , ptr %stack_pointer
423
424
424
425
%next = load %Stack , ptr %next_pointer
426
+
427
+ %isNull = icmp eq %Stack %next , null
428
+ br i1 %isNull , label %error , label %check
429
+
430
+ error:
431
+ call void @duplicated_prompt ()
432
+ ret void
433
+
434
+ check:
425
435
%isEnd = icmp eq %Stack %next , %end
426
436
br i1 %isEnd , label %done , label %continue
427
437
428
438
done:
429
439
ret void
430
440
431
441
continue:
432
- tail call void @displace (%Stack %next , %Stack %end )
442
+ tail call void @invalidate (%Stack %next , %Stack %end )
433
443
ret void
434
444
}
435
445
436
446
define private %Stack @resume (%Resumption %resumption , %Stack %oldStack ) {
437
447
%uniqueResumption = call %Resumption @uniqueStack (%Resumption %resumption )
438
448
%rest_pointer = getelementptr %StackValue , %Resumption %uniqueResumption , i64 0 , i32 4
439
449
%start = load %Stack , ptr %rest_pointer
440
- call void @updatePrompts (%Stack %start )
450
+ call void @revalidate (%Stack %start )
441
451
442
452
store %Stack %oldStack , ptr %rest_pointer
443
453
0 commit comments