native dup native pop native swap func # { pop } native alen native aget native aput native anew native _array native _char native _byte native _int native _float native _long native _double native ischar native isbyte native isint native isfloat native islong native isdouble native isarray "call a dynamically computed function" # "Please keep in mind that this will throw a native error if" # "called incorrectly - this means wrong layer parameter will" # "instantly crash the program." # native _layer_call func call { 1 _layer_call } native subprocess "This returns the last word as a string, from an index." # "index has to be <16, index 0 is this call" # native _last_word native include native reload native getfile native putchar native mktype native mkinstance native getos native typename native typeid native gettype native settype "a b extends => a.extends(b) | b.isSuperOf(a) | a == b" # native extends "try and do are keywords, not functions" # native throw native exit native eq native gt native lt native not native neg native or native and native + native - native / native * native ** native % native ^ native fcall native deffunc native defmethod native deffield native defsuper native delete "deletes all field values from an object" # native callmethod func ++ { 1 + } func -- { 1 - } "this looks so wrong" # func ( { } func ) { } func ! { dup } "The TYPE_ prefix is deprecated, but will be kept for backwards compatibility." # "int must be registered first." # def TYPE_INT construct int { # "no fields needed" ; construct { pop 0 } new { "int has the new method because all types are ints" # mkinstance } } =TYPE_INT def TYPE_CHAR "char" mktype =TYPE_CHAR def TYPE_BYTE "byte" mktype =TYPE_BYTE def TYPE_FLOAT "float" mktype =TYPE_FLOAT def TYPE_LONG "long" mktype =TYPE_LONG def TYPE_DOUBLE "double" mktype =TYPE_DOUBLE def TYPE_NULL "null" mktype =TYPE_NULL native null def TYPE_FUNCTION "func" mktype =TYPE_FUNCTION def Function TYPE_FUNCTION =Function def Error construct error { ; construct { with id message this ; id message throw this } stacktrace { native error.stacktrace error.stacktrace } } =Error def __aput_native &aput =__aput_native def TYPE_ARRAY construct array { ; construct { pop anew } foreach { def this =this def lambda =lambda def i 0 =i while { i this alen lt } { this i aget lambda fcall i ++ =i } } stackTraceToString { def this =this def s "INTERPRET" =s def ind " " =ind { with element ; s "\n" ind "\\ " strconcat strconcat strconcat =s def p "" =p { with name ; "/" name p strconcat strconcat =p } element foreach s p strconcat =s ind " " strconcat =ind } this foreach s } ? { with idx this ; this idx aget } =? { with item idx this ; this idx item aput } } =TYPE_ARRAY def Array TYPE_ARRAY =Array def TYPE_STRING construct string array { ; _array { Array settype } } =TYPE_STRING def String TYPE_STRING =String def TYPE_JIO construct jio { ; class { pop native jio.class jio.class } getclass { pop native jio.getclass jio.getclass } context { mirrorInterpreterData native jio.context jio.context } stack { pop "java.lang.Thread" JIO class currentThread0 getId0 JIO context debuggerIPC stack get1 } mirrorInterpreterData { pop native jio.mirror jio.mirror } } =TYPE_JIO def JIO 0 TYPE_JIO settype =JIO def TYPE_REFERENCE construct reference { ? } =TYPE_REFERENCE func reference { def this TYPE_REFERENCE mkinstance =this this =? this } func ->? { reference } func _string { def object =object object ischar if { 1 anew =object object TYPE_STRING settype } object isbyte if { object itos =object } object isint if { object itos =object } object isfloat if { object ftos =object } object islong if { object ltos =object } object isdouble if { object dtos =object } object isarray if { object TYPE_STRING settype =object } object isstring not if { "IncompatibleTypes" "Incompatible types: " object gettype typename " - string" strconcat strconcat throw } object } func isstring { gettype typename "string" eq } func stoi { stol _int } func stof { stod _float } func itos { _long ltos } func ftos { _double dtos } func dtos { "NotImplemented" "dtos is not implemented" throw } func stod { "NotImplemented" "stod is not implemented" throw } "Number to string" # func ltos { def n =n "bind number" # def s 0 anew =s "make array" # def ne n 0 lt dup if { n neg =n } =ne func rem { 10 _long / } def c0 "0" char =c0 n 0 gt not if { "0" =s } while { n 0 gt } { ( ( ( n 10 _long % _char ) c0 + ) _char 1 anewput _string ) s strconcat =s n rem =n "divide by ten to remove last digit" # } ne if { "-" s strconcat =s } s _string } func stol { def s _array =s "bind string" # def n 0 _long =n "the number to return" # def ne s 0 aget "-" char eq =ne def len s alen =len ne if { s ( len 1 - dup =len anew ) 1 0 len acopy =s } func rem { dup ( ( def len alen 1 - =len ) len anew ) 1 0 len acopy } def c0 "0" char =c0 while { s alen 0 eq not } { def chr s char =chr "extract first char" # n 10 _long * =n n ( chr c0 - _long ) + =n s rem =s "remove first digit" # } n ( ne 2 * 1 - neg ) _long * } func char { _array 0 aget } "Copy array" # func acopy { "bind args" # def len =len def idx2 =idx2 def idx1 =idx1 def arr2 =arr2 def arr1 =arr1 def i 0 =i while { i len lt } { arr2 ( i idx2 + ) ( arr1 ( i idx1 + ) aget ) aput i 1 + =i } arr2 } func strconcat { "bind args" # def str2 _string _array =str2 def str1 _string _array =str1 def str str1 alen str2 alen + anew =str str1 str 0 0 str1 alen acopy pop str2 str 0 str1 alen str2 alen acopy pop str _string } func strsplit { "bind args" # def splitter _string _array =splitter def str _string _array =str def sequences 0 anew =sequences def sequence 0 anew =sequence def i 0 =i def sm 0 =sm while { i str alen lt } { def j 0 =j def chr str i aget =chr while { j splitter alen lt i j + str alen lt and } { str i j + aget splitter j aget eq if { sm inc sm splitter alen eq if { sequences [ sequence _string ] aadd =sequences 0 anew =sequence 0 =sm i splitter alen + =i 4 stop } } j inc } sequence [ chr ] aadd =sequence i inc } sequences [ sequence _string ] aadd =sequences sequences } func strjoin { "bind args" # def joiner _string =joiner def arr _array =arr 1 neg =i def s "" =s while { ( i 1 + =i ) ( i arr alen lt ) } { s arr i aget joiner strconcat strconcat =s } s } func strsub { def pos2 _int =pos2 def pos1 _int =pos1 _array pos1 pos2 asub _string } func asub { "bind args" # def pos2 _int =pos2 def pos1 _int =pos1 def arr =arr def length pos2 pos1 - =length arr length anew pos1 0 length acopy } func puts { def str _array =str def i 1 neg =i while { ( i 1 + =i ) ( i str alen lt ) } { str i aget putchar } } func anewput { def size =size def arr size anew =arr def i 0 =i while { i size lt } { arr swap i swap aput i inc } arr areverse } func areverse { def arr =arr def newarr arr alen anew =newarr def i arr alen 1 - =i def j 0 =j while { i 0 lt not } { newarr j arr i aget aput j 1 + =j i 1 - =i } newarr } func strcontains { acontains } func acontains { def check _array =check "bind check" # def s _array =s "bind array" # def found 0 =found def counter 0 =counter def i 0 =i while { i s alen lt } { s i aget check counter aget eq dup if { counter inc } not if { 0 =counter s i aget check counter aget eq if { counter inc } } counter check alen eq if { 1 =found s alen =i } i inc } found } "These functions are magic, they use natives to get recent words and modify the" # "variables, do not touch them unless you know exactly what you're doing!" # func inc { def varname 4 _last_word =varname pop ( varname 1 _layer_call ) "Get var" # 1 + "Increment" # ( "=" varname strconcat 1 _layer_call ) "Store var" # } func dec { def varname 4 _last_word =varname pop ( varname 1 _layer_call ) "Get var" # 1 - "Decrement" # ( "=" varname strconcat 1 _layer_call ) "Store var" # } func strlowercase { def s _array =s "bind string" # def i 0 =i while { i s alen lt } { def chr s i aget =chr chr "A" char lt not chr "Z" char gt not and if { s i chr "a" char "A" char - + aput } i inc } s _string } func struppercase { def s _array =s "bind string" # def i 0 =i while { i s alen lt } { def chr s i aget =chr chr "a" char lt not chr "z" char gt not and if { s i chr "a" char "A" char - - aput } i inc } s _string } func main { pop 0 } func aadd { def arr2 =arr2 def arr1 =arr1 def newarr arr1 alen arr2 alen + anew =newarr arr1 newarr 0 0 arr1 alen acopy =newarr arr2 newarr 0 arr1 alen arr2 alen acopy =newarr newarr } def TYPE_SHADOW "shadow" mktype =TYPE_SHADOW func [ { TYPE_ARRAY TYPE_SHADOW settype } "For some reason, this makes objects lose their identity. I do not know, why." # "Fixed in commit 81eff27, bug was in dup native." # func ] { "create an array containing everything on stack until the arrayshadow" # def array 0 anew =array while { dup [ eq not } { 1 anewput array aadd =array } pop array } func astartswith_old { def match _array =match def str _array =str str alen match alen lt if { 0 2 stop } str alen match alen eq if { str match eq 2 stop } def i 0 =i while { i match alen lt } { str i aget match i aget eq not if { 0 3 stop } i inc } 1 } func astartswith { def match _array =match def val _array =val val alen match alen lt if { 0 2 stop } val alen match alen eq if { val match eq 2 stop } val 0 match alen asub match eq } func times { with callable amount ; def i 0 =i callable [ while { i amount lt } { i i 1 + =i } ] foreach }