shell: expand set of possible errors
Requires a change to mu.subx, to unify literal strings with generic (addr array _)
This commit is contained in:
parent
d2f2ac59b6
commit
e375f0104c
|
@ -2264,6 +2264,29 @@ test-convert-function-call-with-literal-string-arg:
|
||||||
5d/pop-to-ebp
|
5d/pop-to-ebp
|
||||||
c3/return
|
c3/return
|
||||||
|
|
||||||
|
test-convert-function-call-with-literal-string-arg-and-type-parameter-in-signature:
|
||||||
|
# . prologue
|
||||||
|
55/push-ebp
|
||||||
|
89/<- %ebp 4/r32/esp
|
||||||
|
# setup
|
||||||
|
(clear-stream _test-input-stream)
|
||||||
|
(clear-stream $_test-input-buffered-file->buffer)
|
||||||
|
(clear-stream _test-output-stream)
|
||||||
|
(clear-stream $_test-output-buffered-file->buffer)
|
||||||
|
#
|
||||||
|
(write _test-input-stream "fn foo {\n")
|
||||||
|
(write _test-input-stream " string-func \"abc\"\n")
|
||||||
|
(write _test-input-stream "}\n")
|
||||||
|
(write _test-input-stream "sig string-func in: (addr array _)\n")
|
||||||
|
# convert
|
||||||
|
(convert-mu _test-input-buffered-file _test-output-buffered-file Stderr 0)
|
||||||
|
# no errors
|
||||||
|
# not bothering checking output
|
||||||
|
# . epilogue
|
||||||
|
89/<- %esp 5/r32/ebp
|
||||||
|
5d/pop-to-ebp
|
||||||
|
c3/return
|
||||||
|
|
||||||
test-convert-function-call-with-null-addr:
|
test-convert-function-call-with-null-addr:
|
||||||
# . prologue
|
# . prologue
|
||||||
55/push-ebp
|
55/push-ebp
|
||||||
|
@ -26417,7 +26440,7 @@ type-match?: # def: (addr type-tree), call: (addr type-tree), type-parameters:
|
||||||
# . prologue
|
# . prologue
|
||||||
55/push-ebp
|
55/push-ebp
|
||||||
89/<- %ebp 4/r32/esp
|
89/<- %ebp 4/r32/esp
|
||||||
# if (call is literal and def is numberlike) return true
|
# if call is literal and def is numberlike, return true
|
||||||
{
|
{
|
||||||
$type-match?:check-literal-int:
|
$type-match?:check-literal-int:
|
||||||
(simple-mu-type? *(ebp+0xc) 0) # literal => eax
|
(simple-mu-type? *(ebp+0xc) 0) # literal => eax
|
||||||
|
@ -26429,16 +26452,13 @@ $type-match?:check-literal-int:
|
||||||
b8/copy-to-eax 1/imm32/true
|
b8/copy-to-eax 1/imm32/true
|
||||||
e9/jump $type-match?:end/disp32
|
e9/jump $type-match?:end/disp32
|
||||||
}
|
}
|
||||||
# if (call is literal-string and def is string) return true
|
# if call is literal-string, match against (addr array byte)
|
||||||
{
|
{
|
||||||
$type-match?:check-literal-string:
|
$type-match?:check-literal-string:
|
||||||
(simple-mu-type? *(ebp+0xc) 0x10) # literal-string => eax
|
(simple-mu-type? *(ebp+0xc) 0x10) # literal-string => eax
|
||||||
3d/compare-eax-and 0/imm32/false
|
3d/compare-eax-and 0/imm32/false
|
||||||
74/jump-if-= break/disp8
|
74/jump-if-= break/disp8
|
||||||
(mu-string-type? *(ebp+8)) # => eax
|
(type-component-match? *(ebp+8) Addr-type-string *(ebp+0x10)) # => eax
|
||||||
3d/compare-eax-and 0/imm32/false
|
|
||||||
74/jump-if-= break/disp8
|
|
||||||
b8/copy-to-eax 1/imm32/true
|
|
||||||
e9/jump $type-match?:end/disp32
|
e9/jump $type-match?:end/disp32
|
||||||
}
|
}
|
||||||
$type-match?:baseline:
|
$type-match?:baseline:
|
||||||
|
@ -28795,7 +28815,6 @@ $emit-subx-stmt:primitive:
|
||||||
e9/jump $emit-subx-stmt:end/disp32
|
e9/jump $emit-subx-stmt:end/disp32
|
||||||
}
|
}
|
||||||
# - otherwise emit a call
|
# - otherwise emit a call
|
||||||
# TODO: type-checking
|
|
||||||
$emit-subx-stmt:call:
|
$emit-subx-stmt:call:
|
||||||
(emit-call *(ebp+8) *(ebp+0xc))
|
(emit-call *(ebp+8) *(ebp+0xc))
|
||||||
$emit-subx-stmt:end:
|
$emit-subx-stmt:end:
|
||||||
|
@ -35255,6 +35274,14 @@ Type-addr: # (payload type-tree)
|
||||||
0/imm32/right:null
|
0/imm32/right:null
|
||||||
0/imm32/right:null
|
0/imm32/right:null
|
||||||
|
|
||||||
|
Type-array: # (payload type-tree)
|
||||||
|
0x11/imm32/alloc-id:fake:payload
|
||||||
|
1/imm32/is-atom
|
||||||
|
3/imm32/value:array
|
||||||
|
0/imm32/left:unused
|
||||||
|
0/imm32/right:null
|
||||||
|
0/imm32/right:null
|
||||||
|
|
||||||
Type-byte: # (payload type-tree)
|
Type-byte: # (payload type-tree)
|
||||||
0x11/imm32/alloc-id:fake:payload
|
0x11/imm32/alloc-id:fake:payload
|
||||||
1/imm32/is-atom
|
1/imm32/is-atom
|
||||||
|
@ -35271,6 +35298,27 @@ Type-float: # (payload type-tree)
|
||||||
0/imm32/right:null
|
0/imm32/right:null
|
||||||
0/imm32/right:null
|
0/imm32/right:null
|
||||||
|
|
||||||
|
Addr-type-string: # (addr type-tree)
|
||||||
|
0/imm32/not-atom
|
||||||
|
0x11/imm32/alloc-id:fake
|
||||||
|
Type-addr/imm32/left
|
||||||
|
0x11/imm32/alloc-id:fake
|
||||||
|
_Addr-type-string:array/imm32/right
|
||||||
|
_Addr-type-string:array: # (payload type-tree)
|
||||||
|
0x11/imm32/alloc-id:fake:payload
|
||||||
|
0/imm32/not-atom
|
||||||
|
0x11/imm32/alloc-id:fake
|
||||||
|
Type-array/imm32/left
|
||||||
|
0x11/imm32/alloc-id:fake
|
||||||
|
_Addr-type-string:byte/imm32/right
|
||||||
|
_Addr-type-string:byte: # (payload type-tree)
|
||||||
|
0x11/imm32/alloc-id:fake:payload
|
||||||
|
0/imm32/not-atom
|
||||||
|
0x11/imm32/alloc-id:fake
|
||||||
|
Type-byte/imm32/left
|
||||||
|
0/imm32/right:null
|
||||||
|
0/imm32/right:null
|
||||||
|
|
||||||
== code
|
== code
|
||||||
emit-subx-primitive: # out: (addr buffered-file), stmt: (addr stmt), primitive: (addr primitive), err: (addr buffered-file), ed: (addr exit-descriptor)
|
emit-subx-primitive: # out: (addr buffered-file), stmt: (addr stmt), primitive: (addr primitive), err: (addr buffered-file), ed: (addr exit-descriptor)
|
||||||
# . prologue
|
# . prologue
|
||||||
|
|
|
@ -10,7 +10,7 @@ type environment {
|
||||||
sandbox: sandbox
|
sandbox: sandbox
|
||||||
# some state for a modal dialog for navigating between functions
|
# some state for a modal dialog for navigating between functions
|
||||||
partial-function-name: (handle gap-buffer)
|
partial-function-name: (handle gap-buffer)
|
||||||
function-not-found?: boolean
|
function-modal-error: (handle array byte)
|
||||||
#
|
#
|
||||||
cursor-in-globals?: boolean
|
cursor-in-globals?: boolean
|
||||||
cursor-in-function-modal?: boolean
|
cursor-in-function-modal?: boolean
|
||||||
|
@ -240,8 +240,8 @@ fn edit-environment _self: (addr environment), key: grapheme, data-disk: (addr d
|
||||||
break-if-!=
|
break-if-!=
|
||||||
var cursor-in-function-modal-a/eax: (addr boolean) <- get self, cursor-in-function-modal?
|
var cursor-in-function-modal-a/eax: (addr boolean) <- get self, cursor-in-function-modal?
|
||||||
copy-to *cursor-in-function-modal-a, 0/false
|
copy-to *cursor-in-function-modal-a, 0/false
|
||||||
var function-not-found?/eax: (addr boolean) <- get self, function-not-found?
|
var function-modal-error-ah/eax: (addr handle array byte) <- get self, function-modal-error
|
||||||
copy-to *function-not-found? 0/false
|
clear-object function-modal-error-ah
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
# enter = switch to function name and exit modal dialog
|
# enter = switch to function name and exit modal dialog
|
||||||
|
@ -258,8 +258,8 @@ fn edit-environment _self: (addr environment), key: grapheme, data-disk: (addr d
|
||||||
var cursor-in-globals-a/eax: (addr boolean) <- get self, cursor-in-globals?
|
var cursor-in-globals-a/eax: (addr boolean) <- get self, cursor-in-globals?
|
||||||
copy-to *cursor-in-globals-a, 0/false
|
copy-to *cursor-in-globals-a, 0/false
|
||||||
# reset error state
|
# reset error state
|
||||||
var function-not-found?/eax: (addr boolean) <- get self, function-not-found?
|
var function-modal-error-ah/eax: (addr handle array byte) <- get self, function-modal-error
|
||||||
copy-to *function-not-found? 0/false
|
clear-object function-modal-error-ah
|
||||||
# done with function modal
|
# done with function modal
|
||||||
var cursor-in-function-modal-a/eax: (addr boolean) <- get self, cursor-in-function-modal?
|
var cursor-in-function-modal-a/eax: (addr boolean) <- get self, cursor-in-function-modal?
|
||||||
copy-to *cursor-in-function-modal-a, 0/false
|
copy-to *cursor-in-function-modal-a, 0/false
|
||||||
|
@ -275,14 +275,14 @@ fn edit-environment _self: (addr environment), key: grapheme, data-disk: (addr d
|
||||||
{
|
{
|
||||||
compare index, 0
|
compare index, 0
|
||||||
break-if->=
|
break-if->=
|
||||||
var function-not-found?/eax: (addr boolean) <- get self, function-not-found?
|
var function-modal-error-ah/eax: (addr handle array byte) <- get self, function-modal-error
|
||||||
copy-to *function-not-found? 1/true
|
copy-array-object "no such function", function-modal-error-ah
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
# otherwise clear modal state
|
# otherwise clear modal state
|
||||||
clear-gap-buffer partial-function-name
|
clear-gap-buffer partial-function-name
|
||||||
var function-not-found?/eax: (addr boolean) <- get self, function-not-found?
|
var function-modal-error-ah/eax: (addr handle array byte) <- get self, function-modal-error
|
||||||
copy-to *function-not-found? 0/false
|
clear-object function-modal-error-ah
|
||||||
# switch focus to function at index
|
# switch focus to function at index
|
||||||
var globals-cursor-index/eax: (addr int) <- get globals, cursor-index
|
var globals-cursor-index/eax: (addr int) <- get globals, cursor-index
|
||||||
copy-to *globals-cursor-index, index
|
copy-to *globals-cursor-index, index
|
||||||
|
@ -658,10 +658,11 @@ fn render-function-modal screen: (addr screen), _self: (addr environment) {
|
||||||
subtract-from xmin, 4
|
subtract-from xmin, 4
|
||||||
increment ymin
|
increment ymin
|
||||||
{
|
{
|
||||||
var function-not-found?/eax: (addr boolean) <- get self, function-not-found?
|
var function-modal-error-ah/eax: (addr handle array byte) <- get self, function-modal-error
|
||||||
compare *function-not-found?, 0/false
|
var function-modal-error/eax: (addr array byte) <- lookup *function-modal-error-ah
|
||||||
|
compare function-modal-error, 0
|
||||||
break-if-=
|
break-if-=
|
||||||
var dummy/eax: int <- draw-text-rightward screen, "no such function", xmin, xmax, ymin, 4/fg=error, 0xf/bg=modal
|
var dummy/eax: int <- draw-text-rightward screen, function-modal-error, xmin, xmax, ymin, 4/fg=error, 0xf/bg=modal
|
||||||
}
|
}
|
||||||
increment ymin
|
increment ymin
|
||||||
var dummy/eax: int <- copy 0
|
var dummy/eax: int <- copy 0
|
||||||
|
|
Loading…
Reference in New Issue