mirror of
https://github.com/irmen/prog8.git
synced 2024-11-18 19:12:44 +00:00
callgraph: mark start() also in use
This commit is contained in:
parent
a1f3b82333
commit
ccebd22856
@ -28,7 +28,7 @@ class CallGraph(private val program: Program) : IAstVisitor {
|
||||
}
|
||||
|
||||
private val usedSubroutines: Set<Subroutine> by lazy {
|
||||
calledBy.keys
|
||||
calledBy.keys + program.entrypoint()
|
||||
}
|
||||
|
||||
private val usedBlocks: Set<Block> by lazy {
|
||||
@ -54,8 +54,8 @@ class CallGraph(private val program: Program) : IAstVisitor {
|
||||
val thisModule = directive.definingModule()
|
||||
if (directive.directive == "%import") {
|
||||
val importedModule: Module = program.modules.single { it.name == directive.args[0].name }
|
||||
imports[thisModule] = imports.getValue(thisModule).plus(importedModule)
|
||||
importedBy[importedModule] = importedBy.getValue(importedModule).plus(thisModule)
|
||||
imports[thisModule] = imports.getValue(thisModule) + importedModule
|
||||
importedBy[importedModule] = importedBy.getValue(importedModule) + thisModule
|
||||
}
|
||||
|
||||
super.visit(directive)
|
||||
@ -65,8 +65,8 @@ class CallGraph(private val program: Program) : IAstVisitor {
|
||||
val otherSub = functionCall.target.targetSubroutine(program)
|
||||
if (otherSub != null) {
|
||||
functionCall.definingSubroutine()?.let { thisSub ->
|
||||
calls[thisSub] = calls.getValue(thisSub).plus(otherSub)
|
||||
calledBy[otherSub] = calledBy.getValue(otherSub).plus(functionCall)
|
||||
calls[thisSub] = calls.getValue(thisSub) + otherSub
|
||||
calledBy[otherSub] = calledBy.getValue(otherSub) + functionCall
|
||||
}
|
||||
}
|
||||
super.visit(functionCall)
|
||||
@ -76,8 +76,8 @@ class CallGraph(private val program: Program) : IAstVisitor {
|
||||
val otherSub = functionCallStatement.target.targetSubroutine(program)
|
||||
if (otherSub != null) {
|
||||
functionCallStatement.definingSubroutine()?.let { thisSub ->
|
||||
calls[thisSub] = calls.getValue(thisSub).plus(otherSub)
|
||||
calledBy[otherSub] = calledBy.getValue(otherSub).plus(functionCallStatement)
|
||||
calls[thisSub] = calls.getValue(thisSub) + otherSub
|
||||
calledBy[otherSub] = calledBy.getValue(otherSub) + functionCallStatement
|
||||
}
|
||||
}
|
||||
super.visit(functionCallStatement)
|
||||
@ -87,8 +87,8 @@ class CallGraph(private val program: Program) : IAstVisitor {
|
||||
val otherSub = addressOf.identifier.targetSubroutine(program)
|
||||
if(otherSub!=null) {
|
||||
addressOf.definingSubroutine()?.let { thisSub ->
|
||||
calls[thisSub] = calls.getValue(thisSub).plus(otherSub)
|
||||
calledBy[otherSub] = calledBy.getValue(otherSub).plus(thisSub)
|
||||
calls[thisSub] = calls.getValue(thisSub) + otherSub
|
||||
calledBy[otherSub] = calledBy.getValue(otherSub) + thisSub
|
||||
}
|
||||
}
|
||||
super.visit(addressOf)
|
||||
@ -98,8 +98,8 @@ class CallGraph(private val program: Program) : IAstVisitor {
|
||||
val otherSub = jump.identifier?.targetSubroutine(program)
|
||||
if (otherSub != null) {
|
||||
jump.definingSubroutine()?.let { thisSub ->
|
||||
calls[thisSub] = calls.getValue(thisSub).plus(otherSub)
|
||||
calledBy[otherSub] = calledBy.getValue(otherSub).plus(jump)
|
||||
calls[thisSub] = calls.getValue(thisSub) + otherSub
|
||||
calledBy[otherSub] = calledBy.getValue(otherSub) + jump
|
||||
}
|
||||
}
|
||||
super.visit(jump)
|
||||
|
@ -12,16 +12,16 @@ main {
|
||||
store_logo()
|
||||
|
||||
txt.lowercase()
|
||||
vtui.screen_set(0)
|
||||
vtui.screen_set(2)
|
||||
vtui.clr_scr('%', $50)
|
||||
vtui.gotoxy(5,5)
|
||||
vtui.fill_box(':', 70, 50, $c6)
|
||||
vtui.gotoxy(10,10)
|
||||
vtui.border(1, 40, 6, $47)
|
||||
vtui.gotoxy(12,12)
|
||||
vtui.print_str2(@"Hello, world! vtui from Prog8!", $f2, $80)
|
||||
vtui.print_str2(@"Hello, world! vtui from Prog8!", $f2, false)
|
||||
vtui.gotoxy(12,13)
|
||||
vtui.print_str2("Hello, world! vtui from Prog8!", $f2, $00)
|
||||
vtui.print_str2("Hello, world! vtui from Prog8!", $f2, true)
|
||||
|
||||
str inputbuffer = "?" * 20
|
||||
|
||||
@ -31,11 +31,11 @@ main {
|
||||
; txt.chrout('\n')
|
||||
|
||||
vtui.gotoxy(5,20)
|
||||
vtui.print_str2(@"Enter your name: ", $e3, $80)
|
||||
vtui.print_str2(@"Enter your name: ", $e3, false)
|
||||
ubyte length = vtui.input_str(inputbuffer, len(inputbuffer), $21)
|
||||
|
||||
vtui.gotoxy(8,22)
|
||||
vtui.print_str2(@"Your name is: ", $e3, $80)
|
||||
vtui.print_str2(@"Your name is: ", $e3, false)
|
||||
;vtui.print_str2(inputbuffer, $67, $00)
|
||||
vtui.print_str(inputbuffer, length, $67, $00)
|
||||
|
||||
@ -58,7 +58,7 @@ main {
|
||||
|
||||
;vtui.screen_set(2)
|
||||
vtui.gotoxy(30, 32)
|
||||
vtui.print_str2("arrow keys to move!", $61, 0)
|
||||
vtui.print_str2("arrow keys to move!", $61, true)
|
||||
|
||||
char_loop:
|
||||
ubyte char = c64.GETIN()
|
||||
@ -135,10 +135,13 @@ vtui $1000 {
|
||||
romsub $1032 = rest_rect(ubyte ramtype @A, ubyte vbank @Pc, uword address @R0, ubyte width @R1, ubyte height @R2) clobbers(A, X, Y)
|
||||
romsub $1035 = input_str(uword buffer @R0, ubyte buflen @Y, ubyte colors @X) clobbers (A) -> ubyte @Y
|
||||
|
||||
; -- helper function to do string length counting for you internally
|
||||
asmsub print_str2(str txtstring @R0, ubyte colors @X, ubyte convertchars @A) clobbers(A, Y) {
|
||||
; -- helper function to do string length counting for you internally, and turn the convertchars flag into a boolean again
|
||||
asmsub print_str2(str txtstring @R0, ubyte colors @X, ubyte convertchars @Pc) clobbers(A, Y) {
|
||||
%asm {{
|
||||
pha
|
||||
lda #0
|
||||
bcs +
|
||||
lda #$80
|
||||
+ pha
|
||||
lda cx16.r0
|
||||
ldy cx16.r0+1
|
||||
jsr prog8_lib.strlen
|
||||
|
@ -1,12 +1,54 @@
|
||||
%target cx16
|
||||
%import textio
|
||||
%zeropage dontuse
|
||||
%option no_sysinit
|
||||
%zeropage basicsafe
|
||||
|
||||
; simple test program for the "VTUI" text user interface library
|
||||
; see: https://github.com/JimmyDansbo/VTUIlib
|
||||
|
||||
main {
|
||||
|
||||
sub start() {
|
||||
ubyte num = cx16.numbanks()
|
||||
|
||||
txt.print_ub(num)
|
||||
txt.nl()
|
||||
vtui.initialize()
|
||||
txt.print("ok")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
vtui $1000 {
|
||||
|
||||
%asmbinary "cx16/vtui/VTUI0.8.BIN", 2 ; skip the 2 dummy load address bytes
|
||||
|
||||
; NOTE: base address $1000 here must be the same as the block's memory address, for obvious reasons!
|
||||
; The routines below are for VTUI 0.8
|
||||
romsub $1000 = initialize() clobbers(A, X, Y)
|
||||
romsub $1002 = screen_set(ubyte mode @A) clobbers(A, X, Y)
|
||||
romsub $1005 = set_bank(ubyte bank @Pc) clobbers(A)
|
||||
romsub $1008 = set_stride(ubyte stride @A) clobbers(A)
|
||||
romsub $100b = set_decr(ubyte incrdecr @Pc) clobbers(A)
|
||||
romsub $100e = clr_scr(ubyte char @A, ubyte colors @X) clobbers(Y)
|
||||
romsub $1011 = gotoxy(ubyte column @A, ubyte row @Y)
|
||||
romsub $1014 = plot_char(ubyte char @A, ubyte colors @X)
|
||||
romsub $1017 = scan_char() -> ubyte @A, ubyte @X
|
||||
romsub $101a = hline(ubyte char @A, ubyte length @Y, ubyte colors @X) clobbers(A)
|
||||
romsub $101d = vline(ubyte char @A, ubyte height @Y, ubyte colors @X) clobbers(A)
|
||||
romsub $1020 = print_str(str txtstring @R0, ubyte length @Y, ubyte colors @X, ubyte convertchars @A) clobbers(A, Y)
|
||||
romsub $1023 = fill_box(ubyte char @A, ubyte width @R1, ubyte height @R2, ubyte colors @X) clobbers(A, Y)
|
||||
romsub $1026 = pet2scr(ubyte char @A) -> ubyte @A
|
||||
romsub $1029 = scr2pet(ubyte char @A) -> ubyte @A
|
||||
romsub $102c = border(ubyte mode @A, ubyte width @R1, ubyte height @R2, ubyte colors @X) clobbers(Y) ; NOTE: mode 6 means 'custom' characters taken from r3 - r6
|
||||
romsub $102f = save_rect(ubyte ramtype @A, ubyte vbank @Pc, uword address @R0, ubyte width @R1, ubyte height @R2) clobbers(A, X, Y)
|
||||
romsub $1032 = rest_rect(ubyte ramtype @A, ubyte vbank @Pc, uword address @R0, ubyte width @R1, ubyte height @R2) clobbers(A, X, Y)
|
||||
romsub $1035 = input_str(uword buffer @R0, ubyte buflen @Y, ubyte colors @X) clobbers (A) -> ubyte @Y
|
||||
|
||||
; -- helper function to do string length counting for you internally
|
||||
asmsub print_str2(str txtstring @R0, ubyte colors @X, ubyte convertchars @A) clobbers(A, Y) {
|
||||
%asm {{
|
||||
pha
|
||||
lda cx16.r0
|
||||
ldy cx16.r0+1
|
||||
jsr prog8_lib.strlen
|
||||
pla
|
||||
jmp print_str
|
||||
}}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user