mirror of
https://github.com/irmen/prog8.git
synced 2025-01-10 20:30:23 +00:00
renamed 'string' module to 'strings' for consistency
This commit is contained in:
parent
42e2c5f605
commit
906b137a7c
@ -252,7 +252,7 @@ class ConstExprEvaluator {
|
||||
return when(call.target.nameInSource[0]) {
|
||||
"math" -> evalMath(call, constArgs)
|
||||
"floats" -> evalFloats(call, constArgs)
|
||||
"string" -> evalString(call, constArgs)
|
||||
"strings" -> evalString(call, constArgs)
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
@ -546,7 +546,7 @@ class ExpressionSimplifier(private val program: Program, private val errors: IEr
|
||||
return listOf(IAstModification.ReplaceNode(functionCallExpr, cast, parent))
|
||||
}
|
||||
}
|
||||
else if(functionCallExpr.target.nameInSource == listOf("string", "contains")) {
|
||||
else if(functionCallExpr.target.nameInSource == listOf("strings", "contains")) {
|
||||
val target = (functionCallExpr.args[0] as? IdentifierReference)?.targetVarDecl(program)
|
||||
if(target?.value is StringLiteral) {
|
||||
errors.info("for actual strings, use a regular containment check instead: 'char in string'", functionCallExpr.position)
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
%import textio
|
||||
%import conv
|
||||
%import string
|
||||
%import strings
|
||||
%import syslib
|
||||
|
||||
diskio {
|
||||
@ -163,7 +163,7 @@ io_error:
|
||||
if lf_start_list(pattern_ptr) {
|
||||
while lf_next_entry() {
|
||||
if list_filetype!="dir" {
|
||||
filenames_buffer += string.copy(list_filename, filenames_buffer) + 1
|
||||
filenames_buffer += strings.copy(list_filename, filenames_buffer) + 1
|
||||
files_found++
|
||||
if filenames_buffer - buffer_start > filenames_buf_size-20 {
|
||||
@(filenames_buffer)=0
|
||||
@ -265,7 +265,7 @@ io_error:
|
||||
if not list_skip_disk_name {
|
||||
if list_pattern==0
|
||||
return true
|
||||
if string.pattern_match(list_filename, list_pattern)
|
||||
if strings.pattern_match(list_filename, list_pattern)
|
||||
return true
|
||||
}
|
||||
list_skip_disk_name = false
|
||||
@ -297,7 +297,7 @@ close_end:
|
||||
; if you're going to read from it yourself instead of using f_read()!
|
||||
f_close()
|
||||
|
||||
cbm.SETNAM(string.length(filenameptr), filenameptr)
|
||||
cbm.SETNAM(strings.length(filenameptr), filenameptr)
|
||||
cbm.SETLFS(READ_IO_CHANNEL, drivenumber, READ_IO_CHANNEL) ; note: has to be Channel,x,Channel because otherwise f_seek doesn't work
|
||||
void cbm.OPEN() ; open 12,8,12,"filename"
|
||||
if_cc {
|
||||
@ -457,7 +457,7 @@ _end jsr cbm.READST
|
||||
modifier[3] = 'w'
|
||||
if open_for_seeks
|
||||
modifier[3] = 'm'
|
||||
cx16.r0L = string.append(list_filename, modifier) ; secondary 13 requires a mode suffix to signal we're writing/modifying
|
||||
cx16.r0L = strings.append(list_filename, modifier) ; secondary 13 requires a mode suffix to signal we're writing/modifying
|
||||
cbm.SETNAM(cx16.r0L, list_filename)
|
||||
cbm.SETLFS(WRITE_IO_CHANNEL, drivenumber, WRITE_IO_CHANNEL)
|
||||
void cbm.OPEN() ; open 13,8,13,"filename"
|
||||
@ -519,7 +519,7 @@ no_mciout:
|
||||
str device_not_present_error = "device not present #xx"
|
||||
if cbm.READST()==128 {
|
||||
device_not_present_error[len(device_not_present_error)-2] = 0
|
||||
void string.copy(conv.str_ub(drivenumber), &device_not_present_error+len(device_not_present_error)-2)
|
||||
void strings.copy(conv.str_ub(drivenumber), &device_not_present_error+len(device_not_present_error)-2)
|
||||
return device_not_present_error
|
||||
}
|
||||
|
||||
@ -596,7 +596,7 @@ io_error:
|
||||
}
|
||||
|
||||
sub internal_save_routine(uword filenameptr, uword startaddress, uword savesize, bool headerless) -> bool {
|
||||
cbm.SETNAM(string.length(filenameptr), filenameptr)
|
||||
cbm.SETNAM(strings.length(filenameptr), filenameptr)
|
||||
cbm.SETLFS(1, drivenumber, 0)
|
||||
uword @shared end_address = startaddress + savesize
|
||||
cx16.r0L = 0
|
||||
@ -651,7 +651,7 @@ io_error:
|
||||
|
||||
|
||||
sub internal_load_routine(uword filenameptr, uword address_override, bool headerless) -> uword {
|
||||
cbm.SETNAM(string.length(filenameptr), filenameptr)
|
||||
cbm.SETNAM(strings.length(filenameptr), filenameptr)
|
||||
ubyte secondary = 1
|
||||
cx16.r1 = 0
|
||||
if address_override!=0
|
||||
@ -677,7 +677,7 @@ io_error:
|
||||
; -- delete a file on the drive
|
||||
list_filename[0] = 's'
|
||||
list_filename[1] = ':'
|
||||
ubyte flen = string.copy(filenameptr, &list_filename+2)
|
||||
ubyte flen = strings.copy(filenameptr, &list_filename+2)
|
||||
cbm.SETNAM(flen+2, list_filename)
|
||||
cbm.SETLFS(1, drivenumber, 15)
|
||||
void cbm.OPEN()
|
||||
@ -689,9 +689,9 @@ io_error:
|
||||
; -- rename a file on the drive
|
||||
list_filename[0] = 'r'
|
||||
list_filename[1] = ':'
|
||||
ubyte flen_new = string.copy(newfileptr, &list_filename+2)
|
||||
ubyte flen_new = strings.copy(newfileptr, &list_filename+2)
|
||||
list_filename[flen_new+2] = '='
|
||||
ubyte flen_old = string.copy(oldfileptr, &list_filename+3+flen_new)
|
||||
ubyte flen_old = strings.copy(oldfileptr, &list_filename+3+flen_new)
|
||||
cbm.SETNAM(3+flen_new+flen_old, list_filename)
|
||||
cbm.SETLFS(1, drivenumber, 15)
|
||||
void cbm.OPEN()
|
||||
@ -701,7 +701,7 @@ io_error:
|
||||
|
||||
sub send_command(uword commandptr) {
|
||||
; -- send a dos command to the drive (don't read any response)
|
||||
cbm.SETNAM(string.length(commandptr), commandptr)
|
||||
cbm.SETNAM(strings.length(commandptr), commandptr)
|
||||
cbm.SETLFS(15, drivenumber, 15)
|
||||
void cbm.OPEN()
|
||||
cbm.CLRCHN()
|
||||
@ -776,7 +776,7 @@ internal_vload:
|
||||
list_filename[0] = 'c'
|
||||
list_filename[1] = 'd'
|
||||
list_filename[2] = ':'
|
||||
void string.copy(path, &list_filename+3)
|
||||
void strings.copy(path, &list_filename+3)
|
||||
send_command(list_filename)
|
||||
}
|
||||
|
||||
@ -785,19 +785,19 @@ internal_vload:
|
||||
list_filename[0] = 'm'
|
||||
list_filename[1] = 'd'
|
||||
list_filename[2] = ':'
|
||||
void string.copy(name, &list_filename+3)
|
||||
void strings.copy(name, &list_filename+3)
|
||||
send_command(list_filename)
|
||||
}
|
||||
|
||||
sub rmdir(str name) {
|
||||
; -- remove a subdirectory.
|
||||
void string.find(name, '*')
|
||||
void strings.find(name, '*')
|
||||
if_cs
|
||||
return ; refuse to act on a wildcard *
|
||||
list_filename[0] = 'r'
|
||||
list_filename[1] = 'd'
|
||||
list_filename[2] = ':'
|
||||
void string.copy(name, &list_filename+3)
|
||||
void strings.copy(name, &list_filename+3)
|
||||
send_command(list_filename)
|
||||
}
|
||||
|
||||
@ -860,7 +860,7 @@ io_error:
|
||||
sub prepend(str dir) {
|
||||
if dir[0]=='/' and dir[1]==0
|
||||
return
|
||||
cx16.r9L = string.length(dir)
|
||||
cx16.r9L = strings.length(dir)
|
||||
cx16.r12 -= cx16.r9L
|
||||
sys.memcopy(dir, cx16.r12, cx16.r9L)
|
||||
cx16.r12--
|
||||
@ -874,7 +874,7 @@ io_error:
|
||||
list_filename[1] = '-'
|
||||
list_filename[2] = 'h'
|
||||
list_filename[3] = ':'
|
||||
void string.copy(name, &list_filename+4)
|
||||
void strings.copy(name, &list_filename+4)
|
||||
send_command(list_filename)
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
%import textio
|
||||
%import conv
|
||||
%import string
|
||||
%import strings
|
||||
%import syslib
|
||||
|
||||
diskio {
|
||||
@ -141,7 +141,7 @@ io_error:
|
||||
if lf_start_list(pattern_ptr) {
|
||||
while lf_next_entry() {
|
||||
if list_filetype!="dir" {
|
||||
filenames_buffer += string.copy(list_filename, filenames_buffer) + 1
|
||||
filenames_buffer += strings.copy(list_filename, filenames_buffer) + 1
|
||||
files_found++
|
||||
if filenames_buffer - buffer_start > filenames_buf_size-20 {
|
||||
@(filenames_buffer)=0
|
||||
@ -243,7 +243,7 @@ io_error:
|
||||
if not list_skip_disk_name {
|
||||
if list_pattern==0
|
||||
return true
|
||||
if string.pattern_match(list_filename, list_pattern)
|
||||
if strings.pattern_match(list_filename, list_pattern)
|
||||
return true
|
||||
}
|
||||
list_skip_disk_name = false
|
||||
@ -275,7 +275,7 @@ close_end:
|
||||
; if you're going to read from it yourself instead of using f_read()!
|
||||
f_close()
|
||||
|
||||
cbm.SETNAM(string.length(filenameptr), filenameptr)
|
||||
cbm.SETNAM(strings.length(filenameptr), filenameptr)
|
||||
cbm.SETLFS(READ_IO_CHANNEL, drivenumber, READ_IO_CHANNEL) ; note: has to be Channel,x,Channel because otherwise f_seek doesn't work
|
||||
void cbm.OPEN() ; open 12,8,12,"filename"
|
||||
if_cc {
|
||||
@ -398,7 +398,7 @@ _end jsr cbm.READST
|
||||
; and check the drive's status message!
|
||||
f_close_w()
|
||||
|
||||
cbm.SETNAM(string.length(filenameptr), filenameptr)
|
||||
cbm.SETNAM(strings.length(filenameptr), filenameptr)
|
||||
cbm.SETLFS(WRITE_IO_CHANNEL, drivenumber, 1)
|
||||
void cbm.OPEN() ; open 13,8,1,"filename"
|
||||
if_cc {
|
||||
@ -444,7 +444,7 @@ _end jsr cbm.READST
|
||||
str device_not_present_error = "device not present #xx"
|
||||
if cbm.READST()==128 {
|
||||
device_not_present_error[len(device_not_present_error)-2] = 0
|
||||
void string.copy(conv.str_ub(drivenumber), &device_not_present_error+len(device_not_present_error)-2)
|
||||
void strings.copy(conv.str_ub(drivenumber), &device_not_present_error+len(device_not_present_error)-2)
|
||||
return device_not_present_error
|
||||
}
|
||||
uword messageptr = &list_filename
|
||||
@ -508,7 +508,7 @@ io_error:
|
||||
}
|
||||
|
||||
sub save(uword filenameptr, uword start_address, uword savesize) -> bool {
|
||||
cbm.SETNAM(string.length(filenameptr), filenameptr)
|
||||
cbm.SETNAM(strings.length(filenameptr), filenameptr)
|
||||
cbm.SETLFS(1, drivenumber, 0)
|
||||
uword @shared end_address = start_address + savesize
|
||||
cx16.r0L = 0
|
||||
@ -539,7 +539,7 @@ io_error:
|
||||
; and the rest is loaded at the given location in memory.
|
||||
; Returns the end load address+1 if successful or 0 if a load error occurred.
|
||||
sub load(uword filenameptr, uword address_override) -> uword {
|
||||
cbm.SETNAM(string.length(filenameptr), filenameptr)
|
||||
cbm.SETNAM(strings.length(filenameptr), filenameptr)
|
||||
ubyte secondary = 1
|
||||
cx16.r1 = 0
|
||||
if address_override!=0
|
||||
@ -578,7 +578,7 @@ io_error:
|
||||
; -- delete a file on the drive
|
||||
list_filename[0] = 's'
|
||||
list_filename[1] = ':'
|
||||
ubyte flen = string.copy(filenameptr, &list_filename+2)
|
||||
ubyte flen = strings.copy(filenameptr, &list_filename+2)
|
||||
cbm.SETNAM(flen+2, list_filename)
|
||||
cbm.SETLFS(1, drivenumber, 15)
|
||||
void cbm.OPEN()
|
||||
@ -590,9 +590,9 @@ io_error:
|
||||
; -- rename a file on the drive
|
||||
list_filename[0] = 'r'
|
||||
list_filename[1] = ':'
|
||||
ubyte flen_new = string.copy(newfileptr, &list_filename+2)
|
||||
ubyte flen_new = strings.copy(newfileptr, &list_filename+2)
|
||||
list_filename[flen_new+2] = '='
|
||||
ubyte flen_old = string.copy(oldfileptr, &list_filename+3+flen_new)
|
||||
ubyte flen_old = strings.copy(oldfileptr, &list_filename+3+flen_new)
|
||||
cbm.SETNAM(3+flen_new+flen_old, list_filename)
|
||||
cbm.SETLFS(1, drivenumber, 15)
|
||||
void cbm.OPEN()
|
||||
@ -611,7 +611,7 @@ io_error:
|
||||
|
||||
sub send_command(uword commandptr) {
|
||||
; -- send a dos command to the drive
|
||||
cbm.SETNAM(string.length(commandptr), commandptr)
|
||||
cbm.SETNAM(strings.length(commandptr), commandptr)
|
||||
cbm.SETLFS(15, drivenumber, 15)
|
||||
void cbm.OPEN()
|
||||
cbm.CLRCHN()
|
||||
|
@ -1,4 +1,4 @@
|
||||
string {
|
||||
strings {
|
||||
; the string functions shared across compiler targets
|
||||
%option merge, no_symbol_prefixing, ignore_unused
|
||||
|
||||
@ -12,11 +12,11 @@ string {
|
||||
; -- gets rid of whitespace and other non-visible characters at the end of the string
|
||||
if s[0]==0
|
||||
return
|
||||
cx16.r0L = string.length(s)
|
||||
cx16.r0L = length(s)
|
||||
do {
|
||||
cx16.r0L--
|
||||
cx16.r1L = s[cx16.r0L]
|
||||
} until cx16.r0L==0 or string.isprint(cx16.r1L) and not string.isspace(cx16.r1L)
|
||||
} until cx16.r0L==0 or isprint(cx16.r1L) and not isspace(cx16.r1L)
|
||||
s[cx16.r0L+1] = 0
|
||||
}
|
||||
|
||||
@ -24,7 +24,7 @@ string {
|
||||
; -- gets rid of whitespace and other non-visible characters at the start of the string (destructive)
|
||||
cx16.r0 = lstripped(s)
|
||||
if cx16.r0 != s
|
||||
void string.copy(cx16.r0, s)
|
||||
void copy(cx16.r0, s)
|
||||
}
|
||||
|
||||
sub lstripped(str s) -> str {
|
||||
@ -35,7 +35,7 @@ string {
|
||||
do {
|
||||
cx16.r0L++
|
||||
cx16.r1L = s[cx16.r0L]
|
||||
} until cx16.r1L==0 or string.isprint(cx16.r1L) and not string.isspace(cx16.r1L)
|
||||
} until cx16.r1L==0 or isprint(cx16.r1L) and not isspace(cx16.r1L)
|
||||
return s+cx16.r0L
|
||||
}
|
||||
|
||||
@ -49,11 +49,11 @@ string {
|
||||
; -- gets rid of whitespace characters at the end of the string
|
||||
if s[0]==0
|
||||
return
|
||||
cx16.r0L = string.length(s)
|
||||
cx16.r0L = length(s)
|
||||
do {
|
||||
cx16.r0L--
|
||||
cx16.r1L = s[cx16.r0L]
|
||||
} until cx16.r0L==0 or not string.isspace(cx16.r1L)
|
||||
} until cx16.r0L==0 or not isspace(cx16.r1L)
|
||||
s[cx16.r0L+1] = 0
|
||||
}
|
||||
|
||||
@ -61,7 +61,7 @@ string {
|
||||
; -- gets rid of whitespace characters at the start of the string (destructive)
|
||||
cx16.r0 = ltrimmed(s)
|
||||
if cx16.r0 != s
|
||||
void string.copy(cx16.r0, s)
|
||||
void copy(cx16.r0, s)
|
||||
}
|
||||
|
||||
sub ltrimmed(str s) -> str {
|
||||
@ -72,41 +72,41 @@ string {
|
||||
do {
|
||||
cx16.r0L++
|
||||
cx16.r1L = s[cx16.r0L]
|
||||
} until not string.isspace(cx16.r1L)
|
||||
} until not isspace(cx16.r1L)
|
||||
return s+cx16.r0L
|
||||
}
|
||||
|
||||
sub startswith(str st, str prefix) -> bool {
|
||||
ubyte prefix_len = string.length(prefix)
|
||||
ubyte str_len = string.length(st)
|
||||
ubyte prefix_len = length(prefix)
|
||||
ubyte str_len = length(st)
|
||||
if prefix_len > str_len
|
||||
return false
|
||||
cx16.r9L = st[prefix_len]
|
||||
st[prefix_len] = 0
|
||||
cx16.r9H = string.compare(st, prefix) as ubyte
|
||||
cx16.r9H = compare(st, prefix) as ubyte
|
||||
st[prefix_len] = cx16.r9L
|
||||
return cx16.r9H==0
|
||||
}
|
||||
|
||||
sub endswith(str st, str suffix) -> bool {
|
||||
ubyte suffix_len = string.length(suffix)
|
||||
ubyte str_len = string.length(st)
|
||||
ubyte suffix_len = length(suffix)
|
||||
ubyte str_len = length(st)
|
||||
if suffix_len > str_len
|
||||
return false
|
||||
return string.compare(st + str_len - suffix_len, suffix) == 0
|
||||
return compare(st + str_len - suffix_len, suffix) == 0
|
||||
}
|
||||
|
||||
sub findstr(str haystack, str needle) -> ubyte {
|
||||
; searches for needle in haystack.
|
||||
; returns index in haystack where it first occurs, and Carry set,
|
||||
; or if needle doesn't occur in haystack it returns Carry clear and 255 (an invalid index.)
|
||||
cx16.r2L = string.length(haystack)
|
||||
cx16.r3L = string.length(needle)
|
||||
cx16.r2L = length(haystack)
|
||||
cx16.r3L = length(needle)
|
||||
if cx16.r3L <= cx16.r2L {
|
||||
cx16.r2L = cx16.r2L-cx16.r3L+1
|
||||
cx16.r3 = haystack
|
||||
repeat cx16.r2L {
|
||||
if string.startswith(cx16.r3, needle) {
|
||||
if startswith(cx16.r3, needle) {
|
||||
sys.set_carry()
|
||||
return cx16.r3-haystack as ubyte
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
%import shared_string_functions
|
||||
|
||||
string {
|
||||
strings {
|
||||
%option no_symbol_prefixing, ignore_unused
|
||||
|
||||
asmsub length(uword string @AY) clobbers(A) -> ubyte @Y {
|
||||
@ -60,7 +60,7 @@ _loop dey
|
||||
stx P8ZP_SCRATCH_B1
|
||||
sta cx16.r0
|
||||
sty cx16.r0+1
|
||||
jsr string.length
|
||||
jsr length
|
||||
tya
|
||||
sec
|
||||
sbc P8ZP_SCRATCH_B1
|
||||
@ -158,7 +158,7 @@ _found tya
|
||||
stx P8ZP_SCRATCH_B1
|
||||
sta _str
|
||||
sty _str+1
|
||||
jsr string.length
|
||||
jsr length
|
||||
dey
|
||||
lda _str
|
||||
sta P8ZP_SCRATCH_W1
|
@ -2,7 +2,7 @@
|
||||
|
||||
%import shared_string_functions
|
||||
|
||||
string {
|
||||
strings {
|
||||
%option ignore_unused
|
||||
|
||||
sub length(str st) -> ubyte {
|
||||
@ -73,7 +73,7 @@ string {
|
||||
; returns Carry set if found + index in A, or Carry clear if not found (and A will be 255, an invalid index).
|
||||
; NOTE: because this isn't an asmsub, there's only a SINGLE return value here. On the c64/cx16 targets etc there are 2 return values.
|
||||
ubyte ix
|
||||
for ix in string.length(stringptr)-1 downto 0 {
|
||||
for ix in length(stringptr)-1 downto 0 {
|
||||
if stringptr[ix]==character {
|
||||
sys.set_carry()
|
||||
return ix
|
||||
@ -96,8 +96,8 @@ string {
|
||||
; Often you don’t have to call this explicitly and can just write string1 = string2
|
||||
; but this function is useful if you’re dealing with addresses for instance.
|
||||
%ir {{
|
||||
loadm.w r65534,string.copy.source
|
||||
loadm.w r65535,string.copy.target
|
||||
loadm.w r65534,strings.copy.source
|
||||
loadm.w r65535,strings.copy.target
|
||||
syscall 39 (r65534.w, r65535.w): r0.b
|
||||
returnr.b r0
|
||||
}}
|
||||
@ -116,8 +116,8 @@ string {
|
||||
; Note that you can also directly compare strings and string values with eachother using
|
||||
; comparison operators ==, < etcetera (this will use strcmp automatically).
|
||||
%ir {{
|
||||
loadm.w r65534,string.compare.st1
|
||||
loadm.w r65535,string.compare.st2
|
||||
loadm.w r65534,strings.compare.st1
|
||||
loadm.w r65535,strings.compare.st2
|
||||
syscall 16 (r65534.w, r65535.w) : r0.b
|
||||
returnr.b r0
|
||||
}}
|
@ -109,7 +109,7 @@ private fun builtinSizeof(args: List<Expression>, position: Position, program: P
|
||||
val elementDt = ArrayToElementTypes.getValue(dt.getOr(DataType.UNDEFINED))
|
||||
NumericLiteral.optimalInteger(program.memsizer.memorySize(elementDt) * length, position)
|
||||
}
|
||||
dt istype DataType.STR -> throw SyntaxError("sizeof(str) is undefined, did you mean len, or perhaps string.length?", position)
|
||||
dt istype DataType.STR -> throw SyntaxError("sizeof(str) is undefined, did you mean len, or perhaps strings.length?", position)
|
||||
else -> NumericLiteral(DataType.UBYTE, program.memsizer.memorySize(dt.getOr(DataType.UNDEFINED)).toDouble(), position)
|
||||
}
|
||||
} else {
|
||||
|
@ -97,7 +97,10 @@ class ModuleImporter(private val program: Program,
|
||||
importModule(it)
|
||||
},
|
||||
failure = {
|
||||
errors.err("no module found with name $moduleName. Searched in: $sourcePaths (and internal libraries)", import.position)
|
||||
if(moduleName=="string")
|
||||
errors.err("the 'string' module is now named 'strings'", import.position)
|
||||
else
|
||||
errors.err("no module found with name $moduleName. Searched in: $sourcePaths (and internal libraries)", import.position)
|
||||
return null
|
||||
}
|
||||
)
|
||||
|
@ -1989,7 +1989,7 @@ internal class AstChecker(private val program: Program,
|
||||
}
|
||||
else if(targetDatatype==DataType.STR) {
|
||||
if(sourceDatatype==DataType.UWORD)
|
||||
errors.err("can't assign UWORD to STR. If the source is a string and you actually want to overwrite the target string, use an explicit string.copy(src,tgt) instead.", position)
|
||||
errors.err("can't assign UWORD to STR. If the source is a string and you actually want to overwrite the target string, use an explicit strings.copy(src,tgt) instead.", position)
|
||||
else
|
||||
errors.err("type of value $sourceDatatype doesn't match target $targetDatatype", position)
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
%import floats
|
||||
%import textio
|
||||
%import string
|
||||
%import strings
|
||||
%import anyall
|
||||
%zeropage basicsafe
|
||||
|
||||
@ -24,10 +24,10 @@ main {
|
||||
if length!=5 txt.print("error len1\n")
|
||||
length = len(uwarr)
|
||||
if length!=5 txt.print("error len2\n")
|
||||
length=string.length(name)
|
||||
length=strings.length(name)
|
||||
if length!=5 txt.print("error strlen1\n")
|
||||
name[3] = 0
|
||||
length=string.length(name)
|
||||
length=strings.length(name)
|
||||
if length!=3 txt.print("error strlen2\n")
|
||||
|
||||
; ANY
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
%import textio
|
||||
%import floats
|
||||
%import string
|
||||
%import strings
|
||||
%import syslib
|
||||
%import math
|
||||
%import anyall
|
||||
|
@ -238,13 +238,13 @@ main {
|
||||
val src="""
|
||||
%import floats
|
||||
%import math
|
||||
%import string
|
||||
%import strings
|
||||
|
||||
main {
|
||||
sub start() {
|
||||
float fl = 1.2 ; no other assignments
|
||||
bool @shared result1 = string.isdigit(math.diff(119, floats.floor(floats.deg(fl)) as ubyte))
|
||||
bool @shared result2 = string.isletter(math.diff(119, floats.floor(floats.deg(1.2)) as ubyte))
|
||||
bool @shared result1 = strings.isdigit(math.diff(119, floats.floor(floats.deg(fl)) as ubyte))
|
||||
bool @shared result2 = strings.isletter(math.diff(119, floats.floor(floats.deg(1.2)) as ubyte))
|
||||
}
|
||||
}"""
|
||||
val result = compileText(Cx16Target(), true, src, writeAssembly = false)!!
|
||||
|
@ -1,7 +1,7 @@
|
||||
%zeropage basicsafe
|
||||
%import textio
|
||||
%import floats
|
||||
%import string
|
||||
%import strings
|
||||
|
||||
main {
|
||||
sub start() {
|
||||
@ -15,10 +15,10 @@ main {
|
||||
sub test_string() {
|
||||
str name="john"
|
||||
|
||||
if (string.compare(name, "aaa")==0) or (string.compare(name, "john")==0) or (string.compare(name, "bbb")==0) {
|
||||
if (strings.compare(name, "aaa")==0) or (strings.compare(name, "john")==0) or (strings.compare(name, "bbb")==0) {
|
||||
txt.print("name1 ok\n")
|
||||
}
|
||||
if (string.compare(name, "aaa")==0) or (string.compare(name, "zzz")==0) or (string.compare(name, "bbb")==0) {
|
||||
if (strings.compare(name, "aaa")==0) or (strings.compare(name, "zzz")==0) or (strings.compare(name, "bbb")==0) {
|
||||
txt.print("name2 fail!\n")
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
%import cx16logo
|
||||
%import math
|
||||
%import prog8_lib
|
||||
%import string
|
||||
%import strings
|
||||
%import syslib
|
||||
%import test_stack
|
||||
%import textio
|
||||
|
@ -9,7 +9,7 @@
|
||||
;;%import floats
|
||||
%import math
|
||||
%import prog8_lib
|
||||
%import string
|
||||
%import strings
|
||||
%import syslib
|
||||
%import test_stack
|
||||
%import textio
|
||||
|
@ -10,7 +10,7 @@
|
||||
%import graphics
|
||||
%import math
|
||||
%import prog8_lib
|
||||
%import string
|
||||
%import strings
|
||||
%import syslib
|
||||
%import test_stack
|
||||
%import textio
|
||||
|
@ -18,7 +18,7 @@
|
||||
%import prog8_lib
|
||||
%import psg
|
||||
%import sprites
|
||||
%import string
|
||||
%import strings
|
||||
%import syslib
|
||||
%import test_stack
|
||||
%import textio
|
||||
|
@ -6,5 +6,5 @@
|
||||
%import conv
|
||||
%import math
|
||||
%import prog8_lib
|
||||
%import string
|
||||
%import strings
|
||||
%import syslib
|
||||
|
@ -7,7 +7,7 @@
|
||||
%import cx16logo
|
||||
%import math
|
||||
%import prog8_lib
|
||||
%import string
|
||||
%import strings
|
||||
%import syslib
|
||||
%import test_stack
|
||||
%import textio
|
||||
|
@ -11,7 +11,7 @@
|
||||
%import math
|
||||
%import monogfx
|
||||
%import prog8_lib
|
||||
%import string
|
||||
%import strings
|
||||
%import syslib
|
||||
%import test_stack
|
||||
%import textio
|
||||
|
@ -1,5 +1,6 @@
|
||||
|
||||
Prog8 compiler v10.5.1 by Irmen de Jong (irmen@razorvine.net)
|
||||
Prog8 compiler v10.6-SNAPSHOT by Irmen de Jong (irmen@razorvine.net)
|
||||
Prerelease version from git commit 7a647300 in branch nextversion
|
||||
This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html
|
||||
|
||||
Compiling program import-all-atari.p8
|
||||
@ -137,10 +138,10 @@ math {
|
||||
}
|
||||
|
||||
|
||||
LIBRARY MODULE NAME: string
|
||||
---------------------------
|
||||
LIBRARY MODULE NAME: strings
|
||||
----------------------------
|
||||
|
||||
string {
|
||||
strings {
|
||||
append (uword target @R0, uword suffix @R1) -> clobbers (Y) -> ubyte @A
|
||||
compare (uword string1 @R0, uword string2 @AY) -> clobbers (Y) -> byte @A
|
||||
contains (uword string @AY, ubyte character @X) -> bool @Pc
|
||||
@ -192,12 +193,20 @@ atari {
|
||||
}
|
||||
|
||||
sys {
|
||||
const ubyte sizeof_bool
|
||||
const ubyte sizeof_byte
|
||||
const ubyte sizeof_float
|
||||
const ubyte sizeof_ubyte
|
||||
const ubyte sizeof_uword
|
||||
const ubyte sizeof_word
|
||||
const byte MAX_BYTE
|
||||
const ubyte MAX_UBYTE
|
||||
const uword MAX_UWORD
|
||||
const word MAX_WORD
|
||||
const byte MIN_BYTE
|
||||
const ubyte MIN_UBYTE
|
||||
const uword MIN_UWORD
|
||||
const word MIN_WORD
|
||||
const ubyte SIZEOF_BOOL
|
||||
const ubyte SIZEOF_BYTE
|
||||
const ubyte SIZEOF_FLOAT
|
||||
const ubyte SIZEOF_UBYTE
|
||||
const ubyte SIZEOF_UWORD
|
||||
const ubyte SIZEOF_WORD
|
||||
const ubyte target
|
||||
clear_carry ()
|
||||
clear_irqd ()
|
||||
|
@ -1,5 +1,6 @@
|
||||
|
||||
Prog8 compiler v10.5.1 by Irmen de Jong (irmen@razorvine.net)
|
||||
Prog8 compiler v10.6-SNAPSHOT by Irmen de Jong (irmen@razorvine.net)
|
||||
Prerelease version from git commit 7a647300 in branch nextversion
|
||||
This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html
|
||||
|
||||
Compiling program import-all-c128.p8
|
||||
@ -179,10 +180,10 @@ diskio {
|
||||
}
|
||||
|
||||
|
||||
LIBRARY MODULE NAME: string
|
||||
---------------------------
|
||||
LIBRARY MODULE NAME: strings
|
||||
----------------------------
|
||||
|
||||
string {
|
||||
strings {
|
||||
append (uword target @R0, uword suffix @R1) -> clobbers (Y) -> ubyte @A
|
||||
compare (uword string1 @R0, uword string2 @AY) -> clobbers (Y) -> byte @A
|
||||
contains (uword string @AY, ubyte character @X) -> bool @Pc
|
||||
@ -453,12 +454,20 @@ c128 {
|
||||
}
|
||||
|
||||
sys {
|
||||
const ubyte sizeof_bool
|
||||
const ubyte sizeof_byte
|
||||
const ubyte sizeof_float
|
||||
const ubyte sizeof_ubyte
|
||||
const ubyte sizeof_uword
|
||||
const ubyte sizeof_word
|
||||
const byte MAX_BYTE
|
||||
const ubyte MAX_UBYTE
|
||||
const uword MAX_UWORD
|
||||
const word MAX_WORD
|
||||
const byte MIN_BYTE
|
||||
const ubyte MIN_UBYTE
|
||||
const uword MIN_UWORD
|
||||
const word MIN_WORD
|
||||
const ubyte SIZEOF_BOOL
|
||||
const ubyte SIZEOF_BYTE
|
||||
const ubyte SIZEOF_FLOAT
|
||||
const ubyte SIZEOF_UBYTE
|
||||
const ubyte SIZEOF_UWORD
|
||||
const ubyte SIZEOF_WORD
|
||||
const ubyte target
|
||||
clear_carry ()
|
||||
clear_irqd ()
|
||||
|
@ -1,5 +1,6 @@
|
||||
|
||||
Prog8 compiler v10.5.1 by Irmen de Jong (irmen@razorvine.net)
|
||||
Prog8 compiler v10.6-SNAPSHOT by Irmen de Jong (irmen@razorvine.net)
|
||||
Prerelease version from git commit 7a647300 in branch nextversion
|
||||
This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html
|
||||
|
||||
Compiling program import-all-c64.p8
|
||||
@ -102,6 +103,8 @@ LIBRARY MODULE NAME: floats
|
||||
---------------------------
|
||||
|
||||
floats {
|
||||
const float E
|
||||
const float EPSILON
|
||||
const float PI
|
||||
const float TWOPI
|
||||
const float π
|
||||
@ -300,10 +303,10 @@ diskio {
|
||||
}
|
||||
|
||||
|
||||
LIBRARY MODULE NAME: string
|
||||
---------------------------
|
||||
LIBRARY MODULE NAME: strings
|
||||
----------------------------
|
||||
|
||||
string {
|
||||
strings {
|
||||
append (uword target @R0, uword suffix @R1) -> clobbers (Y) -> ubyte @A
|
||||
compare (uword string1 @R0, uword string2 @AY) -> clobbers (Y) -> byte @A
|
||||
contains (uword string @AY, ubyte character @X) -> bool @Pc
|
||||
@ -575,12 +578,22 @@ c64 {
|
||||
}
|
||||
|
||||
sys {
|
||||
const ubyte sizeof_bool
|
||||
const ubyte sizeof_byte
|
||||
const ubyte sizeof_float
|
||||
const ubyte sizeof_ubyte
|
||||
const ubyte sizeof_uword
|
||||
const ubyte sizeof_word
|
||||
const byte MAX_BYTE
|
||||
const float MAX_FLOAT
|
||||
const ubyte MAX_UBYTE
|
||||
const uword MAX_UWORD
|
||||
const word MAX_WORD
|
||||
const byte MIN_BYTE
|
||||
const float MIN_FLOAT
|
||||
const ubyte MIN_UBYTE
|
||||
const uword MIN_UWORD
|
||||
const word MIN_WORD
|
||||
const ubyte SIZEOF_BOOL
|
||||
const ubyte SIZEOF_BYTE
|
||||
const ubyte SIZEOF_FLOAT
|
||||
const ubyte SIZEOF_UBYTE
|
||||
const ubyte SIZEOF_UWORD
|
||||
const ubyte SIZEOF_WORD
|
||||
const ubyte target
|
||||
clear_carry ()
|
||||
clear_irqd ()
|
||||
|
@ -1,5 +1,6 @@
|
||||
|
||||
Prog8 compiler v10.5.1 by Irmen de Jong (irmen@razorvine.net)
|
||||
Prog8 compiler v10.6-SNAPSHOT by Irmen de Jong (irmen@razorvine.net)
|
||||
Prerelease version from git commit 7a647300 in branch nextversion
|
||||
This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html
|
||||
|
||||
Compiling program import-all-cx16.p8
|
||||
@ -236,6 +237,8 @@ LIBRARY MODULE NAME: floats
|
||||
---------------------------
|
||||
|
||||
floats {
|
||||
const float E
|
||||
const float EPSILON
|
||||
const float PI
|
||||
const float TWOPI
|
||||
const float π
|
||||
@ -600,10 +603,10 @@ sprites {
|
||||
}
|
||||
|
||||
|
||||
LIBRARY MODULE NAME: string
|
||||
---------------------------
|
||||
LIBRARY MODULE NAME: strings
|
||||
----------------------------
|
||||
|
||||
string {
|
||||
strings {
|
||||
append (uword target @R0, uword suffix @R1) -> clobbers (Y) -> ubyte @A
|
||||
compare (uword string1 @R0, uword string2 @AY) -> clobbers (Y) -> byte @A
|
||||
contains (uword string @AY, ubyte character @X) -> bool @Pc
|
||||
@ -1129,12 +1132,22 @@ cx16 {
|
||||
}
|
||||
|
||||
sys {
|
||||
const ubyte sizeof_bool
|
||||
const ubyte sizeof_byte
|
||||
const ubyte sizeof_float
|
||||
const ubyte sizeof_ubyte
|
||||
const ubyte sizeof_uword
|
||||
const ubyte sizeof_word
|
||||
const byte MAX_BYTE
|
||||
const float MAX_FLOAT
|
||||
const ubyte MAX_UBYTE
|
||||
const uword MAX_UWORD
|
||||
const word MAX_WORD
|
||||
const byte MIN_BYTE
|
||||
const float MIN_FLOAT
|
||||
const ubyte MIN_UBYTE
|
||||
const uword MIN_UWORD
|
||||
const word MIN_WORD
|
||||
const ubyte SIZEOF_BOOL
|
||||
const ubyte SIZEOF_BYTE
|
||||
const ubyte SIZEOF_FLOAT
|
||||
const ubyte SIZEOF_UBYTE
|
||||
const ubyte SIZEOF_UWORD
|
||||
const ubyte SIZEOF_WORD
|
||||
const ubyte target
|
||||
clear_carry ()
|
||||
clear_irqd ()
|
||||
@ -1192,8 +1205,7 @@ LIBRARY MODULE NAME: textio
|
||||
txt {
|
||||
const ubyte DEFAULT_HEIGHT
|
||||
const ubyte DEFAULT_WIDTH
|
||||
const uword VERA_TEXTMATRIX_ADDR
|
||||
const ubyte VERA_TEXTMATRIX_BANK
|
||||
const long VERA_TEXTMATRIX
|
||||
ubyte[] color_to_charcode
|
||||
bell ()
|
||||
chrout (ubyte character @A) = $ffd2
|
||||
|
@ -1,5 +1,6 @@
|
||||
|
||||
Prog8 compiler v10.5.1 by Irmen de Jong (irmen@razorvine.net)
|
||||
Prog8 compiler v10.6-SNAPSHOT by Irmen de Jong (irmen@razorvine.net)
|
||||
Prerelease version from git commit 7a647300 in branch nextversion
|
||||
This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html
|
||||
|
||||
Compiling program import-all-neo.p8
|
||||
@ -127,10 +128,10 @@ math {
|
||||
}
|
||||
|
||||
|
||||
LIBRARY MODULE NAME: string
|
||||
---------------------------
|
||||
LIBRARY MODULE NAME: strings
|
||||
----------------------------
|
||||
|
||||
string {
|
||||
strings {
|
||||
append (uword target @R0, uword suffix @R1) -> clobbers (Y) -> ubyte @A
|
||||
compare (uword string1 @R0, uword string2 @AY) -> clobbers (Y) -> byte @A
|
||||
contains (uword string @AY, ubyte character @X) -> bool @Pc
|
||||
@ -177,12 +178,20 @@ neo {
|
||||
}
|
||||
|
||||
sys {
|
||||
const ubyte sizeof_bool
|
||||
const ubyte sizeof_byte
|
||||
const ubyte sizeof_float
|
||||
const ubyte sizeof_ubyte
|
||||
const ubyte sizeof_uword
|
||||
const ubyte sizeof_word
|
||||
const byte MAX_BYTE
|
||||
const ubyte MAX_UBYTE
|
||||
const uword MAX_UWORD
|
||||
const word MAX_WORD
|
||||
const byte MIN_BYTE
|
||||
const ubyte MIN_UBYTE
|
||||
const uword MIN_UWORD
|
||||
const word MIN_WORD
|
||||
const ubyte SIZEOF_BOOL
|
||||
const ubyte SIZEOF_BYTE
|
||||
const ubyte SIZEOF_FLOAT
|
||||
const ubyte SIZEOF_UBYTE
|
||||
const ubyte SIZEOF_UWORD
|
||||
const ubyte SIZEOF_WORD
|
||||
const ubyte target
|
||||
clear_carry ()
|
||||
clear_irqd ()
|
||||
|
@ -1,5 +1,6 @@
|
||||
|
||||
Prog8 compiler v10.5.1 by Irmen de Jong (irmen@razorvine.net)
|
||||
Prog8 compiler v10.6-SNAPSHOT by Irmen de Jong (irmen@razorvine.net)
|
||||
Prerelease version from git commit 7a647300 in branch nextversion
|
||||
This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html
|
||||
|
||||
Compiling program import-all-pet32.p8
|
||||
@ -137,10 +138,10 @@ math {
|
||||
}
|
||||
|
||||
|
||||
LIBRARY MODULE NAME: string
|
||||
---------------------------
|
||||
LIBRARY MODULE NAME: strings
|
||||
----------------------------
|
||||
|
||||
string {
|
||||
strings {
|
||||
append (uword target @R0, uword suffix @R1) -> clobbers (Y) -> ubyte @A
|
||||
compare (uword string1 @R0, uword string2 @AY) -> clobbers (Y) -> byte @A
|
||||
contains (uword string @AY, ubyte character @X) -> bool @Pc
|
||||
@ -210,12 +211,20 @@ cbm {
|
||||
}
|
||||
|
||||
sys {
|
||||
const ubyte sizeof_bool
|
||||
const ubyte sizeof_byte
|
||||
const ubyte sizeof_float
|
||||
const ubyte sizeof_ubyte
|
||||
const ubyte sizeof_uword
|
||||
const ubyte sizeof_word
|
||||
const byte MAX_BYTE
|
||||
const ubyte MAX_UBYTE
|
||||
const uword MAX_UWORD
|
||||
const word MAX_WORD
|
||||
const byte MIN_BYTE
|
||||
const ubyte MIN_UBYTE
|
||||
const uword MIN_UWORD
|
||||
const word MIN_WORD
|
||||
const ubyte SIZEOF_BOOL
|
||||
const ubyte SIZEOF_BYTE
|
||||
const ubyte SIZEOF_FLOAT
|
||||
const ubyte SIZEOF_UBYTE
|
||||
const ubyte SIZEOF_UWORD
|
||||
const ubyte SIZEOF_WORD
|
||||
const ubyte target
|
||||
clear_carry ()
|
||||
clear_irqd ()
|
||||
|
@ -1,5 +1,6 @@
|
||||
|
||||
Prog8 compiler v10.5.1 by Irmen de Jong (irmen@razorvine.net)
|
||||
Prog8 compiler v10.6-SNAPSHOT by Irmen de Jong (irmen@razorvine.net)
|
||||
Prerelease version from git commit 7a647300 in branch nextversion
|
||||
This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html
|
||||
|
||||
Compiling program import-all-virtual.p8
|
||||
@ -143,6 +144,8 @@ LIBRARY MODULE NAME: floats
|
||||
---------------------------
|
||||
|
||||
floats {
|
||||
const float E
|
||||
const float EPSILON
|
||||
const float PI
|
||||
const float TWOPI
|
||||
const float π
|
||||
@ -251,10 +254,10 @@ monogfx {
|
||||
}
|
||||
|
||||
|
||||
LIBRARY MODULE NAME: string
|
||||
---------------------------
|
||||
LIBRARY MODULE NAME: strings
|
||||
----------------------------
|
||||
|
||||
string {
|
||||
strings {
|
||||
append (str target, str suffix) -> ubyte
|
||||
compare (str st1, str st2) -> byte
|
||||
contains (str st, ubyte character) -> bool
|
||||
@ -294,12 +297,22 @@ LIBRARY MODULE NAME: syslib
|
||||
---------------------------
|
||||
|
||||
sys {
|
||||
const ubyte sizeof_bool
|
||||
const ubyte sizeof_byte
|
||||
const ubyte sizeof_float
|
||||
const ubyte sizeof_ubyte
|
||||
const ubyte sizeof_uword
|
||||
const ubyte sizeof_word
|
||||
const byte MAX_BYTE
|
||||
const float MAX_FLOAT
|
||||
const ubyte MAX_UBYTE
|
||||
const uword MAX_UWORD
|
||||
const word MAX_WORD
|
||||
const byte MIN_BYTE
|
||||
const float MIN_FLOAT
|
||||
const ubyte MIN_UBYTE
|
||||
const uword MIN_UWORD
|
||||
const word MIN_WORD
|
||||
const ubyte SIZEOF_BOOL
|
||||
const ubyte SIZEOF_BYTE
|
||||
const ubyte SIZEOF_FLOAT
|
||||
const ubyte SIZEOF_UBYTE
|
||||
const ubyte SIZEOF_UWORD
|
||||
const ubyte SIZEOF_WORD
|
||||
const ubyte target
|
||||
clear_carry ()
|
||||
clear_irqd ()
|
||||
|
@ -78,7 +78,7 @@ len (x)
|
||||
Note: this can be different from the number of *bytes* in memory if the datatype isn't a byte. See sizeof().
|
||||
Note: lengths of strings and arrays are determined at compile-time! If your program modifies the actual
|
||||
length of the string during execution, the value of len(s) may no longer be correct!
|
||||
(use the ``string.length`` routine if you want to dynamically determine the length by counting to the
|
||||
(use the ``strings.length`` routine if you want to dynamically determine the length by counting to the
|
||||
first 0-byte)
|
||||
|
||||
|
||||
@ -482,8 +482,8 @@ to see what's in there. (Note: slight variations for different compiler targets)
|
||||
descriptions for the various methods in this library for details and tips.
|
||||
|
||||
|
||||
string
|
||||
------
|
||||
strings
|
||||
-------
|
||||
Provides string manipulation routines.
|
||||
|
||||
``length (str) -> ubyte length``
|
||||
@ -527,7 +527,7 @@ Provides string manipulation routines.
|
||||
``compare (string1, string2) -> ubyte result``
|
||||
Returns -1, 0 or 1 depending on whether string1 sorts before, equal or after string2.
|
||||
Note that you can also directly compare strings and string values with each other
|
||||
using ``==``, ``<`` etcetera (it will use string.compare for you under water automatically).
|
||||
using ``==``, ``<`` etcetera (it will use strings.compare for you under water automatically).
|
||||
This even works when dealing with uword (pointer) variables when comparing them to a string type.
|
||||
|
||||
``copy (from, to) -> ubyte length``
|
||||
|
@ -432,13 +432,13 @@ read the syntax reference on strings.
|
||||
|
||||
Using the ``in`` operator you can easily check if a character is present in a string,
|
||||
example: ``if '@' in email_address {....}`` (however this gives no clue about the location
|
||||
in the string where the character is present, if you need that, use the ``string.find()``
|
||||
in the string where the character is present, if you need that, use the ``strings.find()``
|
||||
library function instead)
|
||||
**Caution:**
|
||||
This checks *all* elements in the string with the length as it was initially declared.
|
||||
Even when a string was changed and is terminated early with a 0-byte early,
|
||||
the containment check with ``in`` will still look at all character positions in the initial string.
|
||||
Consider using ``string.find`` followed by ``if_cs`` (for instance) to do a "safer" search
|
||||
Consider using ``strings.find`` followed by ``if_cs`` (for instance) to do a "safer" search
|
||||
for a character in such strings (one that stops at the first 0 byte)
|
||||
|
||||
|
||||
@ -482,7 +482,7 @@ by the compiler everywhere you refer to the constant (and no memory is allocated
|
||||
for the constant itself). Onlythe simple numeric types (byte, word, float) can be defined as a constant.
|
||||
If something is defined as a constant, very efficient code can usually be generated from it.
|
||||
Variables on the other hand can't be optimized as much, need memory, and more code to manipulate them.
|
||||
Note that a subset of the library routines in the ``math``, ``string`` and ``floats`` modules are recognised in
|
||||
Note that a subset of the library routines in the ``math``, ``strings`` and ``floats`` modules are recognised in
|
||||
compile time expressions. For example, the compiler knows what ``math.sin8u(12)`` is and replaces it with the computed result.
|
||||
|
||||
When using ``&`` (the address-of operator but now applied to a datatype), the variable will point to specific location in memory,
|
||||
|
@ -8,7 +8,6 @@ Future Things and Ideas
|
||||
^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
- something to reduce the need to use fully qualified names all the time. 'with' ? Or 'using <prefix>'?
|
||||
- rename 'string' module to 'strings' to be consistent with 'floats'?
|
||||
- on the C64: make the floating point routines @banked so that basic can be permanently banked out even if you use floats? But this will crash when the call is done from program code at $a000+
|
||||
- Libraries: improve ability to create library files in prog8; for instance there's still stuff injected into the start of the start() routine AND there is separate setup logic going on before calling it.
|
||||
Make up our mind! Maybe all setup does need to be put into start() ? because the program cannot function correctly when the variables aren't initialized properly bss is not cleared etc. etc.
|
||||
|
@ -1,5 +1,5 @@
|
||||
%import textio
|
||||
%import string
|
||||
%import strings
|
||||
|
||||
; Animal guessing game where the computer gets smarter every time.
|
||||
; Note: this program can be compiled for multiple target systems.
|
||||
@ -114,8 +114,8 @@ main {
|
||||
|
||||
animals[new_animal_number] = animal_names_ptr
|
||||
questions[new_question_number] = questions_ptr
|
||||
animal_names_ptr += string.copy(name, animal_names_ptr)+1 ; store animal name in buffer
|
||||
questions_ptr += string.copy(userinput, questions_ptr)+1 ; store question in buffer
|
||||
animal_names_ptr += strings.copy(name, animal_names_ptr)+1 ; store animal name in buffer
|
||||
questions_ptr += strings.copy(userinput, questions_ptr)+1 ; store question in buffer
|
||||
|
||||
answers_questions[new_question_number] = mkword(0, 0)
|
||||
if answer[0]=='y'
|
||||
|
@ -1,4 +1,4 @@
|
||||
%import string
|
||||
%import strings
|
||||
%import textio
|
||||
%option no_sysinit
|
||||
%zeropage basicsafe
|
||||
@ -9,7 +9,7 @@ main {
|
||||
sub start() {
|
||||
; copy basic rom to ram and replace ready prompt
|
||||
sys.memcopy($a000, $a000, $2000)
|
||||
void string.copy(iso:"HELLO!\r", $a378)
|
||||
void strings.copy(iso:"HELLO!\r", $a378)
|
||||
|
||||
txt.print("8 bytes at $f000 (kernal rom):\n")
|
||||
for cx16.r0 in $f000 to $f007 {
|
||||
@ -21,7 +21,7 @@ main {
|
||||
; store some other data in the RAM below those kernal ROM locations
|
||||
; switch off kernal rom to see those bytes
|
||||
; we cannot print during this time and the IRQ has to be disabled temporarily as well.
|
||||
void string.copy("hello !?", $f000)
|
||||
void strings.copy("hello !?", $f000)
|
||||
sys.set_irqd()
|
||||
c64.banks(%101) ; switch off roms
|
||||
ubyte[8] buffer
|
||||
|
@ -1,6 +1,6 @@
|
||||
%import textio
|
||||
%import palette
|
||||
%import string
|
||||
%import strings
|
||||
%import gfx_hires
|
||||
|
||||
; Mockup of a classic Amiga Workbench screen.
|
||||
@ -164,7 +164,7 @@ widget {
|
||||
const ubyte height = 28
|
||||
highlightedrect(x, y, width, height, false, false)
|
||||
uword middlex = x+width/2+1
|
||||
ubyte halfstring = string.length(caption) * 4
|
||||
ubyte halfstring = strings.length(caption) * 4
|
||||
gfx_hires.text(middlex-halfstring,y+height+1,1,caption)
|
||||
gfx_hires.disc(x+width/4+4, y+height/2, height/2-3, 1)
|
||||
gfx_hires.fillrect(x+20,y+12,width/2,height/2-4,3)
|
||||
|
@ -1,5 +1,5 @@
|
||||
%import syslib
|
||||
%import string
|
||||
%import strings
|
||||
|
||||
; Streaming routine for MCF files (multipurpose chunk format):
|
||||
; 1. call open()
|
||||
@ -18,7 +18,7 @@ mcf {
|
||||
|
||||
sub open(str filename, ubyte drive, ubyte channel) -> bool {
|
||||
file_channel = channel
|
||||
cbm.SETNAM(string.length(filename), filename)
|
||||
cbm.SETNAM(strings.length(filename), filename)
|
||||
cbm.SETLFS(channel, drive, 2)
|
||||
void cbm.OPEN()
|
||||
if_cc {
|
||||
|
@ -16,8 +16,8 @@ main {
|
||||
if diskio.f_open_w("@:seektestfile.bin") {
|
||||
repeat 100 {
|
||||
str text = "hello world.*"
|
||||
void diskio.f_write(text, string.length(text))
|
||||
total += string.length(text)
|
||||
void diskio.f_write(text, strings.length(text))
|
||||
total += strings.length(text)
|
||||
}
|
||||
diskio.f_close_w()
|
||||
txt.print("written size=")
|
||||
|
@ -1,6 +1,6 @@
|
||||
%import floats
|
||||
%import textio
|
||||
%import string
|
||||
%import strings
|
||||
%zeropage basicsafe
|
||||
|
||||
main {
|
||||
@ -75,7 +75,7 @@ main {
|
||||
'-' -> negative=true
|
||||
'+', ' ' -> { /* skip */ }
|
||||
else -> {
|
||||
if string.isdigit(cx16.r0L) {
|
||||
if strings.isdigit(cx16.r0L) {
|
||||
result *= 10
|
||||
result += cx16.r0L - '0'
|
||||
} else
|
||||
@ -92,7 +92,7 @@ main {
|
||||
cx16.r0L = @(stringptr)
|
||||
if cx16.r0L==' '
|
||||
continue
|
||||
else if string.isdigit(cx16.r0L) {
|
||||
else if strings.isdigit(cx16.r0L) {
|
||||
exponent--
|
||||
result *= 10
|
||||
result += cx16.r0L - '0'
|
||||
@ -113,7 +113,7 @@ main {
|
||||
'+', ' ' -> { /* skip */ }
|
||||
'-' -> neg_exponent=true
|
||||
else -> {
|
||||
if string.isdigit(cx16.r0L) {
|
||||
if strings.isdigit(cx16.r0L) {
|
||||
exp_value *= 10
|
||||
exp_value += cx16.r0L - '0'
|
||||
} else
|
||||
|
@ -1,5 +1,7 @@
|
||||
%import floats
|
||||
|
||||
%import strings
|
||||
|
||||
main {
|
||||
sub start() {
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
%import textio
|
||||
%import conv
|
||||
%import diskio
|
||||
%import string
|
||||
%import strings
|
||||
%zeropage basicsafe
|
||||
|
||||
; Prog8 adaptation of the Text-Elite galaxy system trading simulation engine.
|
||||
@ -517,7 +517,7 @@ galaxy {
|
||||
ubyte distance = planet.distance(px, py)
|
||||
if distance <= max_distance {
|
||||
planet.name = make_current_planet_name()
|
||||
planet.name[0] = string.upperchar(planet.name[0])
|
||||
planet.name[0] = strings.upperchar(planet.name[0])
|
||||
uword tx = planet.x
|
||||
uword ty = planet.y
|
||||
if local {
|
||||
@ -803,7 +803,7 @@ planet {
|
||||
}
|
||||
}
|
||||
randname[nx] = 0
|
||||
randname[0] = string.upperchar(randname[0])
|
||||
randname[0] = strings.upperchar(randname[0])
|
||||
return randname
|
||||
}
|
||||
|
||||
@ -875,12 +875,12 @@ planet {
|
||||
source_ptr = source_stack[stack_ptr]
|
||||
} else {
|
||||
if c == $b0 {
|
||||
@(result_ptr) = string.upperchar(name[0])
|
||||
@(result_ptr) = strings.upperchar(name[0])
|
||||
result_ptr++
|
||||
concat_string(&name + 1)
|
||||
}
|
||||
else if c == $b1 {
|
||||
@(result_ptr) = string.upperchar(name[0])
|
||||
@(result_ptr) = strings.upperchar(name[0])
|
||||
result_ptr++
|
||||
ubyte ni
|
||||
for ni in 1 to len(name) {
|
||||
@ -995,7 +995,7 @@ planet {
|
||||
|
||||
sub print_name_uppercase() {
|
||||
for cx16.r0L in name
|
||||
txt.chrout(string.upperchar(cx16.r0L))
|
||||
txt.chrout(strings.upperchar(cx16.r0L))
|
||||
}
|
||||
|
||||
sub getword(ubyte listnum, ubyte wordidx) -> uword {
|
||||
@ -1012,7 +1012,7 @@ util {
|
||||
if pc == 0
|
||||
return true
|
||||
; to lowercase for case insensitive compare:
|
||||
if string.lowerchar(pc)!=string.lowerchar(sc)
|
||||
if strings.lowerchar(pc)!=strings.lowerchar(sc)
|
||||
return false
|
||||
prefixptr++
|
||||
stringptr++
|
||||
@ -1020,7 +1020,7 @@ util {
|
||||
}
|
||||
|
||||
sub print_right(ubyte width, uword s) {
|
||||
repeat width - string.length(s) {
|
||||
repeat width - strings.length(s) {
|
||||
txt.spc()
|
||||
}
|
||||
txt.print(s)
|
||||
|
Loading…
x
Reference in New Issue
Block a user