summary refs log tree commit diff stats
path: root/compiler/vm.nim
Commit message (Expand)AuthorAgeFilesLines
* new gensym handling (#11985)Andreas Rumpf2019-08-231-1/+1
* Lock semchecked ast for macros (#11883) [bugfix]Arne Döring2019-08-081-10/+15
* int128 on firstOrd, lastOrd and lengthOrd (#11701)Arne Döring2019-08-071-3/+3
* VM exception fixes (#11868)Oscar Nihlgård2019-08-021-2/+10
* Fix VM conversion to var type [bugfix] (#11866)Oscar Nihlgård2019-08-011-2/+2
* [refactoring] remove unused imports in the compiler and in some stdlib modulesAraq2019-07-181-1/+1
* 'nim check' stability improvementsAraq2019-07-141-1/+9
* fixes #8405: -d:useNimRtl now works even when {.rtl.} procs are used at compi...Timothee Cour2019-07-031-1/+4
* [refactoring] remove zeroExtend and friends from the compiler builtins. (#11531)Arne Döring2019-06-241-10/+0
* fix for passing tuples as static params to macros (#11423); fixes #10751 [bug...Arne Döring2019-06-071-3/+20
* fix macrocache implementation (#11404)andri lim2019-06-051-7/+9
* intVal works now on enum field symbols (#11403)Arne Döring2019-06-051-3/+8
* pass typedesc as NimNode to macros (#11400)Arne Döring2019-06-051-2/+2
* make fullpaths the default in error messages and stack traces for mor… (#11...Andreas Rumpf2019-06-051-1/+1
* Remove immediate pragma (#11308)Arne Döring2019-05-291-11/+6
* right shift is now by default sign preserving (#11322)Arne Döring2019-05-291-5/+11
* Allow void macro result (#11286)Arne Döring2019-05-211-1/+1
* Replace countup(x, y) with x .. yClyybber2019-05-071-1/+1
* Replace countup(x, y-1) with x ..< yClyybber2019-05-071-3/+3
* Compiler plugin for implementing incremental computation in user space (#10819)cooldome2019-04-111-3/+1
* sizeof alignof offsetof macros api (#10855)Arne Döring2019-03-191-0/+21
* Initial version of the hot-code reloading support for native targets (#10729)zah2019-02-261-2/+9
* FFI at CT (#10150)Timothee Cour2019-02-231-11/+26
* revive #10228 (fix #9880) (#10610)Timothee Cour2019-02-131-11/+11
* fixes #10547Andreas Rumpf2019-02-131-5/+6
* Rework exception handling in the VM (#10544)LemonBoy2019-02-081-101/+156
* Vm bitops fixes (#10520)Arne Döring2019-02-051-0/+5
* Fixes https://github.com/nim-lang/Nim/issues/8484 (#10470) [backport]Neelesh Chandola2019-01-281-1/+2
* Object downconversion in VM should not copy (#10378)LemonBoy2019-01-221-0/+5
* Support system.reset in vm (#10400)Oscar Nihlgård2019-01-211-2/+0
* improve vmgen.codeListing formatting (#10306)Timothee Cour2019-01-151-4/+3
* fixes #10104Araq2019-01-131-6/+12
* [error messages, stacktraces] fix #8794 #9270 #9767 #9768 (#9766)Timothee Cour2019-01-081-5/+10
* fix #9872: setLen now works properly at CT [backport]Timothee Cour2018-12-081-16/+2
* Add isInstanceOf for generic procs to the macros module (#9730)cooldome2018-11-211-0/+11
* Of operator in vm fixes [backport] (#9717)cooldome2018-11-151-1/+1
* VM: don't inject destructor calls, refs #7041Andreas Rumpf2018-11-061-6/+6
* Add testAndrii Riabushenko2018-10-241-5/+9
* Add int float casts to vmAndrii Riabushenko2018-10-241-0/+12
* Change the order of compilation passes, transformation is made lazy at code g...cooldome2018-10-181-0/+11
* Make the registered passes local to the ModuleGraph (#9259)LemonBoy2018-10-091-1/+1
* Fix error during field access in VMLemonBoy2018-09-171-3/+7
* Add sym owner to macros (#8253)cooldome2018-09-031-0/+9
* fixes the remaining fixable Nimrod->Nim renamings; closes #2032Araq2018-09-031-1/+1
* fixes #8740Araq2018-09-031-1/+1
* Allow `hint` and `warning` to specify its loc info (#8771)LemonBoy2018-08-281-8/+12
* fixes 8754 (#8755)cooldome2018-08-241-0/+8
* even more strict isNil handling for strings/seqs in order to detect bugsAraq2018-08-221-12/+10
* fixes #6255, add `system.ashr` arithmetic right shift (#8547)andri lim2018-08-071-0/+3
* fixes #5617, 'copyLineInfo' addition (#8523)andri lim2018-08-051-14/+13
n class="s2">"0", "q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "a", "s", "d", "f", "g", "h", "j", "k", "l", "z", "x", "c", "v", "b", "n", "m"} local upper = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "A", "S", "D", "F", "G", "H", "J", "K", "L", "Z", "X", "C", "V", "B", "N", "M"} local xCoords = { 38, 74, 110, 146, 182, 218, 254, 290, 326, 362, 38, 74, 110, 146, 182, 218, 254, 290, 326, 362, 56, 92, 128, 164, 200, 236, 272, 308, 344, 74, 110,146, 182, 218, 254, 290} local yCoords = {100, 125, 150, 175} local row1CharCount = 10 local row2CharCount = 10 local row3CharCount = 9 local row4CharCount = 8 local row5CharCount = 2 local keyRow1Y = 100 local keyRow2Y = 125 local keyRow3Y = 150 local keyRow4Y = 175 local focusWidth = 26 local focusHeight = 30 local margin = 20 function TextInputScreen:init() TextInputScreen.super.init(self) self.lower = true self.showing = false self.input = "" self.defaultFont = gfx.getFont() local pixarlmed = gfx.font.new("Fonts/pixarlmed") gfx.setFont(pixarlmed) self.backgroundImageLower = playdate.graphics.image.new(400, 240) gfx.pushContext(self.backgroundImageLower) playdate.graphics.setColor(playdate.graphics.kColorWhite) gfx.fillRect(0, 0, 400, 240) playdate.graphics.setColor(playdate.graphics.kColorBlack) for n=1,36 do local y = 0 if n <= 10 then y = keyRow1Y elseif n <= 20 then y = keyRow2Y elseif n <= 29 then y = keyRow3Y else y = keyRow4Y end gfx.drawTextAligned(chars[n], xCoords[n], y, kTextAlignment.center) end gfx.drawTextAligned("del", 343, 175, kTextAlignment.center) gfx.drawTextAligned("space", 200, 205, kTextAlignment.center) gfx.drawTextAligned("done", 335, 205, kTextAlignment.center) gfx.popContext() self.backgroundImageUpper = playdate.graphics.image.new(400, 240) gfx.pushContext(self.backgroundImageUpper) playdate.graphics.setColor(playdate.graphics.kColorWhite) gfx.fillRect(0, 0, 400, 240) playdate.graphics.setColor(playdate.graphics.kColorBlack) for n=1,36 do local y = 0 if n <= 10 then y = keyRow1Y elseif n <= 20 then y = keyRow2Y elseif n <= 29 then y = keyRow3Y else y = keyRow4Y end gfx.drawTextAligned(upper[n], xCoords[n], y, kTextAlignment.center) end gfx.drawTextAligned("del", 343, 175, kTextAlignment.center) gfx.drawTextAligned("space", 200, 205, kTextAlignment.center) gfx.drawTextAligned("done", 335, 205, kTextAlignment.center) gfx.popContext() self:setImage(self.backgroundImageLower) self:moveTo(200, 120) self.rowIndex = 3 self.letterIndex = 5 local focusImage = playdate.graphics.image.new(focusWidth, focusHeight) gfx.pushContext(focusImage) playdate.graphics.setColor(playdate.graphics.kColorBlack) gfx.drawRoundRect(0, 0, focusWidth, focusHeight, 7) gfx.popContext() self.focusSprite = gfx.sprite.new(focusImage) local spacebarWidth = 136 local spacebarHeight = focusHeight local spacebarImage = playdate.graphics.image.new(spacebarWidth, 30) gfx.pushContext(spacebarImage) playdate.graphics.setColor(playdate.graphics.kColorBlack) gfx.drawRoundRect(0, 0, spacebarWidth, spacebarHeight, 7) gfx.popContext() self.spacebarSprite = gfx.sprite.new(spacebarImage) self.spacebarSprite:moveTo(200, 216) local deleteWidth = 50 local deleteHeight = focusHeight local deleteImage = playdate.graphics.image.new(deleteWidth, 30) gfx.pushContext(deleteImage) playdate.graphics.setColor(playdate.graphics.kColorBlack) gfx.drawRoundRect(0, 0, deleteWidth, deleteHeight, 7) gfx.popContext() self.deleteSprite = gfx.sprite.new(deleteImage) self.deleteSprite:moveTo(345, keyRow4Y + (focusHeight/2) - 5) local doneWidth = 63 local doneHeight = focusHeight local doneImage = playdate.graphics.image.new(doneWidth, 30) gfx.pushContext(doneImage) playdate.graphics.setColor(playdate.graphics.kColorBlack) gfx.drawRoundRect(0, 0, doneWidth, doneHeight, 7) gfx.popContext() self.doneSprite = gfx.sprite.new(doneImage) self.doneSprite:moveTo(336, 216) local inputImage = playdate.graphics.image.new(1, 1) self.inputSprite = gfx.sprite.new(inputImage) self.inputSprite:moveTo(200, 67) end function TextInputScreen:isShowing() return self.showing end function TextInputScreen:push(message, onDone) self.onDone = onDone self:add() self.focusSprite:add() self.inputSprite:add() self:updateFocusCaret() if message ~= nil then local messageImage = gfx.imageWithText(message, 400, 100) self.messageSprite = gfx.sprite.new(messageImage) self.messageSprite:moveTo(200, 25) self.messageSprite:add() end self.inputHandler = { cranked = function(change, acceleratedChange) end, leftButtonDown = function() self.letterIndex = math.max(1, self.letterIndex - 1) self:updateFocusCaret() end, rightButtonDown = function() self.letterIndex += 1 if self.rowIndex == 1 then if self.letterIndex > row1CharCount then self.letterIndex = row1CharCount end elseif self.rowIndex == 2 then if self.letterIndex > row2CharCount then self.letterIndex = row2CharCount end elseif self.rowIndex == 3 then if self.letterIndex > row3CharCount then self.letterIndex = row3CharCount end elseif self.rowIndex == 4 then if self.letterIndex > row4CharCount then self.letterIndex = row4CharCount end end self:updateFocusCaret() end, upButtonDown = function() self.rowIndex = math.max(1, self.rowIndex - 1) if self.rowIndex == 4 then self.letterIndex = 4 end self:updateFocusCaret() end, downButtonDown = function() self.rowIndex = math.min(5, self.rowIndex + 1) if self.rowIndex == 1 then if self.letterIndex > row1CharCount then self.letterIndex = row1CharCount end elseif self.rowIndex == 2 then if self.letterIndex > row2CharCount then self.letterIndex = row2CharCount end elseif self.rowIndex == 3 then if self.letterIndex > row3CharCount then self.letterIndex = row3CharCount end elseif self.rowIndex == 4 then if self.letterIndex > row4CharCount then self.letterIndex = row4CharCount end elseif self.rowIndex == 5 then --space bar self.letterIndex = 1 end self:updateFocusCaret() end, BButtonDown = function() self.lower = not self.lower if self.lower then self:setImage(self.backgroundImageLower) else self:setImage(self.backgroundImageUpper) end end, AButtonDown = function() self.focusSprite:moveBy(0, 1) self.spacebarSprite:moveBy(0, 1) self.deleteSprite:moveBy(0, 1) if self.rowIndex == 1 then if self.lower then self.input = self.input .. chars[self.letterIndex] else self.input = self.input .. upper[self.letterIndex] end elseif self.rowIndex == 2 then if self.lower then self.input = self.input .. chars[self.letterIndex + 10] else self.input = self.input .. upper[self.letterIndex + 10] end elseif self.rowIndex == 3 then if self.lower then self.input = self.input .. chars[self.letterIndex + 20] else self.input = self.input .. upper[self.letterIndex + 20] end elseif self.rowIndex == 4 then if self.letterIndex == row4CharCount then if string.len(self.input) > 0 then self.input = self.input:sub(1, -2) end else if self.lower then self.input = self.input .. chars[self.letterIndex + 29] else self.input = self.input .. upper[self.letterIndex + 29] end end elseif self.rowIndex == 5 then if self.letterIndex == 1 then self.input = self.input .. " " elseif self.letterIndex == 2 then self:pop() return end end print("Input: " .. self.input) if string.len(self.input) > 0 then local inputImage = gfx.imageWithText(self.input, 400, 100) self.inputSprite:setImage(inputImage) self.inputSprite:add() else self.inputSprite:remove() end end, BButtonUp = function() end, AButtonUp = function() self.focusSprite:moveBy(0, -1) self.spacebarSprite:moveBy(0, -1) self.deleteSprite:moveBy(0, -1) end } playdate.inputHandlers.push(self.inputHandler) self.showing = true end function TextInputScreen:updateFocusCaret() if self.rowIndex == 1 then self.focusSprite:moveTo(xCoords[self.letterIndex], yCoords[self.rowIndex] + (focusHeight/2) - 5) self.focusSprite:add() self.spacebarSprite:remove() self.deleteSprite:remove() elseif self.rowIndex == 2 then self.focusSprite:moveTo(xCoords[self.letterIndex + 10], yCoords[self.rowIndex] + (focusHeight/2) - 5) self.focusSprite:add() self.spacebarSprite:remove() self.deleteSprite:remove() elseif self.rowIndex == 3 then self.focusSprite:moveTo(xCoords[self.letterIndex + 20], yCoords[self.rowIndex] + (focusHeight/2) - 5) self.focusSprite:add() self.spacebarSprite:remove() self.deleteSprite:remove() elseif self.rowIndex == 4 then if self.letterIndex == row4CharCount then --delete self.focusSprite:remove() self.spacebarSprite:remove() self.deleteSprite:add() else self.focusSprite:moveTo(xCoords[self.letterIndex + 29], yCoords[self.rowIndex] + (focusHeight/2) - 5) self.focusSprite:add() self.spacebarSprite:remove() self.deleteSprite:remove() end self.doneSprite:remove() elseif self.rowIndex == 5 then self.focusSprite:remove() self.deleteSprite:remove() if self.letterIndex == 1 then self.spacebarSprite:add() self.doneSprite:remove() elseif self.letterIndex == 2 then self.spacebarSprite:remove() self.doneSprite:add() end else print("Invalid row index: " .. self.rowIndex) end end function TextInputScreen:pop() self.isShowing = false gfx.setFont(self.defaultFont) self.focusSprite:remove() self.spacebarSprite:remove() self.deleteSprite:remove() self.doneSprite:remove() self.inputSprite:remove() self.focusSprite = nil self.spacebarSprite = nil self.deleteSprite = nil self.doneSprite = nil self.inputSprite = nil if self.messageSprite ~= nil then self.messageSprite:remove() self.messageSprite = nil end self:remove() playdate.inputHandlers.pop() if self.onDone ~= nil then self.onDone(self.input) end end