├── README.md ├── bin ├── build.bat ├── build_run.bat ├── check_all.bat ├── compile_speed.bat ├── example │ ├── 1.h │ ├── 10_1.h │ ├── 10_2.h │ ├── 10_3.h │ ├── 11_1.h │ ├── 11_2.h │ ├── 11_3.h │ ├── 11_4.h │ ├── 11_5.h │ ├── 11_6.h │ ├── 11_7.h │ ├── 12.h │ ├── 13.h │ ├── 14_1.h │ ├── 14_2.h │ ├── 16_1.h │ ├── 16_2.h │ ├── 16_3.h │ ├── 16_4.h │ ├── 17_1.h │ ├── 17_2.h │ ├── 18_1.h │ ├── 18_2.h │ ├── 19_1.h │ ├── 19_2.h │ ├── 2.h │ ├── 20.h │ ├── 21_1.h │ ├── 21_2.h │ ├── 22_1.h │ ├── 22_2.h │ ├── 23_1.h │ ├── 23_2.h │ ├── 23_3.h │ ├── 24.h │ ├── 25_1.h │ ├── 25_2.h │ ├── 25_3.h │ ├── 26_1.h │ ├── 26_2.h │ ├── 27.h │ ├── 28.h │ ├── 29.h │ ├── 3.h │ ├── 30_1.h │ ├── 30_2.h │ ├── 31.h │ ├── 32_1.h │ ├── 32_2.h │ ├── 32_3.h │ ├── 33_1.h │ ├── 33_2.h │ ├── 34_1.h │ ├── 34_2.h │ ├── 35.h │ ├── 36_1.h │ ├── 36_10.h │ ├── 36_2.h │ ├── 36_3.h │ ├── 36_4.h │ ├── 36_5.h │ ├── 36_6.h │ ├── 36_7.h │ ├── 36_8.h │ ├── 36_9.h │ ├── 40_1.h │ ├── 40_2.h │ ├── 40_3.h │ ├── 40_4.h │ ├── 40_5.h │ ├── 42.h │ ├── 44.h │ ├── 4_1.h │ ├── 4_2.h │ ├── 50.h │ ├── 51.h │ ├── 52.h │ ├── 53.h │ ├── 54.h │ ├── 55.h │ ├── 56.h │ ├── 57.h │ ├── 5_1.h │ ├── 5_2.h │ ├── 6.h │ ├── 7.h │ ├── 8.h │ ├── 9.h │ ├── answer │ │ ├── 1.txt │ │ ├── 10_1.txt │ │ ├── 10_2.txt │ │ ├── 10_3.txt │ │ ├── 11_1.txt │ │ ├── 11_2.txt │ │ ├── 11_3.txt │ │ ├── 11_4.txt │ │ ├── 11_5.txt │ │ ├── 11_6.txt │ │ ├── 11_7.txt │ │ ├── 12.txt │ │ ├── 13.txt │ │ ├── 14_1.txt │ │ ├── 17_1.txt │ │ ├── 17_2.txt │ │ ├── 18_1.txt │ │ ├── 18_2.txt │ │ ├── 19_1.txt │ │ ├── 19_2.txt │ │ ├── 2.txt │ │ ├── 20.txt │ │ ├── 21_1.txt │ │ ├── 21_2.txt │ │ ├── 22_1.txt │ │ ├── 23_1.txt │ │ ├── 23_2.txt │ │ ├── 23_3.txt │ │ ├── 24.txt │ │ ├── 25_1.txt │ │ ├── 25_2.txt │ │ ├── 25_3.txt │ │ ├── 26_1.txt │ │ ├── 26_2.txt │ │ ├── 27.txt │ │ ├── 28.txt │ │ ├── 29.txt │ │ ├── 3.txt │ │ ├── 30_1.txt │ │ ├── 30_2.txt │ │ ├── 31.txt │ │ ├── 32_1.txt │ │ ├── 32_2.txt │ │ ├── 32_3.txt │ │ ├── 33_1.txt │ │ ├── 33_2.txt │ │ ├── 34_1.txt │ │ ├── 34_2.txt │ │ ├── 35.txt │ │ ├── 36_1.txt │ │ ├── 36_10.txt │ │ ├── 36_2.txt │ │ ├── 36_3.txt │ │ ├── 36_4.txt │ │ ├── 36_5.txt │ │ ├── 36_6.txt │ │ ├── 36_7.txt │ │ ├── 42.txt │ │ ├── 44.txt │ │ ├── 4_1.txt │ │ ├── 4_2.txt │ │ ├── 50.txt │ │ ├── 51.txt │ │ ├── 52.txt │ │ ├── 53.txt │ │ ├── 54.txt │ │ ├── 55.txt │ │ ├── 56.txt │ │ ├── 57.txt │ │ ├── 5_1.txt │ │ ├── 5_2.txt │ │ ├── 6.txt │ │ ├── 7.txt │ │ ├── 8.txt │ │ └── 9.txt │ ├── asm_opt.h │ ├── bf.h │ ├── check.h │ ├── code.h │ ├── compile_speed.h │ ├── count.h │ ├── find.h │ ├── http.h │ ├── line_check.h │ ├── lisp.h │ ├── run.h │ ├── snake.h │ ├── speed_test.h │ ├── time.h │ └── win.h ├── gl │ ├── 1.h │ ├── 2.h │ ├── 3.h │ ├── frame.h │ ├── freeglut.dll │ ├── gl.h │ ├── line.h │ └── sphere.h ├── ide │ ├── License.txt │ ├── SciLexer.dll │ ├── SciTE.exe │ ├── SciTE.properties │ ├── SciTEGlobal.properties │ ├── asm.properties │ ├── cpp.properties │ ├── lisp.properties │ ├── luaCOPYRIGHT │ ├── modules.api │ ├── python.properties │ └── scite.1 ├── launch_ide.bat ├── line_check.bat ├── nasm │ ├── GoLink.exe │ ├── bin.bat │ ├── bin.h │ ├── cell.bin │ ├── cell.h │ ├── dec.inc │ ├── grldr │ ├── menu.lst │ ├── nasm.exe │ └── windemos.inc ├── open_cmd.bat ├── pic │ ├── flappy.png │ ├── god.png │ ├── rpp.png │ ├── rpp_snake.png │ ├── rpp_speed.png │ └── rpp_win.png ├── rcheck.bat ├── rinf │ ├── conf.txt │ ├── key.txt │ ├── match.txt │ ├── optr.txt │ └── optr2.txt ├── rjit.bat ├── rjit_win.bat ├── rpack.bat ├── rpack_win.bat ├── rpp.exe ├── rpp_win.exe ├── rsrc │ ├── basic.h │ ├── carray.h │ ├── char.h │ ├── chs.h │ ├── double.h │ ├── double_j.h │ ├── double_n.h │ ├── eval.h │ ├── float.h │ ├── func.h │ ├── int.h │ ├── int8.h │ ├── int8_j.h │ ├── int8_n.h │ ├── math.h │ ├── new.h │ ├── ralgo.h │ ├── rbuf.h │ ├── rbufm.h │ ├── rcc.h │ ├── rcode.h │ ├── rcode_n.h │ ├── rdic.h │ ├── rdir.h │ ├── rf.h │ ├── rf_g.h │ ├── rf_j.h │ ├── rf_n.h │ ├── rff.h │ ├── rff_j.h │ ├── rff_n.h │ ├── rfile.h │ ├── rfs.h │ ├── rfs_j.h │ ├── rfs_n.h │ ├── rhash.h │ ├── rlist.h │ ├── rmutex.h │ ├── rmutex_j.h │ ├── rmutex_n.h │ ├── rp.h │ ├── rpp.h │ ├── rset.h │ ├── rsock.h │ ├── rstr.h │ ├── rstrw.h │ ├── short.h │ ├── uint.h │ ├── ushort.h │ ├── var.h │ └── varf.h └── run.bat ├── del.bat ├── proj ├── rpp.sln ├── rpp.vcxproj ├── rpp.vcxproj.filters └── rpp_win │ ├── rpp_win.sln │ ├── rpp_win.vcxproj │ └── rpp_win.vcxproj.filters ├── rlib ├── gbk.txt ├── ralgo.h ├── rbase.h ├── rbuf.h ├── rclass.h ├── rcode.h ├── rdb.h ├── rdic.h ├── rdir.h ├── rf.h ├── rfile.h ├── rhash.h ├── rindex.h ├── rlist.h ├── rmutex.h ├── rset.h ├── rsock.h ├── rstr.h ├── rstrw.h └── rthread.h ├── rpp.pdf ├── rpp ├── rpp.cpp ├── rpp_def.h ├── rpp_win.cpp ├── talloc.h ├── tanalyse.h ├── tconf.h ├── tsh.h ├── tstruct.h ├── tvm.h ├── tvm_struct.h ├── zadd.h ├── zasm.h ├── zautof.h ├── zbin.h ├── zclass.h ├── zcontrol.h ├── zctl.h ├── zexp.h ├── zfind.h ├── zftl.h ├── zjit.h ├── zjitb.h ├── zjitf.h ├── zjiti.h ├── zlambda.h ├── zmac.h ├── zmain.h ├── zmatch.h ├── zmemb.h ├── znasm.h ├── zopt.h ├── zpre.h ├── zread.h ├── zsent.h ├── zsrep.h └── zsuper.h └── update.txt /README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/README.md -------------------------------------------------------------------------------- /bin/build.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | rpp.exe example\run.h %1 -build -------------------------------------------------------------------------------- /bin/build_run.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | rem cd /d %~dp0 3 | rpp.exe example\run.h %1 -------------------------------------------------------------------------------- /bin/check_all.bat: -------------------------------------------------------------------------------- 1 | rjit example\check.h -------------------------------------------------------------------------------- /bin/compile_speed.bat: -------------------------------------------------------------------------------- 1 | rpp example\compile_speed.h 2 | pause -------------------------------------------------------------------------------- /bin/example/1.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/1.h -------------------------------------------------------------------------------- /bin/example/10_1.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/10_1.h -------------------------------------------------------------------------------- /bin/example/10_2.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/10_2.h -------------------------------------------------------------------------------- /bin/example/10_3.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/10_3.h -------------------------------------------------------------------------------- /bin/example/11_1.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/11_1.h -------------------------------------------------------------------------------- /bin/example/11_2.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/11_2.h -------------------------------------------------------------------------------- /bin/example/11_3.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/11_3.h -------------------------------------------------------------------------------- /bin/example/11_4.h: -------------------------------------------------------------------------------- 1 |  2 | void main() 3 | { 4 | putsl(XC_SY_DEFAULT) 5 | putsl(test()) 6 | putsl(test2()) 7 | } 8 | 9 | mac test() 123 10 | 11 | mac test2() 12 | { 13 | 234 14 | } 15 | 16 | mac XC_SY_DEFAULT 17 | { 18 | (1+ 19 | 2+ 20 | 3) 21 | } -------------------------------------------------------------------------------- /bin/example/11_5.h: -------------------------------------------------------------------------------- 1 |  2 | void main() 3 | { 4 | B 1 2 5 | C 1 [2 *3] 6 | C 1 [2*3*4] 7 | D 1 [2 3] 8 | 9 | v=array[7,8,9] 10 | v.join('').printl 11 | 12 | v=E(1,2,3) 13 | v.join('').printl 14 | 15 | v=E(1,2,3,4) 16 | v.join('').printl 17 | } 18 | 19 | mac$ B _word _word 20 | { 21 | rf.printl($0##$1) 22 | } 23 | 24 | mac$ C _word [ _mword ] 25 | { 26 | putsl($0+$1) 27 | } 28 | 29 | mac$ D _word [ _mword ] 30 | { 31 | putsl($0+$1=>0+$1=>1) 32 | } 33 | 34 | mac$ E ( _mword ) 35 | { 36 | array[$0] 37 | } -------------------------------------------------------------------------------- /bin/example/11_6.h: -------------------------------------------------------------------------------- 1 |  2 | void main() 3 | { 4 | ==> 2 3 <== 5 | 6 | ┏━━━━━┓ 7 | ┃ 1 2 ┃ 8 | ┃ 3 4 ┃ 9 | ┗━━━━━┛ 10 | } 11 | 12 | mac$ ==> _word _word <== 13 | { 14 | putsl(rstr($0)+rstr($1)) 15 | } 16 | 17 | mac$ ┏━━━━━┓┃ _word _word ┃ ┃ _word _word ┃┗━━━━━┛ 18 | { 19 | putsl(rstr($0)+'--'+rstr($1)+'--'+rstr($2)+'--'+rstr($3)) 20 | } 21 | -------------------------------------------------------------------------------- /bin/example/11_7.h: -------------------------------------------------------------------------------- 1 | /* 2 | 对比宏和模板函数 3 | 注意宏是无格式的,因此花括号和分号不可省略 4 | */ 5 | 6 | void main() 7 | { 8 | putsl fb(1,2) 9 | putsl fb(0.5,0.6) 10 | 11 | putsl fa_int(1,2) 12 | putsl fa_double(0.5,0.6) 13 | } 14 | 15 | T fb(T a,T b) 16 | { 17 | return a+b; 18 | } 19 | 20 | fa int 21 | fa double 22 | 23 | define$ fa _word 24 | { 25 | $0 fa_##$0($0 a,$0 b) 26 | { 27 | return a+b; 28 | } 29 | } -------------------------------------------------------------------------------- /bin/example/12.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/12.h -------------------------------------------------------------------------------- /bin/example/13.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/13.h -------------------------------------------------------------------------------- /bin/example/14_1.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/14_1.h -------------------------------------------------------------------------------- /bin/example/14_2.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/14_2.h -------------------------------------------------------------------------------- /bin/example/16_1.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/16_1.h -------------------------------------------------------------------------------- /bin/example/16_2.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/16_2.h -------------------------------------------------------------------------------- /bin/example/16_3.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/16_3.h -------------------------------------------------------------------------------- /bin/example/16_4.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/16_4.h -------------------------------------------------------------------------------- /bin/example/17_1.h: -------------------------------------------------------------------------------- 1 | /* 2 | 闭包 3 | */ 4 | 5 | void main() 6 | { 7 | int a=2 8 | void[lambda(){puts a}] 9 | } -------------------------------------------------------------------------------- /bin/example/17_2.h: -------------------------------------------------------------------------------- 1 | /* 2 | 匿名函数 3 | */ 4 | 5 | void main() 6 | { 7 | p=lambda(int a,int b){ 8 | putsl a+b 9 | } 10 | 11 | void[p,1,2] 12 | 13 | p=lambda(int,int a,int b){ 14 | return a+b 15 | } 16 | 17 | putsl int[p,1,2] 18 | } -------------------------------------------------------------------------------- /bin/example/18_1.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/18_1.h -------------------------------------------------------------------------------- /bin/example/18_2.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/18_2.h -------------------------------------------------------------------------------- /bin/example/19_1.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/19_1.h -------------------------------------------------------------------------------- /bin/example/19_2.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/19_2.h -------------------------------------------------------------------------------- /bin/example/2.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/2.h -------------------------------------------------------------------------------- /bin/example/20.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/20.h -------------------------------------------------------------------------------- /bin/example/21_1.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/21_1.h -------------------------------------------------------------------------------- /bin/example/21_2.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/21_2.h -------------------------------------------------------------------------------- /bin/example/22_1.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/22_1.h -------------------------------------------------------------------------------- /bin/example/22_2.h: -------------------------------------------------------------------------------- 1 | main 2 | { 3 | stdcall["MessageBoxA",0,"abc","123",0] 4 | stdcall["MessageBoxW",0,utf16c("abc"),utf16c("123"),0] 5 | @MessageBoxA(0,"aaa","bbb",0) 6 | 7 | #ifdef _JIT 8 | void[rf.find_dll("MessageBoxA"),0,"111","222",0] 9 | #endif 10 | } -------------------------------------------------------------------------------- /bin/example/23_1.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/23_1.h -------------------------------------------------------------------------------- /bin/example/23_2.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/23_2.h -------------------------------------------------------------------------------- /bin/example/23_3.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/23_3.h -------------------------------------------------------------------------------- /bin/example/24.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/24.h -------------------------------------------------------------------------------- /bin/example/25_1.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/25_1.h -------------------------------------------------------------------------------- /bin/example/25_2.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/25_2.h -------------------------------------------------------------------------------- /bin/example/25_3.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/25_3.h -------------------------------------------------------------------------------- /bin/example/26_1.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/26_1.h -------------------------------------------------------------------------------- /bin/example/26_2.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/26_2.h -------------------------------------------------------------------------------- /bin/example/27.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/27.h -------------------------------------------------------------------------------- /bin/example/28.h: -------------------------------------------------------------------------------- 1 | /* 2 | 全局变量定义的时候不能使用类型推断 3 | */ 4 | 5 | 6 | int g_a=2 7 | rbuf g_b(3) 8 | 9 | main 10 | { 11 | putsl g_a 12 | b=g_b 13 | b.count.printl 14 | } -------------------------------------------------------------------------------- /bin/example/29.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/29.h -------------------------------------------------------------------------------- /bin/example/3.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/3.h -------------------------------------------------------------------------------- /bin/example/30_1.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/30_1.h -------------------------------------------------------------------------------- /bin/example/30_2.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/30_2.h -------------------------------------------------------------------------------- /bin/example/31.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/31.h -------------------------------------------------------------------------------- /bin/example/32_1.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/32_1.h -------------------------------------------------------------------------------- /bin/example/32_2.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/32_2.h -------------------------------------------------------------------------------- /bin/example/32_3.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/32_3.h -------------------------------------------------------------------------------- /bin/example/33_1.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/33_1.h -------------------------------------------------------------------------------- /bin/example/33_2.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/33_2.h -------------------------------------------------------------------------------- /bin/example/34_1.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/34_1.h -------------------------------------------------------------------------------- /bin/example/34_2.h: -------------------------------------------------------------------------------- 1 | //嵌套类和嵌套命名空间 2 | 3 | namespace A 4 | { 5 | } 6 | 7 | class A.B 8 | { 9 | int m_b 10 | 11 | A.B() 12 | { 13 | putsl('constructor') 14 | } 15 | 16 | static void func() 17 | { 18 | putsl('func') 19 | } 20 | } 21 | 22 | namespace A.B.C 23 | { 24 | void func() 25 | { 26 | putsl('func') 27 | } 28 | } 29 | 30 | void main() 31 | { 32 | A.B b 33 | b.m_b=3 34 | putsl(b.m_b) 35 | A.B.func() 36 | A.B.C.func() 37 | } -------------------------------------------------------------------------------- /bin/example/35.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/35.h -------------------------------------------------------------------------------- /bin/example/36_1.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/36_1.h -------------------------------------------------------------------------------- /bin/example/36_10.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/36_10.h -------------------------------------------------------------------------------- /bin/example/36_2.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/36_2.h -------------------------------------------------------------------------------- /bin/example/36_3.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/36_3.h -------------------------------------------------------------------------------- /bin/example/36_4.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/36_4.h -------------------------------------------------------------------------------- /bin/example/36_5.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/36_5.h -------------------------------------------------------------------------------- /bin/example/36_6.h: -------------------------------------------------------------------------------- 1 | import rdic.h 2 | 3 | main 4 | { 5 | rdic a 6 | a['abc']=3 7 | a['121213']=4 8 | a['1']=1 9 | for i=1 to 1000 10 | a[i.torstr]=i 11 | a['121213'].printl 12 | } -------------------------------------------------------------------------------- /bin/example/36_7.h: -------------------------------------------------------------------------------- 1 | /* 2 | read self 3 | */ 4 | 5 | import "rfile.h" 6 | 7 | main 8 | { 9 | rfile file("example/36_7.h") 10 | file.read_all.sub(3).print 11 | //auto close file in destructor 12 | } -------------------------------------------------------------------------------- /bin/example/36_8.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/36_8.h -------------------------------------------------------------------------------- /bin/example/36_9.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/36_9.h -------------------------------------------------------------------------------- /bin/example/40_1.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/40_1.h -------------------------------------------------------------------------------- /bin/example/40_2.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/40_2.h -------------------------------------------------------------------------------- /bin/example/40_3.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/40_3.h -------------------------------------------------------------------------------- /bin/example/40_4.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/40_4.h -------------------------------------------------------------------------------- /bin/example/40_5.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/40_5.h -------------------------------------------------------------------------------- /bin/example/42.h: -------------------------------------------------------------------------------- 1 | /* 2 | RPP不支持重载小括号, 3 | 但是可以重载中括号实现C++的函数对象(仿函数) 4 | */ 5 | 6 | void main() 7 | { 8 | A a=lambda(int,int n){return n*n} 9 | puts a[3] 10 | } 11 | 12 | class A 13 | { 14 | void* m_func 15 | 16 | =(void* p) 17 | { 18 | m_func=p 19 | } 20 | 21 | T1 [](T2 n) 22 | { 23 | return T1[m_func,n] 24 | } 25 | } -------------------------------------------------------------------------------- /bin/example/44.h: -------------------------------------------------------------------------------- 1 | /* 2 | 惰性求值的方式实现短路求值 3 | RPP是同时支持call_by_name和call_by_need和call_by_value的语言 4 | 该示例只能以JIT模式运行 5 | */ 6 | 7 | import eval.h 8 | 9 | void main() 10 | { 11 | int* p=null 12 | 13 | //不能用 p!=null&&*p==2 因为 && 是非惰性的 14 | if and(p!=null,*p==2) 15 | putsl('and') 16 | 17 | rbuf v 18 | 19 | //不能用 v.empty||v[0]!=5 因为 || 是非惰性的 20 | if or(v.empty,v[0]!=5) 21 | putsl('or') 22 | 23 | //and和or是惰性的,可以带多个参数 24 | if and(2>1,p==null,v.empty,3!=4) 25 | putsl('true') 26 | 27 | if and(and(2>1),3!=4) 28 | putsl('true') 29 | 30 | a=1 31 | b=2 32 | c=3 33 | 34 | putsl and(and(a,b),c) 35 | putsl or(or(a,b),c) 36 | 37 | a=0 38 | b=1 39 | c=0 40 | 41 | putsl and(and(a,b),c) 42 | putsl or(or(a,b),c) 43 | putsl or(and(a,b),c) 44 | putsl and(or(a,b),c) 45 | } -------------------------------------------------------------------------------- /bin/example/4_1.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/4_1.h -------------------------------------------------------------------------------- /bin/example/4_2.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/4_2.h -------------------------------------------------------------------------------- /bin/example/50.h: -------------------------------------------------------------------------------- 1 |  2 | main 3 | { 4 | test1 5 | test2 6 | test3 7 | test4 8 | test5 9 | test6 10 | } 11 | 12 | //浮点测试 13 | test1 14 | { 15 | putsl 0.2+0.3 16 | putsl 0.2*0.3 17 | putsl 0.2/0.3 18 | putsl 0.2-0.3 19 | putsl 0.2<0.3 20 | putsl 0.2>0.3 21 | a=99.2*20 22 | putsl a 23 | putsl(-2) 24 | } 25 | 26 | //逻辑运算测试 27 | test2 28 | { 29 | putsl 0&&0 30 | putsl 1&&0 31 | putsl 0&&1 32 | putsl 1&&1 33 | putsl 0||0 34 | putsl 1||0 35 | putsl 0||1 36 | putsl 1||1 37 | } 38 | 39 | //自动类型转换测试 40 | test3 41 | { 42 | uint a=1 43 | int c=5 44 | putsl a+sizeof(int)!=c 45 | } 46 | 47 | //64位运算测试 48 | test4 49 | { 50 | int8 a=9 51 | int8 b=3 52 | putsl a/b 53 | putsl a*b 54 | putsl a%b 55 | putsl a-b 56 | putsl ab 58 | } 59 | 60 | test5 61 | { 62 | if (2)==2 63 | putsl('ok',,,) 64 | } 65 | 66 | test6 67 | { 68 | putsl ORM[1,2] 69 | putsl ORM[1,2,4,8] 70 | putsl ORM[1] 71 | } -------------------------------------------------------------------------------- /bin/example/51.h: -------------------------------------------------------------------------------- 1 | /* 2 | 仅用位运算实现加减乘除,面试专用 3 | */ 4 | 5 | main 6 | { 7 | fadd(1,2).printl 8 | fadd(19,29999).printl 9 | 10 | fsub(-1,3).printl 11 | fsub(19,2345).printl 12 | 13 | fmul(99,98).printl 14 | fmul(-29,235).printl 15 | 16 | fdiv(99,98).printl 17 | fdiv(9,3).printl 18 | fdiv(-9,3).printl 19 | fdiv(8,3).printl 20 | } 21 | 22 | int fadd(int x,int y) 23 | { 24 | for 25 | a=AND(x,y) 26 | b=XOR(x,y) 27 | x=SHL(a,1) 28 | y=b 29 | ifn a 30 | break 31 | return b 32 | } 33 | 34 | int fneg(int x) 35 | { 36 | return fadd(NOT(x),1) 37 | } 38 | 39 | int fsub(int x,int y) 40 | { 41 | return fadd(x,fneg(y)) 42 | } 43 | 44 | int fmul(int x,int y) 45 | { 46 | m=1 47 | z=0 48 | if x<0 49 | x=fneg(x) 50 | y=fneg(y) 51 | for x>=m&&y 52 | if AND(x,m) 53 | z=fadd(y,z) 54 | y=SHL(y,1) 55 | m=SHL(m,1) 56 | return z 57 | } 58 | 59 | int fdiv(int x,int y) 60 | { 61 | c=0 62 | sign=0 63 | if x<0 64 | x=fneg(x) 65 | sign=XOR(sign,1) 66 | if y<0 67 | y=fneg(y) 68 | sign=XOR(sign,1) 69 | if y 70 | for x>=y 71 | x=fsub(x,y) 72 | c=fadd(c,1) 73 | if sign 74 | c=fneg(c) 75 | return c 76 | } -------------------------------------------------------------------------------- /bin/example/52.h: -------------------------------------------------------------------------------- 1 | /* 2 | 全排列的非递归实现,支持去掉重复 3 | */ 4 | 5 | void main() 6 | { 7 | rbuf v 8 | #v.push(1,2,3,4) 9 | for 10 | v.join('').printl 11 | ifn next_permutation(v) 12 | break 13 | } 14 | 15 | bool next_permutation(rbuf& v) 16 | { 17 | if v.count<=1 18 | return false 19 | next=v.count-1 20 | for 21 | temp=next 22 | next-- 23 | if v[next](v[next],v[mid]) 28 | r_reverse(v,temp) 29 | return true 30 | if next==0 31 | r_reverse(v,0) 32 | return false 33 | } -------------------------------------------------------------------------------- /bin/example/53.h: -------------------------------------------------------------------------------- 1 | /* 2 | KMP算法 3 | */ 4 | 5 | void main() 6 | { 7 | putsl(find('abc123','c1')) 8 | putsl(find('abc123','c2')) 9 | } 10 | 11 | int find(rstr s,rstr p) 12 | { 13 | next=get_next(p) 14 | i=0 15 | j=0 16 | for i get_next(rstr p) 28 | { 29 | rbuf next(p.count) 30 | next[0]=-1 31 | k=-1 32 | j=0 33 | for j stack 8 | #stack.push(3,4,1,9,10,2) 9 | print(stack) 10 | func(stack) 11 | print(stack) 12 | reverse(stack) 13 | print(stack) 14 | sort(stack) 15 | print(stack) 16 | } 17 | 18 | void print(rbuf& stack) 19 | { 20 | for i=0 to stack.count-1 21 | putsl(stack[i]) 22 | putsl 23 | } 24 | 25 | void sort(rbuf& stack) 26 | { 27 | if stack.empty 28 | return 29 | a=stack.pop 30 | if stack.empty 31 | stack.push(a) 32 | return 33 | sort(stack) 34 | b=stack.pop 35 | if a& stack) 46 | { 47 | if stack.count<=1 48 | return 49 | a=stack.pop 50 | func(stack) 51 | b=stack.pop 52 | if a& stack) 62 | { 63 | if stack.count<=1 64 | return 65 | a=stack.pop 66 | reverse(stack) 67 | b=stack.pop 68 | reverse(stack) 69 | stack.push(a) 70 | reverse(stack) 71 | stack.push(b) 72 | } -------------------------------------------------------------------------------- /bin/example/56.h: -------------------------------------------------------------------------------- 1 | /* 2 | 组合遍历 3 | */ 4 | 5 | main 6 | { 7 | n=7 8 | sum=0 9 | for i=0;i[1,2,3,4,5] 8 | v.join(' ').printl 9 | v.parallel(4,lambda(int& a){ 10 | a*=3 11 | }) 12 | v.join(' ').printl 13 | } -------------------------------------------------------------------------------- /bin/example/5_1.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/5_1.h -------------------------------------------------------------------------------- /bin/example/5_2.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/5_2.h -------------------------------------------------------------------------------- /bin/example/6.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/6.h -------------------------------------------------------------------------------- /bin/example/7.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/7.h -------------------------------------------------------------------------------- /bin/example/8.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/8.h -------------------------------------------------------------------------------- /bin/example/9.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/9.h -------------------------------------------------------------------------------- /bin/example/answer/1.txt: -------------------------------------------------------------------------------- 1 | 3 -------------------------------------------------------------------------------- /bin/example/answer/10_1.txt: -------------------------------------------------------------------------------- 1 | 553628800553628800 -------------------------------------------------------------------------------- /bin/example/answer/10_2.txt: -------------------------------------------------------------------------------- 1 | 259 -------------------------------------------------------------------------------- /bin/example/answer/10_3.txt: -------------------------------------------------------------------------------- 1 | 1 2 | rp 3 | 47 -------------------------------------------------------------------------------- /bin/example/answer/11_1.txt: -------------------------------------------------------------------------------- 1 | 9 2 | 5 3 | 55 4 | 3628800 5 | -------------------------------------------------------------------------------- /bin/example/answer/11_2.txt: -------------------------------------------------------------------------------- 1 | 1 2 | abc 3 | 98 4 | 3 5 | -------------------------------------------------------------------------------- /bin/example/answer/11_3.txt: -------------------------------------------------------------------------------- 1 | 1 2 | abc 3 | 2 4 | 5 5 | 20 6 | 100 7 | -------------------------------------------------------------------------------- /bin/example/answer/11_4.txt: -------------------------------------------------------------------------------- 1 | 6 2 | 123 3 | 234 4 | -------------------------------------------------------------------------------- /bin/example/answer/11_5.txt: -------------------------------------------------------------------------------- 1 | 12 2 | 7 3 | 25 4 | 6 5 | 789 6 | 123 7 | 1234 8 | -------------------------------------------------------------------------------- /bin/example/answer/11_6.txt: -------------------------------------------------------------------------------- 1 | 23 2 | 1--2--3--4 3 | -------------------------------------------------------------------------------- /bin/example/answer/11_7.txt: -------------------------------------------------------------------------------- 1 | 3 2 | 1.100000 3 | 3 4 | 1.100000 5 | -------------------------------------------------------------------------------- /bin/example/answer/12.txt: -------------------------------------------------------------------------------- 1 | 3 2 | 3 3 | 3 4 | 3 5 | -------------------------------------------------------------------------------- /bin/example/answer/13.txt: -------------------------------------------------------------------------------- 1 | 33333 -------------------------------------------------------------------------------- /bin/example/answer/14_1.txt: -------------------------------------------------------------------------------- 1 | 123 2 | 123 3 | 2 4 | 3 5 | 99 6 | 98 7 | test 8 | main 9 | C 10 | 5 11 | -------------------------------------------------------------------------------- /bin/example/answer/17_1.txt: -------------------------------------------------------------------------------- 1 | 2 -------------------------------------------------------------------------------- /bin/example/answer/17_2.txt: -------------------------------------------------------------------------------- 1 | 3 2 | 3 3 | -------------------------------------------------------------------------------- /bin/example/answer/18_1.txt: -------------------------------------------------------------------------------- 1 | 12 -------------------------------------------------------------------------------- /bin/example/answer/18_2.txt: -------------------------------------------------------------------------------- 1 | 12 -------------------------------------------------------------------------------- /bin/example/answer/19_1.txt: -------------------------------------------------------------------------------- 1 | 3 2 | 6 3 | 103 4 | 10 5 | 16 6 | -------------------------------------------------------------------------------- /bin/example/answer/19_2.txt: -------------------------------------------------------------------------------- 1 | 3 2 | 5 3 | -------------------------------------------------------------------------------- /bin/example/answer/2.txt: -------------------------------------------------------------------------------- 1 | 3 -------------------------------------------------------------------------------- /bin/example/answer/20.txt: -------------------------------------------------------------------------------- 1 | 43 -------------------------------------------------------------------------------- /bin/example/answer/21_1.txt: -------------------------------------------------------------------------------- 1 | 02 -------------------------------------------------------------------------------- /bin/example/answer/21_2.txt: -------------------------------------------------------------------------------- 1 | 2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 -------------------------------------------------------------------------------- /bin/example/answer/22_1.txt: -------------------------------------------------------------------------------- 1 | 3 2 | 3 3 | 0 4 | 1 5 | -1 6 | 3 7 | -------------------------------------------------------------------------------- /bin/example/answer/23_1.txt: -------------------------------------------------------------------------------- 1 | uint 2 | uint 3 | uint 4 | rstr 5 | int 6 | 97 7 | 255 8 | -------------------------------------------------------------------------------- /bin/example/answer/23_2.txt: -------------------------------------------------------------------------------- 1 | 2 -------------------------------------------------------------------------------- /bin/example/answer/23_3.txt: -------------------------------------------------------------------------------- 1 | int 2 | int 3 | 0 4 | -------------------------------------------------------------------------------- /bin/example/answer/24.txt: -------------------------------------------------------------------------------- 1 | 411c12 -------------------------------------------------------------------------------- /bin/example/answer/25_1.txt: -------------------------------------------------------------------------------- 1 | 0000011111222223333344444 -------------------------------------------------------------------------------- /bin/example/answer/25_2.txt: -------------------------------------------------------------------------------- 1 | 000011112222000011112222000011112222000011112222000011112222 -------------------------------------------------------------------------------- /bin/example/answer/25_3.txt: -------------------------------------------------------------------------------- 1 | 000011112222000011112222000011112222000011112222000011112222 -------------------------------------------------------------------------------- /bin/example/answer/26_1.txt: -------------------------------------------------------------------------------- 1 | func int 2 | func char 3 | -------------------------------------------------------------------------------- /bin/example/answer/26_2.txt: -------------------------------------------------------------------------------- 1 | 22 -------------------------------------------------------------------------------- /bin/example/answer/27.txt: -------------------------------------------------------------------------------- 1 | 2253344 -------------------------------------------------------------------------------- /bin/example/answer/28.txt: -------------------------------------------------------------------------------- 1 | 2 2 | 3 3 | -------------------------------------------------------------------------------- /bin/example/answer/29.txt: -------------------------------------------------------------------------------- 1 | 23 -------------------------------------------------------------------------------- /bin/example/answer/3.txt: -------------------------------------------------------------------------------- 1 | 3 -------------------------------------------------------------------------------- /bin/example/answer/30_1.txt: -------------------------------------------------------------------------------- 1 | i>=10 2 | 1 3 | 0 4 | -------------------------------------------------------------------------------- /bin/example/answer/30_2.txt: -------------------------------------------------------------------------------- 1 | 3 -------------------------------------------------------------------------------- /bin/example/answer/31.txt: -------------------------------------------------------------------------------- 1 | 123 2 | 123 3 | abc'123 4 | abc'123 5 | 97 6 | 97 7 | 97 8 | 100000000 9 | 100000000 10 | 10 11 | 10 12 | 10 13 | 0.500000 14 | -------------------------------------------------------------------------------- /bin/example/answer/32_1.txt: -------------------------------------------------------------------------------- 1 | pass 1 2 | pass 1 3 | pass 1 4 | pass 1 5 | pass 1 6 | pass 2 7 | other 8 | pass 2 9 | pass 2 10 | pass 2 11 | other 12 | other 13 | default 14 | default 15 | default 16 | -------------------------------------------------------------------------------- /bin/example/answer/32_2.txt: -------------------------------------------------------------------------------- 1 | 123456789123456789123456789123456789 -------------------------------------------------------------------------------- /bin/example/answer/32_3.txt: -------------------------------------------------------------------------------- 1 | a less than b 2 | a less than b 3 | 0123456789 -------------------------------------------------------------------------------- /bin/example/answer/33_1.txt: -------------------------------------------------------------------------------- 1 | 23 -------------------------------------------------------------------------------- /bin/example/answer/33_2.txt: -------------------------------------------------------------------------------- 1 | 34 -------------------------------------------------------------------------------- /bin/example/answer/34_1.txt: -------------------------------------------------------------------------------- 1 | 2224 -------------------------------------------------------------------------------- /bin/example/answer/34_2.txt: -------------------------------------------------------------------------------- 1 | constructor 2 | constructor 3 | 3 4 | func 5 | func 6 | -------------------------------------------------------------------------------- /bin/example/answer/35.txt: -------------------------------------------------------------------------------- 1 | 3 2 | 2 3 | 1 4 | -------------------------------------------------------------------------------- /bin/example/answer/36_1.txt: -------------------------------------------------------------------------------- 1 | 3 2 | 2 3 | 4 4 | 3 5 | 2 6 | 4 7 | -------------------------------------------------------------------------------- /bin/example/answer/36_10.txt: -------------------------------------------------------------------------------- 1 | protected code -------------------------------------------------------------------------------- /bin/example/answer/36_2.txt: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | 1 5 | 3 6 | 7 | 1 8 | 3 9 | -------------------------------------------------------------------------------- /bin/example/answer/36_3.txt: -------------------------------------------------------------------------------- 1 | 4 2 | -------------------------------------------------------------------------------- /bin/example/answer/36_4.txt: -------------------------------------------------------------------------------- 1 | 321 2 | 1343 3 | fj242i 4 | 12 5 | 6 | 12 7 | 1343 8 | 321 9 | fj242i 10 | 11 | 12 12 | 2 13 | -------------------------------------------------------------------------------- /bin/example/answer/36_5.txt: -------------------------------------------------------------------------------- 1 | 3 2 | 6 3 | 123 4 | -------------------------------------------------------------------------------- /bin/example/answer/36_6.txt: -------------------------------------------------------------------------------- 1 | 4 2 | -------------------------------------------------------------------------------- /bin/example/answer/36_7.txt: -------------------------------------------------------------------------------- 1 | /* 2 | read self 3 | */ 4 | 5 | import "rfile.h" 6 | 7 | main 8 | { 9 | rfile file("example/36_7.h") 10 | file.read_all.sub(3).print 11 | //auto close file in destructor 12 | } -------------------------------------------------------------------------------- /bin/example/answer/42.txt: -------------------------------------------------------------------------------- 1 | 9 -------------------------------------------------------------------------------- /bin/example/answer/44.txt: -------------------------------------------------------------------------------- 1 | or 2 | true 3 | true 4 | 1 5 | 1 6 | 0 7 | 1 8 | 0 9 | 0 10 | -------------------------------------------------------------------------------- /bin/example/answer/4_1.txt: -------------------------------------------------------------------------------- 1 | 3 -------------------------------------------------------------------------------- /bin/example/answer/4_2.txt: -------------------------------------------------------------------------------- 1 | 3 2 | 3 3 | 0 4 | 4 5 | -------------------------------------------------------------------------------- /bin/example/answer/50.txt: -------------------------------------------------------------------------------- 1 | 0.500000 2 | 0.060000 3 | 0.666667 4 | -0.100000 5 | 1 6 | 0 7 | 1984.000000 8 | -2 9 | 0 10 | 0 11 | 0 12 | 1 13 | 0 14 | 1 15 | 1 16 | 1 17 | 0 18 | 3 19 | 27 20 | 0 21 | 6 22 | 0 23 | 1 24 | ok 25 | 3 26 | 15 27 | 1 28 | -------------------------------------------------------------------------------- /bin/example/answer/51.txt: -------------------------------------------------------------------------------- 1 | 3 2 | 30018 3 | -4 4 | -2326 5 | 9702 6 | -6815 7 | 1 8 | 3 9 | -3 10 | 2 11 | -------------------------------------------------------------------------------- /bin/example/answer/52.txt: -------------------------------------------------------------------------------- 1 | 1234 2 | 1243 3 | 1324 4 | 1342 5 | 1423 6 | 1432 7 | 2134 8 | 2143 9 | 2314 10 | 2341 11 | 2413 12 | 2431 13 | 3124 14 | 3142 15 | 3214 16 | 3241 17 | 3412 18 | 3421 19 | 4123 20 | 4132 21 | 4213 22 | 4231 23 | 4312 24 | 4321 25 | -------------------------------------------------------------------------------- /bin/example/answer/53.txt: -------------------------------------------------------------------------------- 1 | 2 2 | -1 3 | -------------------------------------------------------------------------------- /bin/example/answer/54.txt: -------------------------------------------------------------------------------- 1 | 1 2 | 1 3 | -------------------------------------------------------------------------------- /bin/example/answer/55.txt: -------------------------------------------------------------------------------- 1 | 3 2 | 4 3 | 1 4 | 9 5 | 10 6 | 2 7 | 8 | 1 9 | 2 10 | 3 11 | 4 12 | 9 13 | 10 14 | 15 | 10 16 | 9 17 | 4 18 | 3 19 | 2 20 | 1 21 | 22 | 1 23 | 2 24 | 3 25 | 4 26 | 9 27 | 10 28 | 29 | -------------------------------------------------------------------------------- /bin/example/answer/56.txt: -------------------------------------------------------------------------------- 1 | 35 2 | 120 3 | 720 4 | 35 5 | -------------------------------------------------------------------------------- /bin/example/answer/57.txt: -------------------------------------------------------------------------------- 1 | 1 2 3 4 5 2 | 3 6 9 12 15 3 | -------------------------------------------------------------------------------- /bin/example/answer/5_1.txt: -------------------------------------------------------------------------------- 1 | 454545 -------------------------------------------------------------------------------- /bin/example/answer/5_2.txt: -------------------------------------------------------------------------------- 1 | true232323233 -------------------------------------------------------------------------------- /bin/example/answer/6.txt: -------------------------------------------------------------------------------- 1 | 1abc 2 | 123abc 3 | 123abc 4 | -------------------------------------------------------------------------------- /bin/example/answer/7.txt: -------------------------------------------------------------------------------- 1 | -2-2-222 -------------------------------------------------------------------------------- /bin/example/answer/8.txt: -------------------------------------------------------------------------------- 1 | 3eax is not zero -------------------------------------------------------------------------------- /bin/example/answer/9.txt: -------------------------------------------------------------------------------- 1 | cab132 2 | 123abc 3 | -------------------------------------------------------------------------------- /bin/example/asm_opt.h: -------------------------------------------------------------------------------- 1 | /* 2 | 汇编优化工具 3 | 使汇编代码更具可读性,并提高汇编速度 4 | 优化15000行大约需要30秒 5 | */ 6 | 7 | import rfile.h 8 | 9 | main 10 | { 11 | //name=getsl 12 | name='http.asm' 13 | s=rfile.read_all_n(name) 14 | 15 | s=s.replace('\n','\r\n') 16 | s=s.replace('dword esp','esp') 17 | s=s.replace('dword ebp','ebp') 18 | s=s.replace('dword edi','edi') 19 | s=s.replace('dword esi','esi') 20 | s=s.replace('dword ebx','ebx') 21 | s=s.replace(',ecx',', ecx') 22 | s=s.replace('ebx,0','ebx , 0') 23 | s=s.replace('ecx,[','ecx , [') 24 | s=s.replace('mov dword [ edi ] , esi','mov [ edi ] , esi') 25 | s=opt_sym(s) 26 | s=line_del(s) 27 | s=opt_jmp(s) 28 | s=line_del(s) 29 | s=opt_two(s) 30 | s=line_del(s) 31 | s=sym_replace(s) 32 | s=line_del(s) 33 | 34 | rfile.write_all_n(name,s) 35 | } 36 | 37 | rstr line_del(rstr& s) 38 | { 39 | return s.replace('\r\n\r\n\r\n','\r\n\r\n') 40 | } 41 | 42 | //符号替换 43 | rstr sym_replace(rstr s) 44 | { 45 | rbuf arr 46 | r_split_e(s,'\r\n',arr) 47 | rstr ret 48 | for i in arr 49 | temp=arr[i] 50 | if temp.get_top==`:&&is_symbol(temp.sub(0,temp.count-1)) 51 | ret+=sym_trans(temp.sub(0,temp.count-1))+':' 52 | ret+='\r\n' 53 | continue 54 | if (temp.sub(0,5)==' jmp '|| 55 | temp.sub(0,6)==' call '|| 56 | temp.sub(0,5)==' jnz '|| 57 | temp.sub(0,4)==' jg '|| 58 | temp.sub(0,4)==' jl '|| 59 | temp.sub(0,5)==' jae '|| 60 | temp.sub(0,4)==' jz ') 61 | index=temp.find(' ') 62 | symbol=temp.sub(index+1) 63 | if is_symbol(symbol) 64 | ret+=temp.sub(0,index+1)+sym_trans(symbol) 65 | ret+='\r\n' 66 | continue 67 | ret+=temp 68 | ret+='\r\n' 69 | return ret 70 | } 71 | 72 | rstr sym_trans(rstr s) 73 | { 74 | rstr ret 75 | for i in s 76 | two=s.sub(i,i+2) 77 | if two=='28'||two=='29'//() 78 | i++ 79 | ret+='_' 80 | elif two=='2E'||two=='2C'||two=='5F'//.,_ 81 | i++ 82 | ret+='_' 83 | elif two=='26' 84 | i++ 85 | ret+='q' 86 | elif two=='7E' 87 | i++ 88 | ret+='d' 89 | elif two=='7C' 90 | i++ 91 | ret+='h' 92 | elif two=='5B' 93 | i++ 94 | ret+='i' 95 | elif two=='5D' 96 | i++ 97 | ret+='j' 98 | elif two=='3D'//= 99 | i++ 100 | ret+='a' 101 | elif two=='2B' 102 | i++ 103 | ret+='b' 104 | elif two=='2D'//- 105 | i++ 106 | ret+='s' 107 | elif two=='2A'//* 108 | i++ 109 | ret+='t' 110 | elif two=='2F' 111 | i++ 112 | ret+='f' 113 | elif two=='25' 114 | i++ 115 | ret+='e' 116 | elif two=='21'//! 117 | i++ 118 | ret+='o' 119 | elif two=='3E'//> 120 | i++ 121 | ret+='x' 122 | elif two=='3C'//< 123 | i++ 124 | ret+='y' 125 | else 126 | ret+=s[i] 127 | return seq_replace(ret) 128 | } 129 | 130 | rstr seq_replace(rstr s) 131 | { 132 | //s=s.replace('__','_') 133 | //s=s.replace('__','_') 134 | //s=s.replace('__','_') 135 | if s.get_top==`_ 136 | s.pop 137 | if s.get_top==`_ 138 | s.pop 139 | return s 140 | } 141 | 142 | //无引用符号删除 143 | rstr opt_sym(rstr s) 144 | { 145 | rbuf arr 146 | r_split_e(s,'\r\n',arr) 147 | rstr ret 148 | for i in arr 149 | temp=arr[i] 150 | full=temp.sub(0,temp.count-1) 151 | if temp.get_top==`:&&is_symbol(full) 152 | symbol=get_symbol(full) 153 | ifn symbol.empty 154 | if get_count(arr,i,symbol,full)==1 155 | continue 156 | ret+=temp 157 | ret+='\r\n' 158 | return ret 159 | } 160 | 161 | //jmp后接一个跳转符号 162 | rstr opt_jmp(rstr s) 163 | { 164 | rbuf arr 165 | r_split_e(s,'\r\n',arr) 166 | rstr ret 167 | for i in arr 168 | temp=arr[i] 169 | a=arr.get(i+1) 170 | full=a.sub(0,a.count-1) 171 | if temp.sub(0,5)==' jmp '&&temp.sub(5)==full&&a.get_top==`: 172 | symbol=get_symbol(full) 173 | ifn symbol.empty 174 | if get_count(arr,i,symbol,full)==2 175 | i++ 176 | continue 177 | else 178 | continue 179 | ret+=temp 180 | ret+='\r\n' 181 | return ret 182 | } 183 | 184 | //连续2个jmp,后一个jmp不可能被执行 185 | rstr opt_two(rstr s) 186 | { 187 | rbuf arr 188 | r_split_e(s,'\r\n',arr) 189 | rstr ret 190 | for i in arr 191 | temp=arr[i] 192 | a=arr.get(i+1) 193 | if temp.sub(0,5)==' jmp '&&a.sub(0,5)==' jmp ' 194 | ret+=temp 195 | ret+='\r\n' 196 | i++ 197 | continue 198 | ret+=temp 199 | ret+='\r\n' 200 | return ret 201 | } 202 | 203 | int get_count(rbuf& arr,int i,rstr& symbol,rstr& full) 204 | { 205 | for j=i-1;j>=0;j-- 206 | if arr[j].sub(0,arr[j].count-1)==symbol&&`:==arr[j].get_top 207 | break 208 | for k=i+1;k=0;i-- 217 | if s[i]==`_&&s.sub(i+1).is_number 218 | return s.sub(0,i) 219 | return '' 220 | } 221 | 222 | int find_count(rbuf& arr,int left,int right,rstr& symbol) 223 | { 224 | count=0 225 | for i=left;i<=right;i++ 226 | count+=find_count(arr[i],symbol) 227 | return count 228 | } 229 | 230 | int find_count(rstr src,rstr dst) 231 | { 232 | count=0 233 | for i in src 234 | if src.sub(i,i+dst.count)==dst 235 | count++ 236 | return count 237 | } 238 | 239 | bool is_symbol(rstr s) 240 | { 241 | for i in s 242 | ifn is_symbol(s[i]) 243 | return false 244 | return true 245 | } 246 | 247 | bool is_symbol(char ch) 248 | { 249 | return ch>=`A&&ch<=`Z||ch>=`a&&ch<=`z||ch>=`0&&ch<=`9||ch==`_ 250 | } 251 | -------------------------------------------------------------------------------- /bin/example/bf.h: -------------------------------------------------------------------------------- 1 | /* 2 | BF解释器增强版,支持32位运算 3 | 这个语言并不像看上去那么简单,下面是一个BF版的Hello World: 4 | ++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++. 5 | >+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>. 6 | */ 7 | 8 | void main() 9 | { 10 | code=getsl 11 | rbuf data(30000) 12 | rf.memset(data.begin,0,data.size) 13 | pd=0 14 | for pc=0;pc 17 | pd++ 18 | case `< 19 | pd-- 20 | case `+ 21 | data[pd]++ 22 | case `- 23 | data[pd]-- 24 | case `. 25 | puts(rstr.format('%c',data[pd])) 26 | case `, 27 | data[pd]=rf.getch 28 | case `[ 29 | ifn data[pd] 30 | pc=find< ++ >(pc,code,`[,`]) 31 | continue//这里也可用continued 32 | case `] 33 | if data[pd] 34 | pc=find< -- >(pc,code,`],`[) 35 | continue 36 | } 37 | 38 | int find(int pc,rstr& code,int left,int right) 39 | { 40 | count=0 41 | for i=pc;;i T 42 | if code[i]==left 43 | count++ 44 | elif code[i]==right 45 | count-- 46 | if count==0 47 | return i 48 | } -------------------------------------------------------------------------------- /bin/example/check.h: -------------------------------------------------------------------------------- 1 | /* 2 | 分别以解释方式和编译方式运行example下所有例子, 3 | 并与标准答案进行对比,以此来检验编译器的正确性。 4 | */ 5 | 6 | import rdir.h 7 | import rfile.h 8 | 9 | int g_sta_ok 10 | int g_total 11 | 12 | main 13 | { 14 | use_paral=rf.get_param.get_top=='-paral' 15 | g_sta_ok=1 16 | start=rf.tick 17 | g_total=0 18 | v=rdir.get_file_bfs('./example/') 19 | rbuf vname 20 | for i in v 21 | name=rdir.get_name(v[i]) 22 | suffix=rdir.get_suffix(name) 23 | if suffix!='h' 24 | continue 25 | a=name.sub(0,name.count-2) 26 | if is_ignore(a) 27 | continue 28 | vname.push(a) 29 | rbuf vtime 30 | num=4 31 | time=rf.tick 32 | 33 | if use_paral 34 | vname.parallel(num,lambda(rstr& b){ 35 | check_interpret(b) 36 | }) 37 | else 38 | for i in vname 39 | check_interpret(vname[i]) 40 | 41 | vtime.push(rf.tick-time) 42 | time=rf.tick 43 | 44 | if use_paral 45 | vname.parallel(num,lambda(rstr& b){ 46 | check_jit(b) 47 | }) 48 | else 49 | for i in vname 50 | check_jit(vname[i]) 51 | 52 | vtime.push(rf.tick-time) 53 | time=rf.tick 54 | 55 | if use_paral 56 | vname.parallel(num,lambda(rstr& b){ 57 | check_pack(b) 58 | }) 59 | else 60 | for i in vname 61 | check_pack(vname[i]) 62 | 63 | vtime.push(rf.tick-time) 64 | time=rf.tick 65 | 66 | if use_paral 67 | vname.parallel(num,lambda(rstr& b){ 68 | check_exe(b) 69 | }) 70 | else 71 | for i in vname 72 | check_exe(vname[i]) 73 | 74 | vtime.push(rf.tick-time) 75 | 76 | putsl 77 | for i in vtime 78 | putsl 'time'+i+': '+vtime[i] 79 | putsl 80 | putsl('total: '+g_total) 81 | putsl('time: '+(rf.tick-start)) 82 | putsl('state: '+r_cond(g_sta_ok,'ok','error')) 83 | rf.getch 84 | } 85 | 86 | bool is_ignore(rstr a) 87 | { 88 | ifn a.sub(0,1).is_number 89 | return true 90 | if a=='14_2'||a=='22_2'||a=='36_8'||a=='36_9' 91 | return true 92 | if a.sub(0,3)=='16_' 93 | return true 94 | if a.sub(0,3)=='40_' 95 | return true 96 | return false 97 | } 98 | 99 | check_interpret(rstr a) 100 | { 101 | if a=='21_2'||a=='44'||a=='14_1' 102 | return 103 | rf.cmd('rpp example/'+a+'.h > example/answer/'+a+'_tmp.txt') 104 | check_interpret('example/answer/'+a+'_tmp.txt', 105 | 'example/answer/'+a+'.txt') 106 | } 107 | 108 | check_jit(rstr a) 109 | { 110 | rf.cmd('rjit example\\'+a+'.h > example/answer/'+a+'_tmp.txt') 111 | check_jit('example/answer/'+a+'_tmp.txt','example/answer/'+a+'.txt') 112 | } 113 | 114 | check_pack(rstr a) 115 | { 116 | rf.cmd('rpack example\\'+a+'.h') 117 | rf.cmd('example\\'+a+'.exe > example/answer/'+a+'_tmp.txt') 118 | check_pack('example/answer/'+a+'_tmp.txt','example/answer/'+a+'.txt') 119 | rfile.remove('example\\'+a+'.exe') 120 | } 121 | 122 | check_exe(rstr a) 123 | { 124 | if a=='13'||a=='22_1'||a=='44'||a=='14_1' 125 | return 126 | rf.cmd('run example\\'+a+'.h > example/answer/'+a+'_tmp.txt') 127 | check_exe('example/answer/'+a+'_tmp.txt','example/answer/'+a+'.txt') 128 | } 129 | 130 | check_interpret(rstr a,rstr b) 131 | { 132 | //不严谨,应该使用互斥体 133 | g_total++ 134 | cont=rfile.read_all_n(a); 135 | if cont.count>0&&cont==rfile.read_all_n(b) 136 | puts('ok ') 137 | else 138 | puts('* * * error ') 139 | g_sta_ok=0 140 | putsl('interpret '+a.sub(15)+' vs '+b.sub(15)) 141 | ifn rfile.remove(a) 142 | putsl('* * * error ') 143 | g_sta_ok=0 144 | } 145 | 146 | check_jit(rstr a,rstr b) 147 | { 148 | g_total++ 149 | cont=rfile.read_all_n(a); 150 | if cont.count>0&&cont==rfile.read_all_n(b) 151 | puts('ok ') 152 | else 153 | puts('* * * error ') 154 | g_sta_ok=0 155 | putsl('jit '+a.sub(15)+' vs '+b.sub(15)) 156 | ifn rfile.remove(a) 157 | putsl('* * * error ') 158 | g_sta_ok=0 159 | } 160 | 161 | check_pack(rstr a,rstr b) 162 | { 163 | g_total++ 164 | cont=rfile.read_all_n(a); 165 | if cont.count>0&&cont==rfile.read_all_n(b) 166 | puts('ok ') 167 | else 168 | puts('* * * error ') 169 | g_sta_ok=0 170 | putsl('pack '+a.sub(15)+' vs '+b.sub(15)) 171 | ifn rfile.remove(a) 172 | putsl('* * * error ') 173 | g_sta_ok=0 174 | } 175 | 176 | check_exe(rstr a,rstr b) 177 | { 178 | g_total++ 179 | cont=rfile.read_all_n(a) 180 | cont=cont.sub(cont.find('\x73\x0d\x0a')+3)//去掉golink打印的信息 181 | if cont.count>0&&cont==rfile.read_all_n(b) 182 | puts('ok ') 183 | else 184 | puts('* * * error ') 185 | g_sta_ok=0 186 | putsl('exe '+a.sub(15)+' vs '+b.sub(15)) 187 | ifn rfile.remove(a) 188 | putsl('* * * error ') 189 | g_sta_ok=0 190 | } -------------------------------------------------------------------------------- /bin/example/code.h: -------------------------------------------------------------------------------- 1 | /* 2 | 检查当前目录下文本文件的编码类型 3 | */ 4 | 5 | import "rdir.h" 6 | 7 | main 8 | { 9 | v=rdir.get_file_bfs('./') 10 | for i in v 11 | { 12 | if v[i].get_top==`/ 13 | continue 14 | rfile file(v[i]) 15 | rbuf buf(3) 16 | ifn(file.read(3,buf.begin)) 17 | break 18 | s=v[i]+' ' 19 | if(buf[0]==0xff&&buf[1]==0xfe) 20 | s+='utf16' 21 | elif(buf[0]==0xef&&buf[1]==0xbb&&buf[2]==0xbf) 22 | s+='utf8' 23 | else 24 | s+='gbk' 25 | s.printl 26 | } 27 | } -------------------------------------------------------------------------------- /bin/example/compile_speed.h: -------------------------------------------------------------------------------- 1 | //1.h amd 3.45GHZ cost time 3600ms ,new version 2800ms 1.89 2609ms fix2 2516ms 2094ms 2 | //36_2.h cost time 5375ms (1.83 4985ms),new version 4438ms 1.89 4156ms 3375ms 3 | main 4 | { 5 | start=rf.tick 6 | for i=1 to 10 7 | //rf.cmd("rpp example\\36_2.h") 8 | rf.cmd("rpp example\\1.h") 9 | putsl 10 | putsl(rf.tick-start) 11 | } -------------------------------------------------------------------------------- /bin/example/count.h: -------------------------------------------------------------------------------- 1 | /* 2 | 统计当前目录下代码行数 3 | 如果使用utf16统计更准确 4 | */ 5 | 6 | import rdir.h 7 | import rfile.h 8 | 9 | int g_sum=0 10 | 11 | count_line(rstr name) 12 | { 13 | s=rfile.read_all_n(name) 14 | sum=1 15 | for i=0;i['cpp','h'] 12 | str='s_ret' 13 | //todo utf16转换 14 | v=rdir.get_file_bfs(dir) 15 | for i in v 16 | name=rdir.get_name(v[i]) 17 | suffix=rdir.get_suffix(name) 18 | if(v[i].get_top()==`/) 19 | continue 20 | ifn arr.exist(suffix) 21 | continue 22 | s=rfile.read_all_n(v[i]) 23 | if s.find(str)(temp,'\r\n') 37 | for i in v 38 | ifn check_line(v[i]) 39 | putsl('line '+(i+1)) 40 | return false 41 | return true 42 | } 43 | 44 | bool check_file(rstr name) 45 | { 46 | rfile file(name) 47 | rbuf buf(3) 48 | ifn(file.read(3,buf.begin)) 49 | return false 50 | ok=false 51 | if(buf[0]==0xff&&buf[1]==0xfe) 52 | s=rfile.read_all_n(name).sub(2) 53 | ok=check_s(rstrw(s.begin,s.count)) 54 | elif(buf[0]==0xef&&buf[1]==0xbb&&buf[2]==0xbf) 55 | s=rfile.read_all_n(name).sub(3) 56 | ok=check_s(rstrw(s)) 57 | if ok 58 | return true 59 | putsl(name) 60 | return false 61 | } 62 | 63 | void main() 64 | { 65 | if rf.get_param.count<3 66 | return 67 | v=rdir.get_file_bfs(rf.get_param.top) 68 | for i in v 69 | name=v[i] 70 | if name.sub(name.count-2)=='.h' 71 | ifn check_file(name) 72 | break 73 | elif name.sub(name.count-4)=='.cpp' 74 | ifn check_file(name) 75 | break 76 | } -------------------------------------------------------------------------------- /bin/example/lisp.h: -------------------------------------------------------------------------------- 1 | /* 2 | 60行RPP实现的lisp解释器 3 | 未处理lambda、上下文等,有待完善 4 | */ 5 | 6 | void main() 7 | { 8 | for 9 | putsl(eval(getsl)) 10 | } 11 | 12 | rstr eval(rstr s) 13 | { 14 | return eval(tokenize(s).split(' ')) 15 | } 16 | 17 | rstr eval(rbuf& v) 18 | { 19 | if v.get(0)!='(' 20 | return v.get(0) 21 | next=find(v.sub(2))+2 22 | switch v.get(1) 23 | case '+' 24 | return eval(v.sub(2,next)).toint+eval(v.sub(next,v.count-1)).toint 25 | case '-' 26 | return eval(v.sub(2,next)).toint-eval(v.sub(next,v.count-1)).toint 27 | case '*' 28 | return eval(v.sub(2,next)).toint*eval(v.sub(next,v.count-1)).toint 29 | case '/' 30 | return eval(v.sub(2,next)).toint/eval(v.sub(next,v.count-1)).toint 31 | return '' 32 | } 33 | 34 | int find(rbuf& v) 35 | { 36 | return r_cond(v.get(0)=='(',find_sbk(v)+1,1) 37 | } 38 | 39 | int find_sbk(rbuf& v) 40 | { 41 | count=0 42 | for i in v 43 | if '('==v[i] 44 | ++count 45 | if ')'==v[i] 46 | --count 47 | if 0==count 48 | return i 49 | return v.count 50 | } 51 | 52 | rstr tokenize(rstr s) 53 | { 54 | rstr ret 55 | for i in s 56 | if s[i]==`( 57 | ret+=' ( ' 58 | elif s[i]==`) 59 | ret+=' ) ' 60 | elif s[i]==0xa||s[i]==0xd||s[i]==9 61 | ret+=' ' 62 | else 63 | ret+=s[i] 64 | return ret 65 | } -------------------------------------------------------------------------------- /bin/example/run.h: -------------------------------------------------------------------------------- 1 | /* 2 | 编译生成exe并运行 3 | */ 4 | 5 | import rfile.h 6 | import rdir.h 7 | 8 | main 9 | { 10 | v=rf.get_param 11 | if v.count<3 12 | putsl('invaild param') 13 | return 14 | a=v[2] 15 | if rf.cmd('rpp.exe -win '+a)==0 16 | putsl('compile error') 17 | return 18 | b=rdir.get_real_name(a) 19 | if rf.cmd('nasm\\nasm.exe -f win32 '+b+'.asm -o '+b+'.obj')==0 20 | clear(b) 21 | putsl('asm error') 22 | return 23 | cmd='nasm\\GoLink.exe /console /mix /entry _main ' 24 | cmd+=b+'.obj msvcrt.dll ws2_32.dll kernel32.dll user32.dll' 25 | if rf.cmd(cmd)==0 26 | clear(b) 27 | putsl('link error') 28 | return 29 | clear(b) 30 | if v.count==3 31 | rf.cmd(b+'.exe') 32 | elif v.count==4&&v.get(3)=='-build' 33 | ; 34 | elif v.count==4&&v.get(3)=='-del' 35 | rf.cmd(b+'.exe') 36 | ifn rfile.remove(rcode.gbk_to_utf8(b)+'.exe') 37 | ;//很可能是由于golink没有关闭EXE导致无法删除 38 | elif v.count==4&&v.get(3)=='-check' 39 | ifn rfile.remove(rcode.gbk_to_utf8(b)+'.exe') 40 | putsl 'delete error' 41 | } 42 | 43 | clear(rstr b) 44 | { 45 | b=rcode.gbk_to_utf8(b) 46 | rfile.remove(b+'.asm') 47 | rfile.remove(b+'.obj') 48 | } -------------------------------------------------------------------------------- /bin/example/snake.h: -------------------------------------------------------------------------------- 1 | /* 2 | 彩色版控制台贪食蛇 3 | 该游戏只能以解释模式或JIT模式运行 4 | */ 5 | 6 | int g_std_out 7 | rbuf g_arr 8 | int g_next 9 | int g_food 10 | 11 | void main() 12 | { 13 | begin: 14 | init 15 | start=rf.tick 16 | for 17 | key 18 | if rf.tick-start<100 19 | continue 20 | start=rf.tick 21 | ifn check 22 | goto begin 23 | g_arr.push_front(g_arr[0]+g_next) 24 | if g_food!=g_arr[0] 25 | g_arr.pop 26 | else 27 | food 28 | update 29 | } 30 | 31 | void update() 32 | { 33 | for i=0 to 199 34 | gotoxy(i%10*2,i/10) 35 | if g_arr.exist(i) 36 | out("■") 37 | elif i==g_food 38 | out("★") 39 | else 40 | puts(" ") 41 | } 42 | 43 | void init() 44 | { 45 | rf.srand 46 | g_std_out=rf.GetStdHandle(-11) 47 | g_next=10 48 | g_arr.clear 49 | g_arr.push(105) 50 | food 51 | 52 | CONSOLE_CURSOR_INFO cur_info 53 | cur_info.dwSize=1 54 | cur_info.bVisible=0 55 | rf.SetConsoleCursorInfo(g_std_out,&cur_info) 56 | rf.cmd("mode con cols=20 lines=22")//保留一行留给输入法 57 | 58 | rf.SetConsoleTextAttribute(g_std_out,0x0a) 59 | gotoxy(0,20) 60 | puts(" ******************") 61 | } 62 | 63 | void key() 64 | { 65 | if rf.GetAsyncKeyState(0x26) 66 | temp=-10 67 | elif rf.GetAsyncKeyState(0x28) 68 | temp=10 69 | elif rf.GetAsyncKeyState(0x25) 70 | temp=-1 71 | elif rf.GetAsyncKeyState(0x27) 72 | temp=1 73 | else 74 | return 75 | if g_arr.count<2||g_arr.get(1)!=g_arr.get(0)+temp 76 | g_next=temp 77 | } 78 | 79 | bool check() 80 | { 81 | temp=g_arr[0]+g_next 82 | if temp<0||temp>199||int.abs(temp%10-g_arr[0]%10)>1||g_arr.exist(temp) 83 | rf.MessageBoxA(0,('over len '+g_arr.count).cstr,"",0) 84 | return false 85 | return true 86 | } 87 | 88 | void food() 89 | { 90 | g_food=rf.rand()%200 91 | if g_arr.exist(g_food) 92 | food 93 | } 94 | 95 | void out(char* s) 96 | { 97 | puts(rcode.utf8_to_gbk(s)) 98 | } 99 | 100 | void gotoxy(int x,int y) 101 | { 102 | COORD pos 103 | pos.x=x 104 | pos.y=y 105 | rf.SetConsoleCursorPosition(g_std_out,*(&pos).to) 106 | } 107 | 108 | struct CONSOLE_CURSOR_INFO 109 | { 110 | int dwSize 111 | bool bVisible 112 | } 113 | 114 | struct COORD 115 | { 116 | ushort x 117 | ushort y 118 | } -------------------------------------------------------------------------------- /bin/example/speed_test.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/speed_test.h -------------------------------------------------------------------------------- /bin/example/time.h: -------------------------------------------------------------------------------- 1 | main 2 | { 3 | s=getsl 4 | start=rf.tick 5 | rf.cmd(s) 6 | putsl 7 | putsl(rf.tick-start) 8 | } -------------------------------------------------------------------------------- /bin/example/win.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/example/win.h -------------------------------------------------------------------------------- /bin/gl/1.h: -------------------------------------------------------------------------------- 1 | /* 2 | 下面是编译期计算示例,sum是一个宏,计算从0加到N 3 | */ 4 | 5 | import rpp.h 6 | 7 | void main() 8 | { 9 | putsl sum(100)//输出5050 10 | putsl sum(10)//输出55 11 | } 12 | 13 | macro void sum(rbuf& v,int index) 14 | { 15 | result=0 16 | param=v.get(index+2).val.toint 17 | for i=0;i<=param;i++ 18 | result+=i 19 | v[index].val=result 20 | for i=1;i<=3;i++ 21 | v[index+i].val.clear 22 | } -------------------------------------------------------------------------------- /bin/gl/2.h: -------------------------------------------------------------------------------- 1 | /* 2 | RPP的macro具有和Lisp宏一样强大的表达能力 3 | 这种宏可以用写代码对代码进行变换,这就比C语言的宏强大得多 4 | 下面是变参宏示例 5 | 注意macro只能是全局的 6 | */ 7 | 8 | import rpp.h 9 | 10 | void main() 11 | { 12 | putsl sum(98,56) 13 | putsl sum(1,2,3,4) 14 | putsl sum(43,534,65,645,54,2) 15 | } 16 | 17 | macro void sum(rbuf& v,int index) 18 | { 19 | left=index+1 20 | right=find_symm_sbk(v,left) 21 | result=0 22 | for i=index+2;i& v,int index) 18 | { 19 | count=v[index-1].val.toint 20 | for i=index;i 5 | define M3DVector4f carray 6 | define M3DMatrix44f carray 7 | 8 | class GLFrame 9 | { 10 | M3DVector3f vOrigin 11 | M3DVector3f vForward 12 | M3DVector3f vUp 13 | 14 | GLFrame() 15 | { 16 | vOrigin[0]=0.0f 17 | vOrigin[1]=0.0f 18 | vOrigin[2]=0.0f 19 | vUp[0]=0.0f 20 | vUp[1]=1.0f 21 | vUp[2]=0.0f 22 | vForward[0]=0.0f 23 | vForward[1]=0.0f 24 | vForward[2]=-1.0f 25 | } 26 | 27 | void MoveForward(float fDelta) 28 | { 29 | vOrigin[0]+=vForward[0]*fDelta 30 | vOrigin[1]+=vForward[1]*fDelta 31 | vOrigin[2]+=vForward[2]*fDelta 32 | } 33 | 34 | void MoveRight(float fDelta) 35 | { 36 | M3DVector3f vCross 37 | m3dCrossProduct(vCross,vUp,vForward) 38 | 39 | vOrigin[0]+=vCross[0]*fDelta 40 | vOrigin[1]+=vCross[1]*fDelta 41 | vOrigin[2]+=vCross[2]*fDelta 42 | } 43 | 44 | static void m3dGetPlaneEquation(M3DVector4f& planeEq,M3DVector3f& p1, 45 | M3DVector3f& p2,M3DVector3f& p3) 46 | { 47 | M3DVector3f v1 48 | M3DVector3f v2 49 | 50 | v1[0]=p3[0]-p1[0] 51 | v1[1]=p3[1]-p1[1] 52 | v1[2]=p3[2]-p1[2] 53 | 54 | v2[0]=p2[0]-p1[0] 55 | v2[1]=p2[1]-p1[1] 56 | v2[2]=p2[2]-p1[2] 57 | 58 | m3dCrossProduct(*(&planeEq).to,v1,v2) 59 | m3dNormalizeVector(*(&planeEq).to) 60 | planeEq[3]=-(planeEq[0]*p3[0]+planeEq[1]*p3[1]+planeEq[2]*p3[2]) 61 | } 62 | 63 | static float m3dGetVectorLengthSquared(M3DVector3f& u) 64 | { 65 | return(u[0]*u[0])+(u[1]*u[1])+(u[2]*u[2]) 66 | } 67 | 68 | static float m3dGetVectorLength(M3DVector3f& u) 69 | { 70 | return FL(math.sqrt(double(m3dGetVectorLengthSquared(u)))) 71 | } 72 | 73 | static void m3dNormalizeVector(M3DVector3f& u) 74 | { 75 | m3dScaleVector3(u,1.0f/m3dGetVectorLength(u)) 76 | } 77 | 78 | static void m3dScaleVector3(M3DVector3f& v,float scale) 79 | { 80 | v[0]*=scale 81 | v[1]*=scale 82 | v[2]*=scale 83 | } 84 | 85 | static void m3dCrossProduct(M3DVector3f& result,M3DVector3f& u,M3DVector3f& v) 86 | { 87 | result[0]=u[1]*v[2]-v[1]*u[2] 88 | result[1]=-u[0]*v[2]+v[0]*u[2] 89 | result[2]=u[0]*v[1]-v[0]*u[1] 90 | } 91 | 92 | void ApplyCameraTransform(bool bRotOnly=false) 93 | { 94 | M3DMatrix44f m 95 | GetCameraOrientation(m) 96 | @glMultMatrixf(&m) 97 | if(!bRotOnly) 98 | { 99 | @glTranslatef(-vOrigin[0],-vOrigin[1],-vOrigin[2]) 100 | } 101 | } 102 | 103 | static void m3dMakePlanarShadowMatrix( 104 | M3DMatrix44f& proj, 105 | M3DVector4f& planeEq, 106 | M3DVector4f& vLightPos) 107 | { 108 | float a=planeEq[0] 109 | float b=planeEq[1] 110 | float c=planeEq[2] 111 | float d=planeEq[3] 112 | 113 | float dx=-vLightPos[0] 114 | float dy=-vLightPos[1] 115 | float dz=-vLightPos[2] 116 | 117 | proj[0]=b*dy+c*dz 118 | proj[1]=-a*dy 119 | proj[2]=-a*dz 120 | proj[3]=0.0 121 | 122 | proj[4]=-b*dx 123 | proj[5]=a*dx+c*dz 124 | proj[6]=-b*dz 125 | proj[7]=0.0 126 | 127 | proj[8]=-c*dx 128 | proj[9]=-c*dy 129 | proj[10]=a*dx+b*dy 130 | proj[11]=0.0 131 | 132 | proj[12]=-d*dx 133 | proj[13]=-d*dy 134 | proj[14]=-d*dz 135 | proj[15]=a*dx+b*dy+c*dz 136 | } 137 | 138 | mac M(row,col) m[col*4+row] 139 | 140 | void GetCameraOrientation(M3DMatrix44f& m) 141 | { 142 | M3DVector3f x 143 | M3DVector3f z 144 | 145 | z[0]=-vForward[0] 146 | z[1]=-vForward[1] 147 | z[2]=-vForward[2] 148 | 149 | m3dCrossProduct(x,vUp,z) 150 | 151 | M(0,0)=x[0] 152 | M(0,1)=x[1] 153 | M(0,2)=x[2] 154 | M(0,3)=0.0 155 | M(1,0)=vUp[0] 156 | M(1,1)=vUp[1] 157 | M(1,2)=vUp[2] 158 | M(1,3)=0.0 159 | M(2,0)=z[0] 160 | M(2,1)=z[1] 161 | M(2,2)=z[2] 162 | M(2,3)=0.0 163 | M(3,0)=0.0 164 | M(3,1)=0.0 165 | M(3,2)=0.0 166 | M(3,3)=1.0 167 | } 168 | } -------------------------------------------------------------------------------- /bin/gl/freeglut.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/gl/freeglut.dll -------------------------------------------------------------------------------- /bin/gl/gl.h: -------------------------------------------------------------------------------- 1 |  2 | void init_glut() 3 | { 4 | v=rf.get_param 5 | num=v.count 6 | rbuf argv 7 | for i=0;i,*((&(a)).to+1) 18 | } 19 | 20 | mac cd_protect 21 | { 22 | push ebx; 23 | push esi; 24 | push edi; 25 | } 26 | 27 | mac cd_ret 28 | { 29 | pop edi; 30 | pop esi; 31 | pop ebx; 32 | pop ebp; 33 | retn; 34 | } 35 | 36 | mac GL_PI 3.1415926 37 | 38 | #define GL_POINTS 0x0000 39 | #define GL_LINES 0x0001 40 | #define GL_MODELVIEW 0x1700 41 | #define GL_PROJECTION 0x1701 42 | #define GLfloat float 43 | 44 | #define GL_COLOR_BUFFER_BIT 0x00004000 45 | #define GL_DEPTH_BUFFER_BIT 0x00000100 46 | 47 | #define GLUT_KEY_F1 0x0001 48 | #define GLUT_KEY_F2 0x0002 49 | #define GLUT_KEY_F3 0x0003 50 | #define GLUT_KEY_F4 0x0004 51 | #define GLUT_KEY_F5 0x0005 52 | #define GLUT_KEY_F6 0x0006 53 | #define GLUT_KEY_F7 0x0007 54 | #define GLUT_KEY_F8 0x0008 55 | #define GLUT_KEY_F9 0x0009 56 | #define GLUT_KEY_F10 0x000A 57 | #define GLUT_KEY_F11 0x000B 58 | #define GLUT_KEY_F12 0x000C 59 | #define GLUT_KEY_LEFT 0x0064 60 | #define GLUT_KEY_UP 0x0065 61 | #define GLUT_KEY_RIGHT 0x0066 62 | #define GLUT_KEY_DOWN 0x0067 63 | #define GLUT_KEY_PAGE_UP 0x0068 64 | #define GLUT_KEY_PAGE_DOWN 0x0069 65 | #define GLUT_KEY_HOME 0x006A 66 | #define GLUT_KEY_END 0x006B 67 | #define GLUT_KEY_INSERT 0x006C 68 | 69 | #define GLUT_LEFT_BUTTON 0x0000 70 | #define GLUT_MIDDLE_BUTTON 0x0001 71 | #define GLUT_RIGHT_BUTTON 0x0002 72 | #define GLUT_DOWN 0x0000 73 | #define GLUT_UP 0x0001 74 | #define GLUT_LEFT 0x0000 75 | #define GLUT_ENTERED 0x0001 76 | 77 | #define GLUT_RGB 0x0000 78 | #define GLUT_RGBA 0x0000 79 | #define GLUT_INDEX 0x0001 80 | #define GLUT_SINGLE 0x0000 81 | #define GLUT_DOUBLE 0x0002 82 | #define GLUT_ACCUM 0x0004 83 | #define GLUT_ALPHA 0x0008 84 | #define GLUT_DEPTH 0x0010 85 | #define GLUT_STENCIL 0x0020 86 | #define GLUT_MULTISAMPLE 0x0080 87 | #define GLUT_STEREO 0x0100 88 | #define GLUT_LUMINANCE 0x0200 89 | 90 | #define GLUT_MENU_NOT_IN_USE 0x0000 91 | #define GLUT_MENU_IN_USE 0x0001 92 | #define GLUT_NOT_VISIBLE 0x0000 93 | #define GLUT_VISIBLE 0x0001 94 | #define GLUT_HIDDEN 0x0000 95 | #define GLUT_FULLY_RETAINED 0x0001 96 | #define GLUT_PARTIALLY_RETAINED 0x0002 97 | #define GLUT_FULLY_COVERED 0x0003 98 | 99 | #define GL_LIGHT0 0x4000 100 | #define GL_LIGHT1 0x4001 101 | #define GL_LIGHT2 0x4002 102 | #define GL_LIGHT3 0x4003 103 | #define GL_LIGHT4 0x4004 104 | #define GL_LIGHT5 0x4005 105 | #define GL_LIGHT6 0x4006 106 | #define GL_LIGHT7 0x4007 107 | 108 | #define GL_AMBIENT 0x1200 109 | #define GL_DIFFUSE 0x1201 110 | #define GL_SPECULAR 0x1202 111 | #define GL_POSITION 0x1203 112 | #define GL_SPOT_DIRECTION 0x1204 113 | #define GL_SPOT_EXPONENT 0x1205 114 | #define GL_SPOT_CUTOFF 0x1206 115 | #define GL_CONSTANT_ATTENUATION 0x1207 116 | #define GL_LINEAR_ATTENUATION 0x1208 117 | #define GL_QUADRATIC_ATTENUATION 0x1209 118 | 119 | #define GL_DEPTH_TEST 0x0B71 120 | #define GL_LIGHTING 0x0B50 121 | 122 | #define GL_FRONT 0x0404 123 | #define GL_BACK 0x0405 124 | #define GL_CCW 0x0901 125 | #define GL_CULL_FACE 0x0B44 126 | #define GL_LIGHT_MODEL_AMBIENT 0x0B53 127 | #define GL_COLOR_MATERIAL 0x0B57 128 | #define GL_AMBIENT_AND_DIFFUSE 0x1602 129 | #define GL_SHININESS 0x1601 -------------------------------------------------------------------------------- /bin/gl/line.h: -------------------------------------------------------------------------------- 1 | /* 2 | RPP for OpenGL 3 | 使用上下左右旋转,代码摘自《OpenGL超级宝典》 4 | 该例子只能以JIT模式运行,并且需要最新的显卡驱动 5 | 运行命令:rjit gl\line.h 6 | */ 7 | 8 | import math.h 9 | import gl.h 10 | 11 | double g_x 12 | double g_y 13 | 14 | void main() 15 | { 16 | g_x=0 17 | g_y=0 18 | 19 | void* handle=@LoadLibraryA("gl/freeglut.dll") 20 | if handle==null 21 | return 22 | void[rf.find_dll("set_dll_list")] 23 | 24 | init_glut 25 | @glutInitWindowSize(800,600) 26 | @glutCreateWindow("line") 27 | @glutInitDisplayMode(ORM[GLUT_DOUBLE,GLUT_RGBA,GLUT_DEPTH]) 28 | @glutDisplayFunc(&render) 29 | 30 | @glutSpecialFunc(lambda(int key,int x,int y){ 31 | cd_protect 32 | input(key,x,y) 33 | cd_ret 34 | }) 35 | @glutReshapeFunc(lambda(int w,int h){ 36 | cd_protect 37 | change(w,h) 38 | cd_ret 39 | }) 40 | 41 | init() 42 | 43 | @glutMainLoop() 44 | 45 | @FreeLibrary(handle) 46 | } 47 | 48 | cfunc void render() 49 | { 50 | @glClear(GL_COLOR_BUFFER_BIT) 51 | @glPushMatrix() 52 | @glRotatef(FL(g_x),1.0f,0.0f,0.0f) 53 | @glRotatef(FL(g_y),0.0f,1.0f,0.0f) 54 | 55 | @glBegin(GL_LINES) 56 | z=0.0 57 | for angle=0.0;angle<=GL_PI;angle+=GL_PI/20.0 58 | x=50.0*math.sin(angle) 59 | y=50.0*math.cos(angle) 60 | @glVertex3f(FL(x),FL(y),FL(z)) 61 | x=50.0*math.sin(angle+GL_PI) 62 | y=50.0*math.cos(angle+GL_PI) 63 | @glVertex3f(FL(x),FL(y),FL(z)) 64 | @glEnd() 65 | 66 | @glPopMatrix() 67 | @glutSwapBuffers() 68 | } 69 | 70 | void input(int key,int x,int y) 71 | { 72 | switch key 73 | case GLUT_KEY_UP 74 | g_x-=5.0 75 | case GLUT_KEY_DOWN 76 | g_x+=5.0 77 | case GLUT_KEY_LEFT 78 | g_y-=5.0 79 | case GLUT_KEY_RIGHT 80 | g_y+=5.0 81 | @glutPostRedisplay() 82 | } 83 | 84 | void change(int w,int h) 85 | { 86 | range=100.0 87 | if h==0 88 | h=1 89 | @glViewport(0,0,w,h) 90 | @glMatrixMode(GL_PROJECTION) 91 | @glLoadIdentity() 92 | if w<=h 93 | @glOrtho(D8(-range),D8(range),D8(-range*h/w), 94 | D8(range*h/w),D8(-range),D8(range)) 95 | else 96 | @glOrtho(D8(-range*w/h),D8(range*w/h),D8(-range), 97 | D8(range),D8(-range),D8(range)) 98 | @glMatrixMode(GL_MODELVIEW) 99 | @glLoadIdentity() 100 | } 101 | 102 | void init() 103 | { 104 | @glClearColor(0.0f,0.0f,0.0f,0.0f) 105 | @glColor3f(0.0f,1.0f,0.0f) 106 | } -------------------------------------------------------------------------------- /bin/gl/sphere.h: -------------------------------------------------------------------------------- 1 | /* 2 | RPP for OpenGL 3 | 使用上下左右移动,代码摘自《OpenGL超级宝典》 4 | 该例子只能以JIT模式运行,并且需要最新的显卡驱动 5 | 运行命令:rjit gl\sphere.h 6 | */ 7 | 8 | import math.h 9 | import gl.h 10 | import frame.h 11 | 12 | M3DMatrix44f g_shadow_matrix 13 | GLFrame g_camera 14 | double g_y 15 | carray g_light_pos 16 | carray g_no_light 17 | carray g_low_light 18 | carray g_bright_light 19 | 20 | void main() 21 | { 22 | g_y=0 23 | g_light_pos=array[-100.0f, 100.0f, 50.0f, 1.0f] 24 | g_no_light=array[0.0f, 0.0f, 0.0f, 0.0f] 25 | g_low_light=array[0.25f, 0.25f, 0.25f, 1.0f] 26 | g_bright_light=array[1.0f, 1.0f, 1.0f, 1.0f] 27 | 28 | void* handle=@LoadLibraryA("gl/freeglut.dll") 29 | if handle==null 30 | return 31 | void[rf.find_dll("set_dll_list")] 32 | 33 | init_glut 34 | @glutInitWindowSize(800,600) 35 | @glutCreateWindow("sphere") 36 | @glutInitDisplayMode(ORM[GLUT_DOUBLE,GLUT_RGBA,GLUT_DEPTH]) 37 | @glutDisplayFunc(&render) 38 | 39 | @glutSpecialFunc(lambda(int key,int x,int y){ 40 | cd_protect 41 | input(key,x,y) 42 | cd_ret 43 | }) 44 | @glutReshapeFunc(lambda(int w,int h){ 45 | cd_protect 46 | change(w,h) 47 | cd_ret 48 | }) 49 | 50 | init() 51 | 52 | @glutMainLoop() 53 | 54 | @FreeLibrary(handle) 55 | } 56 | 57 | void draw(int shadow) 58 | { 59 | if shadow==0 60 | g_y+=0.3f 61 | else 62 | @glColor3f(0.0f,0.0f,0.0f) 63 | if shadow==0 64 | @glColor3f(0.0f,1.0f,0.0f) 65 | @glPushMatrix() 66 | @glTranslatef(0.0f,0.1f,-2.5f) 67 | if shadow==0 68 | @glColor3f(0.0f,0.0f,1.0f) 69 | 70 | @glPushMatrix() 71 | @glRotatef(FL(-g_y*2.0f),0.0f,1.0f,0.0f) 72 | @glTranslatef(1.0f,0.0f,0.0f) 73 | @glutWireTorus(D8(0.1),D8(0.1),17,9) 74 | @glPopMatrix() 75 | 76 | if shadow==0 77 | @glColor3f(0.0f,1.0f,0.0f) 78 | @glMaterialfv(GL_FRONT,GL_SPECULAR,&g_bright_light) 79 | @glRotatef(g_y.tofloat,0.0f,1.0f,0.0f) 80 | @glutWireTorus(D8(0.15),D8(0.35),61,37) 81 | @glMaterialfv(GL_FRONT,GL_SPECULAR,&g_no_light) 82 | @glPopMatrix() 83 | } 84 | 85 | cfunc void render() 86 | { 87 | @glClear(ORM[GL_COLOR_BUFFER_BIT,GL_DEPTH_BUFFER_BIT]) 88 | @glPushMatrix() 89 | g_camera.ApplyCameraTransform() 90 | 91 | @glLightfv(GL_LIGHT0,GL_POSITION,&g_light_pos) 92 | 93 | @glColor3f(0.60f,0.40f,0.10f) 94 | 95 | @glDisable(GL_DEPTH_TEST) 96 | @glDisable(GL_LIGHTING) 97 | @glPushMatrix() 98 | @glMultMatrixf(&g_shadow_matrix) 99 | 100 | draw(1) 101 | 102 | @glPopMatrix() 103 | @glEnable(GL_LIGHTING) 104 | @glEnable(GL_DEPTH_TEST) 105 | 106 | draw(0) 107 | @glPopMatrix() 108 | @glutSwapBuffers() 109 | @glutPostRedisplay() 110 | } 111 | 112 | void input(int key,int x,int y) 113 | { 114 | switch key 115 | case GLUT_KEY_UP 116 | g_camera.MoveForward(0.1f) 117 | case GLUT_KEY_DOWN 118 | g_camera.MoveForward(-0.1f) 119 | case GLUT_KEY_LEFT 120 | g_camera.MoveRight(0.1f) 121 | case GLUT_KEY_RIGHT 122 | g_camera.MoveRight(-0.1f) 123 | @glutPostRedisplay() 124 | } 125 | 126 | void change(int w,int h) 127 | { 128 | if h==0 129 | h=1 130 | @glViewport(0,0,w,h) 131 | @glMatrixMode(GL_PROJECTION) 132 | @glLoadIdentity() 133 | @gluPerspective(D8(35.0),D8(double(w)/h),D8(1.0f),D8(50.0f)) 134 | @glMatrixMode(GL_MODELVIEW) 135 | @glLoadIdentity() 136 | } 137 | 138 | void init() 139 | { 140 | M3DVector3f vPoints0=array[0.0f,-0.4f,0.0f] 141 | M3DVector3f vPoints1=array[10.0f,-0.4f,0.0f] 142 | M3DVector3f vPoints2=array[5.0f,-0.4f,-5.0f] 143 | 144 | @glClearColor(g_low_light[0],g_low_light[1],g_low_light[2],g_low_light[3]) 145 | 146 | @glCullFace(GL_BACK) 147 | @glFrontFace(GL_CCW) 148 | @glEnable(GL_CULL_FACE) 149 | @glEnable(GL_DEPTH_TEST) 150 | 151 | @glLightModelfv(GL_LIGHT_MODEL_AMBIENT,&g_no_light) 152 | @glLightfv(GL_LIGHT0,GL_AMBIENT,&g_low_light) 153 | @glLightfv(GL_LIGHT0,GL_DIFFUSE,&g_bright_light) 154 | @glLightfv(GL_LIGHT0,GL_SPECULAR,&g_bright_light) 155 | @glEnable(GL_LIGHTING) 156 | @glEnable(GL_LIGHT0) 157 | 158 | M3DVector4f vPlaneEquation 159 | GLFrame.m3dGetPlaneEquation(vPlaneEquation,vPoints0,vPoints1,vPoints2) 160 | 161 | GLFrame.m3dMakePlanarShadowMatrix(g_shadow_matrix,vPlaneEquation,g_light_pos) 162 | 163 | @glEnable(GL_COLOR_MATERIAL) 164 | @glColorMaterial(GL_FRONT,GL_AMBIENT_AND_DIFFUSE) 165 | @glMateriali(GL_FRONT,GL_SHININESS,128) 166 | } -------------------------------------------------------------------------------- /bin/ide/License.txt: -------------------------------------------------------------------------------- 1 | License for Scintilla and SciTE 2 | 3 | Copyright 1998-2003 by Neil Hodgson 4 | 5 | All Rights Reserved 6 | 7 | Permission to use, copy, modify, and distribute this software and its 8 | documentation for any purpose and without fee is hereby granted, 9 | provided that the above copyright notice appear in all copies and that 10 | both that copyright notice and this permission notice appear in 11 | supporting documentation. 12 | 13 | NEIL HODGSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 14 | SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 15 | AND FITNESS, IN NO EVENT SHALL NEIL HODGSON BE LIABLE FOR ANY 16 | SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 17 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 18 | WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 19 | TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE 20 | OR PERFORMANCE OF THIS SOFTWARE. -------------------------------------------------------------------------------- /bin/ide/SciLexer.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/ide/SciLexer.dll -------------------------------------------------------------------------------- /bin/ide/SciTE.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/ide/SciTE.exe -------------------------------------------------------------------------------- /bin/ide/SciTE.properties: -------------------------------------------------------------------------------- 1 | # SciTE.properties is the per directory local options file and can be used to 2 | # override settings made in SciTEGlobal.properties, SciTEUser.properties and 3 | # SciTEDirectory.properties. 4 | command.build.directory.*.cxx=..\win32 5 | command.build.directory.*.h=..\win32 6 | command.build.*.cxx=nmake -f scite.mak DEBUG=1 QUIET=1 7 | command.build.*.h=nmake -f scite.mak DEBUG=1 QUIET=1 8 | command.go.*.cxx=..\bin\SciTE 9 | command.go.*.h=..\bin\SciTE 10 | command.go.needs.*.cxx=cmd /c cd ..\win32 && nmake -f scite.mak DEBUG=1 QUIET=1 11 | -------------------------------------------------------------------------------- /bin/ide/SciTEGlobal.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/ide/SciTEGlobal.properties -------------------------------------------------------------------------------- /bin/ide/lisp.properties: -------------------------------------------------------------------------------- 1 | # Define SciTE settings for lisp and Scheme files. 2 | 3 | file.patterns.lisp=*.lsp;*.lisp 4 | 5 | filter.lisp=LISP (lsp lisp)|$(file.patterns.lisp)| 6 | 7 | file.patterns.scheme=*.scm;*.smd;*.ss 8 | filter.scheme=Scheme (scm smd)|$(file.patterns.scheme)| 9 | 10 | lexer.$(file.patterns.lisp)=lisp 11 | lexer.$(file.patterns.scheme)=lisp 12 | 13 | # lisp build in functions, xlisp dialect 14 | keywords.$(file.patterns.lisp)= not defun + - * / = < > <= >= princ \ 15 | eval apply funcall quote identity function complement backquote lambda set setq setf \ 16 | defun defmacro gensym make symbol intern symbol name symbol value symbol plist get \ 17 | getf putprop remprop hash make array aref car cdr caar cadr cdar cddr caaar caadr cadar \ 18 | caddr cdaar cdadr cddar cdddr caaaar caaadr caadar caaddr cadaar cadadr caddar cadddr \ 19 | cdaaar cdaadr cdadar cdaddr cddaar cddadr cdddar cddddr cons list append reverse last nth \ 20 | nthcdr member assoc subst sublis nsubst nsublis remove length list length \ 21 | mapc mapcar mapl maplist mapcan mapcon rplaca rplacd nconc delete atom symbolp numberp \ 22 | boundp null listp consp minusp zerop plusp evenp oddp eq eql equal cond case and or let l if prog \ 23 | prog1 prog2 progn go return do dolist dotimes catch throw error cerror break \ 24 | continue errset baktrace evalhook truncate float rem min max abs sin cos tan expt exp sqrt \ 25 | random logand logior logxor lognot bignums logeqv lognand lognor \ 26 | logorc2 logtest logbitp logcount integer length nil 27 | 28 | word.chars.lisp=$(chars.alpha)$(chars.numeric)_-<>.#+@$%^&=*!? 29 | word.characters.$(file.patterns.lisp)=$(word.chars.lisp) 30 | 31 | # Scheme functions, R5RS 32 | keywords.$(file.patterns.scheme)= + - * / = < > <= >= => \ 33 | abs acos and angle append apply asin assoc assoc assq assv atan \ 34 | begin boolean? \ 35 | caar cadr call-with-current-continuation call/cc \ 36 | call-with-input-file call-with-output-file call-with-values \ 37 | car cdr \ 38 | caar cadr cdar cddr \ 39 | caaar caadr cadar caddr cdaar cdadr cddar cdddr \ 40 | caaaar caaadr caadar caaddr cadaar cadadr caddar cadddr \ 41 | cdaaar cdaadr cdadar cdaddr cddaar cddadr cdddar cddddr \ 42 | case ceiling char->integer \ 43 | char-alphabetic? char-ci<=? char-ci=? char-ci>? \ 44 | char-downcase char-lower-case? char-numeric? char-ready? \ 45 | char-upcase char-upper-case? char-whitespace? \ 46 | char<=? char=? char>? char? \ 47 | close-input-port close-output-port complex? cond cons cos \ 48 | current-input-port current-output-port \ 49 | define define-syntax delay denominator display do dynamic-wind \ 50 | else eof-object? eq? equal? eqv? eval even? exact->inexact exact? \ 51 | exp expt \ 52 | floor for-each force \ 53 | gcd \ 54 | if imag-part inexact->exact inexact? input-port? integer->char integer? interaction-environment \ 55 | lambda lcm length let let* let-syntax letrec letrec-syntax \ 56 | list list->string list->vector list-ref list-tail list? load log \ 57 | magnitude make-polar make-rectangular make-string make-vector \ 58 | map max member memq memv min modulo \ 59 | negative? newline not null-environment null? number->string number? numerator \ 60 | odd? open-input-file open-output-file or output-port? \ 61 | pair? peek-char input-port? output-port? positive? procedure? \ 62 | quasiquote quote quotient \ 63 | rational? rationalize read read-char real-part real? remainder reverse round \ 64 | scheme-report-environment set! set-car! set-cdr! sin sqrt string \ 65 | string->list string->number string->symbol string-append \ 66 | string-ci<=? string-ci=? string-ci>? \ 67 | string-copy string-fill! string-length string-ref string-set! \ 68 | string<=? string=? string>? string? \ 69 | substring symbol->string symbol? syntax-rules \ 70 | transcript-off transcript-on truncate \ 71 | unquote unquote-splicing \ 72 | values vector vector->list vector-fill! vector-length vector-ref vector-set! vector? \ 73 | with-input-from-file with-output-to-file write write-char \ 74 | zero? 75 | 76 | word.chars.scheme=$(chars.alpha)$(chars.numeric)!$%&*/:<=>?^_~+-.@ 77 | word.characters.$(file.patterns.scheme)=$(word.chars.scheme) 78 | 79 | 80 | comment.block.lisp=; 81 | comment.box.start.lisp=;; 82 | comment.box.middle.lisp=;; 83 | comment.box.end.lisp=;; 84 | 85 | 86 | # LISP styles 87 | 88 | # Default 89 | style.lisp.32=$(font.base) 90 | # White space 91 | style.lisp.0=fore:#808080 92 | # Line Comment 93 | style.lisp.1=$(colour.code.comment.box),$(font.code.comment.box) 94 | # Number 95 | style.lisp.2=$(colour.number) 96 | # Keyword 97 | style.lisp.3=$(colour.keyword),bold 98 | # String 99 | style.lisp.6=$(colour.string) 100 | # Operators 101 | style.lisp.10=$(colour.operator),bold 102 | # Identifiers 103 | style.lisp.9= 104 | # End of line where string is not closed 105 | style.lisp.8=fore:#000000,font:Verdana,size:9,back:#fefecc,eolfilled 106 | # Matched Operators 107 | style.lisp.34=fore:#0000FF,bold 108 | style.lisp.35=fore:#FF0000,bold 109 | # Braces are only matched in operator style 110 | braces.lisp.style=10 111 | 112 | #command.go.$(file.patterns.scheme)=c:\tools\pscheme\pscheme.exe /r $(FilePath) 113 | command.go.$(file.patterns.scheme)=c:\tools\gambit\gsi.exe -f $(FilePath) 114 | #command.go.$(file.patterns.scheme)=c:\tools\plt\mzscheme.exe -r $(FilePath) 115 | command.go.subsystem.$(file.patterns.scheme)=0 116 | -------------------------------------------------------------------------------- /bin/ide/luaCOPYRIGHT: -------------------------------------------------------------------------------- 1 | Lua License 2 | ----------- 3 | 4 | Lua is licensed under the terms of the MIT license reproduced below. 5 | This means that Lua is free software and can be used for both academic 6 | and commercial purposes at absolutely no cost. 7 | 8 | For details and rationale, see http://www.lua.org/license.html . 9 | 10 | =============================================================================== 11 | 12 | Copyright (C) 1994-2008 Lua.org, PUC-Rio. 13 | 14 | Permission is hereby granted, free of charge, to any person obtaining a copy 15 | of this software and associated documentation files (the "Software"), to deal 16 | in the Software without restriction, including without limitation the rights 17 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 18 | copies of the Software, and to permit persons to whom the Software is 19 | furnished to do so, subject to the following conditions: 20 | 21 | The above copyright notice and this permission notice shall be included in 22 | all copies or substantial portions of the Software. 23 | 24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 27 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 29 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 30 | THE SOFTWARE. 31 | 32 | =============================================================================== 33 | 34 | (end of COPYRIGHT) 35 | -------------------------------------------------------------------------------- /bin/ide/modules.api: -------------------------------------------------------------------------------- 1 | rbool 2 | uchar 3 | ushort 4 | short 5 | true 6 | false 7 | null 8 | elif 9 | else 10 | if 11 | ifn 12 | while 13 | for 14 | default 15 | namespace 16 | friend 17 | class 18 | goto 19 | struct 20 | static 21 | operator 22 | puts 23 | putsl 24 | getsl 25 | findf 26 | switch 27 | case 28 | 29 | calle 30 | call 31 | retn 32 | reti 33 | 34 | push 35 | pop 36 | 37 | jmp 38 | jebxz 39 | jebxnz 40 | 41 | halt 42 | nop 43 | 44 | lea 45 | mov 46 | mov1 47 | mov8 48 | 49 | add 50 | sub 51 | imul 52 | idiv 53 | imod 54 | 55 | cesb 56 | cnesb 57 | cgsb 58 | cgesb 59 | clsb 60 | clesb 61 | 62 | add8 63 | sub8 64 | imul8 65 | idiv8 66 | imod8 67 | cgsb8 68 | clsb8 69 | 70 | _fadd8 71 | _fsub8 72 | _fmul8 73 | _fdiv8 74 | _fcgsb8 75 | _fclsb8 76 | 77 | band 78 | bor 79 | bnot 80 | bxor 81 | bshl 82 | bshr 83 | bsar 84 | 85 | _udiv 86 | _umod 87 | _ucgsb 88 | _ucgesb 89 | _uclsb 90 | _uclesb 91 | 92 | rn 93 | 94 | rd1 95 | rd2 96 | rd4 97 | rd8 98 | rdp 99 | 100 | esp 101 | ebp 102 | eax 103 | ebx 104 | ecx 105 | edx 106 | esi 107 | edi 108 | 109 | void 110 | char 111 | int 112 | uint 113 | int8 114 | double 115 | rp 116 | var 117 | rbuf 118 | rstr 119 | rcs 120 | 121 | function 122 | 123 | break 124 | continue 125 | continued 126 | return 127 | 128 | this 129 | sizeof 130 | main 131 | include 132 | import 133 | endif 134 | ifdef 135 | ifndef 136 | define 137 | enum 138 | 139 | to 140 | in 141 | 142 | typeof 143 | s_ret 144 | s_off 145 | s_param 146 | s_local 147 | mac 148 | 149 | lambda 150 | 151 | r_ceil_div 152 | r_cond 153 | cdecl 154 | stdcall 155 | array 156 | _reti 157 | NOT 158 | AND 159 | OR 160 | XOR 161 | SHL 162 | SHR 163 | SAR 164 | 165 | r_new 166 | r_new_n 167 | r_delete 168 | r_delete_n 169 | r_swap 170 | r_reverse 171 | r_find_pos 172 | r_split 173 | r_split_e 174 | r_qsort 175 | r_find_pos_b 176 | rbufm 177 | rcode 178 | rdic 179 | rdir 180 | rf 181 | rff 182 | rfs 183 | rstrw 184 | rsock 185 | rset 186 | rmutex 187 | rlist 188 | -------------------------------------------------------------------------------- /bin/ide/python.properties: -------------------------------------------------------------------------------- 1 | # Define SciTE settings for Python files. 2 | 3 | file.patterns.py=*.py;*.pyw 4 | file.patterns.scons=SConstruct;SConscript 5 | 6 | shbang.python=py 7 | 8 | filter.python=Python (py pyw)|$(file.patterns.py)| 9 | 10 | lexer.$(file.patterns.py)=python 11 | lexer.$(file.patterns.scons)=python 12 | 13 | keywordclass.python2=and as assert break class continue def del elif \ 14 | else except exec finally for from global if import in is lambda not \ 15 | or pass print raise return try while with yield 16 | 17 | keywordclass.python3=False None True and as assert break class continue \ 18 | def del elif else except finally for from global if import in is lambda \ 19 | nonlocal not or pass raise return try while with yield 20 | 21 | keywordclass.python=$(keywordclass.python2) 22 | 23 | # Extra keywords for cython 24 | keywordclass.cython=cdef cimport cpdef 25 | 26 | keywords.$(file.patterns.py)=$(keywordclass.python) $(keywordclass.cython) 27 | keywords.$(file.patterns.scons)=$(keywordclass.python) 28 | 29 | # If you uncomment the 3 lines below, 30 | # and put some words after "keywordclass2.python=", 31 | # those words will be styled by style.python.14 32 | 33 | #keywordclass2.python= 34 | #keywords2.$(file.patterns.py)=$(keywordclass2.python) 35 | #keywords2.$(file.patterns.scons)=$(keywordclass2.python) 36 | 37 | #~ statement.indent.$(file.patterns.py)=10 : 38 | statement.indent.$(file.patterns.py)=5 class def elif else except finally \ 39 | for if try while with 40 | 41 | statement.lookback.$(file.patterns.py)=0 42 | block.start.$(file.patterns.py)= 43 | block.end.$(file.patterns.py)= 44 | 45 | view.indentation.examine.*.py=2 46 | 47 | tab.timmy.whinge.level=1 48 | 49 | #fold.quotes.python=1 50 | 51 | comment.block.python=#~ 52 | 53 | indent.python.colon=1 54 | 55 | # Python styles 56 | # White space 57 | style.python.0=fore:#808080 58 | # Comment 59 | style.python.1=fore:#007F00,$(font.comment) 60 | # Number 61 | style.python.2=fore:#007F7F 62 | # String 63 | style.python.3=fore:#7F007F,$(font.monospace) 64 | # Single quoted string 65 | style.python.4=fore:#7F007F,$(font.monospace) 66 | # Keyword 67 | style.python.5=fore:#00007F,bold 68 | # Triple quotes 69 | style.python.6=fore:#7F0000 70 | # Triple double quotes 71 | style.python.7=fore:#7F0000 72 | # Class name definition 73 | style.python.8=fore:#0000FF,bold 74 | # Function or method name definition 75 | style.python.9=fore:#007F7F,bold 76 | # Operators 77 | style.python.10=bold 78 | # Identifiers 79 | style.python.11= 80 | # Comment-blocks 81 | style.python.12=fore:#7F7F7F 82 | # End of line where string is not closed 83 | style.python.13=fore:#000000,$(font.monospace),back:#E0C0E0,eolfilled 84 | # Highlighted identifiers 85 | style.python.14=fore:#407090 86 | # Decorators 87 | style.python.15=fore:#805000 88 | # Matched Operators 89 | style.python.34=fore:#0000FF,bold 90 | style.python.35=fore:#FF0000,bold 91 | # Braces are only matched in operator style 92 | braces.python.style=10 93 | 94 | if PLAT_WIN 95 | command.go.*.py=pythonw -u "$(FileNameExt)" 96 | command.go.subsystem.*.py=1 97 | command.go.*.pyw=pythonw -u "$(FileNameExt)" 98 | command.go.subsystem.*.pyw=1 99 | command.build.SConscript=scons.bat --up . 100 | command.build.SConstruct=scons.bat . 101 | 102 | if PLAT_GTK 103 | command.go.*.py=python -u "$(FileNameExt)" 104 | command.build.SConscript=scons --up . 105 | command.build.SConstruct=scons . 106 | 107 | if PLAT_MAC 108 | command.go.*.py=python -u "$(FileNameExt)" 109 | command.build.SConscript=scons --up . 110 | command.build.SConstruct=scons . 111 | 112 | command.name.1.$(file.patterns.py)=Syntax Check 113 | command.1.$(file.patterns.py)=python -c "import py_compile; py_compile.compile(r'$(FilePath)')" 114 | -------------------------------------------------------------------------------- /bin/ide/scite.1: -------------------------------------------------------------------------------- 1 | .TH SCITE 1 "2001 February 26" 2 | .SH NAME 3 | SciTE \- a programmers text editor 4 | .SH SYNOPSIS 5 | .br 6 | .B SciTE 7 | [file ..] 8 | .SH DESCRIPTION 9 | .B SciTE 10 | is a graphical GTK+ based editor. It has support 11 | for indenting, highlighting, and shortcuts in a myriad 12 | of languages and can be extended by editing object-oriented 13 | configuration files. 14 | .PP 15 | Support is included for Java, C, C++, C#, Shell, Apache. 16 | .SH ON-LINE HELP 17 | Type Alt-H or Click the Help Pulldown menu. 18 | .SH AUTHOR 19 | Most of 20 | .B SciTE 21 | was made by Neil Hodgson, with a lot of help from others. 22 | See Help 23 | .br 24 | .SH BUGS 25 | Probably. 26 | -------------------------------------------------------------------------------- /bin/launch_ide.bat: -------------------------------------------------------------------------------- 1 | start ide\SciTE.exe -------------------------------------------------------------------------------- /bin/line_check.bat: -------------------------------------------------------------------------------- 1 | rpp -jit example\line_check.h ../rpp/ 2 | rpp -jit example\line_check.h ../rlib/ 3 | rpp -jit example\line_check.h rsrc/ 4 | rpp -jit example\line_check.h example/ 5 | rpp -jit example\line_check.h gl/ 6 | pause -------------------------------------------------------------------------------- /bin/nasm/GoLink.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/nasm/GoLink.exe -------------------------------------------------------------------------------- /bin/nasm/bin.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | rem cd /d %~dp0 3 | ..\rpp.exe bin.h %1 -------------------------------------------------------------------------------- /bin/nasm/bin.h: -------------------------------------------------------------------------------- 1 |  2 | import rfile.h 3 | 4 | main 5 | { 6 | v=rf.get_param 7 | if v.count<3 8 | putsl('invaild param') 9 | return 10 | a=v[2] 11 | if rf.cmd('..\\rpp.exe -grub '+a)==0 12 | putsl('compile error') 13 | return 14 | b=a.sub(0,a.count-2) 15 | if rf.cmd('nasm.exe '+b+'.asm -o '+b+'.bin')==0 16 | putsl('asm error') 17 | rfile.remove(rcode.gbk_to_utf8(b)+'.asm') 18 | } -------------------------------------------------------------------------------- /bin/nasm/cell.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/nasm/cell.bin -------------------------------------------------------------------------------- /bin/nasm/cell.h: -------------------------------------------------------------------------------- 1 | /* 2 | 裸机运行细胞自动机(生命游戏) 3 | */ 4 | 5 | import rbufm.h 6 | 7 | main 8 | { 9 | rbufm arr(25,80) 10 | char* p=4194304 11 | for i=0 to 24 12 | for j=0 to 79 13 | arr[i,j]=(*p).toint%7 14 | p++ 15 | char col=0 16 | for 17 | view(arr,col) 18 | delay 19 | trans(arr) 20 | } 21 | 22 | view(rbufm& arr,char& col) 23 | { 24 | for i=0 to 24 25 | for j=0 to 79 26 | if arr[i,j]==1 27 | rf.text(i*80+j,`*.tochar)//后面加上col可以变换颜色 28 | else 29 | rf.text(i*80+j,` .tochar) 30 | col++ 31 | } 32 | 33 | //宏不能省略大括号 34 | mac addc(a,b) 35 | { 36 | if(a>=0&&a<25&&b>=0&&b<80) 37 | { 38 | if(arr[a,b]==1) 39 | { 40 | count++; 41 | } 42 | } 43 | } 44 | 45 | trans(rbufm& arr) 46 | { 47 | for i=0 to 24 48 | for j=0 to 79 49 | count=0 50 | addc(i-1,j-1) 51 | addc(i-1,j) 52 | addc(i-1,j+1) 53 | addc(i,j-1) 54 | addc(i,j+1) 55 | addc(i+1,j-1) 56 | addc(i+1,j) 57 | addc(i+1,j+1) 58 | if count==3 59 | arr[i,j]=1 60 | elif count==2 61 | ; 62 | else 63 | arr[i,j]=0 64 | } 65 | 66 | delay 67 | { 68 | for i=0 to 400_0000 69 | ; 70 | } -------------------------------------------------------------------------------- /bin/nasm/dec.inc: -------------------------------------------------------------------------------- 1 | IMPORT GetCommandLineA 2 | IMPORT GetTickCount 3 | IMPORT Sleep 4 | IMPORT InitializeCriticalSection 5 | IMPORT DeleteCriticalSection 6 | IMPORT EnterCriticalSection 7 | IMPORT LeaveCriticalSection 8 | IMPORT _beginthreadex 9 | IMPORT WaitForSingleObject 10 | IMPORT CloseHandle 11 | 12 | IMPORT lstrlenW 13 | IMPORT FindClose 14 | IMPORT FindNextFileW 15 | IMPORT FindFirstFileW 16 | 17 | IMPORT WSAStartup 18 | IMPORT WSACleanup 19 | IMPORT socket 20 | IMPORT connect 21 | IMPORT closesocket 22 | IMPORT send 23 | IMPORT recv 24 | IMPORT bind 25 | IMPORT listen 26 | IMPORT accept 27 | 28 | IMPORT __iob_func 29 | IMPORT _fseeki64 30 | IMPORT _ftelli64 31 | IMPORT _wremove 32 | IMPORT _wrename 33 | IMPORT _wfopen 34 | IMPORT fopen 35 | IMPORT fclose 36 | IMPORT fread 37 | IMPORT fwrite 38 | IMPORT fseek 39 | IMPORT ftell 40 | 41 | IMPORT _time32 42 | IMPORT srand 43 | IMPORT rand 44 | IMPORT exit 45 | IMPORT system 46 | IMPORT malloc 47 | IMPORT free 48 | IMPORT memcpy 49 | IMPORT memset 50 | IMPORT strcpy 51 | IMPORT strlen 52 | IMPORT strcmp 53 | IMPORT sscanf 54 | IMPORT sprintf 55 | -------------------------------------------------------------------------------- /bin/nasm/grldr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/nasm/grldr -------------------------------------------------------------------------------- /bin/nasm/menu.lst: -------------------------------------------------------------------------------- 1 | 2 | color black/cyan yellow/cyan 3 | timeout 0 4 | default /default 5 | 6 | title rpp 7 | root (hd0,0) 8 | kernel (hd0,0)/cell.bin 9 | boot 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /bin/nasm/nasm.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/nasm/nasm.exe -------------------------------------------------------------------------------- /bin/open_cmd.bat: -------------------------------------------------------------------------------- 1 | cmd.exe -------------------------------------------------------------------------------- /bin/pic/flappy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/pic/flappy.png -------------------------------------------------------------------------------- /bin/pic/god.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/pic/god.png -------------------------------------------------------------------------------- /bin/pic/rpp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/pic/rpp.png -------------------------------------------------------------------------------- /bin/pic/rpp_snake.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/pic/rpp_snake.png -------------------------------------------------------------------------------- /bin/pic/rpp_speed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/pic/rpp_speed.png -------------------------------------------------------------------------------- /bin/pic/rpp_win.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/pic/rpp_win.png -------------------------------------------------------------------------------- /bin/rcheck.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | cd /d %~dp0 3 | rpp.exe example\run.h %1 -check -------------------------------------------------------------------------------- /bin/rinf/conf.txt: -------------------------------------------------------------------------------- 1 | c_export_rbin, 2 | 1 3 | c_export_rasm, 4 | 0 5 | c_export_rp, 6 | 1 7 | c_display_inf, 8 | 0 9 | c_warning, 10 | 0 11 | c_auto_addinit, 12 | 1 13 | c_auto_addfunc, 14 | 1 15 | c_auto_import, 16 | 1 17 | c_auto_bbk, 18 | 1 19 | c_op_empty_func, 20 | 1 21 | c_op_nop, 22 | 1 23 | c_op_zero, 24 | 1 25 | c_op_merge, 26 | 1 27 | c_op_ebp, 28 | 1 29 | c_op_base_calc, 30 | 1 31 | c_op_pass, 32 | 1 33 | c_op_const_eval, 34 | 1 35 | c_op_match, 36 | 1 37 | c_run, 38 | 1 39 | c_pause, 40 | 0 41 | c_stack_size, 42 | 2*1024*1024 43 | -------------------------------------------------------------------------------- /bin/rinf/key.txt: -------------------------------------------------------------------------------- 1 | rjit 2 | 3 | calle 4 | call 5 | retn 6 | reti 7 | 8 | push 9 | pop 10 | 11 | jmp 12 | jebxz 13 | jebxnz 14 | 15 | halt 16 | nop 17 | 18 | lea 19 | mov 20 | mov1 21 | mov8 22 | 23 | add 24 | sub 25 | imul 26 | idiv 27 | imod 28 | 29 | cesb 30 | cnesb 31 | cgsb 32 | cgesb 33 | clsb 34 | clesb 35 | 36 | add8 37 | sub8 38 | imul8 39 | idiv8 40 | imod8 41 | cgsb8 42 | clsb8 43 | 44 | _fadd8 45 | _fsub8 46 | _fmul8 47 | _fdiv8 48 | _fcgsb8 49 | _fclsb8 50 | 51 | band 52 | bor 53 | bnot 54 | bxor 55 | bshl 56 | bshr 57 | bsar 58 | 59 | _udiv 60 | _umod 61 | _ucgsb 62 | _ucgesb 63 | _uclsb 64 | _uclesb 65 | 66 | rn 67 | 68 | rd1 69 | rd2 70 | rd4 71 | rd8 72 | rdp 73 | 74 | eip 75 | esp 76 | ebp 77 | eax 78 | ebx 79 | ecx 80 | edx 81 | esi 82 | edi 83 | eflags 84 | 85 | void 86 | char 87 | int 88 | uint 89 | int8 90 | double 91 | rp 92 | var 93 | rbuf 94 | rstr 95 | rcs 96 | 97 | function 98 | _js_obj 99 | _js_findf 100 | 101 | if 102 | ifn 103 | else 104 | break 105 | continue 106 | continued 107 | return 108 | class 109 | template 110 | this 111 | sizeof 112 | main 113 | include 114 | import 115 | endif 116 | ifdef 117 | ifndef 118 | define 119 | enum 120 | for 121 | to 122 | in 123 | case 124 | friend 125 | cfunc 126 | dynamic 127 | private 128 | protected 129 | public 130 | switch 131 | typename 132 | typeof 133 | s_ret 134 | s_off 135 | s_param 136 | s_local 137 | mac 138 | export 139 | lambda 140 | self 141 | _BTEMP 142 | _PCALL 143 | _LAMBDA 144 | _SELF 145 | _RVM 146 | _RVARA 147 | _RVARB 148 | _TEMP 149 | _LAMBDA_C_P 150 | _PMAIN 151 | _PENV 152 | 153 | -------------------------------------------------------------------------------- /bin/rinf/match.txt: -------------------------------------------------------------------------------- 1 | sub esp , 4 2 | 3 | push @n 4 | push [ @@ + @n ] 5 | call [ & , int , "<=(int,int)" ] 6 | mov ebx , [ esp ] 7 | add esp , 4 8 | 9 | clesb [ @1 + @2 ] , @0 10 | 11 | 12 | push @n 13 | lea esi,[@@+@n] 14 | push esi 15 | call [ & , int , "=(int&,int)" ] 16 | 17 | mov [@1+@2],@0 18 | 19 | push [@@+@n] 20 | lea esi,[@@+@n] 21 | push esi 22 | call [ & , int , "+=(int&,int)" ] 23 | 24 | add [@2+@3],[@0+@1] 25 | 26 | lea esi,[@@+@n] 27 | push esi 28 | call [ & , int , "++(int&)"] 29 | 30 | add [@0+@1],1 31 | 32 | push [ @@ + @n ] 33 | push [ @@ + @n ] 34 | call [ & , int , "+(int,int)" ] 35 | 36 | mov [esp],[@2+@3] 37 | add [esp],[@0+@1] 38 | -------------------------------------------------------------------------------- /bin/rinf/optr.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/rinf/optr.txt -------------------------------------------------------------------------------- /bin/rinf/optr2.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/rinf/optr2.txt -------------------------------------------------------------------------------- /bin/rjit.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | rem cd /d %~dp0 3 | %~dp0\rpp.exe -jit %1 -------------------------------------------------------------------------------- /bin/rjit_win.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | cd /d %~dp0 3 | rpp_win.exe -jit %1 -------------------------------------------------------------------------------- /bin/rpack.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | cd /d %~dp0 3 | rpp.exe -pack %1 -------------------------------------------------------------------------------- /bin/rpack_win.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | cd /d %~dp0 3 | rpp_win.exe -pack %1 -------------------------------------------------------------------------------- /bin/rpp.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/rpp.exe -------------------------------------------------------------------------------- /bin/rpp_win.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/rpp_win.exe -------------------------------------------------------------------------------- /bin/rsrc/basic.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/rsrc/basic.h -------------------------------------------------------------------------------- /bin/rsrc/carray.h: -------------------------------------------------------------------------------- 1 |  2 | class carray 3 | { 4 | T m_buf[N] 5 | 6 | carray() 7 | { 8 | } 9 | 10 | carray(carray& v) 11 | { 12 | this=v 13 | } 14 | 15 | T& [](int num) 16 | { 17 | return (&m_buf)[num] 18 | } 19 | 20 | void =(carray& v) 21 | { 22 | for i=0;i& v) 27 | { 28 | for i=0;i* vstr,tfunc* ptfi,int vebp) 25 | { 26 | push vebp 27 | push ptfi 28 | push vstr 29 | calle "eval_vstr" 30 | mov s_ret,eax 31 | add esp,12 32 | } 33 | 34 | define get_up_func get_up_func_in(ebp,sizeof(s_local)) 35 | define get_cur_ebp ebp 36 | define get_up_ebp (*ebp.to) 37 | 38 | tfunc* get_up_func_in(int v_ebp,int local_size) 39 | { 40 | return get_cur_func_in(*(v_ebp+local_size+4).to); 41 | } 42 | 43 | tfunc* get_cur_func() 44 | { 45 | mov ecx,[ebp+4] 46 | return get_cur_func_in(ecx) 47 | } 48 | 49 | tfunc* get_cur_func_in(int pasm) 50 | { 51 | push pasm 52 | calle "get_cur_func" 53 | mov s_ret,eax 54 | add esp,4 55 | } 56 | 57 | dynamic bool and(rbuf>* p,tfunc* ptfi,int vebp) 58 | { 59 | for i=0;icount;i++ 60 | rbuf v 61 | v.push('return') 62 | v+=(*p)[i] 63 | ifn eval_vstr(&v,ptfi,vebp) 64 | return false 65 | return true 66 | } 67 | 68 | dynamic bool or(rbuf>* p,tfunc* ptfi,int vebp) 69 | { 70 | for i=0;icount;i++ 71 | rbuf v 72 | v.push('return') 73 | v+=(*p)[i] 74 | if eval_vstr(&v,ptfi,vebp) 75 | return true 76 | return false 77 | } -------------------------------------------------------------------------------- /bin/rsrc/float.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/rsrc/float.h -------------------------------------------------------------------------------- /bin/rsrc/func.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/rsrc/func.h -------------------------------------------------------------------------------- /bin/rsrc/int.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/rsrc/int.h -------------------------------------------------------------------------------- /bin/rsrc/int8.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/rsrc/int8.h -------------------------------------------------------------------------------- /bin/rsrc/int8_j.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/rsrc/int8_j.h -------------------------------------------------------------------------------- /bin/rsrc/math.h: -------------------------------------------------------------------------------- 1 |  2 | namespace math 3 | { 4 | double sin(double a) 5 | { 6 | p=&s_ret 7 | push p 8 | push [ebp+(s_off a+4)] 9 | push a 10 | calle "sin" 11 | add esp,12 12 | } 13 | 14 | double cos(double a) 15 | { 16 | p=&s_ret 17 | push p 18 | push [ebp+(s_off a+4)] 19 | push a 20 | calle "cos" 21 | add esp,12 22 | } 23 | 24 | double sqrt(double a) 25 | { 26 | p=&s_ret 27 | push p 28 | push [ebp+(s_off a+4)] 29 | push a 30 | calle "sqrt" 31 | add esp,12 32 | } 33 | } -------------------------------------------------------------------------------- /bin/rsrc/new.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/rsrc/new.h -------------------------------------------------------------------------------- /bin/rsrc/ralgo.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/rsrc/ralgo.h -------------------------------------------------------------------------------- /bin/rsrc/rbuf.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/rsrc/rbuf.h -------------------------------------------------------------------------------- /bin/rsrc/rbufm.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/rsrc/rbufm.h -------------------------------------------------------------------------------- /bin/rsrc/rcode.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/rsrc/rcode.h -------------------------------------------------------------------------------- /bin/rsrc/rcode_n.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/rsrc/rcode_n.h -------------------------------------------------------------------------------- /bin/rsrc/rdic.h: -------------------------------------------------------------------------------- 1 | import 'rset.h' 2 | 3 | template 4 | struct rdic_i 5 | { 6 | T val; 7 | rstr key; 8 | 9 | friend rbool operator<(const rdic_i& a,const rdic_i& b) 10 | { 11 | return a.key& a,const rdic_i& b) 15 | { 16 | return a.key!=b.key; 17 | } 18 | }; 19 | 20 | template 21 | struct rdic 22 | { 23 | rset > m_set; 24 | 25 | rbool exist(const rstr& key) 26 | { 27 | rdic_i item; 28 | item.key=key; 29 | return m_set.exist(item); 30 | } 31 | 32 | T& operator[](const rstr& key) 33 | { 34 | rdic_i item; 35 | item.key=key; 36 | m_set.insert_c(item); 37 | rdic_i* p=m_set.find(item); 38 | return p->val; 39 | } 40 | }; -------------------------------------------------------------------------------- /bin/rsrc/rdir.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/rsrc/rdir.h -------------------------------------------------------------------------------- /bin/rsrc/rf.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/rsrc/rf.h -------------------------------------------------------------------------------- /bin/rsrc/rf_g.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/rsrc/rf_g.h -------------------------------------------------------------------------------- /bin/rsrc/rf_j.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/rsrc/rf_j.h -------------------------------------------------------------------------------- /bin/rsrc/rf_n.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/rsrc/rf_n.h -------------------------------------------------------------------------------- /bin/rsrc/rff.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/rsrc/rff.h -------------------------------------------------------------------------------- /bin/rsrc/rff_j.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/rsrc/rff_j.h -------------------------------------------------------------------------------- /bin/rsrc/rff_n.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/rsrc/rff_n.h -------------------------------------------------------------------------------- /bin/rsrc/rfile.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/rsrc/rfile.h -------------------------------------------------------------------------------- /bin/rsrc/rfs.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/rsrc/rfs.h -------------------------------------------------------------------------------- /bin/rsrc/rfs_j.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/rsrc/rfs_j.h -------------------------------------------------------------------------------- /bin/rsrc/rfs_n.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/rsrc/rfs_n.h -------------------------------------------------------------------------------- /bin/rsrc/rhash.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/rsrc/rhash.h -------------------------------------------------------------------------------- /bin/rsrc/rlist.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/rsrc/rlist.h -------------------------------------------------------------------------------- /bin/rsrc/rmutex.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/rsrc/rmutex.h -------------------------------------------------------------------------------- /bin/rsrc/rmutex_j.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/rsrc/rmutex_j.h -------------------------------------------------------------------------------- /bin/rsrc/rmutex_n.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/rsrc/rmutex_n.h -------------------------------------------------------------------------------- /bin/rsrc/rp.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/rsrc/rp.h -------------------------------------------------------------------------------- /bin/rsrc/rpp.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/rsrc/rpp.h -------------------------------------------------------------------------------- /bin/rsrc/rset.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/rsrc/rset.h -------------------------------------------------------------------------------- /bin/rsrc/rsock.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/rsrc/rsock.h -------------------------------------------------------------------------------- /bin/rsrc/rstrw.h: -------------------------------------------------------------------------------- 1 |  2 | #include "rstr.h" 3 | 4 | struct rstrw 5 | { 6 | rbuf m_buf; 7 | 8 | ~rstrw() 9 | { 10 | } 11 | 12 | rstrw() 13 | { 14 | } 15 | 16 | rstrw(const ushort* p) 17 | { 18 | set(p); 19 | } 20 | 21 | rstrw(const uchar* p,int len) 22 | { 23 | set_size(len); 24 | rf.memcpy(m_buf.begin(),p,len); 25 | } 26 | 27 | rstrw(const rstrw& s) 28 | { 29 | m_buf.alloc_not_change(s.m_buf.m_cmax); 30 | m_buf.m_count=s.count(); 31 | rf.memcpy(begin(),s.begin(),s.size()); 32 | } 33 | 34 | rstrw(const rstr& s) 35 | { 36 | rstr tmp=rcode::utf8_to_utf16(s); 37 | set_size(tmp.size()); 38 | rf.memcpy(begin(),tmp.begin(),tmp.size()); 39 | } 40 | 41 | rstr torstr() 42 | { 43 | return rcode::utf16_to_utf8(rstr(begin(),size())); 44 | } 45 | 46 | ushort* cstrw() 47 | { 48 | m_buf.push(0.toushort); 49 | m_buf.pop(); 50 | return begin(); 51 | } 52 | 53 | void operator=(const rstrw& a) 54 | { 55 | m_buf=a.m_buf; 56 | } 57 | 58 | ushort& operator[](int num) const 59 | { 60 | return m_buf[num]; 61 | } 62 | 63 | friend rbool operator==(const rstrw& a,const rstrw& b) 64 | { 65 | return a.m_buf==b.m_buf; 66 | } 67 | 68 | friend rbool operator!=(const rstrw& a,const rstrw& b) 69 | { 70 | return a.m_buf!=b.m_buf; 71 | } 72 | 73 | friend rstrw operator+(const rstrw& a,const rstrw& b) 74 | { 75 | rstrw ret; 76 | ret.m_buf=a.m_buf+b.m_buf; 77 | return ret; 78 | } 79 | 80 | void operator+=(const rstrw& a) 81 | { 82 | m_buf+=a.m_buf; 83 | } 84 | 85 | void operator+=(ushort ch) 86 | { 87 | m_buf+=ch; 88 | } 89 | 90 | friend rbool operator<(const rstrw& a,const rstrw& b) 91 | { 92 | for(int i=0;i(const rstrw& a,const rstrw& b) 99 | { 100 | return bb); 106 | } 107 | 108 | friend rbool operator>=(const rstrw& a,const rstrw& b) 109 | { 110 | return !(a::extend_num(len)); 128 | m_buf.m_count=len; 129 | rf.memcpy(m_buf.begin(),p,len*2); 130 | } 131 | 132 | void push(ushort ch) 133 | { 134 | m_buf.push(ch); 135 | } 136 | 137 | void push_front(ushort ch) 138 | { 139 | m_buf.push_front(ch); 140 | } 141 | 142 | ushort pop() 143 | { 144 | return m_buf.pop(); 145 | } 146 | 147 | ushort pop_front() 148 | { 149 | return m_buf.pop_front(); 150 | } 151 | 152 | int count() const 153 | { 154 | return m_buf.count(); 155 | } 156 | 157 | int size() const 158 | { 159 | return count()*2; 160 | } 161 | 162 | ushort* begin() const 163 | { 164 | return m_buf.begin(); 165 | } 166 | 167 | ushort* end() const 168 | { 169 | return m_buf.end(); 170 | } 171 | 172 | rbool empty() const 173 | { 174 | return m_buf.empty(); 175 | } 176 | 177 | void clear() 178 | { 179 | m_buf.clear(); 180 | } 181 | 182 | static ushort* next(ushort* p) 183 | { 184 | return p+1; 185 | } 186 | 187 | static ushort* prev(ushort* p) 188 | { 189 | return p-1; 190 | } 191 | 192 | ushort* pos(int num) const 193 | { 194 | return begin()+num; 195 | } 196 | 197 | int pos(ushort* p) const 198 | { 199 | return p-begin(); 200 | } 201 | 202 | rstrw sub(int begin) const 203 | { 204 | return sub(begin,count()); 205 | } 206 | 207 | rstrw sub(int begin,int end) const 208 | { 209 | rstrw ret; 210 | ret.m_buf=m_buf.sub(begin,end); 211 | return ret; 212 | } 213 | 214 | rbool erase(int begin,int end) 215 | { 216 | return m_buf.erase(begin,end); 217 | } 218 | 219 | rbool erase(int i) 220 | { 221 | return erase(i,i+1); 222 | } 223 | 224 | rbool insert(int pos,const rstrw& a) 225 | { 226 | return m_buf.insert(pos,a.m_buf); 227 | } 228 | 229 | ushort get(int i) const 230 | { 231 | if(i>=count()) 232 | return 0.toushort; 233 | else 234 | return m_buf[i]; 235 | } 236 | 237 | ushort get_top() const 238 | { 239 | ushort ret=0; 240 | if(count()>0) 241 | { 242 | ret=m_buf.m_p[count()-1]; 243 | } 244 | return ret; 245 | } 246 | 247 | ushort get_bottom() const 248 | { 249 | ushort ret=0; 250 | if(count()>0) 251 | { 252 | ret=m_buf.m_p[0]; 253 | } 254 | return ret; 255 | } 256 | 257 | int find(rstrw s,int begin=0) 258 | { 259 | return r_find_pos(*this,s,begin); 260 | } 261 | 262 | int find_last(ushort ch) 263 | { 264 | return m_buf.find_last(ch); 265 | } 266 | 267 | printl() 268 | { 269 | this.torstr.printl 270 | } 271 | }; 272 | -------------------------------------------------------------------------------- /bin/rsrc/short.h: -------------------------------------------------------------------------------- 1 | class short 2 | { 3 | rd2 m_in 4 | 5 | ~short() 6 | { 7 | } 8 | 9 | short() 10 | { 11 | } 12 | 13 | short(short& a) 14 | { 15 | mov esi,this 16 | mov edi,a 17 | mov1 [esi],[edi] 18 | mov1 [esi+1],[edi+1] 19 | } 20 | 21 | short(short a) 22 | { 23 | mov esi,this 24 | mov1 [esi],a 25 | mov1 [esi+1],[ebp+(s_off a+1)] 26 | } 27 | 28 | ushort toushort() 29 | { 30 | mov esi,this 31 | mov1 s_ret,[esi] 32 | mov1 [ebp+(s_off s_ret+1)],[esi+1] 33 | } 34 | 35 | int toint() 36 | { 37 | temp=this.toushort 38 | if temp>32767 39 | return temp.toint-65536 40 | else 41 | return temp 42 | } 43 | 44 | rstr torstr() 45 | { 46 | rstr ret(this.toint) 47 | return ret 48 | } 49 | 50 | operator=(short& a) 51 | { 52 | mov esi,this 53 | mov edi,a 54 | mov1 [esi],[edi] 55 | mov1 [esi+1],[edi+1] 56 | } 57 | 58 | operator=(short a) 59 | { 60 | mov esi,this 61 | mov1 [esi],a 62 | mov1 [esi+1],[ebp+(s_off a+1)] 63 | } 64 | 65 | clear() 66 | { 67 | this=0 68 | } 69 | 70 | bool empty() 71 | { 72 | return this.toint==0 73 | } 74 | 75 | print() 76 | { 77 | rf.print this.torstr 78 | } 79 | 80 | printl() 81 | { 82 | rf.printl this.torstr 83 | } 84 | } -------------------------------------------------------------------------------- /bin/rsrc/uint.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/rsrc/uint.h -------------------------------------------------------------------------------- /bin/rsrc/ushort.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/rsrc/ushort.h -------------------------------------------------------------------------------- /bin/rsrc/var.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/bin/rsrc/var.h -------------------------------------------------------------------------------- /bin/rsrc/varf.h: -------------------------------------------------------------------------------- 1 |  2 | namespace varf 3 | { 4 | void* new() 5 | { 6 | sub esp,4 7 | calle c_new 8 | mov s_ret,[esp] 9 | add esp,4 10 | } 11 | 12 | void* new_copy(void* p) 13 | { 14 | sub esp,4 15 | push p 16 | calle c_new_copy 17 | mov s_ret,[esp] 18 | add esp,4 19 | } 20 | 21 | void delete(void* p) 22 | { 23 | push p 24 | calle c_delete 25 | } 26 | 27 | void set_int(void* p,int a) 28 | { 29 | push a 30 | push p 31 | calle c_set_int 32 | } 33 | 34 | void set_double(void* p,double a) 35 | { 36 | sub esp,8 37 | mov8 [esp],a 38 | push p 39 | calle c_set_double 40 | } 41 | 42 | void set_rstr(void* p,char* s,int size) 43 | { 44 | push size 45 | push s 46 | push p 47 | calle c_set_rstr 48 | } 49 | 50 | void set_var(void* p,void* a) 51 | { 52 | push a 53 | push p 54 | calle c_set_var 55 | } 56 | 57 | void set_func(void* p,void* a) 58 | { 59 | push a 60 | push p 61 | calle c_set_func 62 | } 63 | 64 | void* add(void* a,void* b) 65 | { 66 | sub esp,4 67 | push b 68 | push a 69 | calle c_add 70 | mov s_ret,[esp] 71 | add esp,4 72 | } 73 | 74 | void* minus(void* a,void* b) 75 | { 76 | sub esp,4 77 | push b 78 | push a 79 | calle c_minus 80 | mov s_ret,[esp] 81 | add esp,4 82 | } 83 | 84 | void* star(void* a,void* b) 85 | { 86 | sub esp,4 87 | push b 88 | push a 89 | calle c_star 90 | mov s_ret,[esp] 91 | add esp,4 92 | } 93 | 94 | void* divide(void* a,void* b) 95 | { 96 | sub esp,4 97 | push b 98 | push a 99 | calle c_divide 100 | mov s_ret,[esp] 101 | add esp,4 102 | } 103 | 104 | void* modulo(void* a,void* b) 105 | { 106 | sub esp,4 107 | push b 108 | push a 109 | calle c_modulo 110 | mov s_ret,[esp] 111 | add esp,4 112 | } 113 | 114 | void* sub(void* a,int begin,int end) 115 | { 116 | sub esp,4 117 | push end 118 | push begin 119 | push a 120 | calle c_sub 121 | mov s_ret,[esp] 122 | add esp,4 123 | } 124 | 125 | bool equal(void* a,void* b) 126 | { 127 | sub esp,4 128 | push b 129 | push a 130 | calle c_equal 131 | mov s_ret,[esp] 132 | add esp,4 133 | } 134 | 135 | bool less(void* a,void* b) 136 | { 137 | sub esp,4 138 | push b 139 | push a 140 | calle c_less 141 | mov s_ret,[esp] 142 | add esp,4 143 | } 144 | 145 | int toint(void* p) 146 | { 147 | sub esp,4 148 | push p 149 | calle c_toint 150 | mov s_ret,[esp] 151 | add esp,4 152 | } 153 | 154 | int get_rstr(void* p,char* buf) 155 | { 156 | sub esp,4 157 | push buf 158 | push p 159 | calle c_get_rstr 160 | mov s_ret,[esp] 161 | add esp,4 162 | } 163 | 164 | void* findf(void* p,char* name) 165 | { 166 | sub esp,4 167 | push name 168 | push p 169 | calle c_findf 170 | mov s_ret,[esp] 171 | add esp,4 172 | } 173 | 174 | var& quote_attr(void* p,char* name) 175 | { 176 | sub esp,4 177 | push name 178 | push p 179 | calle c_quote_attr 180 | mov s_ret,[esp] 181 | add esp,4 182 | } 183 | 184 | bool have(void* p,char* name) 185 | { 186 | sub esp,4 187 | push name 188 | push p 189 | calle c_have 190 | mov s_ret,[esp] 191 | add esp,4 192 | } 193 | 194 | void insert_pair(void* p,void* name,void* val) 195 | { 196 | push val 197 | push name 198 | push p 199 | calle c_insert_pair 200 | } 201 | 202 | int count(void* p) 203 | { 204 | sub esp,4 205 | push p 206 | calle c_count 207 | mov s_ret,[esp] 208 | add esp,4 209 | } 210 | 211 | void* stringify(void* p) 212 | { 213 | sub esp,4 214 | push p 215 | calle c_stringify 216 | mov s_ret,[esp] 217 | add esp,4 218 | } 219 | 220 | enum 221 | { 222 | c_void, 223 | c_int, 224 | c_double, 225 | c_rstr, 226 | c_dic, 227 | c_func, 228 | }; 229 | 230 | enum 231 | { 232 | c_new=2000, 233 | c_new_copy, 234 | c_delete, 235 | 236 | c_set_int, 237 | c_set_double, 238 | c_set_rstr, 239 | c_set_var, 240 | c_set_func, 241 | 242 | c_add, 243 | c_minus, 244 | c_star, 245 | c_divide, 246 | c_modulo, 247 | c_sub,//求子串或者子数组 248 | 249 | c_equal, 250 | c_less, 251 | 252 | c_toint, 253 | c_get_rstr, 254 | 255 | c_findf, 256 | c_quote_attr, 257 | c_have, 258 | c_insert_pair, 259 | c_count, 260 | c_stringify, 261 | }; 262 | } 263 | 264 | void* _js_findf(var* p,char* name) 265 | { 266 | return varf.findf(p->m_p,name) 267 | } 268 | 269 | var _js_obj(int count) 270 | { 271 | var* p=&count+1 272 | var* pret=p+count 273 | pret->var 274 | pret->set_int(0) 275 | for i=0;im_p,p->m_p,(p+1)->m_p) 277 | p->~var 278 | (p+1)->~var 279 | p+=2 280 | mov ecx,4 281 | imul ecx,count 282 | add ecx,4 283 | pop ebp 284 | add esp,sizeof(s_local) 285 | reti ecx 286 | } -------------------------------------------------------------------------------- /bin/run.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | %~dp0\rpp.exe example\run.h %1 -del -------------------------------------------------------------------------------- /del.bat: -------------------------------------------------------------------------------- 1 | 2 | del /F /Q .\bin\*.ilk 3 | del /F /Q .\bin\*.pdb 4 | 5 | del /F /Q .\*.ncb 6 | attrib -R -S -A -H .\*.suo 7 | del /F /Q .\*.suo 8 | del /F /Q .\*.user 9 | 10 | rd /S /Q .\debug 11 | rd /S /Q .\Release 12 | 13 | del /F /Q .\2005\*.ncb 14 | attrib -R -S -A -H .\2005\*.suo 15 | del /F /Q .\2005\*.suo 16 | del /F /Q .\2005\*.user 17 | 18 | rd /S /Q .\2005\debug 19 | rd /S /Q .\2005\Release 20 | 21 | del /F /Q .\2008\*.ncb 22 | attrib -R -S -A -H .\2008\*.suo 23 | del /F /Q .\2008\*.suo 24 | del /F /Q .\2008\*.user 25 | 26 | rd /S /Q .\2008\debug 27 | rd /S /Q .\2008\Release 28 | 29 | 30 | attrib -R -S -A -H .\2010\*.suo 31 | del /F /Q .\2010\*.suo 32 | del /F /Q .\2010\*.user 33 | rd /S /Q .\2010\debug 34 | rd /S /Q .\2010\Release 35 | 36 | del /F /Q .\proj\rpp_win\*.vsp 37 | rem del /F /Q .\proj\rpp_win\*.filters 38 | del /F /Q .\proj\rpp_win\*.psess 39 | del /F /Q .\proj\rpp_win\*.sdf 40 | del /F /Q .\proj\rpp_win\*.ncb 41 | attrib -R -S -A -H .\proj\rpp_win\*.suo 42 | del /F /Q .\proj\rpp_win\*.suo 43 | del /F /Q .\proj\rpp_win\*.user 44 | 45 | rd /S /Q .\proj\rpp_win\debug 46 | rd /S /Q .\proj\rpp_win\Release 47 | 48 | del /F /Q .\proj\*.vsp 49 | rem del /F /Q .\proj\*.filters 50 | del /F /Q .\proj\*.psess 51 | del /F /Q .\proj\*.sdf 52 | del /F /Q .\proj\*.ncb 53 | attrib -R -S -A -H .\proj\*.suo 54 | del /F /Q .\proj\*.suo 55 | del /F /Q .\proj\*.user 56 | 57 | rd /S /Q .\proj\debug 58 | rd /S /Q .\proj\Release 59 | 60 | pause -------------------------------------------------------------------------------- /proj/rpp.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2012 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rpp", "rpp.vcxproj", "{E00D615C-3C55-4D01-B2EB-0064CFBAA91E}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Debug|x64 = Debug|x64 10 | Release|Win32 = Release|Win32 11 | Release|x64 = Release|x64 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {E00D615C-3C55-4D01-B2EB-0064CFBAA91E}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {E00D615C-3C55-4D01-B2EB-0064CFBAA91E}.Debug|Win32.Build.0 = Debug|Win32 16 | {E00D615C-3C55-4D01-B2EB-0064CFBAA91E}.Debug|x64.ActiveCfg = Debug|x64 17 | {E00D615C-3C55-4D01-B2EB-0064CFBAA91E}.Debug|x64.Build.0 = Debug|x64 18 | {E00D615C-3C55-4D01-B2EB-0064CFBAA91E}.Release|Win32.ActiveCfg = Release|Win32 19 | {E00D615C-3C55-4D01-B2EB-0064CFBAA91E}.Release|Win32.Build.0 = Release|Win32 20 | {E00D615C-3C55-4D01-B2EB-0064CFBAA91E}.Release|x64.ActiveCfg = Release|x64 21 | {E00D615C-3C55-4D01-B2EB-0064CFBAA91E}.Release|x64.Build.0 = Release|x64 22 | EndGlobalSection 23 | GlobalSection(SolutionProperties) = preSolution 24 | HideSolutionNode = FALSE 25 | EndGlobalSection 26 | EndGlobal 27 | -------------------------------------------------------------------------------- /proj/rpp_win/rpp_win.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2012 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rpp_win", "rpp_win.vcxproj", "{D95F2BD0-54D7-4544-9902-FDFBEBBFFF5C}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {D95F2BD0-54D7-4544-9902-FDFBEBBFFF5C}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {D95F2BD0-54D7-4544-9902-FDFBEBBFFF5C}.Debug|Win32.Build.0 = Debug|Win32 14 | {D95F2BD0-54D7-4544-9902-FDFBEBBFFF5C}.Release|Win32.ActiveCfg = Release|Win32 15 | {D95F2BD0-54D7-4544-9902-FDFBEBBFFF5C}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /proj/rpp_win/rpp_win.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | 15 | 16 | 17 | {D95F2BD0-54D7-4544-9902-FDFBEBBFFF5C} 18 | Win32Proj 19 | rpp_win 20 | 21 | 22 | 23 | Application 24 | true 25 | v110_xp 26 | MultiByte 27 | 28 | 29 | Application 30 | false 31 | v110_xp 32 | true 33 | MultiByte 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | true 47 | $(SolutionDir)$(Configuration)\ 48 | $(Configuration)\ 49 | 50 | 51 | false 52 | $(SolutionDir)$(Configuration)\ 53 | $(Configuration)\ 54 | 55 | 56 | 57 | 58 | 59 | Level3 60 | Disabled 61 | WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) 62 | MultiThreadedDebug 63 | 64 | 65 | Windows 66 | true 67 | $(OutDir)..\..\..\bin\$(ProjectName).exe 68 | 2097152 69 | 70 | 71 | 72 | 73 | Level3 74 | 75 | 76 | MaxSpeed 77 | true 78 | true 79 | WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) 80 | MultiThreaded 81 | 82 | 83 | Windows 84 | true 85 | true 86 | true 87 | $(OutDir)..\..\..\bin\$(ProjectName).exe 88 | 2097152 89 | 90 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /proj/rpp_win/rpp_win.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | -------------------------------------------------------------------------------- /rlib/rbase.h: -------------------------------------------------------------------------------- 1 | #ifndef rbase_h__ 2 | #define rbase_h__ 3 | 4 | #ifdef _MSC_VER 5 | 6 | //#define _CRT_SECURE_NO_DEPRECATE 7 | //#pragma warning(disable:4127) 8 | //#pragma warning(disable:4390) 9 | //#pragma warning(disable:4710) 10 | #pragma warning(disable:4996) 11 | #pragma warning(disable:4345) 12 | 13 | #include 14 | #include 15 | #else 16 | #endif 17 | 18 | #ifndef int64 19 | #ifdef _MSC_VER 20 | typedef __int64 int64; 21 | typedef unsigned __int64 uint64; 22 | #else 23 | typedef long long int64; 24 | typedef unsigned long long uint64; 25 | #endif 26 | 27 | typedef int64 int8; 28 | 29 | #endif 30 | 31 | #ifndef uint 32 | typedef unsigned int uint; 33 | #endif 34 | 35 | #ifndef ushort 36 | typedef unsigned short ushort; 37 | #endif 38 | 39 | #ifndef uchar 40 | typedef unsigned char uchar; 41 | #endif 42 | 43 | #ifndef rbool 44 | typedef int rbool; 45 | #endif 46 | 47 | #ifndef wchar 48 | #ifdef _MSC_VER 49 | typedef wchar_t wchar; 50 | #else 51 | typedef ushort wchar; 52 | #endif 53 | #endif 54 | 55 | //#define NEW new(nothrow) 56 | 57 | #ifndef null 58 | #if _MSC_VER >= 1700 59 | #define null nullptr 60 | #else 61 | #define null NULL 62 | #endif 63 | #endif 64 | 65 | #include 66 | 67 | #define elif else if 68 | #define ifn(a) if(!(a)) 69 | 70 | #define r_size(a) ((int)sizeof(a)) 71 | #define r_move(a) std::move(a) 72 | #define r_max(a,b) ((a)>(b)?(a):(b)) 73 | #define r_min(a,b) ((a)>(b)?(b):(a)) 74 | #define r_cond(cond,a,b) ((cond)?(a):(b)) 75 | #define r_ceil_div(a,b) (0==(a)%(b)?(a)/(b):(a)/(b)+1) 76 | 77 | #define r_to static_cast 78 | 79 | #define r_to_int(a) ((int)(a)) 80 | #define r_to_uint(a) ((uint)(a)) 81 | #define r_to_char(a) ((char)(a)) 82 | #define r_to_uchar(a) ((uchar)(a)) 83 | #define r_to_int8(a) ((int8)(a)) 84 | #define r_to_double(a) ((double)(a)) 85 | 86 | #define r_to_pint(a) ((int*)(a)) 87 | #define r_to_puint(a) ((uint*)(a)) 88 | #define r_to_pchar(a) ((char*)(a)) 89 | #define r_to_puchar(a) ((uchar*)(a)) 90 | #define r_to_pint8(a) ((int8*)(a)) 91 | #define r_to_pdouble(a) ((double*)(a)) 92 | #define r_to_prstr(a) ((rstr*)(a)) 93 | 94 | #define AND(a,b) ((a)&(b)) 95 | #define OR(a,b) ((a)|(b)) 96 | #define XOR(a,b) ((a)^(b)) 97 | #define NOT(a) (~(a)) 98 | 99 | #endif 100 | -------------------------------------------------------------------------------- /rlib/rclass.h: -------------------------------------------------------------------------------- 1 | #ifndef rclass_h__ 2 | #define rclass_h__ 3 | 4 | #include "rbuf.h" 5 | #include "rf.h" 6 | #ifdef _MSC_VER 7 | #include 8 | #pragma comment(lib,"Ws2_32") 9 | #else 10 | #include "gbk.txt" 11 | #endif 12 | 13 | struct rclass//本类用于初始化环境,只能实例化一次(单例模式) 14 | { 15 | rclass() 16 | { 17 | #ifdef _MSC_VER 18 | std::set_new_handler(new_fail_handle); 19 | 20 | WORD wVersionRequested; 21 | WSADATA wsaData; 22 | 23 | wVersionRequested=MAKEWORD(1,1); 24 | 25 | if(0!=WSAStartup(wVersionRequested,&wsaData)) 26 | { 27 | return; 28 | } 29 | 30 | if(LOBYTE(wsaData.wVersion)!=1||HIBYTE(wsaData.wVersion)!=1) 31 | { 32 | return; 33 | } 34 | #endif 35 | } 36 | 37 | ~rclass() 38 | { 39 | #ifdef _MSC_VER 40 | WSACleanup(); 41 | #endif 42 | } 43 | 44 | static void new_fail_handle() 45 | { 46 | rf::error("memory insufficient"); 47 | } 48 | }; 49 | 50 | #endif -------------------------------------------------------------------------------- /rlib/rdb.h: -------------------------------------------------------------------------------- 1 | #ifndef rdb_h__ 2 | #define rdb_h__ 3 | 4 | #include "rfile.h" 5 | 6 | #define rdbint rdb 7 | 8 | //TL是数据长度,TA是地址 9 | template//uchar,ushort,uint,uint64 10 | class rdb 11 | { 12 | public: 13 | rfile m_file;//use multi thread please define multi object 14 | rbuf m_index; 15 | 16 | enum 17 | { 18 | c_null,//空数据 19 | c_real, 20 | c_cp,//压缩数据 21 | c_error//异常数据 22 | }; 23 | 24 | rdb() 25 | { 26 | } 27 | 28 | rdb(rstrw name,rstrw mode="r") 29 | { 30 | open(name,mode); 31 | } 32 | 33 | rbool close() 34 | { 35 | return m_file.close(); 36 | } 37 | 38 | rbool open_off(rstrw name,int off,rstrw mode="r") 39 | { 40 | if(!m_file.open(name,mode)) 41 | return false; 42 | m_file.set_off(off); 43 | TL count; 44 | if(!m_file.read(r_size(count),&count)) 45 | return false; 46 | TL cmax; 47 | if(!m_file.read(r_size(cmax),&cmax)) 48 | return false; 49 | m_index.realloc_n_not_change(cmax); 50 | if(!m_file.read(count*r_size(TA),m_index.begin())) 51 | return false; 52 | m_index.m_count=count; 53 | for(int i=0;i=m_index.count()||i<0) 106 | return false; 107 | if(m_index[i]==0) 108 | return true; 109 | char flag; 110 | TA off=m_index[i]; 111 | if(!m_file.read(off,r_size(flag),&flag)) 112 | return false; 113 | if(flag==c_null) 114 | return true; 115 | if(flag!=c_real) 116 | return false; 117 | TL len; 118 | off+=r_size(flag); 119 | if(!m_file.read(off,r_size(len),&len)) 120 | return false; 121 | data.m_buf.realloc_n(len); 122 | off+=r_size(len); 123 | if(!m_file.read(off,data.count(),data.begin())) 124 | return false; 125 | return true; 126 | } 127 | 128 | rbool write(int i,const rstr& data) 129 | { 130 | if(i>=m_index.count()||i<0) 131 | return false; 132 | char flag=c_null; 133 | TA off=m_index[i]; 134 | if(!m_file.write(off,r_size(flag),&flag)) 135 | return false; 136 | flag=c_real; 137 | off=m_file.size(); 138 | m_index[i]=off; 139 | if(!m_file.write(off,r_size(flag),&flag)) 140 | return false; 141 | off+=r_size(flag); 142 | TL len=data.count(); 143 | if(!m_file.write(off,r_size(len),&len)) 144 | return false; 145 | off+=r_size(len); 146 | if(!m_file.write(off,data.count(),data.begin())) 147 | return false; 148 | if(!m_file.write(get_index_off(i),r_size(TA),&m_index[i])) 149 | return false; 150 | return true; 151 | } 152 | 153 | rbool write_new(const rstr& data) 154 | { 155 | if(m_index.m_count>=m_index.m_cmax) 156 | if(!extend()) 157 | return false; 158 | 159 | TA off; 160 | off=m_file.size(); 161 | m_index.push(off); 162 | 163 | char flag=c_real; 164 | if(!m_file.write(off,r_size(flag),&flag)) 165 | return false; 166 | off+=r_size(flag); 167 | TL len=data.count(); 168 | if(!m_file.write(off,r_size(len),&len)) 169 | return false; 170 | off+=r_size(len); 171 | if(!m_file.write(off,data.count(),data.begin())) 172 | return false; 173 | 174 | int i=m_index.count()-1; 175 | if(!m_file.write(get_index_off(i),r_size(TA),&m_index[i])) 176 | return false; 177 | if(!m_file.write(0,r_size(TL),&m_index.m_count)) 178 | return false; 179 | return true; 180 | } 181 | 182 | rbool extend() 183 | { 184 | if(m_file.size()>=128*1024*1024) 185 | return false; 186 | rbuf temp; 187 | temp.alloc(m_file.size()-get_data_off()); 188 | if(!m_file.read(get_data_off(),temp.size(),temp.begin())) 189 | return false; 190 | int cmax=m_index.m_cmax; 191 | m_index.realloc_not_change(m_index.extend_num(m_index.count())); 192 | for(int i=0;i 7 | struct rdic_i 8 | { 9 | T val;//val必须前置 10 | rstr key; 11 | 12 | friend rbool operator<(const rdic_i& a,const rdic_i& b) 13 | { 14 | return a.key 19 | struct rdic 20 | { 21 | rset > m_set; 22 | 23 | void clear() 24 | { 25 | m_set.clear(); 26 | } 27 | 28 | T* begin() const 29 | { 30 | return (T*)m_set.begin(); 31 | } 32 | 33 | T* end() const 34 | { 35 | return (T*)m_set.end(); 36 | } 37 | 38 | T* next(T* p) const 39 | { 40 | return (T*)m_set.next((rdic_i*)p); 41 | } 42 | 43 | rstr get_key(T* p) 44 | { 45 | return ((rdic_i*)p)->key; 46 | } 47 | 48 | rbool empty() const 49 | { 50 | return m_set.empty(); 51 | } 52 | 53 | int count() const 54 | { 55 | return m_set.count(); 56 | } 57 | 58 | rbool exist(const rstr& key) const 59 | { 60 | rdic_i item; 61 | item.key=key; 62 | return m_set.exist(item); 63 | } 64 | 65 | T* find(const rstr& key) const 66 | { 67 | rdic_i item; 68 | item.key=key; 69 | return (T*)m_set.find(item); 70 | } 71 | 72 | void insert(const rstr& key,const T& val) 73 | { 74 | rdic_i item; 75 | item.key=key; 76 | item.val=val; 77 | m_set.insert(item); 78 | } 79 | 80 | T& operator[](const rstr& key) 81 | { 82 | rdic_i item; 83 | item.key=key; 84 | m_set.insert_c(item); 85 | rdic_i* p=m_set.find(item); 86 | return p->val; 87 | } 88 | }; 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /rlib/rdir.h: -------------------------------------------------------------------------------- 1 | #ifndef rdir_h__ 2 | #define rdir_h__ 3 | 4 | #include "rfile.h" 5 | #include "rf.h" 6 | #include "rstrw.h" 7 | #include "rlist.h" 8 | 9 | #ifdef _MSC_VER 10 | #include 11 | #include 12 | #else 13 | //#include 14 | //#include 15 | //#include 16 | //#include 17 | #endif 18 | 19 | //todo 去掉这个结构体 20 | struct rdir_item 21 | { 22 | rstrw path; 23 | rbool is_dir; 24 | 25 | rdir_item() 26 | { 27 | is_dir=false; 28 | } 29 | 30 | friend rbool operator<=(const rdir_item& a,const rdir_item& b) 31 | { 32 | return a.path<=b.path; 33 | } 34 | }; 35 | 36 | #ifndef MAX_PATH 37 | #define MAX_PATH 260 38 | #endif 39 | 40 | struct rdir 41 | { 42 | static rstrw erase_suffix(const rstrw& name) 43 | { 44 | rstrw s=get_suffix(name); 45 | return name.sub(0,name.count()-s.count()-1); 46 | } 47 | 48 | static rstrw get_suffix(const rstrw& name) 49 | { 50 | ushort ch='.'; 51 | int pos=name.find_last(ch); 52 | if(pos=path.count()) 65 | return rstrw(); 66 | return path.sub(0,pos+1); 67 | } 68 | 69 | static rstrw get_name(const rstrw& path) 70 | { 71 | if(path.empty()) 72 | return rstrw(); 73 | ushort ch='/'; 74 | int pos=path.find_last(ch); 75 | if(pos>=path.count()) 76 | return rstrw(); 77 | return path.sub(pos+1); 78 | } 79 | 80 | static rstrw get_exe_name() 81 | { 82 | wchar buf[MAX_PATH+1]; 83 | if(GetModuleFileNameW(null,(wchar*)buf,MAX_PATH)==0) 84 | return rstrw(); 85 | return dir_std(rstrw(buf)); 86 | } 87 | 88 | static rstrw get_exe_dir() 89 | { 90 | rstrw ret; 91 | #ifndef __COCOS2D_H__ 92 | wchar buf[MAX_PATH+1]; 93 | if(GetModuleFileNameW(null,(wchar*)buf,MAX_PATH)==0) 94 | return ret; 95 | ret=buf; 96 | #else 97 | ret=rstr(FileUtils::getInstance()->fullPathForFilename( 98 | "rinf/key.txt").c_str()); 99 | ret=ret.sub(0,ret.count()-rstr("rinf/key.txt").count()+1); 100 | #endif 101 | ret=dir_std(ret); 102 | ret=get_prev_dir(ret); 103 | return ret; 104 | } 105 | 106 | static rstrw get_cur_dir() 107 | { 108 | rstrw ret; 109 | #ifndef __COCOS2D_H__ 110 | wchar buf[MAX_PATH+1]; 111 | if(GetCurrentDirectoryW(MAX_PATH,(wchar*)buf)==0) 112 | return ret; 113 | ret=buf; 114 | ret=dir_std(ret); 115 | ret+='/'; 116 | #else 117 | ret=rstr(FileUtils::getInstance()->fullPathForFilename( 118 | "rinf/key.txt").c_str()); 119 | ret=ret.sub(0,ret.count()-rstr("rinf/key.txt").count()+1); 120 | ret=dir_std(ret); 121 | ret=get_prev_dir(ret); 122 | #endif 123 | return ret; 124 | } 125 | 126 | //非win系统区分大小写 127 | static rstrw dir_std(rstrw s) 128 | { 129 | for(ushort* p=s.begin();p!=s.end();++p) 130 | { 131 | if('\\'==*p) 132 | { 133 | *p='/'; 134 | } 135 | } 136 | return s; 137 | } 138 | 139 | static rbuf get_file_bfs(rstrw path) 140 | { 141 | rbuf ret; 142 | #ifndef __COCOS2D_H__ 143 | if(path.count()>4096||0==path.count())//ubuntu's max path len is 4096 144 | { 145 | return ret; 146 | } 147 | path=dir_std(path); 148 | if(path.count()>=1&&path[path.count()-1]!='/') 149 | { 150 | path+=rstr("/"); 151 | } 152 | rlist queue; 153 | queue.push(path); 154 | while(!queue.empty()) 155 | { 156 | path=queue.pop_front(); 157 | WIN32_FIND_DATAW wfd; 158 | HANDLE handle=FindFirstFileW( 159 | (path+rstr("*.*")).cstrw_t(),&wfd); 160 | if(handle==INVALID_HANDLE_VALUE) 161 | continue; 162 | while(true) 163 | { 164 | rdir_item item; 165 | rstrw name=dir_std(wfd.cFileName); 166 | if(rstr(".")!=name&&rstr("..")!=name) 167 | { 168 | item.path=path+name; 169 | if(0!=(wfd.dwFileAttributes& 170 | FILE_ATTRIBUTE_DIRECTORY)) 171 | { 172 | item.is_dir=true; 173 | queue.push(item.path+rstr("/")); 174 | } 175 | ret.push(item); 176 | } 177 | ifn(FindNextFileW(handle,&wfd)) 178 | { 179 | break; 180 | } 181 | } 182 | FindClose(handle); 183 | } 184 | #endif 185 | return ret; 186 | } 187 | }; 188 | 189 | #endif 190 | -------------------------------------------------------------------------------- /rlib/rf.h: -------------------------------------------------------------------------------- 1 | #ifndef rf_h__ 2 | #define rf_h__ 3 | 4 | #include "rstr.h" 5 | #include 6 | #include 7 | #include 8 | #ifdef _MSC_VER 9 | #include 10 | #include 11 | #else 12 | #include 13 | #include 14 | #endif 15 | #include 16 | #include 17 | //#include 18 | 19 | struct rf 20 | { 21 | enum 22 | { 23 | c_block_size=(64*1024) 24 | }; 25 | 26 | static void error(rstr s=rstr()) 27 | { 28 | printf("\n%s\n",s.cstr()); 29 | getch(); 30 | exit(1); 31 | } 32 | 33 | static void printl(rstr s=rstr()) 34 | { 35 | printf("%s\n",s.cstr()); 36 | } 37 | 38 | static void print(rstr s=rstr()) 39 | { 40 | printf("%s ",s.cstr()); 41 | } 42 | 43 | static void print(const char* s) 44 | { 45 | printf("%s ",s);//必须加上%s防止字符串中出现特殊字符 46 | } 47 | 48 | static int tick() 49 | { 50 | #ifdef _MSC_VER 51 | return GetTickCount(); 52 | #else 53 | return (int)((double)clock()/CLOCKS_PER_SEC*1000); 54 | #endif 55 | } 56 | 57 | static void sleep(int milliseconds) 58 | { 59 | if(milliseconds<50) 60 | { 61 | milliseconds=50; 62 | } 63 | #ifdef _MSC_VER 64 | Sleep(milliseconds); 65 | #else 66 | if(milliseconds>2100000000) 67 | ::sleep(milliseconds/1000); 68 | else 69 | usleep(milliseconds*1000); 70 | #endif 71 | } 72 | 73 | static int getch() 74 | { 75 | #ifdef _MSC_VER 76 | return ::getch(); 77 | #else 78 | struct termios oldt,newt; 79 | int ch; 80 | tcgetattr(STDIN_FILENO,&oldt); 81 | newt=oldt; 82 | newt.c_lflag&=~(ICANON|ECHO); 83 | tcsetattr(STDIN_FILENO,TCSANOW,&newt); 84 | ch=getchar(); 85 | tcsetattr(STDIN_FILENO,TCSANOW,&oldt); 86 | return ch; 87 | #endif 88 | } 89 | 90 | static int round(double a){ 91 | return (int)(a+0.5); 92 | } 93 | 94 | /*static int rand_n(int n){ 95 | random_device rd; 96 | return rd()%n; 97 | }*/ 98 | 99 | static void srand() 100 | { 101 | ::srand((uint)::time(null)); 102 | } 103 | 104 | static int rand() 105 | { 106 | return ::rand(); 107 | } 108 | 109 | static uchar get_bitmap(uchar bitmap[],int block) 110 | { 111 | uchar result; 112 | result=bitmap[block/8]>>(7-block%8); 113 | result&=0x1; 114 | return result; 115 | } 116 | 117 | static void set_bitmap(uchar bitmap[],int block) 118 | { 119 | bitmap[block/8]|=(1<<(7-block%8)); 120 | } 121 | 122 | static rbool execmd(const char* p) 123 | { 124 | return 0==::system(p); 125 | } 126 | #ifdef _MSC_VER 127 | #else 128 | static rbool execmd_r(const char* cmd,rstr& result) 129 | { 130 | result=rstr(); 131 | FILE* fp=popen(cmd,"r"); 132 | 133 | if(null==fp) 134 | { 135 | return false; 136 | } 137 | 138 | rbuf buf(4096+1); 139 | buf.m_p[4096]=0; 140 | int count; 141 | 142 | while(true) 143 | { 144 | count=fread(buf.m_p,1,4096,fp); 145 | 146 | if(count>0) 147 | { 148 | buf.m_p[count]=0; 149 | result+=buf.m_p; 150 | } 151 | 152 | if(count<4096) 153 | { 154 | break; 155 | } 156 | } 157 | 158 | pclose(fp); 159 | return true; 160 | } 161 | #endif 162 | }; 163 | 164 | #endif 165 | -------------------------------------------------------------------------------- /rlib/rhash.h: -------------------------------------------------------------------------------- 1 | #ifndef rhash_h__ 2 | #define rhash_h__ 3 | 4 | #include "rstr.h" 5 | 6 | template 7 | struct rhash_i 8 | { 9 | T val; 10 | rstr name; 11 | rhash_i* pre; 12 | rhash_i* next; 13 | }; 14 | 15 | template 16 | struct rhash 17 | { 18 | rbuf*> m_hash; 19 | int m_count; 20 | 21 | ~rhash() 22 | { 23 | clear(); 24 | } 25 | 26 | rhash() 27 | { 28 | init(); 29 | } 30 | 31 | T& operator[](const rstr& name) 32 | { 33 | T* p=(T*)find(name); 34 | if(p) 35 | return *p; 36 | //找不到则插入一个空值 37 | T a; 38 | insert(a,name); 39 | p=(T*)find(name); 40 | return *p; 41 | } 42 | 43 | void init() 44 | { 45 | //两个字节消耗256K内存,如果用3个字节需要64M内存 46 | m_hash.realloc_n(65536); 47 | for(int i=0;i* p=m_hash[i]; 61 | while(p!=null) 62 | { 63 | rhash_i* temp=p; 64 | p=p->next; 65 | r_delete(temp); 66 | } 67 | } 68 | } 69 | init(); 70 | } 71 | 72 | rbool exist(const rstr& name) 73 | { 74 | return find(name)!=null; 75 | } 76 | 77 | T* find(const rstr& name) 78 | { 79 | int addr=get_addr(name); 80 | rhash_i* p=m_hash[addr]; 81 | while(p) 82 | { 83 | if(p->name==name) 84 | return (T*)p; 85 | p=p->next; 86 | } 87 | return null; 88 | } 89 | 90 | //如果重复则不插入 91 | void insert_c(T& a,rstr name=rstr()) 92 | { 93 | if(exist(name)) 94 | return; 95 | insert(a,name); 96 | } 97 | 98 | void insert(T& a,rstr name=rstr()) 99 | { 100 | int addr=get_addr(name); 101 | rhash_i* p=r_new >(); 102 | p->name=name; 103 | p->next=m_hash[addr]; 104 | p->pre=null; 105 | p->val=a; 106 | if(m_hash[addr]!=null) 107 | m_hash[addr]->pre=p; 108 | m_hash[addr]=p; 109 | m_count++; 110 | } 111 | 112 | rbool erase(rstr name=rstr()) 113 | { 114 | rhash_i* p=(rhash_i*)find(name); 115 | if(p==null) 116 | return false; 117 | if(p->pre!=null) 118 | { 119 | p->pre->next=p->next; 120 | if(p->next!=null) 121 | p->next->pre=p->pre; 122 | } 123 | else 124 | { 125 | m_hash[get_addr(name)]=p->next; 126 | if(p->next!=null) 127 | p->next->pre=null; 128 | } 129 | r_delete(p); 130 | m_count--; 131 | return true; 132 | } 133 | 134 | T* begin() 135 | { 136 | for(int i=0;i=0;i--) 145 | if(m_hash[i]!=null) 146 | { 147 | rhash_i* p=m_hash[i]; 148 | while(p!=null&&p->next!=null) 149 | p=p->next; 150 | return (T*)p; 151 | } 152 | return null; 153 | } 154 | 155 | //这个next有点慢,能不能把一个桶的最后一个元素的next指向下一个桶? 156 | T* next(T* cur) 157 | { 158 | rhash_i* p=(rhash_i*)cur; 159 | if(p->next!=null) 160 | return (T*)p->next; 161 | int addr=get_addr(p->name); 162 | for(int i=addr+1;i list=rdir::get_file_bfs(path); 67 | r_qsort(list); 68 | rdbint db(filename,rstrw("rw")); 69 | for(int i=0;i 7 | struct rlist_i 8 | { 9 | T val; 10 | rlist_i* prev; 11 | rlist_i* next; 12 | }; 13 | 14 | template 15 | struct rlist 16 | { 17 | rlist_i* m_front; 18 | rlist_i* m_rear; 19 | int m_count; 20 | 21 | ~rlist() 22 | { 23 | clear(); 24 | } 25 | 26 | rlist() 27 | { 28 | init(); 29 | } 30 | 31 | void init() 32 | { 33 | m_front=null; 34 | m_rear=null; 35 | m_count=0; 36 | } 37 | 38 | void clear() 39 | { 40 | while(m_front) 41 | { 42 | m_rear=m_front->next; 43 | r_delete(m_front); 44 | m_front=m_rear; 45 | } 46 | init(); 47 | } 48 | 49 | rbool empty() const 50 | { 51 | return m_count==0; 52 | } 53 | 54 | int count() const 55 | { 56 | return m_count; 57 | } 58 | 59 | T& top() 60 | { 61 | return *(T*)m_rear; 62 | } 63 | 64 | void push(const T& a) 65 | { 66 | rlist_i* p=r_new >(); 67 | p->val=a; 68 | p->next=null; 69 | p->prev=m_rear; 70 | if(empty()) 71 | { 72 | m_front=p; 73 | m_rear=p; 74 | } 75 | else 76 | { 77 | m_rear->next=p; 78 | m_rear=p; 79 | } 80 | m_count++; 81 | } 82 | 83 | T pop() 84 | { 85 | m_count--; 86 | rlist_i* p=m_rear; 87 | T ret=p->val; 88 | m_rear=p->prev; 89 | if(m_rear) 90 | { 91 | m_rear->next=null; 92 | } 93 | if(empty()) 94 | { 95 | m_front=null; 96 | } 97 | r_delete(p); 98 | return ret; 99 | } 100 | 101 | void push_front(const T& a) 102 | { 103 | rlist_i* p=r_new >(); 104 | p->val=a; 105 | p->next=m_front; 106 | p->prev=null; 107 | if(empty()) 108 | { 109 | m_front=p; 110 | m_rear=p; 111 | } 112 | else 113 | { 114 | m_front->prev=p; 115 | m_front=p; 116 | } 117 | m_count++; 118 | } 119 | 120 | T pop_front() 121 | { 122 | m_count--; 123 | rlist_i* p=m_front; 124 | T ret=p->val; 125 | m_front=p->next; 126 | if(m_front) 127 | { 128 | m_front->prev=null; 129 | } 130 | if(empty()) 131 | { 132 | m_rear=null; 133 | } 134 | r_delete(p); 135 | return ret; 136 | } 137 | 138 | //前插 139 | void insert(T* pos,const T& a) 140 | { 141 | if(pos==null) 142 | { 143 | push(a); 144 | return; 145 | } 146 | rlist_i* cur=(rlist_i*)pos; 147 | rlist_i* p=r_new >(); 148 | p->val=a; 149 | p->next=cur; 150 | p->prev=cur->prev; 151 | if(cur->prev) 152 | { 153 | cur->prev->next=p; 154 | } 155 | cur->prev=p; 156 | if(p->prev==null) 157 | { 158 | m_front=p; 159 | } 160 | if(p->next==null) 161 | { 162 | m_rear=p; 163 | } 164 | m_count++; 165 | } 166 | 167 | void insert(int pos,const T& a) 168 | { 169 | insert(index(pos),a); 170 | } 171 | 172 | void erase(T* pos) 173 | { 174 | if(pos==null) 175 | { 176 | return; 177 | } 178 | rlist_i* cur=(rlist_i*)pos; 179 | if(cur->prev==null) 180 | { 181 | m_front=cur->next; 182 | } 183 | if(cur->next==null) 184 | { 185 | m_rear=cur->prev; 186 | } 187 | if(cur->prev) 188 | { 189 | cur->prev->next=cur->next; 190 | } 191 | if(cur->next) 192 | { 193 | cur->next->prev=cur->prev; 194 | } 195 | r_delete(cur); 196 | m_count--; 197 | } 198 | 199 | void erase(int pos) 200 | { 201 | erase(index(pos)); 202 | } 203 | 204 | T* index(int n) 205 | { 206 | rlist_i* p=m_front; 207 | for(;n;n--) 208 | { 209 | if(p==null) 210 | { 211 | return null; 212 | } 213 | p=p->next; 214 | } 215 | return (T*)p; 216 | } 217 | 218 | T& operator[](int n) 219 | { 220 | T* p=index(n); 221 | return *p; 222 | } 223 | 224 | T* begin() 225 | { 226 | return (T*)m_front; 227 | } 228 | 229 | T* end() 230 | { 231 | return null; 232 | } 233 | 234 | T* next(void* p) 235 | { 236 | return (T*)((rlist_i*)p)->next; 237 | } 238 | 239 | T* prev(void* p) 240 | { 241 | return (T*)((rlist_i*)p)->prev; 242 | } 243 | }; 244 | 245 | #endif -------------------------------------------------------------------------------- /rlib/rmutex.h: -------------------------------------------------------------------------------- 1 | #ifndef rmutex_h__ 2 | #define rmutex_h__ 3 | 4 | #ifdef _MSC_VER 5 | #include 6 | #else 7 | #include 8 | #endif 9 | 10 | struct rmutex 11 | { 12 | #ifdef _MSC_VER 13 | CRITICAL_SECTION m_mutex; 14 | #else 15 | sem_t m_mutex; 16 | #endif 17 | rmutex() 18 | { 19 | #ifdef _MSC_VER 20 | InitializeCriticalSection(&m_mutex); 21 | #else 22 | sem_init(&m_mutex,0,1); 23 | #endif 24 | } 25 | 26 | ~rmutex() 27 | { 28 | #ifdef _MSC_VER 29 | DeleteCriticalSection(&m_mutex); 30 | #else 31 | #endif 32 | } 33 | 34 | void enter() 35 | { 36 | #ifdef _MSC_VER 37 | EnterCriticalSection(&m_mutex); 38 | #else 39 | sem_wait(&m_mutex); 40 | #endif 41 | } 42 | 43 | void leave() 44 | { 45 | #ifdef _MSC_VER 46 | LeaveCriticalSection(&m_mutex); 47 | #else 48 | sem_post(&m_mutex); 49 | #endif 50 | } 51 | }; 52 | 53 | //用于整个函数的局部临时mutex 54 | struct rmutex_t 55 | { 56 | rmutex* m_p; 57 | 58 | rmutex_t(rmutex& m) 59 | { 60 | m_p=&m; 61 | m_p->enter(); 62 | } 63 | 64 | ~rmutex_t() 65 | { 66 | m_p->leave(); 67 | } 68 | }; 69 | 70 | #endif -------------------------------------------------------------------------------- /rlib/rthread.h: -------------------------------------------------------------------------------- 1 | #ifndef rthread_h__ 2 | #define rthread_h__ 3 | 4 | #include "rbase.h" 5 | typedef void (* rthread_start)(void*); 6 | #ifdef _MSC_VER 7 | #include 8 | #include 9 | typedef uint rthread_ret;//32 bit 10 | #define rthread_call __stdcall 11 | typedef uint (__stdcall* prthread)(void*); 12 | #else 13 | #include 14 | typedef void* rthread_ret; 15 | #define rthread_call 16 | typedef void* (* prthread)(void*); 17 | #endif 18 | 19 | typedef rthread_ret (rthread_call* thread_start)(void*); 20 | 21 | struct rthread 22 | { 23 | static int create(thread_start start,void* param=null) 24 | { 25 | int tid; 26 | #ifdef _MSC_VER 27 | tid=(int)_beginthreadex(null,0,start,param,0,null); 28 | if(0==tid||1==tid) 29 | { 30 | return 0; 31 | } 32 | else 33 | { 34 | return tid; 35 | } 36 | #else 37 | if(0!=pthread_create((pthread_t*)&tid,null,start,param)) 38 | { 39 | return 0; 40 | } 41 | else 42 | { 43 | return tid; 44 | } 45 | #endif 46 | } 47 | 48 | static void wait_exit(int tid) 49 | { 50 | #ifdef _MSC_VER 51 | WaitForSingleObject((HANDLE)tid,INFINITE); 52 | #else 53 | pthread_join((pthread_t)tid,null); 54 | #endif 55 | } 56 | }; 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /rpp.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roundsheep/rpp/45fe569af4ad3b7dccba045c0b85c0a24902d614/rpp.pdf -------------------------------------------------------------------------------- /rpp/rpp.cpp: -------------------------------------------------------------------------------- 1 | #include "zmain.h" 2 | 3 | int main(int argc, char* argv[]) 4 | { 5 | static tvm vm; 6 | return zmain::rpp_main(vm,argc,argv); 7 | } -------------------------------------------------------------------------------- /rpp/rpp_def.h: -------------------------------------------------------------------------------- 1 | #ifndef rpp_def_h__ 2 | #define rpp_def_h__ 3 | 4 | //#define RANALYSE 5 | #define c_rpp_deep 150 6 | #define c_point_size 4 7 | 8 | #define rppkey(a) (sh.m_key[tkey::a]) 9 | #define rppoptr(a) (sh.m_optr[toptr::a]) 10 | #define rppconf(a) (sh.m_conf[tconf::a]) 11 | 12 | #define v_next_ins_js cur=(tins*)((uchar*)cur+r_size(tasm));goto next 13 | #define v_next_ins reg.eip+=r_size(tasm);goto next 14 | 15 | #define v_ato_int(a) (*r_to_pint(&(a))) 16 | #define v_pto_int(a) (*r_to_pint(a)) 17 | #define v_ato_uint(a) (*r_to_puint(&(a))) 18 | #define v_pto_uint(a) (*r_to_puint(a)) 19 | #define v_ato_char(a) (*r_to_pchar(&(a))) 20 | #define v_pto_char(a) (*r_to_pchar(a)) 21 | #define v_pto_int8(a) (*r_to_pint8(a)) 22 | #define v_pto_f8(a) (*r_to_pdouble(a)) 23 | #define v_pto_rstr(a) (*r_to_prstr(a)) 24 | 25 | #define v_pto_pchar(a) ((char*)v_pto_int(a)) 26 | #define v_pto_pvoid(a) ((void*)v_pto_int(a)) 27 | 28 | #define v_get_imme_u(a) (r_to_uint((a).val)) 29 | #define v_get_reg_u(a) v_pto_uint(r_to_puchar(®)+(a).off) 30 | #define v_get_addr_u(a) v_pto_uint(v_get_reg(a)+(a).val) 31 | 32 | #define v_get_imme(a) ((a).val) 33 | #define v_get_reg(a) v_pto_int(r_to_puchar(®)+(a).off) 34 | #define v_get_addr(a) v_pto_int(v_get_reg(a)+(a).val) 35 | #define v_get_lea(a) (v_get_reg(a)+v_get_imme(a)) 36 | #define v_get_addr_1(a) v_pto_char(v_get_reg(a)+(a).val) 37 | #define v_get_addr_8(a) v_pto_int8(v_get_reg(a)+(a).val) 38 | #define v_get_addr_f8(a) v_pto_f8(v_get_reg(a)+(a).val) 39 | 40 | #define rppja znasm::get_opnd1_v(vstr) 41 | #define rppjb znasm::get_opnd2_v(vstr) 42 | #define rppj4(a,b,c,d) (zjiti::a(build_ins(sh,rppkey(c_nop),b,c,d))) 43 | #define rppjf(a,b) sh.m_jit_f[a]=&b 44 | 45 | #define rppjcmp(a) \ 46 | if(znasm::count_mbk_l(vstr)==2) \ 47 | { \ 48 | s+=rppj4(b_mov,rppkey(c_ecx),rppoptr(c_comma),rppjb); \ 49 | s+=rppj4(b_cmp,rppja,rppoptr(c_comma),rppkey(c_ecx)); \ 50 | } \ 51 | else \ 52 | { \ 53 | s+=zjiti::b_cmp(ins); \ 54 | } \ 55 | s+=rppj4(b_mov,rppkey(c_ebx),rppoptr(c_comma),"0"); \ 56 | s+=zjiti::a(); \ 57 | return r_move(s) 58 | 59 | #define rppncmp(a) \ 60 | if(count_mbk_l(vstr)==2) \ 61 | { \ 62 | result+=" mov ecx , "+get_opnd2(vstr)+"\n"; \ 63 | result+=" cmp "+get_opnd1(vstr)+" , ecx\n"; \ 64 | } \ 65 | else \ 66 | { \ 67 | result+=" cmp dword "+link_vstr(vstr.sub(1))+"\n"; \ 68 | } \ 69 | result+=" mov ebx , 0\n"; \ 70 | result+=a; \ 71 | return true 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /rpp/rpp_win.cpp: -------------------------------------------------------------------------------- 1 | #include "zmain.h" 2 | 3 | //#define RPP_SHOW_CONSOLE 4 | 5 | int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance, 6 | LPSTR lpCmdLine,int nCmdShow) 7 | { 8 | rbuf v=zmain::param_split(lpCmdLine); 9 | v.push_front(rcode::utf8_to_gbk(rdir::get_exe_name().torstr())); 10 | int argc=v.count(); 11 | if(argc>c_rpp_deep) 12 | { 13 | return 1; 14 | } 15 | char* argv[c_rpp_deep]; 16 | for(int i=0;i m_list; 16 | 17 | enum 18 | { 19 | c_page_size=4096 20 | }; 21 | 22 | ~talloc() 23 | { 24 | #ifdef _MSC_VER 25 | for(int i=0;i=b.count; 13 | } 14 | }; 15 | 16 | struct tanalyse 17 | { 18 | static void analyse_add(uint addr) 19 | { 20 | analyse_add(((tasm*)addr)->ptfi); 21 | } 22 | 23 | static void analyse_add(tfunc* ptfi) 24 | { 25 | if(ptfi==null) 26 | { 27 | return; 28 | } 29 | ptfi->count++; 30 | } 31 | 32 | static void analyse_print(tsh& sh) 33 | { 34 | rbuf v; 35 | for(tclass* p=sh.m_class.begin(); 36 | p!=sh.m_class.end();p=sh.m_class.next(p)) 37 | { 38 | for(tfunc* q=p->vfunc.begin(); 39 | q!=p->vfunc.end();q=p->vfunc.next(q)) 40 | { 41 | if(q->count==0) 42 | { 43 | continue; 44 | } 45 | tanalyse_item item; 46 | item.count=q->count; 47 | item.name=sh.get_func_declare_name(*p,*q); 48 | v.push(item); 49 | } 50 | } 51 | r_qsort(v); 52 | rf::printl(); 53 | for(int i=0;i& v) 62 | { 63 | if(sh.is_quote(tdi.type)) 64 | return; 65 | if(rppconf(c_op_empty_func)&&zfind::is_empty_struct_type(sh,tdi.type)) 66 | return; 67 | v+=rppoptr(c_mbk_l); 68 | v+=tdi.type; 69 | v+=rppoptr(c_comma); 70 | v+=tdi.type; 71 | v+=rppoptr(c_comma); 72 | v+=rppoptr(c_mbk_l); 73 | v+=tdi.name; 74 | v+=rppoptr(c_mbk_r); 75 | v+=rppoptr(c_mbk_r); 76 | v+=rppoptr(c_semi); 77 | } 78 | 79 | static void add_destructor_func(tsh& sh,tdata& tdi,rbuf& v) 80 | { 81 | if(sh.is_quote(tdi.type)) 82 | return; 83 | if(rppconf(c_op_empty_func)&&zfind::is_empty_struct_type(sh,tdi.type)) 84 | return; 85 | v+=rppoptr(c_mbk_l); 86 | v+=tdi.type; 87 | v+=rppoptr(c_comma); 88 | v+=rppoptr(c_destruct)+tdi.type; 89 | v+=rppoptr(c_comma); 90 | v+=rppoptr(c_mbk_l); 91 | v+=tdi.name; 92 | v+=rppoptr(c_mbk_r); 93 | v+=rppoptr(c_mbk_r); 94 | v+=rppoptr(c_semi); 95 | } 96 | 97 | static void add_structor_func_m(tsh& sh,tdata& tdi,rbuf& v) 98 | { 99 | if(sh.is_quote(tdi.type)) 100 | return; 101 | if(tdi.param.empty()&&rppconf(c_op_empty_func)&& 102 | zfind::is_empty_struct_type(sh,tdi.type)) 103 | return; 104 | v.push(tword(tdi.type)); 105 | v.push(tword(rppoptr(c_dot))); 106 | v.push(tword(tdi.type)); 107 | v.push(tword(rppoptr(c_sbk_l))); 108 | v.push(tword(tdi.name)); 109 | if(!tdi.param.empty()) 110 | { 111 | v.push(tword(rppoptr(c_comma))); 112 | v+=tdi.param; 113 | } 114 | v.push(tword(rppoptr(c_sbk_r))); 115 | v.push(tword(rppoptr(c_semi))); 116 | } 117 | 118 | static void add_member_destruct(tsh& sh,tfunc& tfi) 119 | { 120 | tclass& tci=*tfi.ptci; 121 | tsent sent; 122 | sent.pos=tfi.last_pos; 123 | sent.type=rppkey(c_void); 124 | for(int i=tci.vdata.count()-1;i>=0;i--) 125 | { 126 | if(sh.is_quote(tci.vdata[i].type)) 127 | continue; 128 | tclass* ptci=zfind::class_search(sh,tci.vdata[i].type); 129 | if(null==ptci) 130 | continue; 131 | if(zfind::destruct_search(*ptci)==null) 132 | continue; 133 | add_destructor_func(sh,tci.vdata[i],sent.vword); 134 | } 135 | if(!sent.vword.empty()) 136 | { 137 | tfi.vsent.push_move(sent); 138 | zcontrol::part_vsent(tfi.vsent); 139 | } 140 | } 141 | 142 | static void add_member_struct(tsh& sh,tfunc& tfi) 143 | { 144 | tclass& tci=*tfi.ptci; 145 | tsent sent; 146 | sent.type=rppkey(c_void); 147 | for(int i=0;ifirst_pos; 23 | } 24 | if(zfind::destruct_search(tci)==null) 25 | { 26 | tfunc tfi; 27 | tfi.ptci=&tci; 28 | tfi.first_pos=pos; 29 | tfi.last_pos=pos; 30 | tfi.last_pos.line++; 31 | tfi.name=rppoptr(c_destruct)+tci.name; 32 | 33 | tfi.param.push(tdata(tci.name+rppoptr(c_addr),rppkey(c_this))); 34 | tfi.retval=tdata(rppkey(c_void),rstr()); 35 | 36 | tfi.name_dec=tfi.get_dec(); 37 | tci.vfunc.insert(tfi); 38 | added=true; 39 | } 40 | if(zfind::emptystruct_search(tci)==null) 41 | { 42 | tfunc tfi; 43 | tfi.ptci=&tci; 44 | tfi.first_pos=pos; 45 | tfi.last_pos=pos; 46 | tfi.last_pos.line++; 47 | 48 | tfi.name=tci.name; 49 | 50 | tfi.param.push(tdata(tci.name+rppoptr(c_addr),rppkey(c_this))); 51 | tfi.retval=tdata(rppkey(c_void),rstr()); 52 | 53 | tfi.name_dec=tfi.get_dec(); 54 | tci.vfunc.insert(tfi); 55 | added=true; 56 | } 57 | if(zfind::copystruct_search(tci)==null) 58 | { 59 | tfunc tfi; 60 | tfi.ptci=&tci; 61 | tfi.first_pos=pos; 62 | tfi.last_pos=pos; 63 | tfi.last_pos.line++; 64 | 65 | tfi.name=tci.name; 66 | 67 | tfi.param.push(tdata(tci.name+rppoptr(c_addr),rppkey(c_this))); 68 | tfi.param.push(tdata(tci.name+rppoptr(c_addr),rppkey(c_rvara))); 69 | tfi.retval=tdata(rppkey(c_void),rstr()); 70 | 71 | add_copy_sent(sh,tfi); 72 | tfi.name_dec=tfi.get_dec(); 73 | tci.vfunc.insert(tfi); 74 | added=true; 75 | } 76 | if(zfind::func_search(tci,tci.name, 77 | tci.name+rppoptr(c_addr),tci.name)==null) 78 | { 79 | tfunc tfi=*zfind::copystruct_search(tci); 80 | tfi.ptci=&tci; 81 | tfi.param[1].type=tci.name; 82 | tfi.name_dec=tfi.get_dec(); 83 | tci.vfunc.insert(tfi); 84 | added=true; 85 | } 86 | if(zfind::func_search(tci,rppoptr(c_equal),tci.name+rppoptr(c_addr), 87 | tci.name+rppoptr(c_addr))==null) 88 | { 89 | tfunc tfi; 90 | tfi.ptci=&tci; 91 | tfi.first_pos=pos; 92 | tfi.last_pos=pos; 93 | tfi.last_pos.line++; 94 | 95 | tfi.name=rppoptr(c_equal); 96 | 97 | tfi.param.push(tdata(tci.name+rppoptr(c_addr),rppkey(c_this))); 98 | tfi.param.push(tdata(tci.name+rppoptr(c_addr),rppkey(c_rvara))); 99 | tfi.retval=tdata(rppkey(c_void),rstr()); 100 | 101 | add_copy_sent(sh,tfi); 102 | tfi.name_dec=tfi.get_dec(); 103 | tci.vfunc.insert(tfi); 104 | added=true; 105 | } 106 | if(zfind::func_search(tci,rppoptr(c_equal), 107 | tci.name+rppoptr(c_addr),tci.name)==null) 108 | { 109 | tfunc tfi=*zfind::func_search( 110 | tci,rppoptr(c_equal),tci.name+rppoptr(c_addr), 111 | tci.name+rppoptr(c_addr)); 112 | tfi.ptci=&tci; 113 | tfi.param[1].type=tci.name; 114 | tfi.name_dec=tfi.get_dec(); 115 | tci.vfunc.insert(tfi); 116 | added=true; 117 | } 118 | if(zfind::func_search(tci,rppoptr(c_addr))==null) 119 | { 120 | tfunc tfi; 121 | tfi.ptci=&tci; 122 | tfi.first_pos=pos; 123 | tfi.last_pos=pos; 124 | tfi.last_pos.line++; 125 | 126 | tfi.name=rppoptr(c_addr); 127 | 128 | tfi.param.push(tdata(tci.name+rppoptr(c_addr),rppkey(c_this))); 129 | tfi.retval=tdata("rp<"+tci.name+">",rppkey(c_s_ret)); 130 | 131 | tword twi; 132 | twi.pos=tfi.first_pos; 133 | twi.pos_src=tfi.first_pos; 134 | sh.push_twi(tfi.vword,twi,rppkey(c_mov)); 135 | sh.push_twi(tfi.vword,twi,rppkey(c_s_ret)); 136 | sh.push_twi(tfi.vword,twi,rppoptr(c_comma)); 137 | sh.push_twi(tfi.vword,twi,rppkey(c_this)); 138 | tfi.name_dec=tfi.get_dec(); 139 | if(zfind::is_class(sh,tfi.retval.type)) 140 | tci.vfunc.insert(tfi); 141 | added=true; 142 | } 143 | return true; 144 | } 145 | 146 | static void add_copy_sent(tsh& sh,tfunc& tfi) 147 | { 148 | tclass& tci=*tfi.ptci; 149 | tword twi; 150 | twi.pos_src=tfi.first_pos; 151 | twi.pos=tfi.first_pos; 152 | for(int i=0;i"); 177 | if(p!=null) 178 | { 179 | op_rstr(sh,p->vword); 180 | } 181 | } 182 | 183 | static void op_rstr(tsh& sh,rbuf& v) 184 | { 185 | for(int i=0;i& v,tclass* ptci) 10 | { 11 | for(int i=0;i=v.count()) 42 | { 43 | sh.error(v[left-1],"func template miss >"); 44 | return false; 45 | } 46 | rbuf > vparam=sh.comma_split(v.sub(left+1,right)); 47 | if(vparam.count()!=ptfi->vtl.count()) 48 | { 49 | sh.error(v[left-1],"func template not match"); 50 | return false; 51 | } 52 | for(int j=left;j<=right;j++) 53 | { 54 | v[left-1].val+=v[j].val; 55 | v[j].val.clear(); 56 | } 57 | //模板函数不可能重载,因此只要判断一下函数名是否相同即可 58 | if(zfind::func_search(*ptci,v[left-1].val)!=null) 59 | { 60 | continue; 61 | } 62 | tfunc item=*ptfi; 63 | item.vtl.free(); 64 | zctl::vtl_replace(item.vword,ptfi->vtl,vparam); 65 | if(!f_type_replace(sh,item.vword)) 66 | { 67 | return false; 68 | } 69 | if(!combine_ftl_name(sh,item.vword,ptfi->name)) 70 | { 71 | return false; 72 | } 73 | if(!zmemb::func_add(sh,*ptci,item.vword,false)) 74 | { 75 | return false; 76 | } 77 | i=right; 78 | } 79 | zpre::arrange(v); 80 | return true; 81 | } 82 | 83 | //处理函数模板中又出现新类型的情况 84 | static rbool f_type_replace(tsh& sh,rbuf& v) 85 | { 86 | int cur=sh.m_class.count(); 87 | if(!zctl::type_replace(sh,v)) 88 | { 89 | return false; 90 | } 91 | if(sh.m_class.count()>cur) 92 | { 93 | for(tclass* p=sh.m_class.begin(); 94 | p!=sh.m_class.end();p=sh.m_class.next(p)) 95 | { 96 | if(!f_proc_class(sh,*p)) 97 | { 98 | return false; 99 | } 100 | } 101 | } 102 | return true; 103 | } 104 | 105 | static rbool f_proc_class(tsh& sh,tclass& tci) 106 | { 107 | if(!zctl::a_class(sh,tci)) 108 | { 109 | return false; 110 | } 111 | if(!zmemb::recursion_get_size(sh,tci)) 112 | { 113 | return false; 114 | } 115 | zmemb::obtain_size_func(sh,tci); 116 | return true; 117 | } 118 | 119 | static rbool combine_ftl_name(tsh& sh,rbuf& v,rstr& name) 120 | { 121 | for(int i=1;i=v.count()) 134 | { 135 | sh.error(v[left-1],"miss >"); 136 | return false; 137 | } 138 | for(int j=left;j<=right;j++) 139 | { 140 | v[left-1].val+=v[j].val; 141 | v[j].val.clear(); 142 | } 143 | i=right; 144 | } 145 | zpre::arrange(v); 146 | return true; 147 | } 148 | }; 149 | 150 | #endif 151 | -------------------------------------------------------------------------------- /rpp/zmatch.h: -------------------------------------------------------------------------------- 1 | #ifndef zmatch_h__ 2 | #define zmatch_h__ 3 | 4 | #include "zfind.h" 5 | 6 | struct zmatch 7 | { 8 | //可构造转换传递 9 | static rbool is_construct_pass(tsh& sh,tsent& src,rstr& dst) 10 | { 11 | if(dst==rppkey(c_rcs)) 12 | { 13 | return true; 14 | } 15 | tclass* ptci=zfind::class_search_t(sh,dst); 16 | if(ptci==null) 17 | { 18 | return false; 19 | } 20 | tfunc* ptfi=zfind::func_search(*ptci,sh.get_tname(dst), 21 | sh.get_tname(dst)+rppoptr(c_addr), 22 | sh.get_tname(src.type)+rppoptr(c_addr)); 23 | if(ptfi!=null) 24 | { 25 | return true; 26 | } 27 | ptfi=zfind::func_search(*ptci,sh.get_tname(dst), 28 | sh.get_tname(dst)+rppoptr(c_addr),sh.get_tname(src.type)); 29 | return ptfi!=null; 30 | } 31 | 32 | //可直接传递,返回对象可传递引用 33 | static rbool is_direct_pass(tsh& sh,tsent& src,rstr& dst) 34 | { 35 | if(sh.is_point(src.type)&&sh.is_point(dst)) 36 | return true; 37 | if(dst==rppkey(c_rcs)) 38 | { 39 | return true; 40 | } 41 | if(dst==rppkey(c_rd4)&&zfind::get_type_size(sh,src.type)==4) 42 | return true; 43 | if(sh.get_tname(src.type)!=sh.get_tname(dst)) 44 | return false; 45 | return true; 46 | } 47 | 48 | //是否直接传递或构造转换传递 49 | static rbool is_direct_construct_pass_m(tsh& sh,rbuf& vsent, 50 | rbuf& vparam) 51 | { 52 | if(vsent.count()!=vparam.count()) 53 | { 54 | return false; 55 | } 56 | for(int i=0;i& vsent) 70 | { 71 | for(tfunc* p=tci.vfunc.begin();p!=tci.vfunc.end();p=tci.vfunc.next(p)) 72 | { 73 | if(fname!=p->name) 74 | continue; 75 | if(is_direct_construct_pass_m(sh,vsent,p->param)) 76 | return p; 77 | } 78 | return null; 79 | } 80 | 81 | //可完全传递,临时对象可传递引用,常量和返回对象不可传递引用 82 | static rbool is_full_pass(tsh& sh,tsent& src,rstr& dst) 83 | { 84 | if(!is_direct_pass(sh,src,dst)) 85 | return false; 86 | if(src.vword.count()==1&& 87 | (src.vword[0].is_const()|| 88 | sh.m_key.is_asm_reg(src.vword[0].val))&& 89 | sh.is_quote(dst)) 90 | { 91 | return false; 92 | } 93 | if(src.vword.count()==7&& 94 | sh.is_quote(dst)&& 95 | src.vword[1].val==rppoptr(c_addr)&& 96 | src.vword[0].val==rppoptr(c_mbk_l)) 97 | { 98 | return false; 99 | } 100 | if(is_temp_var(sh,src)) 101 | { 102 | return true; 103 | } 104 | return !sh.is_quote(dst)||!is_ret_obj(sh,src.vword); 105 | } 106 | 107 | static rbool is_full_pass_m(tsh& sh,rbuf& vsent,rbuf& vparam) 108 | { 109 | if(vsent.count()!=vparam.count()) 110 | { 111 | return false; 112 | } 113 | for(int i=0;i& vsent) 125 | { 126 | for(tfunc* p=tci.vfunc.begin();p!=tci.vfunc.end();p=tci.vfunc.next(p)) 127 | { 128 | if(fname!=p->name) 129 | continue; 130 | if(is_full_pass_m(sh,vsent,p->param)) 131 | return p; 132 | } 133 | return null; 134 | } 135 | 136 | static rbool is_temp_var(tsh& sh,tsent& sent) 137 | { 138 | return !tsh::is_quote(sent.type)&& 139 | sent.vword.count()>=3&&sent.type==sent.vword[2].val&& 140 | sent.vword[1].val==rppkey(c_btemp); 141 | } 142 | 143 | //重载的友元属性和返回值类型必须相同 144 | static rbool is_ret_obj(tsh& sh,rbuf& v) 145 | { 146 | if(v.count()<3) 147 | { 148 | return false; 149 | } 150 | int start=0; 151 | while(start+2=v.count()) 162 | { 163 | return false; 164 | } 165 | if(v[start].val==rppkey(c_pcall)) 166 | { 167 | return !sh.is_quote(v[start+2].val); 168 | } 169 | tclass* ptci=zfind::class_search(sh,v[start].val); 170 | if(ptci==null) 171 | { 172 | return false; 173 | } 174 | tfunc* ptfi=zfind::func_search_dec(*ptci,v[start+2].val); 175 | if(ptfi==null) 176 | { 177 | return false; 178 | } 179 | return !sh.is_quote(ptfi->retval.type); 180 | } 181 | 182 | static void insert_type(tsh& sh,tsent& sent,const rstr& type) 183 | { 184 | rbuf result; 185 | result+=rppoptr(c_mbk_l); 186 | result+=rppkey(c_btemp); 187 | result+=rppoptr(c_comma); 188 | result+=type; 189 | result+=rppoptr(c_comma); 190 | result+=rppoptr(c_mbk_l); 191 | result+=sent.vword; 192 | result+=rppoptr(c_mbk_r); 193 | result+=rppoptr(c_mbk_r); 194 | sent.vword=r_move(result); 195 | sent.type=type; 196 | } 197 | 198 | //先完全传递,找不到再尝试替换单词 199 | static tfunc* find_replace(tsh& sh,tclass& tci,const rstr& fname, 200 | rbuf& vsent) 201 | { 202 | tfunc* ptfi=find_full_pass(sh,tci,fname,vsent); 203 | if(ptfi!=null) 204 | { 205 | return ptfi; 206 | } 207 | //可能找到多个,只取第一个 208 | ptfi=find_direct_construct_pass(sh,tci,fname,vsent); 209 | if(ptfi==null) 210 | { 211 | return null; 212 | } 213 | for(int i=0;iparam[i].type)) 217 | { 218 | insert_type(sh,vsent[i], 219 | sh.get_tname(ptfi->param[i].type)); 220 | } 221 | } 222 | return ptfi; 223 | } 224 | }; 225 | 226 | #endif 227 | -------------------------------------------------------------------------------- /rpp/zopt.h: -------------------------------------------------------------------------------- 1 | #ifndef zopt_h__ 2 | #define zopt_h__ 3 | 4 | #include "zsent.h" 5 | 6 | //优化类 7 | struct zopt 8 | { 9 | static rbool is_add_sub(tsh& sh,rstr& s) 10 | { 11 | return s==rppkey(c_add)||s==rppkey(c_sub); 12 | } 13 | 14 | static rbool is_add_sub(tsh& sh,rbuf& v) 15 | { 16 | return v.count()==4&&is_add_sub(sh,v[0])&& 17 | v[2]==rppoptr(c_comma)&&v[3].is_number(); 18 | } 19 | 20 | static rbool op_add_sub(tsh& sh,rbuf& vasm) 21 | { 22 | rbuf result; 23 | for(int i=0;i& item,rbuf& pick) 72 | { 73 | if(item.count()!=pick.count()) 74 | { 75 | return false; 76 | } 77 | for(int i=0;i& item,rbuf& pick,rbuf& dst) 101 | { 102 | rbuf temp; 103 | for(int i=0;i=temp.count()) 122 | { 123 | return false; 124 | } 125 | dst[i].vstr[j]=temp[num]; 126 | } 127 | } 128 | } 129 | return true; 130 | } 131 | 132 | static rbool op_match(tsh& sh,rbuf& vasm) 133 | { 134 | rbuf result; 135 | for(int i=0;ivasm.count()) 142 | { 143 | continue; 144 | } 145 | int k; 146 | for(k=i;k temp=sh.m_match[j].dst; 158 | ifn(replace(vasm.sub(i,i+len),sh.m_match[j].src,temp)) 159 | { 160 | return false; 161 | } 162 | result+=r_move(temp); 163 | i=i+len-1; 164 | break; 165 | } 166 | if(j>=sh.m_match.count()) 167 | { 168 | result+=vasm[i]; 169 | } 170 | } 171 | vasm=r_move(result); 172 | return true; 173 | } 174 | }; 175 | 176 | #endif 177 | -------------------------------------------------------------------------------- /rpp/zsuper.h: -------------------------------------------------------------------------------- 1 | #ifndef zsuper_h__ 2 | #define zsuper_h__ 3 | 4 | #include "tsh.h" 5 | 6 | //超级宏 7 | struct zsuper 8 | { 9 | static rbool add_super_mac(tsh& sh,rbuf& v,int& i,rset& vmac) 10 | { 11 | tmac mitem; 12 | mitem.is_super=true; 13 | mitem.name=v.get(i+2).val; 14 | int left=i+3; 15 | int right=left; 16 | for(;right=v.count()) 19 | { 20 | sh.error(v.get(i),"miss mac"); 21 | return false; 22 | } 23 | if(v[right]!=rppoptr(c_bbk_l)) 24 | { 25 | sh.error(v.get(i),"miss mac $ {"); 26 | return false; 27 | } 28 | mitem.param=sh.vword_to_vstr(v.sub(left,right)); 29 | left=right; 30 | right=sh.find_symm_bbk(v,left); 31 | if(right>=v.count()) 32 | { 33 | sh.error(v.get(i),"miss mac $ }"); 34 | return false; 35 | } 36 | mitem.vstr=sh.vword_to_vstr(v.sub(left+1,right)); 37 | if(vmac.exist(mitem)) 38 | { 39 | vmac.erase(mitem); 40 | /*sh.error(v.get_bottom(),"mac redefined"); 41 | return false;*/ 42 | } 43 | vmac.insert(mitem); 44 | i=right; 45 | return true; 46 | } 47 | 48 | static rbool replace_item(tsh& sh,rbuf& v,int& i,tmac& mitem) 49 | { 50 | for(int j=i+2;j<=v.count();j++) 51 | { 52 | rbuf arr; 53 | rbuf src=sh.vword_to_vstr(v.sub(i+1,j)); 54 | if(match_here(sh,mitem.param,src,arr)) 55 | { 56 | ifn(replace_super_word(v[i],mitem.vstr,arr)) 57 | { 58 | sh.error(v.get(i)); 59 | return false; 60 | } 61 | sh.clear_word_val(v,i,j); 62 | i=j-1; 63 | break; 64 | } 65 | } 66 | return true; 67 | } 68 | 69 | //todo 限制递归深度 70 | static rbool match_here(tsh& sh,const rbuf& reg, 71 | const rbuf& src,rbuf& arr) 72 | { 73 | if(reg.empty()) 74 | { 75 | return src.empty(); 76 | } 77 | if(reg[0]=="_mword") 78 | { 79 | return match_multi(sh,reg.sub(1),src,arr); 80 | } 81 | if(!src.empty()) 82 | { 83 | if(reg[0]=="_word") 84 | { 85 | tword temp; 86 | temp.multi+=src[0]; 87 | arr.push_move(temp); 88 | if(match_here(sh,reg.sub(1),src.sub(1),arr)) 89 | { 90 | return true; 91 | } 92 | arr.pop(); 93 | return false; 94 | } 95 | if(reg[0]!=src[0]) 96 | { 97 | return false; 98 | } 99 | if(src[0]==rppoptr(c_sbk_l)) 100 | { 101 | int right_r=sh.find_symm_sbk(reg,0); 102 | if(right_r>=reg.count()) 103 | { 104 | return false; 105 | } 106 | int right_s=sh.find_symm_sbk(src,0); 107 | if(right_s>=src.count()) 108 | { 109 | return false; 110 | } 111 | return match_here(sh,reg.sub(1,right_r), 112 | src.sub(1,right_s),arr)&& 113 | match_here(sh,reg.sub(right_r+1), 114 | src.sub(right_s+1),arr); 115 | } 116 | return match_here(sh,reg.sub(1),src.sub(1),arr); 117 | } 118 | return false; 119 | } 120 | 121 | static rbool match_multi(tsh& sh,const rbuf& reg, 122 | const rbuf& src,rbuf& arr) 123 | { 124 | for(int i=0;i<=src.count();i++) 125 | { 126 | tword temp; 127 | temp.multi=src.sub(0,i); 128 | arr.push_move(temp); 129 | if(match_here(sh,reg,src.sub(i),arr)) 130 | { 131 | return true; 132 | } 133 | else 134 | { 135 | arr.pop(); 136 | } 137 | } 138 | return false; 139 | } 140 | 141 | static rbool replace_super_word(tword& word,rbuf& vstr,rbuf& arr) 142 | { 143 | word.val.clear(); 144 | for(int i=0;i=arr.count()) 150 | { 151 | return false; 152 | } 153 | if(vstr.get(i+2)=="=>"&&vstr.get(i+3).is_number()) 154 | { 155 | int index=vstr.get(i+3).toint(); 156 | if(index>=arr[num].multi.count()) 157 | { 158 | return false; 159 | } 160 | word.multi+=arr[num].multi[index]; 161 | i+=3; 162 | } 163 | else 164 | { 165 | word.multi+=arr[num].multi; 166 | i++; 167 | } 168 | } 169 | else 170 | { 171 | word.multi+=vstr[i]; 172 | } 173 | } 174 | link_sharp(word.multi); 175 | return true; 176 | } 177 | 178 | static rstr del_quote(rstr s) 179 | { 180 | if(s.get_bottom()=='"') 181 | { 182 | return s.sub(1,s.count()-1); 183 | } 184 | return r_move(s); 185 | } 186 | 187 | static rstr add_quote(const rstr& s) 188 | { 189 | //return "\""+s+"\""; 190 | rstr result; 191 | result+='"'; 192 | for(int i=0;i& v) 203 | { 204 | for(int i=0;i& v) 214 | { 215 | rbuf dst; 216 | rbool ret=false; 217 | for(int i=0;i