about summary refs log tree commit diff stats
path: root/apps/tile/grapheme-stack.mu
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-10-20 01:03:39 -0700
committerKartik Agaram <vc@akkartik.com>2020-10-20 01:07:21 -0700
commitc2d537c46b234f03d683f967aafbca20914a72e1 (patch)
tree4c31db55a98a4187605f13284dcfd6550ec4dfe3 /apps/tile/grapheme-stack.mu
parent0cdbfff25664d2bd3257220ca1509e7bfbd84c75 (diff)
downloadmu-c2d537c46b234f03d683f967aafbca20914a72e1.tar.gz
7080
Constructing new functions with ctrl-d is now working right. But the call
seems exactly flipped.
Diffstat (limited to 'apps/tile/grapheme-stack.mu')
-rw-r--r--apps/tile/grapheme-stack.mu19
1 files changed, 19 insertions, 0 deletions
diff --git a/apps/tile/grapheme-stack.mu b/apps/tile/grapheme-stack.mu
index 3b8d95f9..620e2eda 100644
--- a/apps/tile/grapheme-stack.mu
+++ b/apps/tile/grapheme-stack.mu
@@ -180,3 +180,22 @@ $suffix-match?:body: {
   result <- copy 1   # true
 }
 }
+
+fn grapheme-stack-is-decimal-integer? _self: (addr grapheme-stack) -> result/eax: boolean {
+  var self/esi: (addr grapheme-stack) <- copy _self
+  var data-ah/eax: (addr handle array grapheme) <- get self, data
+  var _data/eax: (addr array grapheme) <- lookup *data-ah
+  var data/edx: (addr array grapheme) <- copy _data
+  var top-addr/ecx: (addr int) <- get self, top
+  var i/ebx: int <- copy 0
+  $grapheme-stack-is-integer?:loop: {
+    compare i, *top-addr
+    break-if->=
+    var g/edx: (addr grapheme) <- index data, i
+    result <- is-decimal-digit? *g
+    compare result, 0  # false
+    break-if-=
+    i <- increment
+    loop
+  }
+}