diff --git a/package/readme.txt b/package/readme.txt index e21b3c4e..1a5aab8b 100644 --- a/package/readme.txt +++ b/package/readme.txt @@ -1,6 +1,6 @@ ------------------------------------------------------------------------------- Kuin Programming Language -v.2018.5.17 +v.2018.6.17 (C) Kuina-chan ------------------------------------------------------------------------------- @@ -43,6 +43,16 @@ v.2018.5.17 4. 変更履歴 ------------------------------------------------------------------------------- +v.2018.6.17 + - 互換性が失われる変更 + - 「+**」構文の廃止と、オーバーライド元メソッドを参照する「super」構文の + 追加 + - 16進数リテラルの構文を「16#」から「0x」に変更 + - 細かな機能追加 + - list.find、list.findLastメソッドの追加 + - math@knapsack、math@dijkstra、math@bellmanFord、math@floydWarshall、 + draw@filterNone、draw@filterMonotone関数の追加 + v.2018.5.17 - 輪郭線を描画するメソッドdraw@Obj.drawOutlineの追加 - トゥーンレンダリングで描画するメソッドdraw@Obj.drawToonの追加 diff --git a/package/samples/0001_kuinote/main.kn b/package/samples/0001_kuinote/main.kn index 4a65852b..4b684513 100644 --- a/package/samples/0001_kuinote/main.kn +++ b/package/samples/0001_kuinote/main.kn @@ -14,12 +14,12 @@ func main() var menuMain: wnd@Menu :: wnd@makeMenu() var popupMainFile: wnd@Popup :: wnd@makePopup() do menuMain.addPopup("&File", popupMainFile) - do popupMainFile.add(16#0001, "&New") + do popupMainFile.add(0x0001, "&New") do popupMainFile.addLine() - do popupMainFile.add(16#0002, "E&xit") + do popupMainFile.add(0x0002, "E&xit") var popupMainHelp: wnd@Popup :: wnd@makePopup() do menuMain.addPopup("&Help", popupMainHelp) - do popupMainHelp.add(16#1001, "&About Kuinote...") + do popupMainHelp.add(0x1001, "&About Kuinote...") ; メニューの登録 do @wndMain.setMenu(menuMain) ; ユーザが操作を行うのを待機する @@ -40,11 +40,11 @@ end func ; メニューが選択されたときに呼ばれるイベント関数 func wndMainOnPushMenu(wnd: wnd@WndBase, id: int) switch(id) - case 16#0001 {New} + case 0x0001 {New} do @editText.setText("") {テキストを空にする} - case 16#0002 {Exit} + case 0x0002 {Exit} do @wndMain.close() {ウインドウを閉じる} - case 16#1001 {About Kuinote} + case 0x1001 {About Kuinote} do wnd@msgBox(@wndMain, "Kuinote\nVersion 1.0.0\n(C)Kuina-chan", "Kuinote", %info, %ok) end switch end func diff --git a/package/samples/0002_draw_2d/main.kn b/package/samples/0002_draw_2d/main.kn index b07198f5..cb611fff 100644 --- a/package/samples/0002_draw_2d/main.kn +++ b/package/samples/0002_draw_2d/main.kn @@ -6,23 +6,23 @@ func main() var texKuin: draw@Tex :: draw@makeTex("res/kuin.png") {画像の読み込み} var fontProportional: draw@Font :: draw@makeFont(null, 32, false, false, true, 0.0) {プロポーショナルフォントの生成} var fontMonospace: draw@Font :: draw@makeFont(null, 32, false, false, false, 40.0) {等幅フォントの生成} - do draw@clearColor(16#FF333333) {背景色の設定} + do draw@clearColor(0xFF333333) {背景色の設定} while(wnd@act()) - do draw@line(100.0, 100.0, 200.0, 200.0, 16#FFFF3333) {線分} - do draw@rectLine(300.0, 100.0, 100.0, 100.0, 16#FF33FF33) {四角形の枠線} - do draw@rect(500.0, 100.0, 100.0, 100.0, 16#FF3333FF) {四角形} - do draw@circle(750.0, 150.0, 50.0, 50.0, 16#FFFFFF33) {円} - do draw@tri(950.0, 100.0, 900.0, 200.0, 1000.0, 200.0, 16#FFFF33FF) {三角形} + do draw@line(100.0, 100.0, 200.0, 200.0, 0xFFFF3333) {線分} + do draw@rectLine(300.0, 100.0, 100.0, 100.0, 0xFF33FF33) {四角形の枠線} + do draw@rect(500.0, 100.0, 100.0, 100.0, 0xFF3333FF) {四角形} + do draw@circle(750.0, 150.0, 50.0, 50.0, 0xFFFFFF33) {円} + do draw@tri(950.0, 100.0, 900.0, 200.0, 1000.0, 200.0, 0xFFFF33FF) {三角形} for i(0, 3) do texKuin.draw(100.0 + i $ float * 200.0, 300.0, 0.0, 0.0, 150.0, 150.0, draw@white) {画像} end for - do draw@rect(175.0, 375.0, 100.0, 100.0, 16#7FFF0000) {半透明} + do draw@rect(175.0, 375.0, 100.0, 100.0, 0x7FFF0000) {半透明} do draw@blend(%add) - do draw@rect(375.0, 375.0, 100.0, 100.0, 16#FFFF0000) {加算} + do draw@rect(375.0, 375.0, 100.0, 100.0, 0xFFFF0000) {加算} do draw@blend(%sub) - do draw@rect(575.0, 375.0, 100.0, 100.0, 16#FFFF0000) {減算} + do draw@rect(575.0, 375.0, 100.0, 100.0, 0xFFFF0000) {減算} do draw@blend(%mul) - do draw@rect(775.0, 375.0, 100.0, 100.0, 16#FFFF0000) {乗算} + do draw@rect(775.0, 375.0, 100.0, 100.0, 0xFFFF0000) {乗算} do draw@blend(%alpha) do texKuin.drawScale(100.0, 500.0, 300.0, 300.0, 0.0, 0.0, 150.0, 150.0, draw@white) {拡大} do texKuin.drawRot(500.0, 575.0, 150.0, 150.0, 0.0, 0.0, 150.0, 150.0, 75.0, 75.0, -draw@cnt() $ float * lib@pi / 60.0, draw@white) {回転} diff --git a/package/samples/0003_draw_3d/main.kn b/package/samples/0003_draw_3d/main.kn index 119b932d..07c519e9 100644 --- a/package/samples/0003_draw_3d/main.kn +++ b/package/samples/0003_draw_3d/main.kn @@ -12,7 +12,7 @@ func main() var objCone: draw@Obj :: draw@makeObj("res/cone.knobj") {コーンモデルの読み込み} var texCone: draw@Tex :: draw@makeTexEvenArgb(1.0, 0.7, 0.2, 0.1) var texConeSpecular: draw@Tex :: draw@makeTexEvenArgb(2.0, 0.3, 0.3, 0.3) - do draw@clearColor(16#FF999999) {背景色の設定} + do draw@clearColor(0xFF999999) {背景色の設定} do draw@depth(true, true) {Zバッファの設定} do objBoard.pos(20.0, 20.0, 20.0, 0.0, 0.0, 0.0, 0.0, 0.0, -15.0) {板モデルの位置設定} do objBox.pos(1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0) {箱モデルの位置設定} diff --git a/package/samples/0003_draw_3d/res/board.knobj b/package/samples/0003_draw_3d/res/board.knobj index 58f6158a..588dc75b 100644 Binary files a/package/samples/0003_draw_3d/res/board.knobj and b/package/samples/0003_draw_3d/res/board.knobj differ diff --git a/package/samples/0003_draw_3d/res/box.knobj b/package/samples/0003_draw_3d/res/box.knobj index c2e93c3c..32b85840 100644 Binary files a/package/samples/0003_draw_3d/res/box.knobj and b/package/samples/0003_draw_3d/res/box.knobj differ diff --git a/package/samples/0003_draw_3d/res/cone.knobj b/package/samples/0003_draw_3d/res/cone.knobj index 7aa185eb..c65cf255 100644 Binary files a/package/samples/0003_draw_3d/res/cone.knobj and b/package/samples/0003_draw_3d/res/cone.knobj differ diff --git a/package/samples/0003_draw_3d/res/sphere.knobj b/package/samples/0003_draw_3d/res/sphere.knobj index bd20c186..39415c8d 100644 Binary files a/package/samples/0003_draw_3d/res/sphere.knobj and b/package/samples/0003_draw_3d/res/sphere.knobj differ diff --git a/package/samples/0005_input/main.kn b/package/samples/0005_input/main.kn index d3e947e8..d5d82942 100644 --- a/package/samples/0005_input/main.kn +++ b/package/samples/0005_input/main.kn @@ -36,7 +36,7 @@ func main() do font.draw(100.0, 700.0, "'Right' button ('Right' key): " ~ input@pad(0, %right).toStr(), draw@white) do font.draw(100.0, 750.0, "'Up' button ('Up' key): " ~ input@pad(0, %up).toStr(), draw@white) do font.draw(100.0, 800.0, "'Down' button ('Down' key): " ~ input@pad(0, %down).toStr(), draw@white) - do draw@circle(@mouseX $ float, @mouseY $ float, 20.0, 20.0, @mouseDownL ?(16#FF0000FF, 16#FFFFFF00)) + do draw@circle(@mouseX $ float, @mouseY $ float, 20.0, 20.0, @mouseDownL ?(0xFF0000FF, 0xFFFFFF00)) do font.draw(800.0, 50.0, "Key: " ~ @keyBuf, draw@white) do draw@render(60) end while @@ -67,11 +67,11 @@ end func func drawMainOnMouseEnter(wnd: wnd@Draw, x: int, y: int) do @mouseDownL :: wnd@key(%mouseL) {左ボタンを押したままウインドウ外に出て入りなおす場合の対処} - do draw@clearColor(16#FFFF9999) {ウインドウ内に入ったら背景色をピンクにする} + do draw@clearColor(0xFFFF9999) {ウインドウ内に入ったら背景色をピンクにする} end func func drawMainOnMouseLeave(wnd: wnd@Draw) - do draw@clearColor(16#FF000000) {ウインドウ外に出たら背景色を黒にする} + do draw@clearColor(0xFF000000) {ウインドウ外に出たら背景色を黒にする} end func func drawMainOnKeyChar(wnd: wnd@Draw, key: char) diff --git a/package/samples/0009_file/main.kn b/package/samples/0009_file/main.kn index 3799b912..8ebe106f 100644 --- a/package/samples/0009_file/main.kn +++ b/package/samples/0009_file/main.kn @@ -64,8 +64,8 @@ end func ; 暗号化の鍵を生成する関数 func getKey(): []bit8 ; 鍵は32byteでなければならない - ret[16#12b8, 16#34b8, 16#56b8, 16#78b8, 16#9Ab8, 16#BCb8, 16#DEb8, 16#F0b8, - |16#75b8, 16#38b8, 16#9Bb8, 16#C4b8, 16#21b8, 16#A0b8, 16#DFb8, 16#E6b8, - |16#49b8, 16#2Fb8, 16#B5b8, 16#3Db8, 16#01b8, 16#68b8, 16#7Ab8, 16#CEb8, - |16#F0b8, 16#52b8, 16#CAb8, 16#E6b8, 16#89b8, 16#D7b8, 16#4Bb8, 16#31b8] + ret[0x12b8, 0x34b8, 0x56b8, 0x78b8, 0x9Ab8, 0xBCb8, 0xDEb8, 0xF0b8, + |0x75b8, 0x38b8, 0x9Bb8, 0xC4b8, 0x21b8, 0xA0b8, 0xDFb8, 0xE6b8, + |0x49b8, 0x2Fb8, 0xB5b8, 0x3Db8, 0x01b8, 0x68b8, 0x7Ab8, 0xCEb8, + |0xF0b8, 0x52b8, 0xCAb8, 0xE6b8, 0x89b8, 0xD7b8, 0x4Bb8, 0x31b8] end func diff --git a/package/samples/0012_kuina_chan_model/main.kn b/package/samples/0012_kuina_chan_model/main.kn index 05d41150..20b437c2 100644 --- a/package/samples/0012_kuina_chan_model/main.kn +++ b/package/samples/0012_kuina_chan_model/main.kn @@ -6,7 +6,7 @@ func main() var obj: draw@Obj :: draw@makeObj("res/kuina_chan.knobj") {くいなちゃんモデルの読み込み} var texAlbedo: draw@Tex :: draw@makeTex("res/albedo.png") {くいなちゃんモデル用のアルベドテクスチャの読み込み} var texNormal: draw@Tex :: draw@makeTexArgb("res/normal.png") {くいなちゃんモデル用の法線マップテクスチャの読み込み} - do draw@clearColor(16#FFEEEEEE) {背景色の設定} + do draw@clearColor(0xFFEEEEEE) {背景色の設定} do draw@depth(true, true) {Zバッファの設定} do obj.pos(1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0) {くいなちゃんモデルの位置設定} var angle: float :: 0.0 {カメラの角度} @@ -16,7 +16,7 @@ func main() do angle :+ lib@pi / 120.0 {4秒間に1周させる} do draw@camera(80.0 * lib@sin(angle), 4.0, 80.0 * lib@cos(angle), 0.0, 0.0, 0.0, 0.0, 1.0, 0.0) {カメラの設定} do obj.drawToon(0, anim, texAlbedo, null, texNormal) {くいなちゃんモデルの描画} - do obj.drawOutline(0, anim, 0.05, 16#FF664444) {輪郭線の描画} + do obj.drawOutline(0, anim, 0.05, 0xFF664444) {輪郭線の描画} do anim :: (anim + 0.5) % 60.0 {アニメーションを行う} do draw@render(60) end while diff --git a/package/sys/draw.kn b/package/sys/draw.kn index 94b83203..4d58ac79 100644 --- a/package/sys/draw.kn +++ b/package/sys/draw.kn @@ -1,5 +1,5 @@ -+const white: int :: 16#FFFFFFFF -+const black: int :: 16#FF000000 ++const white: int :: 0xFFFFFFFF ++const black: int :: 0xFF000000 +func [d0001.knd, _target] target(drawCtrl: wnd@Draw) end func @@ -56,20 +56,26 @@ end func +func [d0001.knd, _circle, _1] circle(x: float, y: float, radiusX: float, radiusY: float, color: int) end func ++func [d0001.knd, _filterNone] filterNone() +end func + ++func [d0001.knd, _filterMonotone, _2] filterMonotone(color: int, rate: float) +end func + +class Tex() *func [d0001.knd, _texDtor, _force] _dtor() end func *func [_force] _copy(): kuin@Class - throw 16#E9170005 + throw 0xE9170005 end func *func [_force] _toBin(): []bit8 - throw 16#E9170005 + throw 0xE9170005 end func *func [_force] _fromBin(bin: []bit8, idx: &int): kuin@Class - throw 16#E9170005 + throw 0xE9170005 end func +func [d0001.knd, _texDraw] draw(dstX: float, dstY: float, srcX: float, srcY: float, srcW: float, srcH: float, color: int) @@ -103,15 +109,15 @@ end func end func *func [_force] _copy(): kuin@Class - throw 16#E9170005 + throw 0xE9170005 end func *func [_force] _toBin(): []bit8 - throw 16#E9170005 + throw 0xE9170005 end func *func [_force] _fromBin(bin: []bit8, idx: &int): kuin@Class - throw 16#E9170005 + throw 0xE9170005 end func +func [d0001.knd, _fontDraw] draw(dstX: float, dstY: float, text: []char, color: int) @@ -155,15 +161,15 @@ end func end func *func [_force] _copy(): kuin@Class - throw 16#E9170005 + throw 0xE9170005 end func *func [_force] _toBin(): []bit8 - throw 16#E9170005 + throw 0xE9170005 end func *func [_force] _fromBin(bin: []bit8, idx: &int): kuin@Class - throw 16#E9170005 + throw 0xE9170005 end func +func [d0001.knd, _objDraw] draw(element: int, frame: float, diffuse: @Tex, specular: @Tex, normal: @Tex) diff --git a/package/sys/excpt.kn b/package/sys/excpt.kn index a0d4a459..b504c3d6 100644 --- a/package/sys/excpt.kn +++ b/package/sys/excpt.kn @@ -1,19 +1,19 @@ -+const userMin: int :: 16#00000000 -+const userMax: int :: 16#0000FFFF -+const accessViolation: int :: 16#C0000005 -+const noMem: int :: 16#C0000017 -+const floatInvalidOperation: int :: 16#C0000090 -+const intDivideByZero: int :: 16#C0000094 -+const stackOverflow: int :: 16#C00000FD -+const ctrlCExit: int :: 16#C000013A -+const dbgAssertFailed: int :: 16#E9170000 -+const classCastFailed: int :: 16#E9170001 -+const dbgArrayIdxOutOfRange: int :: 16#E9170002 -+const dbgIntOverflow: int :: 16#E9170003 -+const invalidCmp: int :: 16#E9170004 -+const libClassInvalidOperation: int :: 16#E9170005 -+const dbgArgOutDomain: int :: 16#E9170006 -+const fileReadFailed: int :: 16#E9170007 -+const invalidDataFmt: int :: 16#E9170008 -+const deviceInitFailed: int :: 16#E9170009 -+const dbgInoperableState: int :: 16#E917000A ++const userMin: int :: 0x00000000 ++const userMax: int :: 0x0000FFFF ++const accessViolation: int :: 0xC0000005 ++const noMem: int :: 0xC0000017 ++const floatInvalidOperation: int :: 0xC0000090 ++const intDivideByZero: int :: 0xC0000094 ++const stackOverflow: int :: 0xC00000FD ++const ctrlCExit: int :: 0xC000013A ++const dbgAssertFailed: int :: 0xE9170000 ++const classCastFailed: int :: 0xE9170001 ++const dbgArrayIdxOutOfRange: int :: 0xE9170002 ++const dbgIntOverflow: int :: 0xE9170003 ++const invalidCmp: int :: 0xE9170004 ++const libClassInvalidOperation: int :: 0xE9170005 ++const dbgArgOutDomain: int :: 0xE9170006 ++const fileReadFailed: int :: 0xE9170007 ++const invalidDataFmt: int :: 0xE9170008 ++const deviceInitFailed: int :: 0xE9170009 ++const dbgInoperableState: int :: 0xE917000A diff --git a/package/sys/file.kn b/package/sys/file.kn index c609d3d7..cdfc57ca 100644 --- a/package/sys/file.kn +++ b/package/sys/file.kn @@ -9,15 +9,15 @@ end enum end func *func [_force] _copy(): kuin@Class - throw 16#E9170005 + throw 0xE9170005 end func *func [_force] _toBin(): []bit8 - throw 16#E9170005 + throw 0xE9170005 end func *func [_force] _fromBin(bin: []bit8, idx: &int): kuin@Class - throw 16#E9170005 + throw 0xE9170005 end func +func [d0000.knd, _streamFin] fin() @@ -70,15 +70,15 @@ end class end func *func [_force] _copy(): kuin@Class - throw 16#E9170005 + throw 0xE9170005 end func *func [_force] _toBin(): []bit8 - throw 16#E9170005 + throw 0xE9170005 end func *func [_force] _fromBin(bin: []bit8, idx: &int): kuin@Class - throw 16#E9170005 + throw 0xE9170005 end func +func [d0000.knd, _streamFin] fin() @@ -118,12 +118,12 @@ end func end func +enum SysDir - desktop :: 16#00 - fonts :: 16#14 - appData :: 16#1A - windows :: 16#24 - system32 :: 16#25 - programFiles :: 16#26 + desktop :: 0x00 + fonts :: 0x14 + appData :: 0x1A + windows :: 0x24 + system32 :: 0x25 + programFiles :: 0x26 end enum +func [d0000.knd, _makeDir] makeDir(path: []char): bool diff --git a/package/sys/input.kn b/package/sys/input.kn index b0095003..8d67bced 100644 --- a/package/sys/input.kn +++ b/package/sys/input.kn @@ -18,7 +18,7 @@ end enum +enum Key - esc :: 16#01 + esc :: 0x01 _1 _2 _3 @@ -101,31 +101,31 @@ end enum num3 num0 numPeriod - f11 :: 16#57 + f11 :: 0x57 f12 - kana :: 16#70 - convert :: 16#79 - noConvert :: 16#7B - yen :: 16#7D - circumflex :: 16#90 - kanji :: 16#94 - numEnter :: 16#9C + kana :: 0x70 + convert :: 0x79 + noConvert :: 0x7B + yen :: 0x7D + circumflex :: 0x90 + kanji :: 0x94 + numEnter :: 0x9C ctrlR - numSlash :: 16#B5 - sysRq :: 16#B7 + numSlash :: 0xB5 + sysRq :: 0xB7 altR - pause :: 16#C5 - home :: 16#C7 + pause :: 0xC5 + home :: 0xC7 up pageUp - left :: 16#CB - right :: 16#CD - end_ :: 16#CF + left :: 0xCB + right :: 0xCD + end_ :: 0xCF down pageDown ins del - winL :: 16#DB + winL :: 0xDB winR menu end enum diff --git a/package/sys/kuin.kn b/package/sys/kuin.kn index 8a6ad770..c43e8920 100644 --- a/package/sys/kuin.kn +++ b/package/sys/kuin.kn @@ -6,7 +6,7 @@ end func +func cmp(t: @Class): int - throw 16#E9170004 + throw 0xE9170004 end func func _copy(): @Class @@ -125,10 +125,16 @@ end func func [d0000.knd, _any_type] _sortDescList(me_: []bit8, type: int) end func -func [d0000.knd, _any_type, _take_child] _find(me_: []bit8, type: int, item: []bit8, start: int): int +func [d0000.knd, _any_type, _take_child] _findArray(me_: []bit8, type: int, item: []bit8, start: int): int end func -func [d0000.knd, _any_type, _take_child] _findLast(me_: []bit8, type: int, item: []bit8, start: int): int +func [d0000.knd, _any_type, _take_child] _findList(me_: []bit8, type: int, item: []bit8): bool +end func + +func [d0000.knd, _any_type, _take_child] _findLastArray(me_: []bit8, type: int, item: []bit8, start: int): int +end func + +func [d0000.knd, _any_type, _take_child] _findLastList(me_: []bit8, type: int, item: []bit8): bool end func func [d0000.knd, _any_type, _take_child] _findBin(me_: []bit8, type: int, item: []bit8): int diff --git a/package/sys/lib.kn b/package/sys/lib.kn index 4788e084..a4029c2e 100644 --- a/package/sys/lib.kn +++ b/package/sys/lib.kn @@ -8,8 +8,8 @@ end func +func [_exit_code] exitCode(code: int) if(dbg) - if(code < 0 | 16#FFFFFFFF < code) - throw 16#E9170006 + if(code < 0 | 0xFFFFFFFF < code) + throw 0xE9170006 end if end if end func @@ -19,15 +19,15 @@ end func end func *func [_force] _copy(): kuin@Class - throw 16#E9170005 + throw 0xE9170005 end func *func [_force] _toBin(): []bit8 - throw 16#E9170005 + throw 0xE9170005 end func *func [_force] _fromBin(bin: []bit8, idx: &int): kuin@Class - throw 16#E9170005 + throw 0xE9170005 end func +func [d0000.knd, _rndRnd] rnd(min: int, max: int): int @@ -176,15 +176,15 @@ end func end func *func [_force] _copy(): kuin@Class - throw 16#E9170005 + throw 0xE9170005 end func *func [_force] _toBin(): []bit8 - throw 16#E9170005 + throw 0xE9170005 end func *func [_force] _fromBin(bin: []bit8, idx: &int): kuin@Class - throw 16#E9170005 + throw 0xE9170005 end func +func [d0000.knd, _bmSearchFind] find(text: []char, start: int): int diff --git a/package/sys/math.kn b/package/sys/math.kn index b82b0d11..fc19c111 100644 --- a/package/sys/math.kn +++ b/package/sys/math.kn @@ -28,20 +28,32 @@ end func +func [d0003.knd, _factInt] factInt(n: int): int end func ++func [d0003.knd, _knapsack] knapsack(weights: []int, values: []int, maxWeight: int, reuse: bool): int +end func + ++func [d0003.knd, _dijkstra] dijkstra(nodeNum: int, fromNodes: []int, toNodes: []int, values: []int, beginNode: int): []int +end func + ++func [d0003.knd, _bellmanFord] bellmanFord(nodeNum: int, fromNodes: []int, toNodes: []int, values: []int, beginNode: int): []int +end func + ++func [d0003.knd, _floydWarshall] floydWarshall(nodeNum: int, fromNodes: []int, toNodes: []int, values: []int): [][]int +end func + +class Mat() *func [d0003.knd, _matDtor, _force] _dtor() end func *func [_force] _copy(): kuin@Class - throw 16#E9170005 + throw 0xE9170005 end func *func [_force] _toBin(): []bit8 - throw 16#E9170005 + throw 0xE9170005 end func *func [_force] _fromBin(bin: []bit8, idx: &int): kuin@Class - throw 16#E9170005 + throw 0xE9170005 end func var row: int diff --git a/package/sys/msg.knd b/package/sys/msg.knd index 8c0c868a..996fb146 100644 --- a/package/sys/msg.knd +++ b/package/sys/msg.knd @@ -110,7 +110,7 @@ EP0015 括弧「(」に対応する「)」があるべき場所に存在しません。 --- EP0016 -数値リテラルに不正な形式の「#」が記述されました。 +数値リテラルに不正な形式の「x」が記述されました。 --- EP0017 数値リテラルに不正な形式の「.」が記述されました。 @@ -119,7 +119,7 @@ EP0018 数値リテラル「%s...」が長すぎます。 1024文字以下でなければなりません。 --- EP0019 -数値リテラルの基数「%d#」は「2#」「8#」「16#」のいずれかでなければなりません。 +16進数リテラルは「0x」としなければなりません。 --- EP0020 浮動小数点リテラル「%s」がオーバーフローもしくはアンダーフローしました。 diff --git a/package/sys/net.kn b/package/sys/net.kn index f96f8fab..66607ceb 100644 --- a/package/sys/net.kn +++ b/package/sys/net.kn @@ -9,15 +9,15 @@ end func end func *func [_force] _copy(): kuin@Class - throw 16#E9170005 + throw 0xE9170005 end func *func [_force] _toBin(): []bit8 - throw 16#E9170005 + throw 0xE9170005 end func *func [_force] _fromBin(bin: []bit8, idx: &int): kuin@Class - throw 16#E9170005 + throw 0xE9170005 end func +func [d0004.knd, _tcpServerFin] fin() @@ -42,15 +42,15 @@ end func end func *func [_force] _copy(): kuin@Class - throw 16#E9170005 + throw 0xE9170005 end func *func [_force] _toBin(): []bit8 - throw 16#E9170005 + throw 0xE9170005 end func *func [_force] _fromBin(bin: []bit8, idx: &int): kuin@Class - throw 16#E9170005 + throw 0xE9170005 end func +func [d0004.knd, _tcpFin] fin() @@ -81,15 +81,15 @@ end func end func *func [_force] _copy(): kuin@Class - throw 16#E9170005 + throw 0xE9170005 end func *func [_force] _toBin(): []bit8 - throw 16#E9170005 + throw 0xE9170005 end func *func [_force] _fromBin(bin: []bit8, idx: &int): kuin@Class - throw 16#E9170005 + throw 0xE9170005 end func +func [d0004.knd, _httpFin] fin() diff --git a/package/sys/regex.kn b/package/sys/regex.kn index 221dc1c0..d664f61b 100644 --- a/package/sys/regex.kn +++ b/package/sys/regex.kn @@ -6,15 +6,15 @@ end func end func *func [_force] _copy(): kuin@Class - throw 16#E9170005 + throw 0xE9170005 end func *func [_force] _toBin(): []bit8 - throw 16#E9170005 + throw 0xE9170005 end func *func [_force] _fromBin(bin: []bit8, idx: &int): kuin@Class - throw 16#E9170005 + throw 0xE9170005 end func +func [d1002.knd, _regexFind] find(pos: &int, text: []char, start: int): [][]char diff --git a/package/sys/snd.kn b/package/sys/snd.kn index dd507a54..a3a47a52 100644 --- a/package/sys/snd.kn +++ b/package/sys/snd.kn @@ -12,15 +12,15 @@ end func end func *func [_force] _copy(): kuin@Class - throw 16#E9170005 + throw 0xE9170005 end func *func [_force] _toBin(): []bit8 - throw 16#E9170005 + throw 0xE9170005 end func *func [_force] _fromBin(bin: []bit8, idx: &int): kuin@Class - throw 16#E9170005 + throw 0xE9170005 end func +func [d0001.knd, _sndPlay] play() diff --git a/package/sys/task.kn b/package/sys/task.kn index 6b26690d..65b9b06f 100644 --- a/package/sys/task.kn +++ b/package/sys/task.kn @@ -3,15 +3,15 @@ end func *func [_force] _copy(): kuin@Class - throw 16#E9170005 + throw 0xE9170005 end func *func [_force] _toBin(): []bit8 - throw 16#E9170005 + throw 0xE9170005 end func *func [_force] _fromBin(bin: []bit8, idx: &int): kuin@Class - throw 16#E9170005 + throw 0xE9170005 end func +func [d0000.knd, _processRun] run(waitUntilExit: bool): int @@ -32,15 +32,15 @@ end func end func *func [_force] _copy(): kuin@Class - throw 16#E9170005 + throw 0xE9170005 end func *func [_force] _toBin(): []bit8 - throw 16#E9170005 + throw 0xE9170005 end func *func [_force] _fromBin(bin: []bit8, idx: &int): kuin@Class - throw 16#E9170005 + throw 0xE9170005 end func +func [d0000.knd, _threadRun] run() @@ -63,15 +63,15 @@ end func end func *func [_force] _copy(): kuin@Class - throw 16#E9170005 + throw 0xE9170005 end func *func [_force] _toBin(): []bit8 - throw 16#E9170005 + throw 0xE9170005 end func *func [_force] _fromBin(bin: []bit8, idx: &int): kuin@Class - throw 16#E9170005 + throw 0xE9170005 end func +func [d0000.knd, _mutexLock] lock() diff --git a/package/sys/undo.kn b/package/sys/undo.kn index 9a520259..2d6a5fc3 100644 --- a/package/sys/undo.kn +++ b/package/sys/undo.kn @@ -14,7 +14,7 @@ end class +func recordBegin() if(dbg & me.state <> 0) do wnd@msgBox(null, "a", "piyo", %none, %ok) - throw 16#E917000A + throw 0xE917000A end if do me.state :: 1 end func @@ -22,7 +22,7 @@ end class +func add(undo: @Cmd, redo: @Cmd) if(dbg & me.state = 0) do wnd@msgBox(null, "b", "piyo", %none, %ok) - throw 16#E917000A + throw 0xE917000A end if do me.bufPtr :: me.bufPtrNext(me.bufPtr) do me.undoBuf[me.bufPtr] :: undo @@ -33,7 +33,7 @@ end class +func recordEnd() if(dbg & me.state = 0) do wnd@msgBox(null, "c", "piyo", %none, %ok) - throw 16#E917000A + throw 0xE917000A end if if(me.state = 2) do me.bufPtr :: me.bufPtrNext(me.bufPtr) @@ -53,7 +53,7 @@ end class +func undo() if(dbg & me.state <> 0) do wnd@msgBox(null, "d", "piyo", %none, %ok) - throw 16#E917000A + throw 0xE917000A end if if(me.undoBuf[me.bufPtrPrev(me.bufPtr)] =& null) ret @@ -70,7 +70,7 @@ end class +func redo() if(dbg & me.state <> 0) do wnd@msgBox(null, "e", "piyo", %none, %ok) - throw 16#E917000A + throw 0xE917000A end if if(me.redoBuf[me.bufPtrNext(me.bufPtr)] =& null) ret diff --git a/package/sys/wnd.kn b/package/sys/wnd.kn index 872343bc..c6c3373c 100644 --- a/package/sys/wnd.kn +++ b/package/sys/wnd.kn @@ -18,8 +18,8 @@ end func dock dockChild } - layered :: 16#10000 - noMinimize :: 16#20000 + layered :: 0x10000 + noMinimize :: 0x20000 end enum +enum Anchor @@ -33,15 +33,15 @@ end enum end func *func [_force] _copy(): kuin@Class - throw 16#E9170005 + throw 0xE9170005 end func *func [_force] _toBin(): []bit8 - throw 16#E9170005 + throw 0xE9170005 end func *func [_force] _fromBin(bin: []bit8, idx: &int): kuin@Class - throw 16#E9170005 + throw 0xE9170005 end func +func [d0001.knd, _wndBaseGetPos] getPos(x: &int, y: &int, width: &int, height: &int) @@ -81,7 +81,7 @@ end enum +func find(name: []char): @WndBase if(dbg) if(name =& null) - throw 16#E9170006 + throw 0xE9170006 end if end if ret findRecursion(me, name) @@ -172,8 +172,8 @@ end class +enum ShiftCtrl none - shift :: 16#01 - ctrl :: 16#02 + shift :: 0x01 + ctrl :: 0x02 end enum +class Draw(@WndBase) @@ -474,7 +474,7 @@ end class +var onSel: func<(@WndBase)> end class -+class Tree(@WndBase) ++class TreeBase(@WndBase) *func [d0001.knd, _wndBaseDtor, _force] _dtor() end func @@ -493,16 +493,42 @@ end class +func [d0001.knd, _treeAllowDraggingToRoot] allowDraggingToRoot(enabled: bool) end func + var draggable_: int + var draggingItem: int + +var onSel: func<(@WndBase)> + +var onMoveNode: func<(@WndBase)> +end class + ++class Tree(@TreeBase) + *func [d0001.knd, _wndBaseDtor, _force] _dtor() + end func + +func [d0001.knd, _treeSetSel] setSel(node: @TreeNode) end func +func [d0001.knd, _treeGetSel, _make_instance] getSel(me2: @TreeNode): @TreeNode end func +end class - var draggable_: int - var draggingItem: int - +var onSel: func<(@WndBase)> - +var onMoveNode: func<(@WndBase)> ++class TreeMulti(@TreeBase) + *func [d0001.knd, _wndBaseDtor, _force] _dtor() + end func + + +func [d0001.knd, _treeMultiSetSel] setSel(nodes: []@TreeNode) + end func + + +func getSel(): []@TreeNode + var result: list<@TreeNode> :: #list<@TreeNode> + var node: @TreeNode :: me.getSelImpl(null) + while(node <>& null) + do result.add(node) + do node :: me.getSelImpl(node) + end while + ret result.toArray() + end func + + func [d0001.knd, _treeMultiGetSel, _make_instance] getSelImpl(me2: @TreeNode, node: @TreeNode): @TreeNode + end func end class +class TreeNode() @@ -511,15 +537,15 @@ end class end func *func [_force] _copy(): kuin@Class - throw 16#E9170005 + throw 0xE9170005 end func *func [_force] _toBin(): []bit8 - throw 16#E9170005 + throw 0xE9170005 end func *func [_force] _fromBin(bin: []bit8, idx: &int): kuin@Class - throw 16#E9170005 + throw 0xE9170005 end func +func [d0001.knd, _treeNodeAddChild, _make_instance] addChild(me2: @TreeNode, name: []char): @TreeNode @@ -588,10 +614,10 @@ end class +enum MsgBoxIcon none - err :: 16#10 - question :: 16#20 - warn :: 16#30 - info :: 16#40 + err :: 0x10 + question :: 0x20 + warn :: 0x30 + info :: 0x40 end enum +enum MsgBoxBtn @@ -778,6 +804,12 @@ end func end if end func ++func [d0001.knd, _makeTreeMulti, _make_instance] makeTreeMulti(me2: @TreeMulti, parent: @WndBase, x: int, y: int, width: int, height: int, anchorX: @Anchor, anchorY: @Anchor): @TreeMulti + if(parent <>& null) + do parent.addChild(me2) + end if +end func + +func [d0001.knd, _makeSplitX, _make_instance] makeSplitX(me2: @SplitX, parent: @WndBase, x: int, y: int, width: int, height: int, anchorX: @Anchor, anchorY: @Anchor): @SplitX if(parent <>& null) do parent.addChild(me2) @@ -807,15 +839,15 @@ end func end func *func [_force] _copy(): kuin@Class - throw 16#E9170005 + throw 0xE9170005 end func *func [_force] _toBin(): []bit8 - throw 16#E9170005 + throw 0xE9170005 end func *func [_force] _fromBin(bin: []bit8, idx: &int): kuin@Class - throw 16#E9170005 + throw 0xE9170005 end func +func [d0001.knd, _menuAdd] add(id: int, text: []char) @@ -850,15 +882,15 @@ end func +class TabOrder() *func [_force] _copy(): kuin@Class - throw 16#E9170005 + throw 0xE9170005 end func *func [_force] _toBin(): []bit8 - throw 16#E9170005 + throw 0xE9170005 end func *func [_force] _fromBin(bin: []bit8, idx: &int): kuin@Class - throw 16#E9170005 + throw 0xE9170005 end func +func [d0001.knd, _tabOrderChk] chk(key: @Key, shiftCtrl: @ShiftCtrl): bool @@ -874,18 +906,18 @@ end func end func +enum Key - mouseL :: 16#01 + mouseL :: 0x01 mouseR - mouseM :: 16#04 - bs :: 16#08 + mouseM :: 0x04 + bs :: 0x08 tab - enter :: 16#0D - shift :: 16#10 + enter :: 0x0D + shift :: 0x10 ctrl alt pause - esc :: 16#1B - space :: 16#20 + esc :: 0x1B + space :: 0x20 pageUp pageDown end_ @@ -894,9 +926,9 @@ end func up right down - ins :: 16#2D + ins :: 0x2D del - _0 :: 16#30 + _0 :: 0x30 _1 _2 _3 @@ -906,7 +938,7 @@ end func _7 _8 _9 - a :: 16#41 + a :: 0x41 b c d @@ -932,7 +964,7 @@ end func x y z - f1 :: 16#70 + f1 :: 0x70 f2 f3 f4 diff --git a/package/sys/xml.kn b/package/sys/xml.kn index af49e1ec..051b37b2 100644 --- a/package/sys/xml.kn +++ b/package/sys/xml.kn @@ -6,15 +6,15 @@ end func end func *func [_force] _copy(): kuin@Class - throw 16#E9170005 + throw 0xE9170005 end func *func [_force] _toBin(): []bit8 - throw 16#E9170005 + throw 0xE9170005 end func *func [_force] _fromBin(bin: []bit8, idx: &int): kuin@Class - throw 16#E9170005 + throw 0xE9170005 end func +func [d1003.knd, _xmlSave] save(path: []char, compact: bool): bool @@ -43,15 +43,15 @@ end func end func *func [_force] _copy(): kuin@Class - throw 16#E9170005 + throw 0xE9170005 end func *func [_force] _toBin(): []bit8 - throw 16#E9170005 + throw 0xE9170005 end func *func [_force] _fromBin(bin: []bit8, idx: &int): kuin@Class - throw 16#E9170005 + throw 0xE9170005 end func +func [d1003.knd, _xmlNodeSetName] setName(name: []char) diff --git a/src/common.c b/src/common.c index 7284a332..d5d43b98 100644 --- a/src/common.c +++ b/src/common.c @@ -25,10 +25,6 @@ void* Heap; S64* HeapCnt; S64 AppCode; const U8* UseResFlags; -/* - UseResFlags: - 1 = draw@circle -*/ HINSTANCE Instance; #if !defined(DBG) @@ -302,8 +298,9 @@ U8* Utf8ToUtf16(const char* str) return buf; } -Bool IsResUsed(S64 idx) +Bool IsResUsed(EUseResFlagsKind kind) { + S64 idx = (S64)kind; ASSERT(1 <= idx && (idx - 1) / 8 < USE_RES_FLAGS_LEN); return (UseResFlags[(idx - 1) / 8] & (1 << ((idx - 1) % 8))) != 0; } diff --git a/src/common.h b/src/common.h index 9898b8a0..dbe12c5e 100644 --- a/src/common.h +++ b/src/common.h @@ -71,7 +71,13 @@ static const S64 DefaultRefCntOpe = 1; // For 'GcInstance'. static void* DummyPtr = (void*)1i64; // An invalid pointer used to point to non-NULL. +typedef enum EUseResFlagsKind +{ + UseResFlagsKind_Draw_Circle = 1, + UseResFlagsKind_Draw_FilterMonotone, +} EUseResFlagsKind; #define USE_RES_FLAGS_LEN (1) + extern void* Heap; extern S64* HeapCnt; extern S64 AppCode; @@ -96,7 +102,7 @@ Bool IsPowerOf2(U64 n); U32 XorShift(U32* seed); char* Utf16ToUtf8(const U8* str); U8* Utf8ToUtf16(const char* str); -Bool IsResUsed(S64 idx); +Bool IsResUsed(EUseResFlagsKind kind); #define THROW(code) ThrowImpl(code) #if defined(DBG) diff --git a/src/compiler/analyze.c b/src/compiler/analyze.c index 69d59010..ed5c7ff7 100644 --- a/src/compiler/analyze.c +++ b/src/compiler/analyze.c @@ -18,9 +18,9 @@ static const Char* BuildInFuncs[] = L"endian\0 \x04", L"exist\0 \x0d", L"fill\0 \x05", - L"find\0 \x05", + L"find\0 \x0e", L"findBin\0 \x05", - L"findLast\0 \x05", + L"findLast\0 \x0e", L"findStr\0 \x06", L"findStrEx\0 \x06", L"findStrLast\0 \x06", @@ -77,7 +77,7 @@ static SAstFunc* SearchMain(void); static const void* ResolveIdentifierCallback(const Char* key, const void* value, void* param); static void ResolveIdentifierRecursion(const Char* src, const SAst* scope); static void InitAst(SAst* ast, EAstTypeId type_id, const SPos* pos); -static SList* RefreshStats(SList* stats, SAstType* ret_type); +static SList* RefreshStats(SList* stats, SAstType* ret_type, SAstFunc* parent_func); static Bool CmpType(const SAstType* type1, const SAstType* type2); static Bool IsComparable(const SAstType* type, Bool less_or_greater); static U64 BitCast(int size, U64 n); @@ -102,18 +102,18 @@ static void RebuildClass(SAstClass* ast); static void RebuildEnum(SAstEnum* ast); static void RebuildEnumElement(SAstExpr* enum_element, SAstType* type); static void RebuildArg(SAstArg* ast); -static SAstStat* RebuildStat(SAstStat* ast, SAstType* ret_type); -static SAstStat* RebuildIf(SAstStatIf* ast, SAstType* ret_type); -static SAstStat* RebuildSwitch(SAstStatSwitch* ast, SAstType* ret_type); -static SAstStat* RebuildWhile(SAstStatWhile* ast, SAstType* ret_type); -static SAstStat* RebuildFor(SAstStatFor* ast, SAstType* ret_type); -static SAstStat* RebuildTry(SAstStatTry* ast, SAstType* ret_type); +static SAstStat* RebuildStat(SAstStat* ast, SAstType* ret_type, SAstFunc* parent_func); +static SAstStat* RebuildIf(SAstStatIf* ast, SAstType* ret_type, SAstFunc* parent_func); +static SAstStat* RebuildSwitch(SAstStatSwitch* ast, SAstType* ret_type, SAstFunc* parent_func); +static SAstStat* RebuildWhile(SAstStatWhile* ast, SAstType* ret_type, SAstFunc* parent_func); +static SAstStat* RebuildFor(SAstStatFor* ast, SAstType* ret_type, SAstFunc* parent_func); +static SAstStat* RebuildTry(SAstStatTry* ast, SAstType* ret_type, SAstFunc* parent_func); static SAstStat* RebuildThrow(SAstStatThrow* ast); -static SAstStat* RebuildBlock(SAstStatBlock* ast, SAstType* ret_type); +static SAstStat* RebuildBlock(SAstStatBlock* ast, SAstType* ret_type, SAstFunc* parent_func); static SAstStat* RebuildRet(SAstStatRet* ast, SAstType* ret_type); static SAstStat* RebuildDo(SAstStatDo* ast); -static SAstStat* RebuildBreak(SAstStat* ast, SAstType* ret_type); -static SAstStat* RebuildSkip(SAstStat* ast, SAstType* ret_type); +static SAstStat* RebuildBreak(SAstStat* ast, SAstType* ret_type, SAstFunc* parent_func); +static SAstStat* RebuildSkip(SAstStat* ast, SAstType* ret_type, SAstFunc* parent_func); static SAstStat* RebuildAssert(SAstStatAssert* ast); static SAstType* RebuildType(SAstType* ast, SAstAlias* parent_alias); static SAstExpr* RebuildExpr(SAstExpr* ast, Bool nullable); @@ -348,14 +348,14 @@ static void InitAstExpr(SAstExpr* ast, EAstTypeId type_id, const SPos* pos) ast->VarKind = AstExprVarKind_Unknown; } -static SList* RefreshStats(SList* stats, SAstType* ret_type) +static SList* RefreshStats(SList* stats, SAstType* ret_type, SAstFunc* parent_func) { SList* stats2 = ListNew(); { SListNode* ptr = stats->Top; while (ptr != NULL) { - SAstStat* stat = RebuildStat((SAstStat*)ptr->Data, ret_type); + SAstStat* stat = RebuildStat((SAstStat*)ptr->Data, ret_type, parent_func); if (stat != NULL) ListAdd(stats2, stat); ptr = ptr->Next; @@ -389,8 +389,6 @@ static Bool CmpType(const SAstType* type1, const SAstType* type2) SAstTypeFunc* func2 = (SAstTypeFunc*)type2; SListNode* ptr1 = func1->Args->Top; SListNode* ptr2 = func2->Args->Top; - if (func1->FuncAttr != func2->FuncAttr) - return False; while (ptr1 != NULL && ptr2 != NULL) { SAstTypeFuncArg* arg1 = (SAstTypeFuncArg*)ptr1->Data; @@ -520,7 +518,7 @@ static SAstFunc* AddSpecialFunc(SAstClass* class_, const Char* name) { // These functions override functions of the root class. SAstClassItem* item = (SAstClassItem*)Alloc(sizeof(SAstClassItem)); - item->Override = 1; + item->Override = True; item->Def = (SAst*)func; item->ParentItem = NULL; item->Addr = -1; @@ -946,10 +944,10 @@ static void RebuildRoot(SAstRoot* ast) assign->Children[1] = var->Var->Expr; do_->Expr = (SAstExpr*)assign; } - ListAdd(init_vars->Stats, RebuildStat((SAstStat*)do_, NULL)); + ListAdd(init_vars->Stats, RebuildStat((SAstStat*)do_, NULL, NULL)); } } - if (IsRef(var->Var->Type)) + if (var->Var->Type != NULL && IsRef(var->Var->Type)) { // Add finalization processing of global variables to '_finVars'. SAstStatDo* do_ = (SAstStatDo*)Alloc(sizeof(SAstStatDo)); @@ -978,7 +976,7 @@ static void RebuildRoot(SAstRoot* ast) } do_->Expr = (SAstExpr*)assign; } - ListAdd(fin_vars->Stats, RebuildStat((SAstStat*)do_, NULL)); + ListAdd(fin_vars->Stats, RebuildStat((SAstStat*)do_, NULL, NULL)); } } else @@ -1024,7 +1022,7 @@ static void RebuildFunc(SAstFunc* ast) } if (ast->Ret != NULL) ast->Ret = RebuildType(ast->Ret, NULL); - ast->Stats = RefreshStats(ast->Stats, ast->Ret); + ast->Stats = RefreshStats(ast->Stats, ast->Ret, ast); } static void RebuildVar(SAstVar* ast) @@ -1133,7 +1131,7 @@ static void RebuildClass(SAstClass* ast) } if (parent_item == NULL) { - if (item->Override != 0) + if (item->Override) { Err(L"EA0005", item->Def->Pos, member_name); return; @@ -1141,7 +1139,7 @@ static void RebuildClass(SAstClass* ast) } else { - if (item->Override == 0) + if (!item->Override) { Err(L"EA0006", item->Def->Pos, member_name); return; @@ -1172,7 +1170,9 @@ static void RebuildClass(SAstClass* ast) { SAstArg* arg1 = (SAstArg*)node1->Data; SAstArg* arg2 = (SAstArg*)node2->Data; - if (!CmpType(arg1->Type, arg2->Type) || ((SAst*)arg1)->Name != NULL && ((SAst*)arg2)->Name != NULL && wcscmp(((SAst*)arg1)->Name, ((SAst*)arg2)->Name) != 0 || arg1->RefVar != arg2->RefVar) + if (((SAst*)arg1->Type)->TypeId == AstTypeId_TypeUser && ((SAst*)arg1->Type)->RefItem == NULL || + ((SAst*)arg2->Type)->TypeId == AstTypeId_TypeUser && ((SAst*)arg2->Type)->RefItem == NULL || + !CmpType(arg1->Type, arg2->Type) || ((SAst*)arg1)->Name != NULL && ((SAst*)arg2)->Name != NULL && wcscmp(((SAst*)arg1)->Name, ((SAst*)arg2)->Name) != 0 || arg1->RefVar != arg2->RefVar) { Err(L"EA0009", item->Def->Pos, member_name); return; @@ -1188,7 +1188,7 @@ static void RebuildClass(SAstClass* ast) if (wcscmp(member_name, L"_dtor") == 0 || wcscmp(member_name, L"_copy") == 0 || wcscmp(member_name, L"_toBin") == 0 || wcscmp(member_name, L"_fromBin") == 0) { ASSERT(item->Def->TypeId == AstTypeId_Func); - if (item->Override != 0 && (((SAstFunc*)item->Def)->FuncAttr & FuncAttr_Force) == 0) + if (item->Override && (((SAstFunc*)item->Def)->FuncAttr & FuncAttr_Force) == 0) { Err(L"EA0010", item->Def->Pos, member_name); return; @@ -1210,49 +1210,7 @@ static void RebuildClass(SAstClass* ast) // Analyze functions and variables in classes because they can be referred to as instances. SAst* def = item->Def; if (def->TypeId == AstTypeId_Func) - { - if (item->Override == 2) - { - // Call its parent's function. - SAstStatDo* do_ = (SAstStatDo*)Alloc(sizeof(SAstStatDo)); - InitAst((SAst*)do_, AstTypeId_StatDo, ((SAst*)ast)->Pos); - { - SAstExprCall* call = (SAstExprCall*)Alloc(sizeof(SAstExprCall)); - InitAstExpr((SAstExpr*)call, AstTypeId_ExprCall, ((SAst*)ast)->Pos); - { - SAstExpr* expr = (SAstExpr*)Alloc(sizeof(SAstExpr)); - InitAstExpr(expr, AstTypeId_ExprRef, ((SAst*)ast)->Pos); - ((SAst*)expr)->RefItem = item->ParentItem->Def; - call->Func = expr; - } - call->Args = ListNew(); - { - SListNode* node = ((SAstFunc*)item->Def)->Args->Top; - while (node != NULL) - { - SAstArg* arg = (SAstArg*)node->Data; - { - SAstExprCallArg* expr = (SAstExprCallArg*)Alloc(sizeof(SAstExprCallArg)); - { - SAstExpr* expr2 = (SAstExpr*)Alloc(sizeof(SAstExpr)); - InitAstExpr(expr2, AstTypeId_ExprRef, ((SAst*)ast)->Pos); - ((SAst*)expr2)->RefName = ((SAst*)arg)->Name; - ((SAst*)expr2)->RefItem = (SAst*)arg; - expr->Arg = expr2; - expr->RefVar = arg->RefVar; - expr->SkipVar = NULL; - } - ListAdd(call->Args, expr); - } - node = node->Next; - } - } - do_->Expr = (SAstExpr*)call; - } - ListIns(((SAstFunc*)def)->Stats, ((SAstFunc*)def)->Stats->Top, do_); - } RebuildFunc((SAstFunc*)def); - } else if (def->TypeId == AstTypeId_Var) RebuildVar((SAstVar*)def); } @@ -1361,7 +1319,7 @@ static void RebuildClass(SAstClass* ast) } do_->Expr = (SAstExpr*)assign; } - ListAdd(dtor->Stats, do_); + ListAdd(dtor->Stats, RebuildStat((SAstStat*)do_, dtor->Ret, dtor)); } ptr2 = ptr2->Next; } @@ -1399,7 +1357,7 @@ static void RebuildClass(SAstClass* ast) } var->Def = var2; } - ListAdd(copy->Stats, var); + ListAdd(copy->Stats, RebuildStat((SAstStat*)var, copy->Ret, copy)); { result = (SAstExpr*)Alloc(sizeof(SAstExpr)); InitAstExpr(result, AstTypeId_ExprRef, ((SAst*)ast)->Pos); @@ -1454,7 +1412,7 @@ static void RebuildClass(SAstClass* ast) } do_->Expr = (SAstExpr*)assign; } - ListAdd(copy->Stats, do_); + ListAdd(copy->Stats, RebuildStat((SAstStat*)do_, copy->Ret, copy)); } } ptr2 = ptr2->Next; @@ -1473,7 +1431,7 @@ static void RebuildClass(SAstClass* ast) as->ChildType = copy->Ret; ret->Value = (SAstExpr*)as; } - ListAdd(copy->Stats, ret); + ListAdd(copy->Stats, RebuildStat((SAstStat*)ret, copy->Ret, copy)); } } // The '_toBin' function. @@ -1530,7 +1488,7 @@ static void RebuildClass(SAstClass* ast) } var->Def = var2; } - ListAdd(to_bin->Stats, var); + ListAdd(to_bin->Stats, RebuildStat((SAstStat*)var, to_bin->Ret, to_bin)); { result = (SAstExpr*)Alloc(sizeof(SAstExpr)); InitAstExpr(result, AstTypeId_ExprRef, ((SAst*)ast)->Pos); @@ -1581,7 +1539,7 @@ static void RebuildClass(SAstClass* ast) } do_->Expr = (SAstExpr*)assign; } - ListAdd(to_bin->Stats, do_); + ListAdd(to_bin->Stats, RebuildStat((SAstStat*)do_, to_bin->Ret, to_bin)); } } ptr2 = ptr2->Next; @@ -1593,7 +1551,7 @@ static void RebuildClass(SAstClass* ast) SAstStatRet* ret = (SAstStatRet*)Alloc(sizeof(SAstStatRet)); InitAst((SAst*)ret, AstTypeId_StatRet, ((SAst*)ast)->Pos); ret->Value = result; - ListAdd(to_bin->Stats, ret); + ListAdd(to_bin->Stats, RebuildStat((SAstStat*)ret, to_bin->Ret, to_bin)); } } // The '_fromBin' function. @@ -1622,7 +1580,7 @@ static void RebuildClass(SAstClass* ast) } var->Def = var2; } - ListAdd(from_bin->Stats, var); + ListAdd(from_bin->Stats, RebuildStat((SAstStat*)var, from_bin->Ret, from_bin)); { result = (SAstExpr*)Alloc(sizeof(SAstExpr)); InitAstExpr(result, AstTypeId_ExprRef, ((SAst*)ast)->Pos); @@ -1682,7 +1640,7 @@ static void RebuildClass(SAstClass* ast) } do_->Expr = (SAstExpr*)assign; } - ListAdd(from_bin->Stats, do_); + ListAdd(from_bin->Stats, RebuildStat((SAstStat*)do_, from_bin->Ret, from_bin)); } } ptr2 = ptr2->Next; @@ -1694,7 +1652,7 @@ static void RebuildClass(SAstClass* ast) SAstStatRet* ret = (SAstStatRet*)Alloc(sizeof(SAstStatRet)); InitAst((SAst*)ret, AstTypeId_StatRet, ((SAst*)ast)->Pos); ret->Value = result; - ListAdd(from_bin->Stats, ret); + ListAdd(from_bin->Stats, RebuildStat((SAstStat*)ret, from_bin->Ret, from_bin)); } } RebuildFunc(dtor); @@ -1786,7 +1744,7 @@ static void RebuildArg(SAstArg* ast) } } -static SAstStat* RebuildStat(SAstStat* ast, SAstType* ret_type) +static SAstStat* RebuildStat(SAstStat* ast, SAstType* ret_type, SAstFunc* parent_func) { switch (((SAst*)ast)->TypeId) { @@ -1799,9 +1757,30 @@ static SAstStat* RebuildStat(SAstStat* ast, SAstType* ret_type) case AstTypeId_StatVar: { SAstStatVar* ast2 = (SAstStatVar*)ast; - if (ast2->Def->Var->Expr == NULL) - return NULL; RebuildVar(ast2->Def); + if (((SAst*)ast2->Def->Var)->Name != NULL && wcscmp(((SAst*)ast2->Def->Var)->Name, L"super") == 0) + { + ASSERT(parent_func != NULL && ((SAst*)parent_func)->Name != NULL); + ASSERT(((SAst*)((SAstArg*)ast2->Def->Var)->Type)->TypeId == AstTypeId_TypeFunc); + SAstClass* ref_class = (SAstClass*)((SAst*)((SAstTypeFuncArg*)((SAstTypeFunc*)((SAstArg*)ast2->Def->Var)->Type)->Args->Top->Data)->Arg)->RefItem; + ASSERT(((SAst*)ref_class)->TypeId == AstTypeId_Class); + SListNode* ptr = ref_class->Items->Top; + while (ptr != NULL) + { + const SAstClassItem* item = (const SAstClassItem*)ptr->Data; + if (item->Def->Name != NULL && wcscmp(item->Def->Name, ((SAst*)parent_func)->Name) == 0) // TODO: + { + ASSERT(item->Override); + SAstExpr* ast_ref = (SAstExpr*)Alloc(sizeof(SAstExpr)); + InitAstExpr(ast_ref, AstTypeId_ExprRef, ((SAst*)ast)->Pos); + ((SAst*)ast_ref)->RefItem = item->ParentItem->Def; + ast2->Def->Var->Expr = ast_ref; + break; + } + ptr = ptr->Next; + } + ASSERT(ptr != NULL); + } if (ast2->Def->Var->Expr == NULL) return NULL; { @@ -1822,21 +1801,21 @@ static SAstStat* RebuildStat(SAstStat* ast, SAstType* ret_type) ast_do->Expr = (SAstExpr*)ast_assign; } ast2->Def->Var->Expr = NULL; - ast = RebuildStat((SAstStat*)ast_do, ret_type); + ast = RebuildStat((SAstStat*)ast_do, ret_type, parent_func); } } break; - case AstTypeId_StatIf: ast = RebuildIf((SAstStatIf*)ast, ret_type); break; - case AstTypeId_StatSwitch: ast = RebuildSwitch((SAstStatSwitch*)ast, ret_type); break; - case AstTypeId_StatWhile: ast = RebuildWhile((SAstStatWhile*)ast, ret_type); break; - case AstTypeId_StatFor: ast = RebuildFor((SAstStatFor*)ast, ret_type); break; - case AstTypeId_StatTry: ast = RebuildTry((SAstStatTry*)ast, ret_type); break; + case AstTypeId_StatIf: ast = RebuildIf((SAstStatIf*)ast, ret_type, parent_func); break; + case AstTypeId_StatSwitch: ast = RebuildSwitch((SAstStatSwitch*)ast, ret_type, parent_func); break; + case AstTypeId_StatWhile: ast = RebuildWhile((SAstStatWhile*)ast, ret_type, parent_func); break; + case AstTypeId_StatFor: ast = RebuildFor((SAstStatFor*)ast, ret_type, parent_func); break; + case AstTypeId_StatTry: ast = RebuildTry((SAstStatTry*)ast, ret_type, parent_func); break; case AstTypeId_StatThrow: ast = RebuildThrow((SAstStatThrow*)ast); break; - case AstTypeId_StatBlock: ast = RebuildBlock((SAstStatBlock*)ast, ret_type); break; + case AstTypeId_StatBlock: ast = RebuildBlock((SAstStatBlock*)ast, ret_type, parent_func); break; case AstTypeId_StatRet: ast = RebuildRet((SAstStatRet*)ast, ret_type); break; case AstTypeId_StatDo: ast = RebuildDo((SAstStatDo*)ast); break; - case AstTypeId_StatBreak: ast = RebuildBreak((SAstStat*)ast, ret_type); break; - case AstTypeId_StatSkip: ast = RebuildSkip((SAstStat*)ast, ret_type); break; + case AstTypeId_StatBreak: ast = RebuildBreak((SAstStat*)ast, ret_type, parent_func); break; + case AstTypeId_StatSkip: ast = RebuildSkip((SAstStat*)ast, ret_type, parent_func); break; case AstTypeId_StatAssert: ast = RebuildAssert((SAstStatAssert*)ast); break; default: ASSERT(False); @@ -1848,7 +1827,7 @@ static SAstStat* RebuildStat(SAstStat* ast, SAstType* ret_type) return ast; } -static SAstStat* RebuildIf(SAstStatIf* ast, SAstType* ret_type) +static SAstStat* RebuildIf(SAstStatIf* ast, SAstType* ret_type, SAstFunc* parent_func) { if (((SAst*)ast)->AnalyzedCache != NULL) return (SAstStat*)((SAst*)ast)->AnalyzedCache; @@ -1856,7 +1835,7 @@ static SAstStat* RebuildIf(SAstStatIf* ast, SAstType* ret_type) ast->Cond = RebuildExpr(ast->Cond, False); if (ast->Cond != NULL && !IsBool(ast->Cond->Type)) Err(L"EA0016", ((SAst*)ast->Cond)->Pos); - ast->StatBlock = (SAstStatBlock*)RebuildBlock(ast->StatBlock, ret_type); + ast->StatBlock = (SAstStatBlock*)RebuildBlock(ast->StatBlock, ret_type, parent_func); { SListNode* ptr = ast->ElIfs->Top; while (ptr != NULL) @@ -1865,12 +1844,12 @@ static SAstStat* RebuildIf(SAstStatIf* ast, SAstType* ret_type) elif->Cond = RebuildExpr(elif->Cond, False); if (elif->Cond != NULL && !IsBool(elif->Cond->Type)) Err(L"EA0017", ((SAst*)elif->Cond)->Pos); - elif->StatBlock = (SAstStatBlock*)RebuildBlock(elif->StatBlock, ret_type); + elif->StatBlock = (SAstStatBlock*)RebuildBlock(elif->StatBlock, ret_type, parent_func); ptr = ptr->Next; } } if (ast->ElseStatBlock != NULL) - ast->ElseStatBlock = (SAstStatBlock*)RebuildBlock(ast->ElseStatBlock, ret_type); + ast->ElseStatBlock = (SAstStatBlock*)RebuildBlock(ast->ElseStatBlock, ret_type, parent_func); if (ast->Cond != NULL) { // Optimize the code. @@ -1917,7 +1896,7 @@ static SAstStat* RebuildIf(SAstStatIf* ast, SAstType* ret_type) return (SAstStat*)ast; } -static SAstStat* RebuildSwitch(SAstStatSwitch* ast, SAstType* ret_type) +static SAstStat* RebuildSwitch(SAstStatSwitch* ast, SAstType* ret_type, SAstFunc* parent_func) { if (((SAst*)ast)->AnalyzedCache != NULL) return (SAstStat*)((SAst*)ast)->AnalyzedCache; @@ -1959,16 +1938,16 @@ static SAstStat* RebuildSwitch(SAstStatSwitch* ast, SAstType* ret_type) } ptr2 = ptr2->Next; } - case_->StatBlock = (SAstStatBlock*)RebuildBlock(case_->StatBlock, ret_type); + case_->StatBlock = (SAstStatBlock*)RebuildBlock(case_->StatBlock, ret_type, parent_func); ptr = ptr->Next; } } if (ast->DefaultStatBlock != NULL) - ast->DefaultStatBlock = (SAstStatBlock*)RebuildBlock(ast->DefaultStatBlock, ret_type); + ast->DefaultStatBlock = (SAstStatBlock*)RebuildBlock(ast->DefaultStatBlock, ret_type, parent_func); return (SAstStat*)ast; } -static SAstStat* RebuildWhile(SAstStatWhile* ast, SAstType* ret_type) +static SAstStat* RebuildWhile(SAstStatWhile* ast, SAstType* ret_type, SAstFunc* parent_func) { if (((SAst*)ast)->AnalyzedCache != NULL) return (SAstStat*)((SAst*)ast)->AnalyzedCache; @@ -1979,11 +1958,11 @@ static SAstStat* RebuildWhile(SAstStatWhile* ast, SAstType* ret_type) if (ast->Cond != NULL && !IsBool(ast->Cond->Type)) Err(L"EA0020", ((SAst*)ast->Cond)->Pos); } - ast->Stats = RefreshStats(ast->Stats, ret_type); + ast->Stats = RefreshStats(ast->Stats, ret_type, parent_func); return (SAstStat*)ast; } -static SAstStat* RebuildFor(SAstStatFor* ast, SAstType* ret_type) +static SAstStat* RebuildFor(SAstStatFor* ast, SAstType* ret_type, SAstFunc* parent_func) { if (((SAst*)ast)->AnalyzedCache != NULL) return (SAstStat*)((SAst*)ast)->AnalyzedCache; @@ -2008,17 +1987,17 @@ static SAstStat* RebuildFor(SAstStatFor* ast, SAstType* ret_type) if (*((S64*)((SAstExprValue*)ast->Step)->Value) == 0) Err(L"EA0025", ((SAst*)ast->Step)->Pos); } - ast->Stats = RefreshStats(ast->Stats, ret_type); + ast->Stats = RefreshStats(ast->Stats, ret_type, parent_func); return (SAstStat*)ast; } -static SAstStat* RebuildTry(SAstStatTry* ast, SAstType* ret_type) +static SAstStat* RebuildTry(SAstStatTry* ast, SAstType* ret_type, SAstFunc* parent_func) { if (((SAst*)ast)->AnalyzedCache != NULL) return (SAstStat*)((SAst*)ast)->AnalyzedCache; ((SAst*)ast)->AnalyzedCache = (SAst*)ast; RebuildArg(((SAstStatBreakable*)ast)->BlockVar); - ast->StatBlock = (SAstStatBlock*)RebuildBlock(ast->StatBlock, ret_type); + ast->StatBlock = (SAstStatBlock*)RebuildBlock(ast->StatBlock, ret_type, parent_func); if (ast->Catches->Len != 0) { SListNode* ptr = ast->Catches->Top; @@ -2040,12 +2019,12 @@ static SAstStat* RebuildTry(SAstStatTry* ast, SAstType* ret_type) } ptr2 = ptr2->Next; } - catch_->StatBlock = (SAstStatBlock*)RebuildBlock(catch_->StatBlock, ret_type); + catch_->StatBlock = (SAstStatBlock*)RebuildBlock(catch_->StatBlock, ret_type, parent_func); ptr = ptr->Next; } } if (ast->FinallyStatBlock != NULL) - ast->FinallyStatBlock = (SAstStatBlock*)RebuildBlock(ast->FinallyStatBlock, ret_type); + ast->FinallyStatBlock = (SAstStatBlock*)RebuildBlock(ast->FinallyStatBlock, ret_type, parent_func); return (SAstStat*)ast; } @@ -2060,12 +2039,12 @@ static SAstStat* RebuildThrow(SAstStatThrow* ast) return (SAstStat*)ast; } -static SAstStat* RebuildBlock(SAstStatBlock* ast, SAstType* ret_type) +static SAstStat* RebuildBlock(SAstStatBlock* ast, SAstType* ret_type, SAstFunc* parent_func) { if (((SAst*)ast)->AnalyzedCache != NULL) return (SAstStat*)((SAst*)ast)->AnalyzedCache; ((SAst*)ast)->AnalyzedCache = (SAst*)ast; - ast->Stats = RefreshStats(ast->Stats, ret_type); + ast->Stats = RefreshStats(ast->Stats, ret_type, parent_func); return (SAstStat*)ast; } @@ -2107,7 +2086,7 @@ static SAstStat* RebuildDo(SAstStatDo* ast) return (SAstStat*)ast; } -static SAstStat* RebuildBreak(SAstStat* ast, SAstType* ret_type) +static SAstStat* RebuildBreak(SAstStat* ast, SAstType* ret_type, SAstFunc* parent_func) { if (((SAst*)ast)->AnalyzedCache != NULL) return (SAstStat*)((SAst*)ast)->AnalyzedCache; @@ -2117,11 +2096,11 @@ static SAstStat* RebuildBreak(SAstStat* ast, SAstType* ret_type) Err(L"EA0033", ((SAst*)ast)->Pos); return (SAstStat*)DummyPtr; } - ((SAst*)ast)->RefItem = (SAst*)RebuildStat((SAstStat*)((SAst*)ast)->RefItem, ret_type); + ((SAst*)ast)->RefItem = (SAst*)RebuildStat((SAstStat*)((SAst*)ast)->RefItem, ret_type, parent_func); return (SAstStat*)ast; } -static SAstStat* RebuildSkip(SAstStat* ast, SAstType* ret_type) +static SAstStat* RebuildSkip(SAstStat* ast, SAstType* ret_type, SAstFunc* parent_func) { if (((SAst*)ast)->AnalyzedCache != NULL) return (SAstStat*)((SAst*)ast)->AnalyzedCache; @@ -2131,7 +2110,7 @@ static SAstStat* RebuildSkip(SAstStat* ast, SAstType* ret_type) Err(L"EA0034", ((SAst*)ast)->Pos); return (SAstStat*)DummyPtr; } - ((SAst*)ast)->RefItem = (SAst*)RebuildStat((SAstStat*)((SAst*)ast)->RefItem, ret_type); + ((SAst*)ast)->RefItem = (SAst*)RebuildStat((SAstStat*)((SAst*)ast)->RefItem, ret_type, parent_func); return (SAstStat*)ast; } @@ -3472,6 +3451,10 @@ static SAstExpr* RebuildExprDot(SAstExprDot* ast) member = L"sortArray"; else if (wcscmp(member, L"sortDesc") == 0) member = L"sortDescArray"; + else if (wcscmp(member, L"find") == 0) + member = L"findArray"; + else if (wcscmp(member, L"findLast") == 0) + member = L"findLastArray"; else ASSERT(False); } @@ -3482,6 +3465,10 @@ static SAstExpr* RebuildExprDot(SAstExprDot* ast) member = L"sortList"; else if (wcscmp(member, L"sortDesc") == 0) member = L"sortDescList"; + else if (wcscmp(member, L"find") == 0) + member = L"findList"; + else if (wcscmp(member, L"findLast") == 0) + member = L"findLastList"; else ASSERT(False); } diff --git a/src/compiler/assemble.c b/src/compiler/assemble.c index b6c23db5..05ce411b 100644 --- a/src/compiler/assemble.c +++ b/src/compiler/assemble.c @@ -130,6 +130,7 @@ static void SetTypeId(EReg reg, const SAstType* type); static int SetTypeIdRecursion(U8* ptr, int idx, const SAstType* type); static void SetTypeIdForFromBin(EReg reg, const SAstType* type); static void SetTypeIdForFromBinRecursion(int* idx_type, U8* data_type, int* idx_class, S64** data_class, const SAstType* type); +static void ExpandMe(SAstExprDot* dot, int reg_i); static void AssembleFunc(SAstFunc* ast, Bool entry); static void AssembleStats(SList* asts); static void AssembleIf(SAstStatIf* ast); @@ -773,7 +774,7 @@ static S64* RefClass(SAstClass* class_) SAstClassItem* item = (SAstClassItem*)ptr->Data; if ((item->Def->TypeId & AstTypeId_Func) == AstTypeId_Func) { - if (item->Override != 0) + if (item->Override) item->Addr = item->ParentItem->Addr; else { @@ -1543,6 +1544,13 @@ static void SetTypeIdForFromBinRecursion(int* idx_type, U8* data_type, int* idx_ return; } +static void ExpandMe(SAstExprDot* dot, int reg_i) +{ + ListAdd(PackAsm->Asms, AsmMOV(ValReg(8, RegI[reg_i]), ValMemS(8, ValReg(8, RegI[reg_i]), NULL, 0x08))); + ListAdd(PackAsm->Asms, AsmLEA(ValReg(8, RegI[reg_i]), ValMemS(8, ValReg(8, RegI[reg_i]), NULL, 0x08 + dot->ClassItem->Addr))); + ListAdd(PackAsm->Asms, AsmADD(ValReg(8, RegI[reg_i]), ValMemS(8, ValReg(8, RegI[reg_i]), NULL, 0x00))); +} + static void AssembleFunc(SAstFunc* ast, Bool entry) { ASSERT(((SAst*)ast)->AnalyzedCache != NULL); @@ -3597,9 +3605,7 @@ static void AssembleExprCall(SAstExprCall* ast, int reg_i, int reg_f) ASSERT(IsRef(((SAstExprCallArg*)ptr->Data)->Arg->Type) && !((SAstExprCallArg*)ptr->Data)->RefVar); GcInc(0); // Expand 'me'. - ListAdd(PackAsm->Asms, AsmMOV(ValReg(8, RegI[0]), ValMemS(8, ValReg(8, RegI[0]), NULL, 0x08))); - ListAdd(PackAsm->Asms, AsmLEA(ValReg(8, RegI[0]), ValMemS(8, ValReg(8, RegI[0]), NULL, 0x08 + ((SAstExprDot*)ast->Func)->ClassItem->Addr))); - ListAdd(PackAsm->Asms, AsmADD(ValReg(8, RegI[0]), ValMemS(8, ValReg(8, RegI[0]), NULL, 0x00))); + ExpandMe((SAstExprDot*)ast->Func, 0); } else if ((((SAstTypeFunc*)ast->Func->Type)->FuncAttr & FuncAttr_AnyType) != 0 && ptr == ast->Args->Top->Next) { @@ -3729,9 +3735,7 @@ static void AssembleExprDot(SAstExprDot* ast, int reg_i, int reg_f, Bool expand_ if (expand_me) { // In case of method call, 'me' should not be expanded. - ListAdd(PackAsm->Asms, AsmMOV(ValReg(8, RegI[0]), ValMemS(8, ValReg(8, RegI[0]), NULL, 0x08))); - ListAdd(PackAsm->Asms, AsmLEA(ValReg(8, RegI[0]), ValMemS(8, ValReg(8, RegI[0]), NULL, 0x08 + ast->ClassItem->Addr))); - ListAdd(PackAsm->Asms, AsmADD(ValReg(8, RegI[0]), ValMemS(8, ValReg(8, RegI[0]), NULL, 0x00))); + ExpandMe(ast, reg_i); } } } diff --git a/src/compiler/ast.c b/src/compiler/ast.c index c26b5a06..ac87b391 100644 --- a/src/compiler/ast.c +++ b/src/compiler/ast.c @@ -502,7 +502,7 @@ static void DumpAstClass(const SAstClass* ast) const SAstClassItem* item = (const SAstClassItem*)ptr->Data; PrintTab(); fwprintf(FilePtr, L"Public ? L"True" : L"False"); - fwprintf(FilePtr, L" Override=\"%d\"", item->Override); + fwprintf(FilePtr, L" Override=\"%s\"", item->Override ? L"True" : L"False"); fwprintf(FilePtr, L" ParentItem=\"%s\"", item->ParentItem == NULL ? L"(Null)" : L"(Ptr)"); fwprintf(FilePtr, L" />\n"); ASSERT(item->Def != NULL); diff --git a/src/compiler/ast.h b/src/compiler/ast.h index 1c833761..ac65296d 100644 --- a/src/compiler/ast.h +++ b/src/compiler/ast.h @@ -163,7 +163,7 @@ typedef struct SAstAlias typedef struct SAstClassItem { Bool Public; - U8 Override; // 0 = none, 1 = override, 2 = override and call its parent method. + Bool Override; SAst* Def; struct SAstClassItem* ParentItem; S64 Addr; diff --git a/src/compiler/main.c b/src/compiler/main.c index baf521ed..e28f5752 100644 --- a/src/compiler/main.c +++ b/src/compiler/main.c @@ -253,7 +253,7 @@ EXPORT Bool Interpret2(const U8* path, const void*(*func_get_src)(const U8*), co EXPORT void Version(S64* major, S64* minor, S64* micro) { *major = 2018; - *minor = 5; + *minor = 6; *micro = 17; } diff --git a/src/compiler/parse.c b/src/compiler/parse.c index 35b05efd..151e07cb 100644 --- a/src/compiler/parse.c +++ b/src/compiler/parse.c @@ -50,6 +50,7 @@ static const Char* Reserved[] = L"ret", L"skip", L"stack", + L"super", L"switch", L"throw", L"to", @@ -153,7 +154,7 @@ static void AddSrc(const Char* name); static Bool IsReserved(const Char* word); static SAstStatBlock* ParseDummyBlock(SAstStat** out_stat, EAstTypeId* out_type_id, EAstTypeId type_id, SAst* block); static SAstRoot* ParseRoot(SAstRoot* ast); -static SAstFunc* ParseFunc(const Char* parent_class); +static SAstFunc* ParseFunc(const Char* parent_class, Bool overridden); static SAstVar* ParseVar(EAstArgKind kind, const Char* parent_class); static SAstConst* ParseConst(void); static SAstAlias* ParseAlias(void); @@ -1393,7 +1394,7 @@ static SAstRoot* ParseRoot(SAstRoot* ast) int col = Col; const Char* id = ReadIdentifier(True, False); if (wcscmp(id, L"func") == 0) - child = (SAst*)ParseFunc(NULL); + child = (SAst*)ParseFunc(NULL, False); else if (wcscmp(id, L"var") == 0) child = (SAst*)ParseVar(AstArgKind_Global, NULL); else if (wcscmp(id, L"const") == 0) @@ -1432,7 +1433,7 @@ static SAstRoot* ParseRoot(SAstRoot* ast) return ast; } -static SAstFunc* ParseFunc(const Char* parent_class) +static SAstFunc* ParseFunc(const Char* parent_class, Bool overridden) { SAstFunc* ast = (SAstFunc*)Alloc(sizeof(SAstFunc)); ast->DllName = NULL; @@ -1580,6 +1581,49 @@ static SAstFunc* ParseFunc(const Char* parent_class) if (c != L'\n') NextCharErr(L'\n', c); } + if (overridden) + { + SAstStatVar* stat_var = (SAstStatVar*)Alloc(sizeof(SAstStatVar)); + { + InitAst((SAst*)stat_var, AstTypeId_StatVar, ((SAst*)ast)->Pos, NULL, False, False); + SAstVar* var = (SAstVar*)Alloc(sizeof(SAstVar)); + { + InitAst((SAst*)var, AstTypeId_Var, ((SAst*)ast)->Pos, NULL, False, False); + SAstArg* arg = (SAstArg*)Alloc(sizeof(SAstArg)); + { + InitAst((SAst*)arg, AstTypeId_Arg, ((SAst*)ast)->Pos, NULL, False, False); + ((SAst*)arg)->Name = L"super"; + arg->Addr = NewAddr(); + arg->Expr = NULL; + arg->Kind = AstArgKind_LocalArg; + arg->RefVar = False; + AddScopeName((SAst*)arg, False); + { + SAstTypeFunc* type = (SAstTypeFunc*)Alloc(sizeof(SAstTypeFunc)); + InitAst((SAst*)type, AstTypeId_TypeFunc, ((SAst*)ast)->Pos, NULL, False, False); + type->FuncAttr = ast->FuncAttr; + type->Args = ListNew(); + { + SListNode* ptr = ast->Args->Top; + while (ptr != NULL) + { + SAstTypeFuncArg* arg2 = (SAstTypeFuncArg*)Alloc(sizeof(SAstTypeFuncArg)); + arg2->RefVar = ((SAstArg*)ptr->Data)->RefVar; + arg2->Arg = ((SAstArg*)ptr->Data)->Type; + ListAdd(type->Args, arg2); + ptr = ptr->Next; + } + } + type->Ret = ast->Ret; + arg->Type = (SAstType*)type; + } + } + var->Var = arg; + } + stat_var->Def = var; + } + ListAdd(ast->Stats, stat_var); + } for (; ; ) { SAstStat* stat = ParseStat((SAst*)ast); @@ -1683,7 +1727,7 @@ static SAstClass* ParseClass(void) int col = Col; SAstClassItem* item = (SAstClassItem*)Alloc(sizeof(SAstClassItem)); item->Public = False; - item->Override = 0; + item->Override = False; item->ParentItem = NULL; item->Addr = -1; if (c == L'+') @@ -1692,24 +1736,17 @@ static SAstClass* ParseClass(void) FileBuf = c; c = ReadChar(); if (c == L'*') - { - item->Override = 1; - c = ReadChar(); - if (c == L'*') - item->Override = 2; - else - FileBuf = c; - } + item->Override = True; else FileBuf = c; { const Char* s = ReadIdentifier(True, False); const Char* class_name = ((SAst*)ast)->ScopeParent->TypeId == AstTypeId_Root ? NewStr(NULL, L"@%s", ((SAst*)ast)->Name) : ((SAst*)ast)->Name; if (wcscmp(s, L"func") == 0) - item->Def = (SAst*)ParseFunc(class_name); + item->Def = (SAst*)ParseFunc(class_name, item->Override); else if (wcscmp(s, L"var") == 0) { - if (item->Override != 0) + if (item->Override) Err(L"EP0028", NewPos(SrcName, row, col), s); item->Def = (SAst*)ParseVar(AstArgKind_Member, class_name); } @@ -1717,7 +1754,7 @@ static SAstClass* ParseClass(void) { if (item->Public) Err(L"EP0029", NewPos(SrcName, row, col), s); - if (item->Override != 0) + if (item->Override) Err(L"EP0028", NewPos(SrcName, row, col), s); if (wcscmp(s, L"end") == 0) { @@ -2010,7 +2047,7 @@ static SAstStat* ParseStatFunc(void) { SAstStatFunc* ast = (SAstStatFunc*)Alloc(sizeof(SAstStatFunc)); InitAst((SAst*)ast, AstTypeId_StatFunc, NULL, NULL, False, False); - ast->Def = ParseFunc(NULL); + ast->Def = ParseFunc(NULL, False); return (SAstStat*)ast; } @@ -3610,7 +3647,7 @@ static SAstExpr* ParseExprNumber(int row, int col, Char c) int bit_size = 0; // The size for bit types. for (; ; ) { - if (c == L'#') + if (c == L'x') { if (change_base || float_type) { @@ -3618,19 +3655,14 @@ static SAstExpr* ParseExprNumber(int row, int col, Char c) ReadUntilRet(c); return NULL; } + if (len != 1 || buf[0] != L'0') { - Char* end_ptr; - errno = 0; - buf[len] = L'\0'; - base = wcstol(buf, &end_ptr, 10); - if (*end_ptr != L'\0' || errno == ERANGE || !(base == 2 || base == 8 || base == 16)) - { - Err(L"EP0019", NewPos(SrcName, row, col), base); - ReadUntilRet(c); - return NULL; - } + Err(L"EP0019", NewPos(SrcName, row, col)); + ReadUntilRet(c); + return NULL; } len = 0; + base = 16; change_base = True; } else if (c == L'.') @@ -3871,7 +3903,7 @@ static void InterpretImpl1Color(int* ptr, int str_level, const Char* str, U8* co { color[*ptr] = new_color; (*ptr)++; - } while (L'0' <= str[*ptr] && str[*ptr] <= L'9' || L'A' <= str[*ptr] && str[*ptr] <= L'F' || str[*ptr] == L'#' || str[*ptr] == L'.'); + } while (L'0' <= str[*ptr] && str[*ptr] <= L'9' || L'A' <= str[*ptr] && str[*ptr] <= L'F' || str[*ptr] == L'x' || str[*ptr] == L'.'); if (str[*ptr] == L'e') { color[*ptr] = new_color; @@ -4274,7 +4306,7 @@ static void InterpretImpl1AlignRecursion(int* ptr_buf, int* ptr_str, int str_lev Interpret1Impl1UpdateCursor(cursor_x, new_cursor_x, ptr_str, ptr_buf); InterpretImpl1Write(ptr_buf, buf, str[*ptr_str]); (*ptr_str)++; - } while (L'0' <= str[*ptr_str] && str[*ptr_str] <= L'9' || L'A' <= str[*ptr_str] && str[*ptr_str] <= L'F' || str[*ptr_str] == L'#' || str[*ptr_str] == L'.'); + } while (L'0' <= str[*ptr_str] && str[*ptr_str] <= L'9' || L'A' <= str[*ptr_str] && str[*ptr_str] <= L'F' || str[*ptr_str] == L'x' || str[*ptr_str] == L'.'); if (str[*ptr_str] == L'e') { Interpret1Impl1UpdateCursor(cursor_x, new_cursor_x, ptr_str, ptr_buf); @@ -5506,6 +5538,7 @@ static Bool GetKeywordsReadExprValue(const Char** str) GetKeywordsAdd(L"false"); GetKeywordsAdd(L"inf"); GetKeywordsAdd(L"null"); + GetKeywordsAdd(L"super"); GetKeywordsAdd(L"true"); GetKeywordsAddKeywords(L'e'); return True; @@ -5522,7 +5555,7 @@ static Bool GetKeywordsReadExprNumber(const Char** str, Char c) { for (; ; ) { - if (!(c == L'#' || c == L'.' || L'0' <= c && c <= L'9' || L'A' <= c && c <= L'F')) + if (!(c == L'x' || c == L'.' || L'0' <= c && c <= L'9' || L'A' <= c && c <= L'F')) break; c = GetKeywordsRead(str); if (c == L'\0') diff --git a/src/kuin_editor/common.kn b/src/kuin_editor/common.kn index a7eccffb..921dfb42 100644 --- a/src/kuin_editor/common.kn +++ b/src/kuin_editor/common.kn @@ -4,7 +4,7 @@ +const langEn: bool :: false +const untitledSrcName: []char :: "_untitled_.kn" +const untitledInternalName: []char :: "\\_untitled_" -+const colorBack: int :: 16#FFFFF5F5 ++const colorBack: int :: 0xFFFFF5F5 +var title: []char +var font: draw@Font diff --git a/src/kuin_editor/doc.kn b/src/kuin_editor/doc.kn index 36561e0b..99c6e8c2 100644 --- a/src/kuin_editor/doc.kn +++ b/src/kuin_editor/doc.kn @@ -24,7 +24,7 @@ +func updateProp(listView: wnd@ListView) end func - +func updateTree(tree: wnd@Tree) + +func updateTree(tree: wnd@TreeMulti) end func +func updateList(list_: wnd@List) diff --git a/src/kuin_editor/doc_ar.kn b/src/kuin_editor/doc_ar.kn index b902e683..14e5a353 100644 --- a/src/kuin_editor/doc_ar.kn +++ b/src/kuin_editor/doc_ar.kn @@ -1,11 +1,12 @@ +class DocArBase(\doc@Doc) - **func ctor() + *func ctor() + do super(me) do me.scrollOffsetX :: 10 do me.scrollOffsetY :: 40 do me.pageX :: -me.scrollOffsetX do me.pageY :: -me.scrollOffsetY do me.mode :: %none - do me.hold :: null + do me.holds :: #list<@Obj2d> do me.ctrl :: 0 end func @@ -59,46 +60,56 @@ +*func draw(width: int, height: int) do draw@rect(0.0, 0.0, width $ float, height $ float, \common@colorBack) - do drawRecursion(me.obj2dRoot, me.pageX, me.pageY, me.hold) + do drawRecursion(me.obj2dRoot, me.pageX, me.pageY, me.holds) + if(me.mode = %select) + do draw@rectLine((me.holdOffsetX - me.pageX) $ float, (me.holdOffsetY - me.pageY) $ float, (me.selectOffsetX - me.holdOffsetX) $ float, (me.selectOffsetY - me.holdOffsetY) $ float, 0xFF6666FF) + end if - func drawRecursion(obj: @Obj2d, pageX: int, pageY: int, hold: @Obj2d) - if(hold =& obj) - do draw@rectLine((obj.absX - 3 - pageX) $ float, (obj.absY - 3 - pageY) $ float, (obj.width + 6) $ float, (obj.height + 6) $ float, 16#FF6666FF) - do draw@rectLine((obj.absX - 4 - pageX) $ float, (obj.absY - 4 - pageY) $ float, (obj.width + 8) $ float, (obj.height + 8) $ float, 16#FF6666FF) + func drawRecursion(obj: @Obj2d, pageX: int, pageY: int, holds: list<@Obj2d>) + do holds.head() + if(holds.find(obj)) + do draw@rectLine((obj.absX - 3 - pageX) $ float, (obj.absY - 3 - pageY) $ float, (obj.width + 6) $ float, (obj.height + 6) $ float, 0xFF6666FF) + do draw@rectLine((obj.absX - 4 - pageX) $ float, (obj.absY - 4 - pageY) $ float, (obj.width + 8) $ float, (obj.height + 8) $ float, 0xFF6666FF) end if do obj.draw(pageX, pageY) do obj.children.head() while(!obj.children.term()) - do drawRecursion(obj.children.get(), pageX, pageY, hold) + do drawRecursion(obj.children.get(), pageX, pageY, holds) do obj.children.next() end while end func end func +*func updateProp(listView: wnd@ListView) - if(me.hold <>& null) - var parent: @Obj2d :: me.hold.parent + do me.holds.head() + while(!me.holds.term()) + var obj: @Obj2d :: me.holds.get() + var parent: @Obj2d :: obj.parent var x: int :: 0 var y: int :: 0 if(parent <>& null) do x :: parent.absX do y :: parent.absY end if - do me.hold.updateProp(listView, x, y) - end if + do obj.updateProp(listView, x, y) + do me.holds.next() + end while end func - +*func updateTree(tree: wnd@Tree) - do updateTreeRecursion(me.hold, tree, tree.root(), me.obj2dRoot) + +*func updateTree(tree: wnd@TreeMulti) + var sels: list :: #list + do updateTreeRecursion(me.holds, tree.root(), me.obj2dRoot, sels) + do tree.setSel(sels.toArray()) - func updateTreeRecursion(hold: @Obj2d, tree: wnd@Tree, node: wnd@TreeNode, obj: @Obj2d) + func updateTreeRecursion(holds: list<@Obj2d>, node: wnd@TreeNode, obj: @Obj2d, sels: list) var node2: wnd@TreeNode :: node.addChild(obj.objName) - if(hold =& obj) - do tree.setSel(node2) + do holds.head() + if(holds.find(obj)) + do sels.add(node2) end if do obj.children.head() while(!obj.children.term()) - do updateTreeRecursion(hold, tree, node2, obj.children.get()) + do updateTreeRecursion(holds, node2, obj.children.get(), sels) do obj.children.next() end while end func @@ -110,25 +121,22 @@ end func +*func treeItemOnSel() - var sel: wnd@TreeNode :: \form@treeItem.getSel() - do me.hold :: selRecursion(\form@treeItem.root().firstChild(), me.obj2dRoot, sel) + var sels: []wnd@TreeNode :: \form@treeItem.getSel() + do me.holds :: #list<@Obj2d> + do selRecursion(\form@treeItem.root().firstChild(), me.obj2dRoot, sels, me.holds) do \form@paintDrawEditor() - func selRecursion(node: wnd@TreeNode, obj: @Obj2d, sel: wnd@TreeNode): @Obj2d - if(node = sel) - ret obj + func selRecursion(node: wnd@TreeNode, obj: @Obj2d, sels: []wnd@TreeNode, holds: list<@Obj2d>) + if(sels.find(node, 0) <> -1) + do holds.add(obj) end if do obj.children.head() var node2: wnd@TreeNode :: node.firstChild() while(!obj.children.term() & node2 <>& null) - var result: @Obj2d :: selRecursion(node2, obj.children.get(), sel) - if(result <>& null) - ret result - end if + do selRecursion(node2, obj.children.get(), sels, holds) do node2 :: node2.next() do obj.children.next() end while - ret null end func end func @@ -185,7 +193,7 @@ end func +*func listPropOnMouseDoubleClick(listView: wnd@ListView) - if(me.hold =& null) + if(^me.holds = 0) ret end if var sel: int :: listView.getSel() @@ -194,20 +202,23 @@ end if var prop: []char :: listView.getText(sel, 0) var value: []char :: listView.getText(sel, 1) - do value :: wndex@inputBox(\form@wndMain, me.hold.objName ~ "." ~ prop, \common@title, value, null) + do me.holds.head() + do value :: wndex@inputBox(\form@wndMain, me.holds.get().objName ~ "." ~ prop, \common@title, value, null) if(value =& null) ret end if + do me.holds.head() + var value2: int switch(prop) case "x" if(value.toInt(&value2)) var parentValue: int - if(me.hold.parent =& null) + if(me.holds.get().parent =& null) do parentValue :: 0 else - do parentValue :: me.hold.parent.absX + do parentValue :: me.holds.get().parent.absX end if do value :: (value2 + parentValue).toStr() else @@ -216,10 +227,10 @@ case "y" if(value.toInt(&value2)) var parentValue: int - if(me.hold.parent =& null) + if(me.holds.get().parent =& null) do parentValue :: 0 else - do parentValue :: me.hold.parent.absY + do parentValue :: me.holds.get().parent.absY end if do value :: (value2 + parentValue).toStr() else @@ -231,7 +242,10 @@ do prop :: "y" end switch - do me.hold.setProp(prop, value) + while(!me.holds.term()) + do me.holds.get().setProp(prop, value) + do me.holds.next() + end while do me.changed :: true do \form@updateProp() do \form@paintDrawEditor() @@ -241,21 +255,30 @@ var x2: int :: x + me.pageX var y2: int :: y + me.pageY if(me.ctrl <= 0) - do me.hold :: selRecursion(me.obj2dRoot, x2, y2) - if(me.hold =& null) - do me.hold :: me.obj2dRoot - end if + var obj: @Obj2d :: selRecursion(me.obj2dRoot, x2, y2) - if(me.hold.absX + me.hold.width - resizeArea <= x2 & me.hold.absY + me.hold.height - resizeArea <= y2) + do me.holdOffsetX :: x2 + do me.holdOffsetY :: y2 + if(obj <>& null & obj.absX + obj.width - resizeArea <= x2 & obj.absY + obj.height - resizeArea <= y2) do me.mode :: %resize - do me.holdOffsetX :: me.hold.absX + me.hold.width - x2 - do me.holdOffsetY :: me.hold.absY + me.hold.height - y2 - elif(me.hold =& me.obj2dRoot) - do me.mode :: %none + elif(obj =& null | obj =& me.obj2dRoot) + do me.mode :: %select + do me.selectOffsetX :: x2 + do me.selectOffsetY :: y2 else do me.mode :: %move - do me.holdOffsetX :: me.hold.absX - x2 - do me.holdOffsetY :: me.hold.absY - y2 + end if + + if(obj =& null) + do obj :: me.obj2dRoot + end if + + var found: bool :: me.holds.find(obj) + if(!wnd@key(%shift) & !wnd@key(%ctrl) & !found) + do me.holds :: #list<@Obj2d> + end if + if(!found) + do me.holds.add(obj) end if else if (\form@getLockingEditor()) @@ -264,21 +287,23 @@ end if var name: []char :: \form@listInfo.getText(me.ctrl) do me.mode :: %put - do me.holdOffsetX :: 0 - do me.holdOffsetY :: 0 + do me.holdOffsetX :: x2 + do me.holdOffsetY :: y2 var obj: @Obj2d :: me.makeObj2d(name) var minWidth: int var minHeight: int do obj.getMinMaxSize(&minWidth, &minHeight, &, &) do obj.init(me.getDefaultName(name), x2, y2, minWidth, minHeight) - if(me.hold =& null) + if(^me.holds = 0) do obj.parent :: me.obj2dRoot do me.obj2dRoot.children.add(obj) else - do obj.parent :: me.hold - do me.hold.children.add(obj) + do me.holds.head() + do obj.parent :: me.holds.get() + do me.holds.get().children.add(obj) end if - do me.hold :: obj + do me.holds :: #list<@Obj2d> + do me.holds.add(obj) end if do me.changed :: true do \form@paintDrawEditor() @@ -310,7 +335,7 @@ do me.resizeObj2d(x + me.pageX, y + me.pageY) do me.mode :: %none do me.ctrl :: 0 - do me.hold :: null + do me.holds :: #list<@Obj2d> do \form@updateTree() do \form@updateProp() do \form@paintDrawEditor() @@ -334,7 +359,39 @@ do \form@updateTree() do \form@updateProp() do \form@paintDrawEditor() + case %select + var x1: int :: me.holdOffsetX + var y1: int :: me.holdOffsetY + var x2: int :: x + me.pageX + var y2: int :: y + me.pageY + if(x1 > x2) + do x1 :$ x2 + end if + if(y1 > y2) + do y1 :$ y2 + end if + do me.holds :: #list<@Obj2d> + do selRecursion(me.obj2dRoot, me.obj2dRoot, x1, y1, x2, y2, me.holds) + if(^me.holds = 0) + do me.holds.add(me.obj2dRoot) + end if + do me.mode :: %none + do \form@updateTree() + do \form@updateProp() + do \form@paintDrawEditor() end switch + + func selRecursion(root: @Obj2d, obj: @Obj2d, x: int, y: int, x2: int, y2: int, sels: list<@Obj2d>) + var result: @Obj2d :: null + if(obj <>& root & obj.absX <= x2 & x <= obj.absX + obj.width & obj.absY <= y2 & y <= obj.absY + obj.height) + do sels.add(obj) + end if + do obj.children.head() + while(!obj.children.term()) + do selRecursion(root, obj.children.get(), x, y, x2, y2, sels) + do obj.children.next() + end while + end func end func +*func mouseDoubleClick(x: int, y: int) @@ -349,6 +406,8 @@ ret end if do me.resizeObj2d(x + me.pageX, y + me.pageY) + do me.holdOffsetX :: x + me.pageX + do me.holdOffsetY :: y + me.pageY do \form@paintDrawEditor() case %move if (\form@getLockingEditor()) @@ -356,6 +415,8 @@ ret end if do me.moveObj2d(x + me.pageX, y + me.pageY) + do me.holdOffsetX :: x + me.pageX + do me.holdOffsetY :: y + me.pageY do \form@paintDrawEditor() case %resize if (\form@getLockingEditor()) @@ -363,6 +424,12 @@ ret end if do me.resizeObj2d(x + me.pageX, y + me.pageY) + do me.holdOffsetX :: x + me.pageX + do me.holdOffsetY :: y + me.pageY + do \form@paintDrawEditor() + case %select + do me.selectOffsetX :: x + me.pageX + do me.selectOffsetY :: y + me.pageY do \form@paintDrawEditor() end switch end func @@ -406,19 +473,24 @@ +*func setMouseImg(): wnd@MouseImg switch(me.mode) case %none - if(me.hold <>& null) + if(^me.holds <> 0) var x: int var y: int do input@mousePos(&x, &y) do \form@drawEditor.screenToClient(&x, &y, x, y) do x :+ me.pageX do y :+ me.pageY - if(me.hold.absX <= x & me.hold.absY <= y & x <= me.hold.absX + me.hold.width & y <= me.hold.absY + me.hold.height) - if(me.hold.absX + me.hold.width - resizeArea <= x & me.hold.absY + me.hold.height - resizeArea <= y) - ret %resizeLTRD + do me.holds.head() + while(!me.holds.term()) + var obj: @Obj2d :: me.holds.get() + if(obj.absX <= x & obj.absY <= y & x <= obj.absX + obj.width & y <= obj.absY + obj.height) + if(obj.absX + obj.width - resizeArea <= x & obj.absY + obj.height - resizeArea <= y) + ret %resizeLTRD + end if + ret %move end if - ret %move - end if + do me.holds.next() + end while end if ret %arrow case %put @@ -427,6 +499,8 @@ ret %move case %resize ret %resizeLTRD + case %select + ret %cross default assert false end switch @@ -453,26 +527,27 @@ end func +*func cmdDel() - if(me.hold =& null | me.hold =& me.obj2dRoot) + if(^me.holds = 0) ret end if - do delRecursion(\form@treeItem.root().firstChild(), me.obj2dRoot, me.hold) + do delRecursion(\form@treeItem.root().firstChild(), me.obj2dRoot, me.holds) do me.changed :: true do \form@updateTree() do \form@updateProp() do \form@paintDrawEditor() - func delRecursion(node: wnd@TreeNode, obj: @Obj2d, hold: @Obj2d): bool + func delRecursion(node: wnd@TreeNode, obj: @Obj2d, holds: list<@Obj2d>): bool var node2: wnd@TreeNode :: node.firstChild() do obj.children.head() while(!obj.children.term() & node2 <>& null) var childObj: @Obj2d :: obj.children.get() - if(hold =& childObj) + do holds.head() + if(holds.find(childObj)) do node.delChild(node2) do obj.children.del() ret true end if - if(delRecursion(node2, childObj, hold)) + if(delRecursion(node2, childObj, holds)) ret true end if do node2 :: node2.next() @@ -499,6 +574,7 @@ put move resize + select end enum var src: [][]char @@ -506,12 +582,14 @@ var pageX: int var pageY: int var mode: Mode - var hold: @Obj2d + var holds: list<@Obj2d> var ctrl: int var holdOffsetX: int var holdOffsetY: int var scrollOffsetX: int var scrollOffsetY: int + var selectOffsetX: int + var selectOffsetY: int +func makeObj2d(name: []char): @Obj2d end func @@ -557,37 +635,48 @@ func resizeObj2d(x: int, y: int) do me.stick(&x, &y) - var width: int :: x - me.hold.absX + me.holdOffsetX - var height: int :: y - me.hold.absY + me.holdOffsetY - var minWidth: int - var minHeight: int - var maxWidth: int - var maxHeight: int - do me.hold.getMinMaxSize(&minWidth, &minHeight, &maxWidth, &maxHeight) - if(width < minWidth) - do width :: minWidth - end if - if(width > maxWidth) - do width :: maxWidth - end if - if(height < minHeight) - do height :: minHeight - end if - if(height > maxHeight) - do height :: maxHeight - end if - do me.hold.width :: width - do me.hold.height :: height + do me.holds.head() + while(!me.holds.term()) + var obj: @Obj2d :: me.holds.get() + var width: int :: obj.width + x - me.holdOffsetX + var height: int :: obj.height + y - me.holdOffsetY + var minWidth: int + var minHeight: int + var maxWidth: int + var maxHeight: int + do obj.getMinMaxSize(&minWidth, &minHeight, &maxWidth, &maxHeight) + if(width < minWidth) + do width :: minWidth + end if + if(width > maxWidth) + do width :: maxWidth + end if + if(height < minHeight) + do height :: minHeight + end if + if(height > maxHeight) + do height :: maxHeight + end if + do obj.width :: width + do obj.height :: height + do me.holds.next() + end while end func func moveObj2d(x: int, y: int) - do me.hold.absX :: x + me.holdOffsetX - do me.hold.absY :: y + me.holdOffsetY - do me.stick(&me.hold.absX, &me.hold.absY) + do me.holds.head() + while(!me.holds.term()) + var obj: @Obj2d :: me.holds.get() + do obj.absX :+ x - me.holdOffsetX + do obj.absY :+ y - me.holdOffsetY + do me.stick(&obj.absX, &obj.absY) + do me.holds.next() + end while end func func stick(x: &int, y: &int) - var parent: @Obj2d :: me.hold.parent + { + var parent: @Obj2d :: me.holds.parent if(parent =& null) ret end if @@ -606,7 +695,7 @@ do parent.children.head() while(!parent.children.term()) var child: @Obj2d :: parent.children.get() - if(child <>& me.hold) + if(child <>& me.holds) if((x - child.absX).abs() <= stickingArea) do x :: child.absX end if @@ -622,14 +711,21 @@ end if do parent.children.next() end while + } + end func end class +class Obj2d() - **func ctor() + *func ctor() + do super(me) do me.init("root", 0, 0, 800, 450) end func + +*func cmp(t: kuin@Class): int + ret t =& me ?(0, 1) + end func + +func init(objName: []char, x: int, y: int, width: int, height: int) do me.parent :: null do me.children :: #list diff --git a/src/kuin_editor/doc_ar_wnd.kn b/src/kuin_editor/doc_ar_wnd.kn index 72cdc0f2..44e64f1e 100644 --- a/src/kuin_editor/doc_ar_wnd.kn +++ b/src/kuin_editor/doc_ar_wnd.kn @@ -1,5 +1,6 @@ +class DocArWnd(\doc_ar@DocArBase) - **func ctor() + *func ctor() + do super(me) do me.obj2dRoot :: #@Obj2dWnd end func @@ -32,7 +33,8 @@ ret null end func - **func addCtrlList(ctrlList: wnd@List) + *func addCtrlList(ctrlList: wnd@List) + do super(me, ctrlList) do ctrlList.add("button") do ctrlList.add("check") do ctrlList.add("group") @@ -48,7 +50,8 @@ end class class Obj2dWnd(\doc_ar@Obj2dRoot) - **func ctor() + *func ctor() + do super(me) do me.style :: 0 do me.layered :: false do me.noMinimize :: false @@ -62,11 +65,13 @@ class Obj2dWnd(\doc_ar@Obj2dRoot) do maxHeight :: lib@intMax end func - +**func load(node: xml@Node) + +*func load(node: xml@Node) + do super(me, node) do me.setProps(node, ["style", "layered", "no_minimize", "text"]) end func - +**func save(node: xml@Node) + +*func save(node: xml@Node) + do super(me, node) do node.setAttr("style", me.style.toStr()) do node.setAttr("layered", me.layered.toStr()) do node.setAttr("no_minimize", me.noMinimize.toStr()) @@ -78,13 +83,14 @@ class Obj2dWnd(\doc_ar@Obj2dRoot) var y: float :: (me.absY - pageY) $ float var width: float :: me.width $ float var height: float :: me.height $ float - do draw@rect(x, y, width, height, 16#FFF0F0F0) - do draw@rect(x, y - 30.0, width, 30.0, 16#FFFFFFFF) - do draw@rectLine(x - 1.0, y - 31.0, width + 2.0, height + 32.0, 16#FF1883D7) + do draw@rect(x, y, width, height, 0xFFF0F0F0) + do draw@rect(x, y - 30.0, width, 30.0, 0xFFFFFFFF) + do draw@rectLine(x - 1.0, y - 31.0, width + 2.0, height + 32.0, 0xFF1883D7) do \common@fontP.draw(x + 30.0, y - 30.0 + 6.0, me.text, draw@black) end func - +**func updateProp(listView: wnd@ListView, x: int, y: int) + +*func updateProp(listView: wnd@ListView, x: int, y: int) + do super(me, listView, x, y) var idx: int :: listView.len() do listView.add("style") do listView.setText(idx + 0, 1, style(me.style)) @@ -109,7 +115,8 @@ class Obj2dWnd(\doc_ar@Obj2dRoot) end func end func - +**func setProp(prop: []char, value: []char) + +*func setProp(prop: []char, value: []char) + do super(me, prop, value) switch(prop) case "style" do me.style :: style(value) @@ -142,24 +149,28 @@ class Obj2dWnd(\doc_ar@Obj2dRoot) end class class Obj2dWndBase(\doc_ar@Obj2d) - **func ctor() + *func ctor() + do super(me) do me.anchorX :: 0 do me.enabled :: true do me.visible :: true end func - +**func load(node: xml@Node) + +*func load(node: xml@Node) + do super(me, node) do me.setProps(node, ["anchor_x", "anchor_y", "enabled", "visible"]) end func - +**func save(node: xml@Node) + +*func save(node: xml@Node) + do super(me, node) do node.setAttr("anchor_x", me.anchorX.toStr()) do node.setAttr("anchor_y", me.anchorY.toStr()) do node.setAttr("enabled", me.enabled.toStr()) do node.setAttr("visible", me.visible.toStr()) end func - +**func updateProp(listView: wnd@ListView, x: int, y: int) + +*func updateProp(listView: wnd@ListView, x: int, y: int) + do super(me, listView, x, y) var idx: int :: listView.len() do listView.add("anchor_x") do listView.setText(idx + 0, 1, anchor(me.anchorX)) @@ -182,7 +193,8 @@ class Obj2dWndBase(\doc_ar@Obj2d) end func end func - +**func setProp(prop: []char, value: []char) + +*func setProp(prop: []char, value: []char) + do super(me, prop, value) switch(prop) case "anchor_x" do me.anchorX :: anchor(value) @@ -213,7 +225,8 @@ class Obj2dWndBase(\doc_ar@Obj2d) end class class Obj2dBtn(@Obj2dWndBase) - **func ctor() + *func ctor() + do super(me) do me.text :: "button" end func @@ -228,11 +241,13 @@ class Obj2dBtn(@Obj2dWndBase) do maxHeight :: lib@intMax end func - +**func load(node: xml@Node) + +*func load(node: xml@Node) + do super(me, node) do me.setProps(node, ["text"]) end func - +**func save(node: xml@Node) + +*func save(node: xml@Node) + do super(me, node) do node.setAttr("text", me.text) end func @@ -241,18 +256,20 @@ class Obj2dBtn(@Obj2dWndBase) var y: float :: (me.absY - pageY) $ float var width: float :: me.width $ float var height: float :: me.height $ float - do draw@rect(x, y, width, height, 16#FFE1E1E1) - do draw@rectLine(x, y, width, height, 16#FFADADAD) + do draw@rect(x, y, width, height, 0xFFE1E1E1) + do draw@rectLine(x, y, width, height, 0xFFADADAD) do \common@fontP.draw(lib@floor(x + (width - \common@fontP.calcWidth(me.text)) / 2.0), lib@floor(y + (height - \common@fontP.maxHeight()) / 2.0), me.text, draw@black) end func - +**func updateProp(listView: wnd@ListView, x: int, y: int) + +*func updateProp(listView: wnd@ListView, x: int, y: int) + do super(me, listView, x, y) var idx: int :: listView.len() do listView.add("text") do listView.setText(idx + 0, 1, me.text) end func - +**func setProp(prop: []char, value: []char) + +*func setProp(prop: []char, value: []char) + do super(me, prop, value) switch(prop) case "text" do me.text :: value @@ -263,7 +280,8 @@ class Obj2dBtn(@Obj2dWndBase) end class class Obj2dChk(@Obj2dWndBase) - **func ctor() + *func ctor() + do super(me) do me.text :: "check" end func @@ -278,11 +296,13 @@ class Obj2dChk(@Obj2dWndBase) do maxHeight :: lib@intMax end func - +**func load(node: xml@Node) + +*func load(node: xml@Node) + do super(me, node) do me.setProps(node, ["text"]) end func - +**func save(node: xml@Node) + +*func save(node: xml@Node) + do super(me, node) do node.setAttr("text", me.text) end func @@ -291,18 +311,20 @@ class Obj2dChk(@Obj2dWndBase) var y: float :: (me.absY - pageY) $ float var width: float :: me.width $ float var height: float :: me.height $ float - do draw@rect(x, lib@floor(y + (height - 13.0) / 2.0), 13.0, 13.0, 16#FFFFFFFF) - do draw@rectLine(x, lib@floor(y + (height - 13.0) / 2.0), 13.0, 13.0, 16#FF333333) + do draw@rect(x, lib@floor(y + (height - 13.0) / 2.0), 13.0, 13.0, 0xFFFFFFFF) + do draw@rectLine(x, lib@floor(y + (height - 13.0) / 2.0), 13.0, 13.0, 0xFF333333) do \common@fontP.draw(x + 18.0, lib@floor(y + (height - \common@fontP.maxHeight()) / 2.0), me.text, draw@black) end func - +**func updateProp(listView: wnd@ListView, x: int, y: int) + +*func updateProp(listView: wnd@ListView, x: int, y: int) + do super(me, listView, x, y) var idx: int :: listView.len() do listView.add("text") do listView.setText(idx + 0, 1, me.text) end func - +**func setProp(prop: []char, value: []char) + +*func setProp(prop: []char, value: []char) + do super(me, prop, value) switch(prop) case "text" do me.text :: value @@ -313,7 +335,8 @@ class Obj2dChk(@Obj2dWndBase) end class class Obj2dGroup(@Obj2dWndBase) - **func ctor() + *func ctor() + do super(me) do me.text :: "group" end func @@ -328,11 +351,13 @@ class Obj2dGroup(@Obj2dWndBase) do maxHeight :: lib@intMax end func - +**func load(node: xml@Node) + +*func load(node: xml@Node) + do super(me, node) do me.setProps(node, ["text"]) end func - +**func save(node: xml@Node) + +*func save(node: xml@Node) + do super(me, node) do node.setAttr("text", me.text) end func @@ -341,17 +366,19 @@ class Obj2dGroup(@Obj2dWndBase) var y: float :: (me.absY - pageY) $ float var width: float :: me.width $ float var height: float :: me.height $ float - do draw@rectLine(x, y + 6.0, width, height - 6.0, 16#FFDCDCDC) + do draw@rectLine(x, y + 6.0, width, height - 6.0, 0xFFDCDCDC) do \common@fontP.draw(x + 8.0, y + 0.0, me.text, draw@black) end func - +**func updateProp(listView: wnd@ListView, x: int, y: int) + +*func updateProp(listView: wnd@ListView, x: int, y: int) + do super(me, listView, x, y) var idx: int :: listView.len() do listView.add("text") do listView.setText(idx + 0, 1, me.text) end func - +**func setProp(prop: []char, value: []char) + +*func setProp(prop: []char, value: []char) + do super(me, prop, value) switch(prop) case "text" do me.text :: value @@ -362,7 +389,8 @@ class Obj2dGroup(@Obj2dWndBase) end class class Obj2dLabel(@Obj2dWndBase) - **func ctor() + *func ctor() + do super(me) do me.text :: "label" end func @@ -377,11 +405,13 @@ class Obj2dLabel(@Obj2dWndBase) do maxHeight :: lib@intMax end func - +**func load(node: xml@Node) + +*func load(node: xml@Node) + do super(me, node) do me.setProps(node, ["text"]) end func - +**func save(node: xml@Node) + +*func save(node: xml@Node) + do super(me, node) do node.setAttr("text", me.text) end func @@ -390,17 +420,19 @@ class Obj2dLabel(@Obj2dWndBase) var y: float :: (me.absY - pageY) $ float var width: float :: me.width $ float var height: float :: me.height $ float - do draw@rect(x, y, width, height, 16#FFEEEEEE) + do draw@rect(x, y, width, height, 0xFFEEEEEE) do \common@fontP.draw(x, y, me.text, draw@black) end func - +**func updateProp(listView: wnd@ListView, x: int, y: int) + +*func updateProp(listView: wnd@ListView, x: int, y: int) + do super(me, listView, x, y) var idx: int :: listView.len() do listView.add("text") do listView.setText(idx + 0, 1, me.text) end func - +**func setProp(prop: []char, value: []char) + +*func setProp(prop: []char, value: []char) + do super(me, prop, value) switch(prop) case "text" do me.text :: value @@ -411,7 +443,8 @@ class Obj2dLabel(@Obj2dWndBase) end class class Obj2dList(@Obj2dWndBase) - **func ctor() + *func ctor() + do super(me) end func +*func getName(): []char @@ -425,10 +458,12 @@ class Obj2dList(@Obj2dWndBase) do maxHeight :: lib@intMax end func - +**func load(node: xml@Node) + +*func load(node: xml@Node) + do super(me, node) end func - +**func save(node: xml@Node) + +*func save(node: xml@Node) + do super(me, node) end func +*func draw(pageX: int, pageY: int) @@ -436,20 +471,23 @@ class Obj2dList(@Obj2dWndBase) var y: float :: (me.absY - pageY) $ float var width: float :: me.width $ float var height: float :: me.height $ float - do draw@rect(x, y, width, height, 16#FFFFFFFF) - do draw@rectLine(x, y, width, height, 16#FF828790) + do draw@rect(x, y, width, height, 0xFFFFFFFF) + do draw@rectLine(x, y, width, height, 0xFF828790) do \common@fontP.draw(x + 5.0, y + 3.0, "list", draw@black) end func - +**func updateProp(listView: wnd@ListView, x: int, y: int) + +*func updateProp(listView: wnd@ListView, x: int, y: int) + do super(me, listView, x, y) end func - +**func setProp(prop: []char, value: []char) + +*func setProp(prop: []char, value: []char) + do super(me, prop, value) end func end class class Obj2dListView(@Obj2dWndBase) - **func ctor() + *func ctor() + do super(me) end func +*func getName(): []char @@ -463,10 +501,12 @@ class Obj2dListView(@Obj2dWndBase) do maxHeight :: lib@intMax end func - +**func load(node: xml@Node) + +*func load(node: xml@Node) + do super(me, node) end func - +**func save(node: xml@Node) + +*func save(node: xml@Node) + do super(me, node) end func +*func draw(pageX: int, pageY: int) @@ -474,20 +514,23 @@ class Obj2dListView(@Obj2dWndBase) var y: float :: (me.absY - pageY) $ float var width: float :: me.width $ float var height: float :: me.height $ float - do draw@rect(x, y, width, height, 16#FFFFFFFF) - do draw@rectLine(x, y, width, height, 16#FF828790) + do draw@rect(x, y, width, height, 0xFFFFFFFF) + do draw@rectLine(x, y, width, height, 0xFF828790) do \common@fontP.draw(x + 5.0, y + 3.0, "list_view", draw@black) end func - +**func updateProp(listView: wnd@ListView, x: int, y: int) + +*func updateProp(listView: wnd@ListView, x: int, y: int) + do super(me, listView, x, y) end func - +**func setProp(prop: []char, value: []char) + +*func setProp(prop: []char, value: []char) + do super(me, prop, value) end func end class class Obj2dDraw(@Obj2dWndBase) - **func ctor() + *func ctor() + do super(me) do me.equalMagnification :: false end func @@ -502,11 +545,13 @@ class Obj2dDraw(@Obj2dWndBase) do maxHeight :: lib@intMax end func - +**func load(node: xml@Node) + +*func load(node: xml@Node) + do super(me, node) do me.setProps(node, ["equal_magnification"]) end func - +**func save(node: xml@Node) + +*func save(node: xml@Node) + do super(me, node) do node.setAttr("equal_magnification", me.equalMagnification.toStr()) end func @@ -515,16 +560,18 @@ class Obj2dDraw(@Obj2dWndBase) var y: float :: (me.absY - pageY) $ float var width: float :: me.width $ float var height: float :: me.height $ float - do draw@rect(x, y, width, height, 16#FF000000) + do draw@rect(x, y, width, height, 0xFF000000) end func - +**func updateProp(listView: wnd@ListView, x: int, y: int) + +*func updateProp(listView: wnd@ListView, x: int, y: int) + do super(me, listView, x, y) var idx: int :: listView.len() do listView.add("equal_magnification") do listView.setText(idx + 0, 1, me.equalMagnification.toStr()) end func - +**func setProp(prop: []char, value: []char) + +*func setProp(prop: []char, value: []char) + do super(me, prop, value) switch(prop) case "equal_magnification" do me.equalMagnification :: value = "true" @@ -535,7 +582,8 @@ class Obj2dDraw(@Obj2dWndBase) end class class Obj2dRadio(@Obj2dWndBase) - **func ctor() + *func ctor() + do super(me) do me.text :: "radio" end func @@ -550,11 +598,13 @@ class Obj2dRadio(@Obj2dWndBase) do maxHeight :: lib@intMax end func - +**func load(node: xml@Node) + +*func load(node: xml@Node) + do super(me, node) do me.setProps(node, ["text"]) end func - +**func save(node: xml@Node) + +*func save(node: xml@Node) + do super(me, node) do node.setAttr("text", me.text) end func @@ -563,18 +613,20 @@ class Obj2dRadio(@Obj2dWndBase) var y: float :: (me.absY - pageY) $ float var width: float :: me.width $ float var height: float :: me.height $ float - do draw@circle(x + 6.5, y + height / 2.0, 6.5, 6.5, 16#FF333333) - do draw@circle(x + 6.5, y + height / 2.0, 5.5, 5.5, 16#FFFFFFFF) + do draw@circle(x + 6.5, y + height / 2.0, 6.5, 6.5, 0xFF333333) + do draw@circle(x + 6.5, y + height / 2.0, 5.5, 5.5, 0xFFFFFFFF) do \common@fontP.draw(x + 18.0, lib@floor(y + (height - \common@fontP.maxHeight()) / 2.0), me.text, draw@black) end func - +**func updateProp(listView: wnd@ListView, x: int, y: int) + +*func updateProp(listView: wnd@ListView, x: int, y: int) + do super(me, listView, x, y) var idx: int :: listView.len() do listView.add("text") do listView.setText(idx + 0, 1, me.text) end func - +**func setProp(prop: []char, value: []char) + +*func setProp(prop: []char, value: []char) + do super(me, prop, value) switch(prop) case "text" do me.text :: value @@ -585,7 +637,8 @@ class Obj2dRadio(@Obj2dWndBase) end class class Obj2dEdit(@Obj2dWndBase) - **func ctor() + *func ctor() + do super(me) do me.readonly :: false end func @@ -600,11 +653,13 @@ class Obj2dEdit(@Obj2dWndBase) do maxHeight :: lib@intMax end func - +**func load(node: xml@Node) + +*func load(node: xml@Node) + do super(me, node) do me.setProps(node, ["readonly"]) end func - +**func save(node: xml@Node) + +*func save(node: xml@Node) + do super(me, node) do node.setAttr("readonly", me.readonly.toStr()) end func @@ -613,18 +668,20 @@ class Obj2dEdit(@Obj2dWndBase) var y: float :: (me.absY - pageY) $ float var width: float :: me.width $ float var height: float :: me.height $ float - do draw@rect(x, y, width, height, 16#FFFFFFFF) - do draw@rectLine(x, y, width, height, 16#FF7A7A7A) + do draw@rect(x, y, width, height, 0xFFFFFFFF) + do draw@rectLine(x, y, width, height, 0xFF7A7A7A) do \common@fontP.draw(x + 5.0, y + 3.0, "edit", draw@black) end func - +**func updateProp(listView: wnd@ListView, x: int, y: int) + +*func updateProp(listView: wnd@ListView, x: int, y: int) + do super(me, listView, x, y) var idx: int :: listView.len() do listView.add("readonly") do listView.setText(idx + 0, 1, me.readonly.toStr()) end func - +**func setProp(prop: []char, value: []char) + +*func setProp(prop: []char, value: []char) + do super(me, prop, value) switch(prop) case "readonly" do me.readonly :: value = "true" @@ -635,7 +692,8 @@ class Obj2dEdit(@Obj2dWndBase) end class class Obj2dEditMulti(@Obj2dWndBase) - **func ctor() + *func ctor() + do super(me) do me.readonly :: false end func @@ -650,11 +708,13 @@ class Obj2dEditMulti(@Obj2dWndBase) do maxHeight :: lib@intMax end func - +**func load(node: xml@Node) + +*func load(node: xml@Node) + do super(me, node) do me.setProps(node, ["readonly"]) end func - +**func save(node: xml@Node) + +*func save(node: xml@Node) + do super(me, node) do node.setAttr("readonly", me.readonly.toStr()) end func @@ -663,18 +723,20 @@ class Obj2dEditMulti(@Obj2dWndBase) var y: float :: (me.absY - pageY) $ float var width: float :: me.width $ float var height: float :: me.height $ float - do draw@rect(x, y, width, height, 16#FFFFFFFF) - do draw@rectLine(x, y, width, height, 16#FF7A7A7A) + do draw@rect(x, y, width, height, 0xFFFFFFFF) + do draw@rectLine(x, y, width, height, 0xFF7A7A7A) do \common@fontP.draw(x + 5.0, y + 3.0, "edit_multi", draw@black) end func - +**func updateProp(listView: wnd@ListView, x: int, y: int) + +*func updateProp(listView: wnd@ListView, x: int, y: int) + do super(me, listView, x, y) var idx: int :: listView.len() do listView.add("readonly") do listView.setText(idx + 0, 1, me.readonly.toStr()) end func - +**func setProp(prop: []char, value: []char) + +*func setProp(prop: []char, value: []char) + do super(me, prop, value) switch(prop) case "readonly" do me.readonly :: value = "true" @@ -685,7 +747,8 @@ class Obj2dEditMulti(@Obj2dWndBase) end class class Obj2dTree(@Obj2dWndBase) - **func ctor() + *func ctor() + do super(me) end func +*func getName(): []char @@ -698,10 +761,12 @@ class Obj2dTree(@Obj2dWndBase) do maxHeight :: lib@intMax end func - +**func load(node: xml@Node) + +*func load(node: xml@Node) + do super(me, node) end func - +**func save(node: xml@Node) + +*func save(node: xml@Node) + do super(me, node) end func +*func draw(pageX: int, pageY: int) @@ -709,14 +774,16 @@ class Obj2dTree(@Obj2dWndBase) var y: float :: (me.absY - pageY) $ float var width: float :: me.width $ float var height: float :: me.height $ float - do draw@rect(x, y, width, height, 16#FFFFFFFF) - do draw@rectLine(x, y, width, height, 16#FF828790) + do draw@rect(x, y, width, height, 0xFFFFFFFF) + do draw@rectLine(x, y, width, height, 0xFF828790) do \common@fontP.draw(x + 5.0, y + 3.0, "tree", draw@black) end func - +**func updateProp(listView: wnd@ListView, x: int, y: int) + +*func updateProp(listView: wnd@ListView, x: int, y: int) + do super(me, listView, x, y) end func - +**func setProp(prop: []char, value: []char) + +*func setProp(prop: []char, value: []char) + do super(me, prop, value) end func end class diff --git a/src/kuin_editor/doc_src.kn b/src/kuin_editor/doc_src.kn index b675d9b6..6272d4ae 100644 --- a/src/kuin_editor/doc_src.kn +++ b/src/kuin_editor/doc_src.kn @@ -25,20 +25,21 @@ var srcCharColor: []int +func init() do @srcCharColor :: #[%max $ @CharColor $ int]int - do @srcCharColor[%none $ @CharColor $ int] :: 16#FF999999 - do @srcCharColor[%identifier $ @CharColor $ int] :: 16#FF009BEA - do @srcCharColor[%global $ @CharColor $ int] :: 16#FFCC00F6 - do @srcCharColor[%reserved $ @CharColor $ int] :: 16#FF1400F6 - do @srcCharColor[%num $ @CharColor $ int] :: 16#FFEA0062 - do @srcCharColor[%str $ @CharColor $ int] :: 16#FFEA0062 - do @srcCharColor[%char_ $ @CharColor $ int] :: 16#FFEA0062 - do @srcCharColor[%lineComment $ @CharColor $ int] :: 16#FF1EB000 - do @srcCharColor[%comment $ @CharColor $ int] :: 16#FF1EB000 - do @srcCharColor[%symbol $ @CharColor $ int] :: 16#FF666666 + do @srcCharColor[%none $ @CharColor $ int] :: 0xFF999999 + do @srcCharColor[%identifier $ @CharColor $ int] :: 0xFF009BEA + do @srcCharColor[%global $ @CharColor $ int] :: 0xFFCC00F6 + do @srcCharColor[%reserved $ @CharColor $ int] :: 0xFF1400F6 + do @srcCharColor[%num $ @CharColor $ int] :: 0xFFEA0062 + do @srcCharColor[%str $ @CharColor $ int] :: 0xFFEA0062 + do @srcCharColor[%char_ $ @CharColor $ int] :: 0xFFEA0062 + do @srcCharColor[%lineComment $ @CharColor $ int] :: 0xFF1EB000 + do @srcCharColor[%comment $ @CharColor $ int] :: 0xFF1EB000 + do @srcCharColor[%symbol $ @CharColor $ int] :: 0xFF666666 end func +class DocSrc(\doc@Doc) - **func ctor() + *func ctor() + do super(me) do me.src :: #Src do me.src.src :: null do me.src.color :: null @@ -123,7 +124,7 @@ end func var left: int :: me.lineNumWidth - me.pageX * \common@cellWidth var x: int :: 0 for j(0, ^str) - assert j = ^str | str[j] <> 16#01 $ char & str[j] <> '\n' + assert j = ^str | str[j] <> 0x01 $ char & str[j] <> '\n' var x2: int :: left + x * \common@cellWidth if(x2 >= width) break j @@ -159,11 +160,11 @@ end func if(inArea) do draw@rect(textX, textY, (\common@cellWidth * (charWidth <= 0 ?(1, charWidth))) $ float, \common@cellHeight $ float, colorAreaBack) do color :: draw@white - elif(me.src.color[me.pageY + i][j].and(16#80b8) <> 0 $ @CharColor $ bit8) + elif(me.src.color[me.pageY + i][j].and(0x80b8) <> 0 $ @CharColor $ bit8) do draw@rect(textX, textY, (\common@cellWidth * (charWidth <= 0 ?(1, charWidth))) $ float, \common@cellHeight $ float, colorErrBack) do color :: draw@white else - do color :: @srcCharColor[me.src.color[me.pageY + i][j].and(16#7Fb8) $ int] + do color :: @srcCharColor[me.src.color[me.pageY + i][j].and(0x7Fb8) $ int] end if switch(str[j]) case '\t' @@ -191,7 +192,7 @@ end func end while end func - +*func updateTree(tree: wnd@Tree) + +*func updateTree(tree: wnd@TreeMulti) ; TODO: end func @@ -250,11 +251,11 @@ end func end if end if if(^me.src.src[me.cursorY] > 0) - var color: bit8 :: me.src.color[me.areaY][me.areaX].and(16#7Fb8) - while(me.areaX > 0 & me.src.color[me.areaY][me.areaX - 1].and(16#7Fb8) = color) + var color: bit8 :: me.src.color[me.areaY][me.areaX].and(0x7Fb8) + while(me.areaX > 0 & me.src.color[me.areaY][me.areaX - 1].and(0x7Fb8) = color) do me.areaX :- 1 end while - while(me.cursorX < ^me.src.src[me.cursorY] & me.src.color[me.cursorY][me.cursorX].and(16#7Fb8) = color) + while(me.cursorX < ^me.src.src[me.cursorY] & me.src.color[me.cursorY][me.cursorX].and(0x7Fb8) = color) do me.cursorX :+ 1 end while end if @@ -822,13 +823,13 @@ end func end if end func - const colorLineNum: int :: 16#FFFF7F7F - const colorAreaBack: int :: 16#FF808080 - const colorErrBack: int :: 16#FFFF3333 + const colorLineNum: int :: 0xFFFF7F7F + const colorAreaBack: int :: 0xFF808080 + const colorErrBack: int :: 0xFFFF3333 enum LineFlag - none :: 16#00 - nextLine :: 16#01 + none :: 0x00 + nextLine :: 0x01 end enum class Src() @@ -883,11 +884,11 @@ end func func charWidth(c: char, x: int): int if(c = '\t') ret 4 - x % 4 - elif(c $ int <= 16#1F) + elif(c $ int <= 0x1F) ret 0 - elif(c $ int <= 16#7E) + elif(c $ int <= 0x7E) ret 1 - elif(c $ int <= 16#A0) + elif(c $ int <= 0xA0) ret 0 end if ret 2 @@ -1428,7 +1429,7 @@ end func ret me.src.src[y].sub(first, last - first).trim() func keyword(color: bit8): bool - do color :: color.and(16#7Fb8) + do color :: color.and(0x7Fb8) ret color = %identifier $ @CharColor $ bit8 | color = %global $ @CharColor $ bit8 | color = %reserved $ @CharColor $ bit8 end func end func diff --git a/src/kuin_editor/form.kn b/src/kuin_editor/form.kn index d4472015..d7a62a98 100644 --- a/src/kuin_editor/form.kn +++ b/src/kuin_editor/form.kn @@ -1,5 +1,5 @@ +var wndMain: wnd@Wnd -+var treeItem: wnd@Tree ++var treeItem: wnd@TreeMulti +var listInfo: wnd@List var editFile: wnd@Edit +var drawEditor: wnd@Draw @@ -25,6 +25,7 @@ var popupMainHelp: wnd@Popup var lockingEditor: bool var lockPropOnChange: bool +var lockTreeItemOnSel: bool var textLog: []char var drag: bool @@ -34,7 +35,7 @@ var drag: bool do @wndMain.onClose :: @wndMainOnClose do @wndMain.onActivate :: @wndMainOnActivate do @wndMain.onPushMenu :: @wndMainOnPushMenu - do @treeItem :: wnd@makeTree(@wndMain, 12, 12, 244, 466, %fix, %fix) + do @treeItem :: wnd@makeTreeMulti(@wndMain, 12, 12, 244, 466, %fix, %fix) do @treeItem.draggable(true) do @treeItem.allowDraggingToRoot(false) do @treeItem.onSel :: @treeItemOnSel @@ -74,41 +75,41 @@ var drag: bool do @listFile.onSel :: @listFileOnSel do @menuMain :: wnd@makeMenu() do @popupMainFile :: wnd@makePopup() - do @popupMainFile.add(16#0001, \common@langEn ?("&New\tCtrl+N", "新規作成(&N)\tCtrl+N")) - do @popupMainFile.add(16#0002, \common@langEn ?("&Load...\tCtrl+O", "開く(&O)\tCtrl+O")) + do @popupMainFile.add(0x0001, \common@langEn ?("&New\tCtrl+N", "新規作成(&N)\tCtrl+N")) + do @popupMainFile.add(0x0002, \common@langEn ?("&Load...\tCtrl+O", "開く(&O)\tCtrl+O")) do @popupMainFile.addLine() - do @popupMainFile.add(16#0003, \common@langEn ?("&Save All\tCtrl+S", "すべて保存(&S)\tCtrl+S")) - do @popupMainFile.add(16#0004, \common@langEn ?("Save &As...\tCtrl+Shift+S", "名前を付けて保存(&A)\tCtrl+Shift+S")) + do @popupMainFile.add(0x0003, \common@langEn ?("&Save All\tCtrl+S", "すべて保存(&S)\tCtrl+S")) + do @popupMainFile.add(0x0004, \common@langEn ?("Save &As...\tCtrl+Shift+S", "名前を付けて保存(&A)\tCtrl+Shift+S")) do @popupMainFile.addLine() - do @popupMainFile.add(16#0005, \common@langEn ?("E&xit\tCtrl+Q", "終了(&E)\tCtrl+Q")) + do @popupMainFile.add(0x0005, \common@langEn ?("E&xit\tCtrl+Q", "終了(&E)\tCtrl+Q")) do @menuMain.addPopup(\common@langEn ?("&File", "ファイル(&F)"), @popupMainFile) do @popupMainEdit :: wnd@makePopup() - do @popupMainEdit.add(16#0030, \common@langEn ?("Add Ne&w File\tCtrl+Shift+A", "新しいファイルを追加(&W)\tCtrl+Shift+A")) - do @popupMainEdit.add(16#0031, \common@langEn ?("Add Existin&g File", "既存のファイルを追加(&G)")) + do @popupMainEdit.add(0x0030, \common@langEn ?("Add Ne&w File\tCtrl+Shift+A", "新しいファイルを追加(&W)\tCtrl+Shift+A")) + do @popupMainEdit.add(0x0031, \common@langEn ?("Add Existin&g File", "既存のファイルを追加(&G)")) do @popupMainEdit.addLine() - do @popupMainEdit.add(16#0032, \common@langEn ?("&Undo\tCtrl+Z", "元に戻す(&U)\tCtrl+Z")) - do @popupMainEdit.add(16#0033, \common@langEn ?("&Redo\tCtrl+Shift+Z, Ctrl+Y", "やり直し(&R)\tCtrl+Shift+Z, Ctrl+Y")) + do @popupMainEdit.add(0x0032, \common@langEn ?("&Undo\tCtrl+Z", "元に戻す(&U)\tCtrl+Z")) + do @popupMainEdit.add(0x0033, \common@langEn ?("&Redo\tCtrl+Shift+Z, Ctrl+Y", "やり直し(&R)\tCtrl+Shift+Z, Ctrl+Y")) do @popupMainEdit.addLine() - do @popupMainEdit.add(16#0034, \common@langEn ?("Cu&t\tCtrl+X", "切り取り(&T)\tCtrl+X")) - do @popupMainEdit.add(16#0035, \common@langEn ?("&Copy\tCtrl+C", "コピー(&C)\tCtrl+C")) - do @popupMainEdit.add(16#0036, \common@langEn ?("&Paste\tCtrl+V", "貼り付け(&P)\tCtrl+V")) - do @popupMainEdit.add(16#0037, \common@langEn ?("&Delete\tDel", "削除(&D)\tDel")) - do @popupMainEdit.add(16#0038, \common@langEn ?("Select &All\tCtrl+A", "すべて選択(&A)\tCtrl+A")) + do @popupMainEdit.add(0x0034, \common@langEn ?("Cu&t\tCtrl+X", "切り取り(&T)\tCtrl+X")) + do @popupMainEdit.add(0x0035, \common@langEn ?("&Copy\tCtrl+C", "コピー(&C)\tCtrl+C")) + do @popupMainEdit.add(0x0036, \common@langEn ?("&Paste\tCtrl+V", "貼り付け(&P)\tCtrl+V")) + do @popupMainEdit.add(0x0037, \common@langEn ?("&Delete\tDel", "削除(&D)\tDel")) + do @popupMainEdit.add(0x0038, \common@langEn ?("Select &All\tCtrl+A", "すべて選択(&A)\tCtrl+A")) do @popupMainEdit.addLine() - do @popupMainEdit.add(16#0039, \common@langEn ?("&Find\tCtrl+F", "検索(&F)\tCtrl+F")) - do @popupMainEdit.add(16#003A, \common@langEn ?("&Replace\tCtrl+H", "置換(&R)\tCtrl+H")) - do @popupMainEdit.add(16#003B, \common@langEn ?("Find Pre&vious\tShift+F3", "前を検索(&V)\tShift+F3")) - do @popupMainEdit.add(16#003C, \common@langEn ?("Find &Next\tF3", "次を検索(&N)\tF3")) + do @popupMainEdit.add(0x0039, \common@langEn ?("&Find\tCtrl+F", "検索(&F)\tCtrl+F")) + do @popupMainEdit.add(0x003A, \common@langEn ?("&Replace\tCtrl+H", "置換(&R)\tCtrl+H")) + do @popupMainEdit.add(0x003B, \common@langEn ?("Find Pre&vious\tShift+F3", "前を検索(&V)\tShift+F3")) + do @popupMainEdit.add(0x003C, \common@langEn ?("Find &Next\tF3", "次を検索(&N)\tF3")) do @menuMain.addPopup(\common@langEn ?("&Edit", "編集(&E)"), @popupMainEdit) do @popupMainBuild :: wnd@makePopup() - do @popupMainBuild.add(16#0020, \common@langEn ?("&Compile && Run\tF5", "コンパイル&実行(&C)\tF5")) + do @popupMainBuild.add(0x0020, \common@langEn ?("&Compile && Run\tF5", "コンパイル&実行(&C)\tF5")) do @popupMainBuild.addLine() - do @popupMainBuild.add(16#0021, \common@langEn ?("&Release Build...\tCtrl+Shift+B", "リリースビルド(&R)...\tCtrl+Shift+B")) + do @popupMainBuild.add(0x0021, \common@langEn ?("&Release Build...\tCtrl+Shift+B", "リリースビルド(&R)...\tCtrl+Shift+B")) do @menuMain.addPopup(\common@langEn ?("&Build", "ビルド(&B)"), @popupMainBuild) do @popupMainHelp :: wnd@makePopup() - do @popupMainHelp.add(16#0010, \common@langEn ?("&View Help\tF1", "ヘルプの表示(&V)\tF1")) + do @popupMainHelp.add(0x0010, \common@langEn ?("&View Help\tF1", "ヘルプの表示(&V)\tF1")) do @popupMainHelp.addLine() - do @popupMainHelp.add(16#0011, \common@langEn ?("&About Kuin...", "Kuinについて(&A)...")) + do @popupMainHelp.add(0x0011, \common@langEn ?("&About Kuin...", "Kuinについて(&A)...")) do @menuMain.addPopup(\common@langEn ?("&Help", "ヘルプ(&H)"), @popupMainHelp) do @wndMain.setMenu(@menuMain) @@ -116,6 +117,7 @@ var drag: bool do @lockingEditor :: false do @lockPropOnChange :: false + do @lockTreeItemOnSel :: false do @textLog :: "" do @drag :: false end func @@ -151,22 +153,22 @@ func onKeyPress(key: wnd@Key, shiftCtrl: wnd@ShiftCtrl): bool do \find@wndFind.close() ret true case %f3 - do @wndMainOnPushMenu(@wndMain, 16#003C) + do @wndMainOnPushMenu(@wndMain, 0x003C) ret true end switch case %shift switch(key) case %f3 - do @wndMainOnPushMenu(@wndMain, 16#003B) + do @wndMainOnPushMenu(@wndMain, 0x003B) ret true end switch case %ctrl switch(key) case %f - do @wndMainOnPushMenu(@wndMain, 16#0039) + do @wndMainOnPushMenu(@wndMain, 0x0039) ret true case %h - do @wndMainOnPushMenu(@wndMain, 16#003A) + do @wndMainOnPushMenu(@wndMain, 0x003A) ret true end switch end switch @@ -180,7 +182,7 @@ func onKeyPress(key: wnd@Key, shiftCtrl: wnd@ShiftCtrl): bool switch(key) case %del if(!editFocused) - do @wndMainOnPushMenu(@wndMain, 16#0037) + do @wndMainOnPushMenu(@wndMain, 0x0037) ret true end if case %esc @@ -192,13 +194,13 @@ func onKeyPress(key: wnd@Key, shiftCtrl: wnd@ShiftCtrl): bool ret true end if case %f1 - do @wndMainOnPushMenu(@wndMain, 16#0010) + do @wndMainOnPushMenu(@wndMain, 0x0010) ret true case %f3 - do @wndMainOnPushMenu(@wndMain, 16#003C) + do @wndMainOnPushMenu(@wndMain, 0x003C) ret true case %f5 - do @wndMainOnPushMenu(@wndMain, 16#0020) + do @wndMainOnPushMenu(@wndMain, 0x0020) ret true case %f12 var definitionPos: \src@Pos :: \completion@getDefinitionPos() @@ -209,73 +211,73 @@ func onKeyPress(key: wnd@Key, shiftCtrl: wnd@ShiftCtrl): bool case %shift switch(key) case %f3 - do @wndMainOnPushMenu(@wndMain, 16#003B) + do @wndMainOnPushMenu(@wndMain, 0x003B) ret true end switch case %ctrl switch(key) case %a if(!editFocused) - do @wndMainOnPushMenu(@wndMain, 16#0038) + do @wndMainOnPushMenu(@wndMain, 0x0038) ret true end if case %c if(!editFocused) - do @wndMainOnPushMenu(@wndMain, 16#0035) + do @wndMainOnPushMenu(@wndMain, 0x0035) ret true end if case %f - do @wndMainOnPushMenu(@wndMain, 16#0039) + do @wndMainOnPushMenu(@wndMain, 0x0039) ret true case %h - do @wndMainOnPushMenu(@wndMain, 16#003A) + do @wndMainOnPushMenu(@wndMain, 0x003A) ret true case %n - do @wndMainOnPushMenu(@wndMain, 16#0001) + do @wndMainOnPushMenu(@wndMain, 0x0001) ret true case %o - do @wndMainOnPushMenu(@wndMain, 16#0002) + do @wndMainOnPushMenu(@wndMain, 0x0002) ret true case %s - do @wndMainOnPushMenu(@wndMain, 16#0003) + do @wndMainOnPushMenu(@wndMain, 0x0003) ret true case %q - do @wndMainOnPushMenu(@wndMain, 16#0005) + do @wndMainOnPushMenu(@wndMain, 0x0005) ret true case %v if(!editFocused) - do @wndMainOnPushMenu(@wndMain, 16#0036) + do @wndMainOnPushMenu(@wndMain, 0x0036) ret true end if case %x if(!editFocused) - do @wndMainOnPushMenu(@wndMain, 16#0034) + do @wndMainOnPushMenu(@wndMain, 0x0034) ret true end if case %y if(!editFocused) - do @wndMainOnPushMenu(@wndMain, 16#0033) + do @wndMainOnPushMenu(@wndMain, 0x0033) ret true end if case %z if(!editFocused) - do @wndMainOnPushMenu(@wndMain, 16#0032) + do @wndMainOnPushMenu(@wndMain, 0x0032) ret true end if end switch case (%shift $ wnd@ShiftCtrl).or(%ctrl) switch(key) case %a - do @wndMainOnPushMenu(@wndMain, 16#0030) + do @wndMainOnPushMenu(@wndMain, 0x0030) case %b - do @wndMainOnPushMenu(@wndMain, 16#0021) + do @wndMainOnPushMenu(@wndMain, 0x0021) ret true case %s - do @wndMainOnPushMenu(@wndMain, 16#0004) + do @wndMainOnPushMenu(@wndMain, 0x0004) ret true case %z if(!editFocused) - do @wndMainOnPushMenu(@wndMain, 16#0033) + do @wndMainOnPushMenu(@wndMain, 0x0033) ret true end if end switch @@ -312,7 +314,7 @@ end func func wndMainOnPushMenu(wnd: wnd@WndBase, id: int) switch(id) - case 16#0001 + case 0x0001 if(@lockingEditor) do @showMsgRunning() ret @@ -320,7 +322,7 @@ func wndMainOnPushMenu(wnd: wnd@WndBase, id: int) if (\src@chkChanged()) do \src@newMainSrc() end if - case 16#0002 + case 0x0002 if(@lockingEditor) do @showMsgRunning() ret @@ -331,15 +333,15 @@ func wndMainOnPushMenu(wnd: wnd@WndBase, id: int) do \src@openMainSrc(file) end if end if - case 16#0003 + case 0x0003 do \src@saveAll() - case 16#0004 + case 0x0004 do \src@saveMainSrc() - case 16#0005 + case 0x0005 do @wndMain.close() - case 16#0010 + case 0x0010 do task@open("http://kuina.ch/kuin") - case 16#0011 + case 0x0011 block var major: int var minor: int @@ -347,56 +349,59 @@ func wndMainOnPushMenu(wnd: wnd@WndBase, id: int) do \dll@version(&major, &minor, µ) do wnd@msgBox(@wndMain, "Kuin Programming Language\nVersion \{major}.\{minor}.\{micro}\n(C)Kuina-chan", \common@title, %info, %ok) end block - case 16#0020 + case 0x0020 if(@lockingEditor) do @showMsgRunning() ret end if do @btnCompileOnPush(@btnCompile) - case 16#0021 + case 0x0021 if(@lockingEditor) do @showMsgRunning() ret end if do @btnRlsOnPush(@btnRls) - case 16#0030 + case 0x0030 if(@lockingEditor) do @showMsgRunning() ret end if do \add_file@addNewFile() - case 16#0031 + case 0x0031 if(@lockingEditor) do @showMsgRunning() ret end if do \add_file@addExistingFile() - case 16#0032 + case 0x0032 do \src@curDoc.cmdUndo() - case 16#0033 + case 0x0033 do \src@curDoc.cmdRedo() - case 16#0034 + case 0x0034 do \src@curDoc.cmdCut() - case 16#0035 + case 0x0035 do \src@curDoc.cmdCopy() - case 16#0036 + case 0x0036 do \src@curDoc.cmdPaste() - case 16#0037 + case 0x0037 do \src@curDoc.cmdDel() - case 16#0038 + case 0x0038 do \src@curDoc.cmdSelAll() - case 16#0039 + case 0x0039 do \find@show(false) - case 16#003A + case 0x003A do \find@show(true) - case 16#003B + case 0x003B do \find@findPrev() - case 16#003C + case 0x003C do \find@findNext() end switch end func func treeItemOnSel(wnd: wnd@WndBase) + if(@lockTreeItemOnSel) + ret + end if do \src@curDoc.treeItemOnSel() end func @@ -693,11 +698,13 @@ end func end func +func updateTree() + do @lockTreeItemOnSel :: true do @treeItem.setRedraw(false) do @treeItem.clear() do \src@curDoc.updateTree(@treeItem) do @treeItem.expand(true) do @treeItem.setRedraw(true) + do @lockTreeItemOnSel :: false end func +func updateList() diff --git a/src/kuin_editor/src.kn b/src/kuin_editor/src.kn index 3c4f38f0..4eb82a18 100644 --- a/src/kuin_editor/src.kn +++ b/src/kuin_editor/src.kn @@ -411,8 +411,8 @@ end func var y: int :: pos.row - 1 var color: bit8 if(moveWordTop(doc2.src.src, doc2.src.color, &x, &y, &color)) - while(x < ^doc2.src.color[y] & doc2.src.color[y][x].and(16#7Fb8) = color) - do doc2.src.color[y][x] :: doc2.src.color[y][x].or(16#80b8) + while(x < ^doc2.src.color[y] & doc2.src.color[y][x].and(0x7Fb8) = color) + do doc2.src.color[y][x] :: doc2.src.color[y][x].or(0x80b8) do x :+ 1 end while end if @@ -425,7 +425,7 @@ end func elif(^srcColor <= y) do y :: ^srcColor - 1 end if - if(1 <= x & x < ^srcColor[y] & (src[y][x] = ' ' | src[y][x] = '\t' | srcColor[y][x].and(16#7Fb8) = %comment $ \doc_src@CharColor $ bit8 | srcColor[y][x].and(16#7Fb8) = %symbol $ \doc_src@CharColor $ bit8)) + if(1 <= x & x < ^srcColor[y] & (src[y][x] = ' ' | src[y][x] = '\t' | srcColor[y][x].and(0x7Fb8) = %comment $ \doc_src@CharColor $ bit8 | srcColor[y][x].and(0x7Fb8) = %symbol $ \doc_src@CharColor $ bit8)) do x :- 1 end if if(x < 0) @@ -434,8 +434,8 @@ end func do x :: ^srcColor[y] - 1 end if if(^srcColor[y] <> 0) - do color :: srcColor[y][x].and(16#7Fb8) - while(x >= 1 & srcColor[y][x - 1].and(16#7Fb8) = color) + do color :: srcColor[y][x].and(0x7Fb8) + while(x >= 1 & srcColor[y][x - 1].and(0x7Fb8) = color) do x :- 1 end while ret true diff --git a/src/lib_common/lib.c b/src/lib_common/lib.c index 52a85f96..ba3c1f0c 100644 --- a/src/lib_common/lib.c +++ b/src/lib_common/lib.c @@ -20,7 +20,7 @@ EXPORT void* _cmdLine(void) { int i; void** ptr; - U8* result = (U8*)AllocMem(0x10 + sizeof(Char*) * (size_t)(num - 1)); + U8* result = (U8*)AllocMem(0x10 + sizeof(void**) * (size_t)(num - 1)); ((S64*)result)[0] = DefaultRefCntFunc; ((S64*)result)[1] = (S64)(num - 1); ptr = (void**)(result + 0x10); diff --git a/src/lib_common/main.c b/src/lib_common/main.c index 65020b0b..c9c4a5f2 100644 --- a/src/lib_common/main.c +++ b/src/lib_common/main.c @@ -1413,7 +1413,7 @@ EXPORT void _sortDescList(void* me_, const U8* type) MergeSortList(me_, type, False); } -EXPORT S64 _find(const void* me_, const U8* type, const void* item, S64 start) +EXPORT S64 _findArray(const void* me_, const U8* type, const void* item, S64 start) { THROWDBG(me_ == NULL, 0xc0000005); size_t size = GetSize(type[1]); @@ -1438,7 +1438,28 @@ EXPORT S64 _find(const void* me_, const U8* type, const void* item, S64 start) return -1; } -EXPORT S64 _findLast(const void* me_, const U8* type, const void* item, S64 start) +EXPORT Bool _findList(const void* me_, const U8* type, const void* item) +{ + THROWDBG(me_ == NULL, 0xc0000005); + size_t size = GetSize(type[1]); + int(*cmp)(const void* a, const void* b) = GetCmpFunc(type + 1); + if (cmp == NULL) + THROW(0xe9170004); + for (; ; ) + { + void* cur = *(void**)((U8*)me_ + 0x20); + if (cur == NULL) + break; + void* value = NULL; + memcpy(&value, (U8*)cur + 0x10, size); + if (cmp(value, item) == 0) + return True; + *(void**)((U8*)me_ + 0x20) = *(void**)((U8*)cur + 0x08); + } + return False; +} + +EXPORT S64 _findLastArray(const void* me_, const U8* type, const void* item, S64 start) { THROWDBG(me_ == NULL, 0xc0000005); size_t size = GetSize(type[1]); @@ -1463,6 +1484,27 @@ EXPORT S64 _findLast(const void* me_, const U8* type, const void* item, S64 star return -1; } +EXPORT Bool _findLastList(const void* me_, const U8* type, const void* item) +{ + THROWDBG(me_ == NULL, 0xc0000005); + size_t size = GetSize(type[1]); + int(*cmp)(const void* a, const void* b) = GetCmpFunc(type + 1); + if (cmp == NULL) + THROW(0xe9170004); + for (; ; ) + { + void* cur = *(void**)((U8*)me_ + 0x20); + if (cur == NULL) + break; + void* value = NULL; + memcpy(&value, (U8*)cur + 0x10, size); + if (cmp(value, item) == 0) + return True; + *(void**)((U8*)me_ + 0x20) = *(void**)cur; + } + return False; +} + EXPORT S64 _findBin(const void* me_, const U8* type, const void* item) { THROWDBG(me_ == NULL, 0xc0000005); diff --git a/src/lib_common/main.h b/src/lib_common/main.h index 746ccbe3..8512ea68 100644 --- a/src/lib_common/main.h +++ b/src/lib_common/main.h @@ -46,8 +46,10 @@ EXPORT void _sortArray(void* me_, const U8* type); EXPORT void _sortDescArray(void* me_, const U8* type); EXPORT void _sortList(void* me_, const U8* type); EXPORT void _sortDescList(void* me_, const U8* type); -EXPORT S64 _find(const void* me_, const U8* type, const void* item, S64 start); -EXPORT S64 _findLast(const void* me_, const U8* type, const void* item, S64 start); +EXPORT S64 _findArray(const void* me_, const U8* type, const void* item, S64 start); +EXPORT Bool _findList(const void* me_, const U8* type, const void* item); +EXPORT S64 _findLastArray(const void* me_, const U8* type, const void* item, S64 start); +EXPORT Bool _findLastList(const void* me_, const U8* type, const void* item); EXPORT S64 _findBin(const void* me_, const U8* type, const void* item); EXPORT void _fill(void* me_, const U8* type, const void* value); EXPORT void* _min(const void* me_, const U8* type); diff --git a/src/lib_math/main.c b/src/lib_math/main.c index 0ccaa665..a1abe32d 100644 --- a/src/lib_math/main.c +++ b/src/lib_math/main.c @@ -260,6 +260,243 @@ EXPORT S64 _factInt(S64 n) return Facts[n]; } +EXPORT S64 _knapsack(const void* weights, const void* values, S64 max_weight, Bool reuse) +{ + THROWDBG(weights == NULL || values == NULL, 0xc0000005); + THROWDBG(*(S64*)((U8*)weights + 0x08) != *(S64*)((U8*)values + 0x08), 0xe9170006); + S64 len = *(S64*)((U8*)weights + 0x08); + const S64* weights2 = (S64*)((U8*)weights + 0x10); + const S64* values2 = (S64*)((U8*)values + 0x10); + S64* dp = (S64*)AllocMem(sizeof(S64) * (size_t)(max_weight + 1)); + S64 i, j; +#if defined(DBG) + for (i = 0; i < len; i++) + THROWDBG(weights2[i] <= 0, 0xe9170006); +#endif + memset(dp, 0, sizeof(S64) * (size_t)(max_weight + 1)); + if (reuse) + { + for (i = 0; i < len; i++) + { + for (j = weights2[i]; j <= max_weight; j++) + { + S64 value = dp[j - weights2[i]] + values2[i]; + if (dp[j] < value) + dp[j] = value; + } + } + } + else + { + for (i = 0; i < len; i++) + { + for (j = max_weight; j >= weights2[i]; j--) + { + S64 value = dp[j - weights2[i]] + values2[i]; + if (dp[j] < value) + dp[j] = value; + } + } + } + S64 result = dp[max_weight]; + FreeMem(dp); + return result; +} + +EXPORT void* _dijkstra(S64 node_num, const void* from_nodes, const void* to_nodes, const void* values, S64 begin_node) +{ + THROWDBG(from_nodes == NULL || to_nodes == NULL || values == NULL, 0xc0000005); + THROWDBG(*(S64*)((U8*)from_nodes + 0x08) != *(S64*)((U8*)to_nodes + 0x08) || *(S64*)((U8*)to_nodes + 0x08) != *(S64*)((U8*)values + 0x08), 0xe9170006); + THROWDBG(node_num <= 0 || begin_node < 0 || node_num <= begin_node, 0xe9170006); + const S64* from_nodes2 = (S64*)((U8*)from_nodes + 0x10); + const S64* to_nodes2 = (S64*)((U8*)to_nodes + 0x10); + const S64* values2 = (S64*)((U8*)values + 0x10); + S64 len = *(S64*)((U8*)from_nodes + 0x08); + S64 i; +#if defined(DBG) + for (i = 0; i < len; i++) + THROWDBG(from_nodes2[i] < 0 || node_num <= from_nodes2[i] || to_nodes2[i] < 0 || node_num <= to_nodes2[i] || values2[i] < 0, 0xe9170006); +#endif + + U8* result = (U8*)AllocMem(0x10 + sizeof(S64) * (size_t)node_num); + ((S64*)result)[0] = DefaultRefCntFunc; + ((S64*)result)[1] = node_num; + S64* distance = (S64*)(result + 0x10); + for (i = 0; i < node_num; i++) + distance[i] = LLONG_MAX; + distance[begin_node] = 0; + + S64* heap = (S64*)AllocMem(sizeof(S64) * (2 * (size_t)(node_num * len) + 2)); + int heap_cnt = 1; + heap[0] = begin_node; + heap[1] = 0; + while (heap_cnt > 0) + { + S64 item_node = heap[0]; + S64 item_value = heap[1]; + heap_cnt--; + heap[0] = heap[heap_cnt * 2]; + heap[1] = heap[heap_cnt * 2 + 1]; + { + S64 del_idx = 0; + for (; ; ) + { + if ((del_idx + 1) * 2 - 1 < heap_cnt && heap[del_idx * 2 + 1] > heap[((del_idx + 1) * 2 - 1) * 2 + 1]) + { + S64 tmp; + tmp = heap[del_idx * 2]; + heap[del_idx * 2] = heap[((del_idx + 1) * 2 - 1) * 2]; + heap[((del_idx + 1) * 2 - 1) * 2] = tmp; + tmp = heap[del_idx * 2 + 1]; + heap[del_idx * 2 + 1] = heap[((del_idx + 1) * 2 - 1) * 2 + 1]; + heap[((del_idx + 1) * 2 - 1) * 2 + 1] = tmp; + del_idx = (del_idx + 1) * 2 - 1; + } + else if ((del_idx + 1) * 2 < heap_cnt && heap[del_idx * 2 + 1] > heap[((del_idx + 1) * 2) * 2 + 1]) + { + S64 tmp; + tmp = heap[del_idx * 2]; + heap[del_idx * 2] = heap[((del_idx + 1) * 2) * 2]; + heap[((del_idx + 1) * 2) * 2] = tmp; + tmp = heap[del_idx * 2 + 1]; + heap[del_idx * 2 + 1] = heap[((del_idx + 1) * 2) * 2 + 1]; + heap[((del_idx + 1) * 2) * 2 + 1] = tmp; + del_idx = (del_idx + 1) * 2; + } + else + break; + } + } + if (distance[item_node] < item_value) + continue; + for (i = 0; i < len; i++) + { + if (from_nodes2[i] != item_node) + continue; + if (distance[to_nodes2[i]] > distance[item_node] + values2[i]) + { + distance[to_nodes2[i]] = distance[item_node] + values2[i]; + heap[heap_cnt * 2] = to_nodes2[i]; + heap[heap_cnt * 2 + 1] = distance[to_nodes2[i]]; + { + S64 ins_idx = heap_cnt; + for (; ; ) + { + if (ins_idx > 0 && heap[ins_idx * 2 + 1] < heap[(ins_idx - 1) / 2 * 2 + 1]) + { + S64 tmp; + tmp = heap[ins_idx * 2]; + heap[ins_idx * 2] = heap[(ins_idx - 1) / 2 * 2]; + heap[(ins_idx - 1) / 2 * 2] = tmp; + tmp = heap[ins_idx * 2 + 1]; + heap[ins_idx * 2 + 1] = heap[(ins_idx - 1) / 2 * 2 + 1]; + heap[(ins_idx - 1) / 2 * 2 + 1] = tmp; + ins_idx = (ins_idx - 1) / 2; + } + else + break; + } + } + heap_cnt++; + } + } + } + FreeMem(heap); + + return result; +} + +EXPORT void* _bellmanFord(S64 node_num, const void* from_nodes, const void* to_nodes, const void* values, S64 begin_node) +{ + THROWDBG(from_nodes == NULL || to_nodes == NULL || values == NULL, 0xc0000005); + THROWDBG(*(S64*)((U8*)from_nodes + 0x08) != *(S64*)((U8*)to_nodes + 0x08) || *(S64*)((U8*)to_nodes + 0x08) != *(S64*)((U8*)values + 0x08), 0xe9170006); + THROWDBG(node_num <= 0 || begin_node < 0 || node_num <= begin_node, 0xe9170006); + const S64* from_nodes2 = (S64*)((U8*)from_nodes + 0x10); + const S64* to_nodes2 = (S64*)((U8*)to_nodes + 0x10); + const S64* values2 = (S64*)((U8*)values + 0x10); + S64 len = *(S64*)((U8*)from_nodes + 0x08); + S64 i; +#if defined(DBG) + for (i = 0; i < len; i++) + THROWDBG(from_nodes2[i] < 0 || node_num <= from_nodes2[i] || to_nodes2[i] < 0 || node_num <= to_nodes2[i], 0xe9170006); +#endif + + U8* result = (U8*)AllocMem(0x10 + sizeof(S64) * (size_t)node_num); + ((S64*)result)[0] = DefaultRefCntFunc; + ((S64*)result)[1] = node_num; + S64* distance = (S64*)(result + 0x10); + for (i = 0; i < node_num; i++) + distance[i] = LLONG_MAX; + distance[begin_node] = 0; + + Bool found; + do + { + found = False; + for (i = 0; i < len; i++) + { + S64 from_distance = distance[from_nodes2[i]]; + if (from_distance != LLONG_MAX && distance[to_nodes2[i]] > from_distance + values2[i]) + { + distance[to_nodes2[i]] = from_distance + values2[i]; + found = True; + } + } + } while (found); + return result; +} + +EXPORT void* _floydWarshall(S64 node_num, const void* from_nodes, const void* to_nodes, const void* values) +{ + THROWDBG(from_nodes == NULL || to_nodes == NULL || values == NULL, 0xc0000005); + THROWDBG(*(S64*)((U8*)from_nodes + 0x08) != *(S64*)((U8*)to_nodes + 0x08) || *(S64*)((U8*)to_nodes + 0x08) != *(S64*)((U8*)values + 0x08), 0xe9170006); + THROWDBG(node_num <= 0, 0xe9170006); + const S64* from_nodes2 = (S64*)((U8*)from_nodes + 0x10); + const S64* to_nodes2 = (S64*)((U8*)to_nodes + 0x10); + const S64* values2 = (S64*)((U8*)values + 0x10); + S64 len = *(S64*)((U8*)from_nodes + 0x08); + S64 i, j, k; +#if defined(DBG) + for (i = 0; i < len; i++) + THROWDBG(from_nodes2[i] < 0 || node_num <= from_nodes2[i] || to_nodes2[i] < 0 || node_num <= to_nodes2[i], 0xe9170006); +#endif + + U8* result = (U8*)AllocMem(0x10 + sizeof(void**) * (size_t)node_num); + ((S64*)result)[0] = DefaultRefCntFunc; + ((S64*)result)[1] = node_num; + void** ptr = (void**)(result + 0x10); + for (i = 0; i < node_num; i++) + { + void* item = AllocMem(0x10 + sizeof(S64) * (size_t)node_num); + ((S64*)item)[0] = 1; + ((S64*)item)[1] = node_num; + S64* ptr2 = (S64*)item + 2; + for (j = 0; j < node_num; j++) + ptr2[j] = i == j ? 0 : LLONG_MAX; + ptr[i] = item; + } + for (i = 0; i < len; i++) + ((S64*)ptr[from_nodes2[i]] + 2)[to_nodes2[i]] = values2[i]; + for (i = 0; i < node_num; i++) + { + for (j = 0; j < node_num; j++) + { + for (k = 0; k < node_num; k++) + { + S64 a = ((S64*)ptr[j] + 2)[i]; + S64 b = ((S64*)ptr[i] + 2)[k]; + if (a == LLONG_MAX || b == LLONG_MAX) + continue; + S64 value = a + b; + if (((S64*)ptr[j] + 2)[k] > value) + ((S64*)ptr[j] + 2)[k] = value; + } + } + } + + return result; +} + EXPORT SClass* _makeMat(SClass* me_, S64 row, S64 col) { THROWDBG(row <= 0 || col <= 0, 0xe9170006); diff --git a/src/lib_math/main.h b/src/lib_math/main.h index fae1c325..870c3f84 100644 --- a/src/lib_math/main.h +++ b/src/lib_math/main.h @@ -13,5 +13,9 @@ EXPORT void* _primeFactors(S64 n); EXPORT double _gamma(double n); EXPORT double _fact(double n); EXPORT S64 _factInt(S64 n); +EXPORT S64 _knapsack(const void* weights, const void* values, S64 max_weight, Bool reuse); +EXPORT void* _dijkstra(S64 node_num, const void* from_nodes, const void* to_nodes, const void* values, S64 begin_node); +EXPORT void* _bellmanFord(S64 node_num, const void* from_nodes, const void* to_nodes, const void* values, S64 begin_node); +EXPORT void* _floydWarshall(S64 node_num, const void* from_nodes, const void* to_nodes, const void* values); EXPORT SClass* _makeMat(SClass* me_, S64 row, S64 col); EXPORT void _matDtor(SClass* me_); diff --git a/src/lib_wnd/draw.cpp b/src/lib_wnd/draw.cpp index cfd53ff9..c0664737 100644 --- a/src/lib_wnd/draw.cpp +++ b/src/lib_wnd/draw.cpp @@ -17,6 +17,7 @@ static const int JointMax = 256; static const int FontBitmapSize = 1024; static const int TexEvenNum = 3; static const double DiscardAlpha = 0.02; +static const int FilterNum = 2; struct SWndBuf { @@ -159,7 +160,8 @@ const U8* GetObjOutlineVsBin(size_t* size); const U8* GetObjOutlineJointVsBin(size_t* size); const U8* GetObjOutlinePsBin(size_t* size); const U8* GetFilterVsBin(size_t* size); -const U8* GetFilterPsBin(size_t* size); +const U8* GetFilterNonePsBin(size_t* size); +const U8* GetFilterMonotonePsBin(size_t* size); const U8* GetToonRampPngBin(size_t* size); static S64 Cnt; @@ -194,7 +196,7 @@ static void* ObjOutlineJointVs = NULL; static void* ObjOutlinePs = NULL; static void* FilterVertex = NULL; static void* FilterVs = NULL; -static void* FilterPs = NULL; +static void* FilterPs[FilterNum] = { NULL }; static double ViewMat[4][4]; static double ProjMat[4][4]; static SObjVsConstBuf ObjVsConstBuf; @@ -206,6 +208,8 @@ ID3D10Texture2D* TexToonRamp; ID3D10ShaderResourceView* ViewToonRamp; ID3D10Texture2D* TexEven[TexEvenNum]; ID3D10ShaderResourceView* ViewEven[TexEvenNum]; +static int FilterIdx = 0; +static float FilterParam[4][4]; EXPORT_CPP void _render(S64 fps) { @@ -223,7 +227,7 @@ EXPORT_CPP void _render(S64 fps) { Draw::ConstBuf(FilterVs, NULL); Device->GSSetShader(NULL); - Draw::ConstBuf(FilterPs, NULL); + Draw::ConstBuf(FilterPs[FilterIdx], FilterIdx == 0 ? NULL : FilterParam); Draw::VertexBuf(FilterVertex); Device->PSSetShaderResources(0, 1, &CurWndBuf->TmpShaderResView); } @@ -535,6 +539,27 @@ EXPORT_CPP void _circle(double x, double y, double radiusX, double radiusY, S64 Device->DrawIndexed(6, 0, 0); } +EXPORT_CPP void _filterNone() +{ + FilterIdx = 0; +} + +EXPORT_CPP void _filterMonotone(S64 color, double rate) +{ + double r, g, b, a; + Draw::ColorToArgb(&a, &r, &g, &b, color); + if (rate < 0.0) + rate = 0.0; + else if (rate > 1.0) + rate = 1.0; + + FilterIdx = 1; + FilterParam[0][0] = static_cast(r); + FilterParam[0][1] = static_cast(g); + FilterParam[0][2] = static_cast(b); + FilterParam[0][3] = static_cast(rate); +} + EXPORT_CPP SClass* _makeTex(SClass* me_, const U8* path) { return Draw::MakeTexImpl(me_, path, False); @@ -1801,7 +1826,7 @@ void Init() } // Initialize 'Circle'. - if (IsResUsed(1)) + if (IsResUsed(UseResFlagsKind_Draw_Circle)) { { float vertices[] = @@ -2042,8 +2067,14 @@ void Init() } { size_t size; - const U8* bin = GetFilterPsBin(&size); - FilterPs = MakeShaderBuf(ShaderKind_Ps, size, bin, 0, 0, NULL, NULL); + const U8* bin = GetFilterNonePsBin(&size); + FilterPs[0] = MakeShaderBuf(ShaderKind_Ps, size, bin, 0, 0, NULL, NULL); + } + if (IsResUsed(UseResFlagsKind_Draw_FilterMonotone)) + { + size_t size; + const U8* bin = GetFilterMonotonePsBin(&size); + FilterPs[1] = MakeShaderBuf(ShaderKind_Ps, size, bin, sizeof(float) * 4, 0, NULL, NULL); } } } @@ -2190,8 +2221,11 @@ void Fin() ViewToonRamp->Release(); if (TexToonRamp != NULL) TexToonRamp->Release(); - if (FilterPs != NULL) - FinShaderBuf(FilterPs); + for (int i = 0; i < FilterNum; i++) + { + if (FilterPs[i] != NULL) + FinShaderBuf(FilterPs[i]); + } if (FilterVs != NULL) FinShaderBuf(FilterVs); if (FilterVertex != NULL) diff --git a/src/lib_wnd/draw.h b/src/lib_wnd/draw.h index 78a30c2f..9be243ee 100644 --- a/src/lib_wnd/draw.h +++ b/src/lib_wnd/draw.h @@ -15,6 +15,8 @@ EXPORT_CPP void _tri(double x1, double y1, double x2, double y2, double x3, doub EXPORT_CPP void _rect(double x, double y, double w, double h, S64 color); EXPORT_CPP void _rectLine(double x, double y, double w, double h, S64 color); EXPORT_CPP void _circle(double x, double y, double radiusX, double radiusY, S64 color); +EXPORT_CPP void _filterNone(); +EXPORT_CPP void _filterMonotone(S64 color, double rate); EXPORT_CPP SClass* _makeTex(SClass* me_, const U8* path); EXPORT_CPP SClass* _makeTexArgb(SClass* me_, const U8* path); EXPORT_CPP SClass* _makeTexEvenArgb(SClass* me_, double a, double r, double g, double b); diff --git a/src/lib_wnd/filter_monotone_ps.c b/src/lib_wnd/filter_monotone_ps.c new file mode 100644 index 00000000..d307f2d9 --- /dev/null +++ b/src/lib_wnd/filter_monotone_ps.c @@ -0,0 +1,40 @@ +#include "../common.h" + +const U8* GetFilterMonotonePsBin(size_t* size) +{ + static const U8 filter_monotone_ps_bin[0x0000039c] = + { + 0x44, 0x58, 0x42, 0x43, 0xbb, 0xac, 0xfa, 0x06, 0x3b, 0xf1, 0xa3, 0xc5, 0x3a, 0x2f, 0x00, 0x1e, 0x41, 0x9c, 0xae, 0x3b, 0x01, 0x00, 0x00, 0x00, 0x9c, 0x03, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x34, 0x00, 0x00, 0x00, 0x4c, 0x01, 0x00, 0x00, 0xa4, 0x01, 0x00, 0x00, 0xd8, 0x01, 0x00, 0x00, 0x20, 0x03, 0x00, 0x00, 0x52, 0x44, 0x45, 0x46, 0x10, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x94, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x04, 0xff, 0xff, 0x00, 0x01, 0x00, 0x00, 0xdc, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x00, + 0x49, 0x6d, 0x67, 0x00, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x42, 0x75, 0x66, 0x00, 0xab, 0xab, 0xab, 0x88, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xac, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0xab, 0xab, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4d, 0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, + 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x36, 0x2e, 0x33, 0x2e, 0x39, + 0x36, 0x30, 0x30, 0x2e, 0x31, 0x36, 0x33, 0x38, 0x34, 0x00, 0xab, 0xab, 0x49, 0x53, 0x47, 0x4e, 0x50, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x53, 0x56, 0x5f, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, + 0x00, 0xab, 0xab, 0xab, 0x4f, 0x53, 0x47, 0x4e, 0x2c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x53, 0x56, 0x5f, 0x54, 0x41, 0x52, 0x47, 0x45, 0x54, 0x00, 0xab, 0xab, 0x53, 0x48, 0x44, 0x52, 0x40, 0x01, 0x00, 0x00, + 0x40, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, 0x04, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x03, 0x00, 0x60, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x58, 0x18, 0x00, 0x04, 0x00, 0x70, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0x62, 0x10, 0x00, 0x03, 0x32, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x65, 0x00, 0x00, 0x03, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x09, 0xf2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x46, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x0a, 0x82, 0x00, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0xfe, 0x0a, 0x99, 0x3e, 0x23, 0x2c, 0x16, 0x3f, 0x71, 0x73, 0xea, 0x3d, 0x00, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x08, 0x72, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x82, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x09, 0x82, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3a, 0x80, 0x20, 0x80, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x80, 0x3f, 0x38, 0x00, 0x00, 0x07, 0x72, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x0a, 0x72, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xf6, 0x8f, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x46, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x82, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x3e, 0x00, 0x00, 0x01, + 0x53, 0x54, 0x41, 0x54, 0x74, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + + *size = 0x0000039c; + return filter_monotone_ps_bin; +} diff --git a/src/lib_wnd/filter_ps.c b/src/lib_wnd/filter_none_ps.c similarity index 96% rename from src/lib_wnd/filter_ps.c rename to src/lib_wnd/filter_none_ps.c index 25e325f7..b5cad7fb 100644 --- a/src/lib_wnd/filter_ps.c +++ b/src/lib_wnd/filter_none_ps.c @@ -1,8 +1,8 @@ #include "../common.h" -const U8* GetFilterPsBin(size_t* size) +const U8* GetFilterNonePsBin(size_t* size) { - static const U8 filter_ps_bin[0x0000024c] = + static const U8 filter_none_ps_bin[0x0000024c] = { 0x44, 0x58, 0x42, 0x43, 0xf6, 0xbf, 0xb0, 0x0d, 0x35, 0xd8, 0x87, 0x27, 0x8c, 0x6e, 0x78, 0xa8, 0xb7, 0x25, 0xe2, 0x75, 0x01, 0x00, 0x00, 0x00, 0x4c, 0x02, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0xd8, 0x00, 0x00, 0x00, 0x30, 0x01, 0x00, 0x00, 0x64, 0x01, 0x00, 0x00, 0xd0, 0x01, 0x00, 0x00, 0x52, 0x44, 0x45, 0x46, 0x9c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -26,5 +26,5 @@ const U8* GetFilterPsBin(size_t* size) }; *size = 0x0000024c; - return filter_ps_bin; + return filter_none_ps_bin; } diff --git a/src/lib_wnd/lib_wnd.vcxproj b/src/lib_wnd/lib_wnd.vcxproj index a69052c7..8a7a053b 100644 --- a/src/lib_wnd/lib_wnd.vcxproj +++ b/src/lib_wnd/lib_wnd.vcxproj @@ -148,7 +148,8 @@ - + + diff --git a/src/lib_wnd/lib_wnd.vcxproj.filters b/src/lib_wnd/lib_wnd.vcxproj.filters index d4a0a127..b674313a 100644 --- a/src/lib_wnd/lib_wnd.vcxproj.filters +++ b/src/lib_wnd/lib_wnd.vcxproj.filters @@ -22,13 +22,14 @@ - + + diff --git a/src/lib_wnd/main.cpp b/src/lib_wnd/main.cpp index b4f83be7..db7ca022 100644 --- a/src/lib_wnd/main.cpp +++ b/src/lib_wnd/main.cpp @@ -45,6 +45,7 @@ enum EWndKind WndKind_Pager, WndKind_Tab, WndKind_Tree, + WndKind_TreeMulti, WndKind_SplitX, WndKind_SplitY, WndKind_ScrollX, @@ -138,15 +139,20 @@ struct SRadio void* OnPush; }; -struct SEdit +struct SEditBase { SWndBase WndBase; void* OnChange; }; +struct SEdit +{ + SEditBase EditBase; +}; + struct SEditMulti { - SWndBase WndBase; + SEditBase EditBase; }; struct SList @@ -228,7 +234,7 @@ struct STab void* OnSel; }; -struct STree +struct STreeBase { SWndBase WndBase; Bool Draggable; @@ -238,6 +244,16 @@ struct STree void* OnMoveNode; }; +struct STree +{ + STreeBase TreeBase; +}; + +struct STreeMulti +{ + STreeBase TreeBase; +}; + struct STreeNode { SClass Class; @@ -1074,7 +1090,7 @@ EXPORT_CPP SClass* _makeEdit(SClass* me_, SClass* parent, S64 x, S64 y, S64 widt { SEdit* me2 = reinterpret_cast(me_); SetCtrlParam(reinterpret_cast(me_), reinterpret_cast(parent), WndKind_Edit, WC_EDIT, WS_EX_CLIENTEDGE, WS_VISIBLE | WS_CHILD | WS_TABSTOP | ES_AUTOHSCROLL, x, y, width, height, L"", WndProcEdit, anchorX, anchorY); - me2->OnChange = NULL; + reinterpret_cast(me2)->OnChange = NULL; return me_; } @@ -1484,11 +1500,23 @@ EXPORT_CPP SClass* _makeTree(SClass* me_, SClass* parent, S64 x, S64 y, S64 widt { STree* me2 = reinterpret_cast(me_); SetCtrlParam(reinterpret_cast(me_), reinterpret_cast(parent), WndKind_Tree, WC_TREEVIEW, WS_EX_CLIENTEDGE, WS_VISIBLE | WS_CHILD | TVS_HASBUTTONS | TVS_HASLINES | TVS_SHOWSELALWAYS | TVS_LINESATROOT, x, y, width, height, L"", WndProcTree, anchorX, anchorY); - me2->Draggable = False; - me2->AllowDraggingToRoot = False; - me2->DraggingItem = NULL; - me2->OnSel = NULL; - me2->OnMoveNode = NULL; + reinterpret_cast(me2)->Draggable = False; + reinterpret_cast(me2)->AllowDraggingToRoot = False; + reinterpret_cast(me2)->DraggingItem = NULL; + reinterpret_cast(me2)->OnSel = NULL; + reinterpret_cast(me2)->OnMoveNode = NULL; + return me_; +} + +EXPORT_CPP SClass* _makeTreeMulti(SClass* me_, SClass* parent, S64 x, S64 y, S64 width, S64 height, S64 anchorX, S64 anchorY) +{ + STree* me2 = reinterpret_cast(me_); + SetCtrlParam(reinterpret_cast(me_), reinterpret_cast(parent), WndKind_TreeMulti, WC_TREEVIEW, WS_EX_CLIENTEDGE, WS_VISIBLE | WS_CHILD | TVS_HASBUTTONS | TVS_HASLINES | TVS_SHOWSELALWAYS | TVS_LINESATROOT, x, y, width, height, L"", WndProcTree, anchorX, anchorY); + reinterpret_cast(me2)->Draggable = False; + reinterpret_cast(me2)->AllowDraggingToRoot = False; + reinterpret_cast(me2)->DraggingItem = NULL; + reinterpret_cast(me2)->OnSel = NULL; + reinterpret_cast(me2)->OnMoveNode = NULL; return me_; } @@ -1517,12 +1545,12 @@ EXPORT_CPP SClass* _treeRoot(SClass* me_, SClass* me2) EXPORT_CPP void _treeDraggable(SClass* me_, Bool enabled) { - reinterpret_cast(me_)->Draggable = enabled; + reinterpret_cast(me_)->Draggable = enabled; } EXPORT_CPP void _treeAllowDraggingToRoot(SClass* me_, Bool enabled) { - reinterpret_cast(me_)->AllowDraggingToRoot = enabled; + reinterpret_cast(me_)->AllowDraggingToRoot = enabled; } EXPORT_CPP void _treeSetSel(SClass* me_, SClass* node) @@ -1539,6 +1567,37 @@ EXPORT_CPP SClass* _treeGetSel(SClass* me_, SClass* me2) STreeNode* me4 = reinterpret_cast(me2); me4->WndHandle = me3->WndHandle; me4->Item = TreeView_GetSelection(me3->WndHandle); + if (me4->Item == NULL) + return NULL; + return me2; +} + +EXPORT_CPP void _treeMultiSetSel(SClass* me_, void* nodes) +{ + SWndBase* me2 = reinterpret_cast(me_); + S64 len = *(S64*)((U8*)nodes + 0x08); + void** ptr = (void**)((U8*)nodes + 0x10); + S64 i; + for (i = 0; i < len; i++) + { + STreeNode* node2 = reinterpret_cast(ptr[i]); + THROWDBG(me2->WndHandle != node2->WndHandle, 0xe9170006); + if (i == 0) + TreeView_Select(me2->WndHandle, node2->Item, TVGN_CARET); + else + TreeView_SetItemState(me2->WndHandle, node2->Item, TVIS_SELECTED, TVIS_SELECTED); + } +} + +EXPORT_CPP SClass* _treeMultiGetSel(SClass* me_, SClass* me2, SClass* node) +{ + SWndBase* me3 = reinterpret_cast(me_); + STreeNode* me4 = reinterpret_cast(me2); + STreeNode* node2 = reinterpret_cast(node); + me4->WndHandle = me3->WndHandle; + me4->Item = TreeView_GetNextItem(me3->WndHandle, node2 == NULL ? NULL : node2->Item, node2 == NULL ? TVGN_CARET : TVGN_NEXTSELECTED); + if (me4->Item == NULL) + return NULL; return me2; } @@ -2106,8 +2165,8 @@ static void CommandAndNotify(HWND wnd, UINT msg, WPARAM w_param, LPARAM l_param) switch (HIWORD(w_param)) { case EN_CHANGE: - if (edit->OnChange != NULL) - Call1Asm(IncWndRef(reinterpret_cast(wnd_ctrl2)), edit->OnChange); + if (reinterpret_cast(edit)->OnChange != NULL) + Call1Asm(IncWndRef(reinterpret_cast(wnd_ctrl2)), reinterpret_cast(edit)->OnChange); // TODO: break; case EN_HSCROLL: @@ -2194,8 +2253,9 @@ static void CommandAndNotify(HWND wnd, UINT msg, WPARAM w_param, LPARAM l_param) } break; case WndKind_Tree: + case WndKind_TreeMulti: { - STree* tree = reinterpret_cast(wnd_ctrl2); + STreeBase* tree = reinterpret_cast(wnd_ctrl2); switch (reinterpret_cast(l_param)->code) { case TVN_BEGINDRAG: @@ -2210,8 +2270,22 @@ static void CommandAndNotify(HWND wnd, UINT msg, WPARAM w_param, LPARAM l_param) } break; case TVN_SELCHANGED: - if (tree->OnSel != NULL) - Call1Asm(IncWndRef(reinterpret_cast(wnd_ctrl2)), tree->OnSel); + if (wnd_ctrl2->Kind == WndKind_Tree) + { + if (tree->OnSel != NULL) + Call1Asm(IncWndRef(reinterpret_cast(wnd_ctrl2)), tree->OnSel); + } + break; + case TVN_ITEMCHANGED: + if (wnd_ctrl2->Kind == WndKind_TreeMulti) + { + if (tree->OnSel != NULL) + { + NMTVITEMCHANGE* param = reinterpret_cast(l_param); + if ((param->uStateOld & TVIS_SELECTED) != (param->uStateNew & TVIS_SELECTED)) + Call1Asm(IncWndRef(reinterpret_cast(wnd_ctrl2)), tree->OnSel); + } + } break; } } @@ -2972,11 +3046,11 @@ static LRESULT CALLBACK WndProcTree(HWND wnd, UINT msg, WPARAM w_param, LPARAM l { SWndBase* wnd2 = ToWnd(wnd); STree* wnd3 = reinterpret_cast(wnd2); - ASSERT(wnd2->Kind == WndKind_Tree); + ASSERT(wnd2->Kind == WndKind_Tree || wnd2->Kind == WndKind_TreeMulti); switch (msg) { case WM_MOUSEMOVE: - if (wnd3->DraggingItem != NULL) + if (reinterpret_cast(wnd3)->DraggingItem != NULL) { POINT point; TVHITTESTINFO hit_test = { 0 }; @@ -2998,7 +3072,7 @@ static LRESULT CALLBACK WndProcTree(HWND wnd, UINT msg, WPARAM w_param, LPARAM l } return 0; case WM_LBUTTONUP: - if (wnd3->DraggingItem != NULL) + if (reinterpret_cast(wnd3)->DraggingItem != NULL) { POINT point; TVHITTESTINFO hit_test = { 0 }; @@ -3009,7 +3083,7 @@ static LRESULT CALLBACK WndProcTree(HWND wnd, UINT msg, WPARAM w_param, LPARAM l hit_test.pt.y = point.y; ScreenToClient(wnd, &hit_test.pt); HTREEITEM item = reinterpret_cast(SendMessage(wnd, TVM_HITTEST, 0, reinterpret_cast(&hit_test))); - if (wnd3->DraggingItem != item && (wnd3->AllowDraggingToRoot || item != NULL)) + if (reinterpret_cast(wnd3)->DraggingItem != item && (reinterpret_cast(wnd3)->AllowDraggingToRoot || item != NULL)) { Bool success = True; { @@ -3017,7 +3091,7 @@ static LRESULT CALLBACK WndProcTree(HWND wnd, UINT msg, WPARAM w_param, LPARAM l HTREEITEM item2 = item; while (item2 != NULL) { - if (item2 == wnd3->DraggingItem) + if (item2 == reinterpret_cast(wnd3)->DraggingItem) { success = False; break; @@ -3028,16 +3102,16 @@ static LRESULT CALLBACK WndProcTree(HWND wnd, UINT msg, WPARAM w_param, LPARAM l if (success) { Char buf[1025]; - CopyTreeNodeRecursion(wnd, item, wnd3->DraggingItem, buf); - TreeView_DeleteItem(wnd, wnd3->DraggingItem); - if (wnd3->OnMoveNode) - Call1Asm(IncWndRef(reinterpret_cast(wnd3)), wnd3->OnMoveNode); + CopyTreeNodeRecursion(wnd, item, reinterpret_cast(wnd3)->DraggingItem, buf); + TreeView_DeleteItem(wnd, reinterpret_cast(wnd3)->DraggingItem); + if (reinterpret_cast(wnd3)->OnMoveNode) + Call1Asm(IncWndRef(reinterpret_cast(wnd3)), reinterpret_cast(wnd3)->OnMoveNode); } } ImageList_DragShowNolock(TRUE); ImageList_DragLeave(NULL); ImageList_EndDrag(); - wnd3->DraggingItem = NULL; + reinterpret_cast(wnd3)->DraggingItem = NULL; } return 0; } diff --git a/src/lib_wnd/main.h b/src/lib_wnd/main.h index 3651e7dd..e2202c77 100644 --- a/src/lib_wnd/main.h +++ b/src/lib_wnd/main.h @@ -99,6 +99,7 @@ EXPORT_CPP void _tabSetSel(SClass* me_, S64 idx); EXPORT_CPP S64 _tabGetSel(SClass* me_); EXPORT_CPP void _tabGetPosInner(SClass* me_, S64* x, S64* y, S64* width, S64* height); EXPORT_CPP SClass* _makeTree(SClass* me_, SClass* parent, S64 x, S64 y, S64 width, S64 height, S64 anchorX, S64 anchorY); +EXPORT_CPP SClass* _makeTreeMulti(SClass* me_, SClass* parent, S64 x, S64 y, S64 width, S64 height, S64 anchorX, S64 anchorY); EXPORT_CPP void _treeClear(SClass* me_); EXPORT_CPP void _treeExpand(SClass* me_, Bool expand); EXPORT_CPP SClass* _treeRoot(SClass* me_, SClass* me2); @@ -106,6 +107,8 @@ EXPORT_CPP void _treeDraggable(SClass* me_, Bool enabled); EXPORT_CPP void _treeAllowDraggingToRoot(SClass* me_, Bool enabled); EXPORT_CPP void _treeSetSel(SClass* me_, SClass* node); EXPORT_CPP SClass* _treeGetSel(SClass* me_, SClass* me2); +EXPORT_CPP void _treeMultiSetSel(SClass* me_, void* nodes); +EXPORT_CPP SClass* _treeMultiGetSel(SClass* me_, SClass* me2, SClass* node); EXPORT_CPP SClass* _treeNodeAddChild(SClass* me_, SClass* me2, const U8* name); EXPORT_CPP SClass* _treeNodeInsChild(SClass* me_, SClass* me2, SClass* node, const U8* name); EXPORT_CPP void _treeNodeDelChild(SClass* me_, SClass* node); diff --git a/src/shaders/build.bat b/src/shaders/build.bat index 083d3527..27e47004 100644 --- a/src/shaders/build.bat +++ b/src/shaders/build.bat @@ -17,5 +17,6 @@ set fxc_path="C:\Program Files (x86)\Windows Kits\8.1\bin\x64\fxc.exe" %fxc_path% obj_outline_vs.fx /T vs_4_0 /Fo obj_outline_joint.vs /DJOINT %fxc_path% obj_outline_ps.fx /T ps_4_0 /Fo obj_outline.ps %fxc_path% filter_vs.fx /T vs_4_0 /Fo filter.vs -%fxc_path% filter_ps.fx /T ps_4_0 /Fo filter.ps +%fxc_path% filter_none_ps.fx /T ps_4_0 /Fo filter_none.ps +%fxc_path% filter_monotone_ps.fx /T ps_4_0 /Fo filter_monotone.ps pause diff --git a/src/shaders/filter_monotone_ps.fx b/src/shaders/filter_monotone_ps.fx new file mode 100644 index 00000000..8fcee9c7 --- /dev/null +++ b/src/shaders/filter_monotone_ps.fx @@ -0,0 +1,23 @@ +cbuffer ConstBuf: register(b0) +{ + float4 Color; +}; + +Texture2D Img: register(t0); +SamplerState Sampler: register(s0); + +struct PS_INPUT +{ + float4 Pos: SV_POSITION; + float2 Tex: TEXCOORD; +}; + +float4 main(PS_INPUT input): SV_TARGET +{ + float4 tex_color = Img.Sample(Sampler, input.Tex); + float luminance = 0.298912f * tex_color.r + 0.586611f * tex_color.g + 0.114478f * tex_color.b; + float4 output; + output.rgb = luminance * float3(Color.rgb) * Color.a + tex_color.rgb * (1.0f - Color.a); + output.a = 1.0f; + return output; +} diff --git a/src/shaders/filter_ps.fx b/src/shaders/filter_none_ps.fx similarity index 100% rename from src/shaders/filter_ps.fx rename to src/shaders/filter_none_ps.fx diff --git a/src/test_src/main.c b/src/test_src/main.c index 6f123b6d..1a4df90a 100644 --- a/src/test_src/main.c +++ b/src/test_src/main.c @@ -10,7 +10,7 @@ #include #define LANG (0) -#define TEST_NUM (21) +#define TEST_NUM (22) #pragma comment(lib, "compiler.lib") diff --git a/test/correct/log0021.txt b/test/correct/log0021.txt new file mode 100644 index 00000000..e889326d --- /dev/null +++ b/test/correct/log0021.txt @@ -0,0 +1,90 @@ +Begin: ../../test/output/output0021.exe +Excpt: 80000003 +> 3 +> 5 +> Not found. +> 3 +> Not found. +> Not found. +> 7 +> 10 +> 0 +> 2 +> 5 +> 7 +> 11 +> 8 +> 16 +> 0 +> 2 +> 5 +> 7 +> 11 +> 8 +> 16 +> 0 +> 2 +> 5 +> 7 +> 11 +> 8 +> 16 +> 3 +> 5 +> Not found. +> 3 +> Not found. +> Not found. +> 7 +> 10 +> 0 +> 2 +> 5 +> 7 +> 11 +> 8 +> 16 +> 0 +> 2 +> 5 +> 7 +> 11 +> 8 +> 16 +> 0 +> 2 +> 5 +> 7 +> 11 +> 8 +> 16 +> 3 +> 5 +> Not found. +> 3 +> Not found. +> Not found. +> 7 +> 10 +> 0 +> 2 +> 5 +> 7 +> 11 +> 8 +> 16 +> 0 +> 2 +> 5 +> 7 +> 11 +> 8 +> 16 +> 0 +> 2 +> 5 +> 7 +> 11 +> 8 +> 16 +end: ../../test/output/output0021.exe diff --git a/test/kn/test0000.kn b/test/kn/test0000.kn index 24e80222..504cd0c9 100644 --- a/test/kn/test0000.kn +++ b/test/kn/test0000.kn @@ -68,9 +68,9 @@ func main() var b: bit32 :: (n + n) / n - n * n + n + n + n + n + n + n + n + n + n + n + (+n) + (-n) {23} do cui@print(b.toStr() ~ ", " ~ (b % n).toStr()) - var c1: bit32 :: 16#FFFFFFFFb32 + 2b32 + var c1: bit32 :: 0xFFFFFFFFb32 + 2b32 var c2: bit32 :: -1b32 - var d1: bit32 :: 16#FFFFFFFFb32 + var d1: bit32 :: 0xFFFFFFFFb32 var d2: bit32 :: 1b32 do d1 :+ 2b32 do d2 :: -d2 @@ -85,9 +85,9 @@ func main() var b: bit64 :: (n + n) / n - n * n + n + n + n + n + n + n + n + n + n + n + (+n) + (-n) {23} do cui@print(b.toStr() ~ ", " ~ (b % n).toStr()) - var c1: bit64 :: 16#FFFFFFFFFFFFFFFFb64 + 2b64 + var c1: bit64 :: 0xFFFFFFFFFFFFFFFFb64 + 2b64 var c2: bit64 :: -1b64 - var d1: bit64 :: 16#FFFFFFFFFFFFFFFFb64 + var d1: bit64 :: 0xFFFFFFFFFFFFFFFFb64 var d2: bit64 :: 1b64 do d1 :+ 2b64 do d2 :: -d2 diff --git a/test/kn/test0001.kn b/test/kn/test0001.kn index 93d8c47d..19fc431e 100644 --- a/test/kn/test0001.kn +++ b/test/kn/test0001.kn @@ -29,58 +29,58 @@ func main() end block block - do cui@print((16#79b8 = 16#81b8).toStr() ~ ", " ~ (16#79b8 <> 16#81b8).toStr() ~ ", " ~ (16#79b8 < 16#81b8).toStr() ~ ", " ~ (16#79b8 <= 16#81b8).toStr() ~ ", " ~ (16#79b8 > 16#81b8).toStr() ~ ", " ~ (16#79b8 >= 16#81b8).toStr()) + do cui@print((0x79b8 = 0x81b8).toStr() ~ ", " ~ (0x79b8 <> 0x81b8).toStr() ~ ", " ~ (0x79b8 < 0x81b8).toStr() ~ ", " ~ (0x79b8 <= 0x81b8).toStr() ~ ", " ~ (0x79b8 > 0x81b8).toStr() ~ ", " ~ (0x79b8 >= 0x81b8).toStr()) - var a: bit8 :: 16#79b8 - var b: bit8 :: 16#81b8 + var a: bit8 :: 0x79b8 + var b: bit8 :: 0x81b8 do cui@print((a = b).toStr() ~ ", " ~ (a <> b).toStr() ~ ", " ~ (a < b).toStr() ~ ", " ~ (a <= b).toStr() ~ ", " ~ (a > b).toStr() ~ ", " ~ (a >= b).toStr()) - do cui@print((16#80b8 = 16#80b8).toStr() ~ ", " ~ (16#80b8 <> 16#80b8).toStr() ~ ", " ~ (16#80b8 < 16#80b8).toStr() ~ ", " ~ (16#80b8 <= 16#80b8).toStr() ~ ", " ~ (16#80b8 > 16#80b8).toStr() ~ ", " ~ (16#80b8 >= 16#80b8).toStr()) + do cui@print((0x80b8 = 0x80b8).toStr() ~ ", " ~ (0x80b8 <> 0x80b8).toStr() ~ ", " ~ (0x80b8 < 0x80b8).toStr() ~ ", " ~ (0x80b8 <= 0x80b8).toStr() ~ ", " ~ (0x80b8 > 0x80b8).toStr() ~ ", " ~ (0x80b8 >= 0x80b8).toStr()) - var c: bit8 :: 16#80b8 - var d: bit8 :: 16#80b8 + var c: bit8 :: 0x80b8 + var d: bit8 :: 0x80b8 do cui@print((c = d).toStr() ~ ", " ~ (c <> d).toStr() ~ ", " ~ (c < d).toStr() ~ ", " ~ (c <= d).toStr() ~ ", " ~ (c > d).toStr() ~ ", " ~ (c >= d).toStr()) end block block - do cui@print((16#7900b16 = 16#8100b16).toStr() ~ ", " ~ (16#7900b16 <> 16#8100b16).toStr() ~ ", " ~ (16#7900b16 < 16#8100b16).toStr() ~ ", " ~ (16#7900b16 <= 16#8100b16).toStr() ~ ", " ~ (16#7900b16 > 16#8100b16).toStr() ~ ", " ~ (16#7900b16 >= 16#8100b16).toStr()) + do cui@print((0x7900b16 = 0x8100b16).toStr() ~ ", " ~ (0x7900b16 <> 0x8100b16).toStr() ~ ", " ~ (0x7900b16 < 0x8100b16).toStr() ~ ", " ~ (0x7900b16 <= 0x8100b16).toStr() ~ ", " ~ (0x7900b16 > 0x8100b16).toStr() ~ ", " ~ (0x7900b16 >= 0x8100b16).toStr()) - var a: bit16 :: 16#7900b16 - var b: bit16 :: 16#8100b16 + var a: bit16 :: 0x7900b16 + var b: bit16 :: 0x8100b16 do cui@print((a = b).toStr() ~ ", " ~ (a <> b).toStr() ~ ", " ~ (a < b).toStr() ~ ", " ~ (a <= b).toStr() ~ ", " ~ (a > b).toStr() ~ ", " ~ (a >= b).toStr()) - do cui@print((16#8000b16 = 16#8000b16).toStr() ~ ", " ~ (16#8000b16 <> 16#8000b16).toStr() ~ ", " ~ (16#8000b16 < 16#8000b16).toStr() ~ ", " ~ (16#8000b16 <= 16#8000b16).toStr() ~ ", " ~ (16#8000b16 > 16#8000b16).toStr() ~ ", " ~ (16#8000b16 >= 16#8000b16).toStr()) + do cui@print((0x8000b16 = 0x8000b16).toStr() ~ ", " ~ (0x8000b16 <> 0x8000b16).toStr() ~ ", " ~ (0x8000b16 < 0x8000b16).toStr() ~ ", " ~ (0x8000b16 <= 0x8000b16).toStr() ~ ", " ~ (0x8000b16 > 0x8000b16).toStr() ~ ", " ~ (0x8000b16 >= 0x8000b16).toStr()) - var c: bit16 :: 16#8000b16 - var d: bit16 :: 16#8000b16 + var c: bit16 :: 0x8000b16 + var d: bit16 :: 0x8000b16 do cui@print((c = d).toStr() ~ ", " ~ (c <> d).toStr() ~ ", " ~ (c < d).toStr() ~ ", " ~ (c <= d).toStr() ~ ", " ~ (c > d).toStr() ~ ", " ~ (c >= d).toStr()) end block block - do cui@print((16#79000000b32 = 16#81000000b32).toStr() ~ ", " ~ (16#79000000b32 <> 16#81000000b32).toStr() ~ ", " ~ (16#79000000b32 < 16#81000000b32).toStr() ~ ", " ~ (16#79000000b32 <= 16#81000000b32).toStr() ~ ", " ~ (16#79000000b32 > 16#81000000b32).toStr() ~ ", " ~ (16#79000000b32 >= 16#81000000b32).toStr()) + do cui@print((0x79000000b32 = 0x81000000b32).toStr() ~ ", " ~ (0x79000000b32 <> 0x81000000b32).toStr() ~ ", " ~ (0x79000000b32 < 0x81000000b32).toStr() ~ ", " ~ (0x79000000b32 <= 0x81000000b32).toStr() ~ ", " ~ (0x79000000b32 > 0x81000000b32).toStr() ~ ", " ~ (0x79000000b32 >= 0x81000000b32).toStr()) - var a: bit32 :: 16#79000000b32 - var b: bit32 :: 16#81000000b32 + var a: bit32 :: 0x79000000b32 + var b: bit32 :: 0x81000000b32 do cui@print((a = b).toStr() ~ ", " ~ (a <> b).toStr() ~ ", " ~ (a < b).toStr() ~ ", " ~ (a <= b).toStr() ~ ", " ~ (a > b).toStr() ~ ", " ~ (a >= b).toStr()) - do cui@print((16#80000000b32 = 16#80000000b32).toStr() ~ ", " ~ (16#80000000b32 <> 16#80000000b32).toStr() ~ ", " ~ (16#80000000b32 < 16#80000000b32).toStr() ~ ", " ~ (16#80000000b32 <= 16#80000000b32).toStr() ~ ", " ~ (16#80000000b32 > 16#80000000b32).toStr() ~ ", " ~ (16#80000000b32 >= 16#80000000b32).toStr()) + do cui@print((0x80000000b32 = 0x80000000b32).toStr() ~ ", " ~ (0x80000000b32 <> 0x80000000b32).toStr() ~ ", " ~ (0x80000000b32 < 0x80000000b32).toStr() ~ ", " ~ (0x80000000b32 <= 0x80000000b32).toStr() ~ ", " ~ (0x80000000b32 > 0x80000000b32).toStr() ~ ", " ~ (0x80000000b32 >= 0x80000000b32).toStr()) - var c: bit32 :: 16#80000000b32 - var d: bit32 :: 16#80000000b32 + var c: bit32 :: 0x80000000b32 + var d: bit32 :: 0x80000000b32 do cui@print((c = d).toStr() ~ ", " ~ (c <> d).toStr() ~ ", " ~ (c < d).toStr() ~ ", " ~ (c <= d).toStr() ~ ", " ~ (c > d).toStr() ~ ", " ~ (c >= d).toStr()) end block block - do cui@print((16#7900000000000000b64 = 16#8100000000000000b64).toStr() ~ ", " ~ (16#7900000000000000b64 <> 16#8100000000000000b64).toStr() ~ ", " ~ (16#7900000000000000b64 < 16#8100000000000000b64).toStr() ~ ", " ~ (16#7900000000000000b64 <= 16#8100000000000000b64).toStr() ~ ", " ~ (16#7900000000000000b64 > 16#8100000000000000b64).toStr() ~ ", " ~ (16#7900000000000000b64 >= 16#8100000000000000b64).toStr()) + do cui@print((0x7900000000000000b64 = 0x8100000000000000b64).toStr() ~ ", " ~ (0x7900000000000000b64 <> 0x8100000000000000b64).toStr() ~ ", " ~ (0x7900000000000000b64 < 0x8100000000000000b64).toStr() ~ ", " ~ (0x7900000000000000b64 <= 0x8100000000000000b64).toStr() ~ ", " ~ (0x7900000000000000b64 > 0x8100000000000000b64).toStr() ~ ", " ~ (0x7900000000000000b64 >= 0x8100000000000000b64).toStr()) - var a: bit64 :: 16#7900000000000000b64 - var b: bit64 :: 16#8100000000000000b64 + var a: bit64 :: 0x7900000000000000b64 + var b: bit64 :: 0x8100000000000000b64 do cui@print((a = b).toStr() ~ ", " ~ (a <> b).toStr() ~ ", " ~ (a < b).toStr() ~ ", " ~ (a <= b).toStr() ~ ", " ~ (a > b).toStr() ~ ", " ~ (a >= b).toStr()) - do cui@print((16#8000000000000000b64 = 16#8000000000000000b64).toStr() ~ ", " ~ (16#8000000000000000b64 <> 16#8000000000000000b64).toStr() ~ ", " ~ (16#8000000000000000b64 < 16#8000000000000000b64).toStr() ~ ", " ~ (16#8000000000000000b64 <= 16#8000000000000000b64).toStr() ~ ", " ~ (16#8000000000000000b64 > 16#8000000000000000b64).toStr() ~ ", " ~ (16#8000000000000000b64 >= 16#8000000000000000b64).toStr()) + do cui@print((0x8000000000000000b64 = 0x8000000000000000b64).toStr() ~ ", " ~ (0x8000000000000000b64 <> 0x8000000000000000b64).toStr() ~ ", " ~ (0x8000000000000000b64 < 0x8000000000000000b64).toStr() ~ ", " ~ (0x8000000000000000b64 <= 0x8000000000000000b64).toStr() ~ ", " ~ (0x8000000000000000b64 > 0x8000000000000000b64).toStr() ~ ", " ~ (0x8000000000000000b64 >= 0x8000000000000000b64).toStr()) - var c: bit64 :: 16#8000000000000000b64 - var d: bit64 :: 16#8000000000000000b64 + var c: bit64 :: 0x8000000000000000b64 + var d: bit64 :: 0x8000000000000000b64 do cui@print((c = d).toStr() ~ ", " ~ (c <> d).toStr() ~ ", " ~ (c < d).toStr() ~ ", " ~ (c <= d).toStr() ~ ", " ~ (c > d).toStr() ~ ", " ~ (c >= d).toStr()) end block diff --git a/test/kn/test0005.kn b/test/kn/test0005.kn index 660a5a3c..e2a5d7bf 100644 --- a/test/kn/test0005.kn +++ b/test/kn/test0005.kn @@ -49,13 +49,13 @@ func main() do cui@print((n $ int).toStr() ~ ", " ~ (n = %f).toStr() ~ ", " ~ (n <> %f).toStr() ~ ", " ~ (n < %e).toStr() ~ ", " ~ (n > %e).toStr()) do n :: 1234 $ A do cui@print((n $ int).toStr()) - do n :: 16#FFb8 $ A + do n :: 0xFFb8 $ A do cui@print((n $ int).toStr()) - do n :: 16#FFb16 $ A + do n :: 0xFFb16 $ A do cui@print((n $ int).toStr()) - do n :: 16#FFb32 $ A + do n :: 0xFFb32 $ A do cui@print((n $ int).toStr()) - do n :: 16#FFb64 $ A + do n :: 0xFFb64 $ A do cui@print((n $ int).toStr()) end block end for diff --git a/test/kn/test0009.kn b/test/kn/test0009.kn index 1590bd51..fdb91b63 100644 --- a/test/kn/test0009.kn +++ b/test/kn/test0009.kn @@ -54,8 +54,8 @@ func main() end block block - var n: bit8 :: 16#F6b8 - var m: bit8 :: 16#0Ab8 + var n: bit8 :: 0xF6b8 + var m: bit8 :: 0x0Ab8 do cui@print(n.or(m).toStr()) do cui@print(n.and(m).toStr()) do cui@print(n.xor(m).toStr()) @@ -66,8 +66,8 @@ func main() end block block - var n: bit16 :: 16#F6F6b16 - var m: bit16 :: 16#0A0Ab16 + var n: bit16 :: 0xF6F6b16 + var m: bit16 :: 0x0A0Ab16 do cui@print(n.or(m).toStr()) do cui@print(n.and(m).toStr()) do cui@print(n.xor(m).toStr()) @@ -78,8 +78,8 @@ func main() end block block - var n: bit32 :: 16#F6F6F6F6b32 - var m: bit32 :: 16#0A0A0A0Ab32 + var n: bit32 :: 0xF6F6F6F6b32 + var m: bit32 :: 0x0A0A0A0Ab32 do cui@print(n.or(m).toStr()) do cui@print(n.and(m).toStr()) do cui@print(n.xor(m).toStr()) @@ -90,8 +90,8 @@ func main() end block block - var n: bit64 :: 16#F6F6F6F6F6F6F6F6b64 - var m: bit64 :: 16#0A0A0A0A0A0A0A0Ab64 + var n: bit64 :: 0xF6F6F6F6F6F6F6F6b64 + var m: bit64 :: 0x0A0A0A0A0A0A0A0Ab64 do cui@print(n.or(m).toStr()) do cui@print(n.and(m).toStr()) do cui@print(n.xor(m).toStr()) diff --git a/test/kn/test0012.kn b/test/kn/test0012.kn index 127e3e81..a265e6b4 100644 --- a/test/kn/test0012.kn +++ b/test/kn/test0012.kn @@ -46,7 +46,7 @@ func main() block - var n: bit8 :: 16#12b8 + var n: bit8 :: 0x12b8 var m: bit8 var bin: []bit8 :: n $> []bit8 do @dump(bin) @@ -55,7 +55,7 @@ func main() end block block - var n: bit16 :: 16#1234b16 + var n: bit16 :: 0x1234b16 var m: bit16 var bin: []bit8 :: n $> []bit8 do @dump(bin) @@ -64,7 +64,7 @@ func main() end block block - var n: bit32 :: 16#12345678b32 + var n: bit32 :: 0x12345678b32 var m: bit32 var bin: []bit8 :: n $> []bit8 do @dump(bin) @@ -73,7 +73,7 @@ func main() end block block - var n: bit64 :: 16#F012345678ABCDEFb64 + var n: bit64 :: 0xF012345678ABCDEFb64 var m: bit64 var bin: []bit8 :: n $> []bit8 do @dump(bin) diff --git a/test/kn/test0014.kn b/test/kn/test0014.kn index 7e9094fa..4f01bbd2 100644 --- a/test/kn/test0014.kn +++ b/test/kn/test0014.kn @@ -16,7 +16,7 @@ func main() block var f: file@Writer :: file@makeWriter("test_file.bin", false) - var b: []bit8 :: [16#01b8, 16#02b8, 16#03b8, 16#04b8, 16#05b8, 16#06b8, 16#07b8] + var b: []bit8 :: [0x01b8, 0x02b8, 0x03b8, 0x04b8, 0x05b8, 0x06b8, 0x07b8] do f.write(b) do f.fin() end block diff --git a/test/kn/test0015.kn b/test/kn/test0015.kn index 4b803486..0848de96 100644 --- a/test/kn/test0015.kn +++ b/test/kn/test0015.kn @@ -33,10 +33,10 @@ func main() end block block - do cui@print((16#12b8).endian().toStr()) - do cui@print((16#1234b16).endian().toStr()) - do cui@print((16#12345678b32).endian().toStr()) - do cui@print((16#12345678ABCDEF01b64).endian().toStr()) + do cui@print((0x12b8).endian().toStr()) + do cui@print((0x1234b16).endian().toStr()) + do cui@print((0x12345678b32).endian().toStr()) + do cui@print((0x12345678ABCDEF01b64).endian().toStr()) end block block @@ -59,7 +59,7 @@ func main() end for var before: []bit8 :: #[14]bit8 for i(0, 13) - do before[i] :: (i * 16#11) $ bit8 + do before[i] :: (i * 0x11) $ bit8 end for var coded: []bit8 :: lib@encrypt(before, key) do cui@print((^coded).toStr()) diff --git a/test/kn/test0017.kn b/test/kn/test0017.kn index 85adad40..e318aacb 100644 --- a/test/kn/test0017.kn +++ b/test/kn/test0017.kn @@ -9,14 +9,16 @@ func main() end class class ObjB(ObjA) - +**func f(str: []char): int + +*func f(str: []char): int + do super(me, str) do cui@print("B" ~ str) ret 2 end func end class class ObjC(ObjB) - +**func f(str: []char): int + +*func f(str: []char): int + do super(me, str) do cui@print("C" ~ str) ret 3 end func diff --git a/test/kn/test0021.kn b/test/kn/test0021.kn new file mode 100644 index 00000000..a88fbb9f --- /dev/null +++ b/test/kn/test0021.kn @@ -0,0 +1,67 @@ +func main() + for(1, 3) + block + var a: list :: #list + do a.add(3) + do a.add(5) + do a.head() + if(a.find(3)) + do cui@print(a.get().toStr()) + else + do cui@print("Not found.") + end if + if(a.find(5)) + do cui@print(a.get().toStr()) + else + do cui@print("Not found.") + end if + if(a.find(7)) + do cui@print(a.get().toStr()) + else + do cui@print("Not found.") + end if + do a.tail() + if(a.findLast(3)) + do cui@print(a.get().toStr()) + else + do cui@print("Not found.") + end if + if(a.findLast(5)) + do cui@print(a.get().toStr()) + else + do cui@print("Not found.") + end if + if(a.findLast(7)) + do cui@print(a.get().toStr()) + else + do cui@print("Not found.") + end if + end block + + block + do cui@print(math@knapsack([2, 1, 3, 2], [3, 2, 4, 2], 5, false).toStr()) + do cui@print(math@knapsack([3, 4, 2], [4, 5, 3], 7, true).toStr()) + end block + + block + var d: []int :: math@dijkstra(7, [0, 1, 0, 2, 1, 2, 1, 3, 2, 3, 1, 4, 4, 5, 3, 5, 4, 6, 5, 6], [1, 0, 2, 0, 2, 1, 3, 1, 3, 2, 4, 1, 5, 4, 5, 3, 6, 4, 6, 5], [2, 2, 5, 5, 4, 4, 6, 6, 2, 2, 10, 10, 3, 3, 1, 1, 5, 5, 9, 9], 0) + for i(0, ^d - 1) + do cui@print(d[i].toStr()) + end for + end block + + block + var d: []int :: math@bellmanFord(7, [0, 1, 0, 2, 1, 2, 1, 3, 2, 3, 1, 4, 4, 5, 3, 5, 4, 6, 5, 6], [1, 0, 2, 0, 2, 1, 3, 1, 3, 2, 4, 1, 5, 4, 5, 3, 6, 4, 6, 5], [2, 2, 5, 5, 4, 4, 6, 6, 2, 2, 10, 10, 3, 3, 1, 1, 5, 5, 9, 9], 0) + for i(0, ^d - 1) + do cui@print(d[i].toStr()) + end for + end block + + block + var d: [][]int :: math@floydWarshall(7, [0, 1, 0, 2, 1, 2, 1, 3, 2, 3, 1, 4, 4, 5, 3, 5, 4, 6, 5, 6], [1, 0, 2, 0, 2, 1, 3, 1, 3, 2, 4, 1, 5, 4, 5, 3, 6, 4, 6, 5], [2, 2, 5, 5, 4, 4, 6, 6, 2, 2, 10, 10, 3, 3, 1, 1, 5, 5, 9, 9]) + for i(0, ^d - 1) + do cui@print(d[0][i].toStr()) + end for + end block + end for +end func