summary refs log tree commit diff stats
path: root/compiler/lowerings.nim
Commit message (Expand)AuthorAgeFilesLines
* made indirectAccess slightly more efficientAndreas Rumpf2015-12-281-1/+2
* first implementation of the new lambda-lifting pass; barely anything worksAndreas Rumpf2015-12-261-1/+1
* tuple unpacking works in a non-var/let contextAraq2015-08-211-0/+26
* Merge branch 'more_concurrency' into develAraq2015-06-301-5/+8
|\
| * first implementation of pinnedSpawnAraq2015-05-281-5/+8
* | fixes #2297, fixes #2946Araq2015-06-181-0/+20
|/
* system.locals is now a plugin for educationAraq2015-04-241-0/+4
* first implementation of overloading of '='; missing: rewriting let/var sectionsAraq2015-04-061-2/+2
* fixes #2286Araq2015-03-121-20/+31
* fixes #325Araq2015-01-281-1/+0
* Happy new year!Guillaume Gelin2015-01-061-1/+1
* fixes a tuple lowering bugAraq2014-12-131-3/+4
* renamed CondVar to SemaphoreAraq2014-11-101-1/+1
* the codegen doesn't emit deepCopy for parallel statementsAraq2014-11-081-10/+17
* fixes exhaustion bug and missing GC_ref code generationAraq2014-11-071-0/+6
* merged things from develAraq2014-09-121-0/+1
|\
| * fixes #665Araq2014-09-111-0/+1
* | Nimrod renamed to NimAraq2014-08-281-1/+1
* | renamefestAraq2014-08-231-6/+6
|/
* progress on 'spawn'Araq2014-08-101-2/+2
* 'parallel' statement works againAraq2014-08-081-6/+4
* progress on deepCopyAraq2014-08-011-25/+41
* new jester compilesAraq2014-06-281-0/+10
* compiles againAraq2014-06-271-1/+1
* some progress for jester+asyncAraq2014-06-271-1/+16
* rewrote lambdalifting; fixes deeply nested closuresAraq2014-06-261-0/+16
* big rename: Promise -> FlowVarAraq2014-06-061-46/+46
* Promises are now refsAraq2014-06-051-22/+23
* fixed codegen for barriersAraq2014-06-021-2/+7
* bugfix: codegen for promisesAraq2014-06-021-4/+11
* fixed codegen for return valuesAraq2014-06-011-12/+15
* pi test compiles, but crashes randomlyAraq2014-06-011-4/+14
* tdisjoint_slice2 worksAraq2014-05-311-1/+1
* correct code generation for tforstmtAraq2014-05-301-20/+34
* bugfix: regionized pointers in a generic context; renamed 'Future' to 'Promise'Araq2014-05-251-44/+44
* progress with futuresAraq2014-05-231-5/+22
* 'parallel' statement almost workingAraq2014-05-221-41/+245
* progress for the 'parallel' statementAraq2014-05-141-0/+1
* initial non-compiling version of 'parallel'Araq2014-05-121-3/+19
* reintroduce thread analysis but disable it for backwards compatibilityAraq2014-04-201-3/+4
* actors compile againAraq2014-04-201-0/+1
* New concurrency model: next stepsAraq2014-04-191-1/+3
* first version of 'spawn'Araq2014-04-161-1/+173
* fixes #404Araq2014-03-231-0/+52
<- address fahrenheit-input-storage initialize-gap-buffer fahrenheit-input, 8/capacity value-to-input fahrenheit, fahrenheit-input # cursor toggle var cursor-in-celsius?/edx: boolean <- copy 0xffffffff/true # render-title screen # event loop { # render render-state screen, celsius-input, fahrenheit-input, cursor-in-celsius? render-menu-bar screen # process a single keystroke $main:input: { var key/eax: byte <- read-key keyboard var key/eax: code-point-utf8 <- copy key compare key, 0 loop-if-= # tab = switch cursor between input areas compare key, 9/tab { break-if-!= cursor-in-celsius? <- not break $main:input } # enter = convert in appropriate direction compare key, 0xa/newline { break-if-!= { compare cursor-in-celsius?, 0/false break-if-= var tmp/xmm0: float <- input-to-value celsius-input celsius <- copy tmp fahrenheit <- celsius-to-fahrenheit celsius value-to-input fahrenheit, fahrenheit-input break $main:input } var tmp/xmm0: float <- input-to-value fahrenheit-input fahrenheit <- copy tmp celsius <- fahrenheit-to-celsius fahrenheit value-to-input celsius, celsius-input break $main:input } # otherwise pass key to appropriate input area compare cursor-in-celsius?, 0/false { break-if-= edit-gap-buffer celsius-input, key break $main:input } edit-gap-buffer fahrenheit-input, key } loop } } # business logic fn fahrenheit-to-celsius f: float -> _/xmm1: float { var result/xmm1: float <- copy f var thirty-two/eax: int <- copy 0x20 var thirty-two-f/xmm0: float <- convert thirty-two result <- subtract thirty-two-f var factor/xmm0: float <- rational 5, 9 result <- multiply factor return result } fn celsius-to-fahrenheit c: float -> _/xmm2: float { var result/xmm1: float <- copy c var factor/xmm0: float <- rational 9, 5 result <- multiply factor var thirty-two/eax: int <- copy 0x20 var thirty-two-f/xmm0: float <- convert thirty-two result <- add thirty-two-f return result } # helpers for UI fn input-to-value in: (addr gap-buffer) -> _/xmm0: float { var s-storage: (stream byte 0x10) var s/ecx: (addr stream byte) <- address s-storage emit-gap-buffer in, s var result/xmm1: float <- parse-float-decimal s return result } fn value-to-input in: float, out: (addr gap-buffer) { var s-storage: (stream byte 0x10) var s/ecx: (addr stream byte) <- address s-storage write-float-decimal-approximate s, in, 2/decimal-places clear-gap-buffer out load-gap-buffer-from-stream out, s } # helpers for rendering to screen # magic constants here need to be consistent between functions fn render-title screen: (addr screen) { set-cursor-position screen, 0x1f/x 0xe/y draw-text-rightward-from-cursor-over-full-screen screen, " Converter ", 0xf/fg 0x16/bg } fn render-state screen: (addr screen), c: (addr gap-buffer), f: (addr gap-buffer), cursor-in-c?: boolean { clear-rect screen, 0x1f/xmin 0xf/ymin, 0x45/xmax 0x14/ymax, 0xc5/color var x/eax: int <- render-gap-buffer screen, c, 0x20/x 0x10/y, cursor-in-c?, 7/fg 0/bg x <- draw-text-rightward screen, " celsius = ", x, 0x45/xmax, 0x10/y, 7/fg 0xc5/bg var cursor-in-f?/ecx: boolean <- copy cursor-in-c? cursor-in-f? <- not x <- render-gap-buffer screen, f, x 0x10/y, cursor-in-f?, 7/fg 0/bg x <- draw-text-rightward screen, " fahrenheit", x, 0x45/xmax, 0x10/y, 7/fg 0xc5/bg } fn render-menu-bar screen: (addr screen) { set-cursor-position screen, 0x21/x 0x12/y draw-text-rightward-from-cursor-over-full-screen screen, " tab ", 0/fg 0x5c/bg=highlight draw-text-rightward-from-cursor-over-full-screen screen, " switch sides ", 7/fg 0xc5/bg draw-text-rightward-from-cursor-over-full-screen screen, " enter ", 0/fg 0x5c/bg=highlight draw-text-rightward-from-cursor-over-full-screen screen, " convert ", 7/fg 0xc5/bg }