doc: update simple example with for-loop

This commit is contained in:
2025-05-08 10:51:59 +01:00
parent 0cf7dd9780
commit c31638c3de
2 changed files with 51 additions and 3 deletions

46
doc/mie/sample/Simple.mie Normal file
View File

@@ -0,0 +1,46 @@
data @cout = external global id
data @.str.0 = str "less"
data @.str.1 = str "more"
data @.str.2 = str "equal"
define void @init(id %self, id %0) static {
entry:
%x = alloca id
store i32 #2, ptr %x
%y = alloca id
store i32 #3, ptr %y
%1 = load i32, ptr %x
%2 = load i32, ptr %y
%3 = cmp lt i32 %1, %2
br i1 %3, label %if.true, label %if.false
if.true:
%4 = load id, ptr @cout
%5 = load str, ptr @.str.0
msg void, id %4, @_M03putE [str %5]
br label %if.end
if.false:
%6 = load i32, ptr %x
%7 = load i32, ptr %y
%8 = cmp gt i32 %6, %7
br i1 %8, label %if.true.0, label %if.false.0
if.true.0:
%9 = load id, ptr @cout
%10 = load str, ptr @.str.1
msg void, id %9, @_M03putE [str %10]
br label %if.end
if.false.0:
%11 = load id, ptr @cout
%12 = load str, ptr @.str.2
msg void, id %11, @_M03putE [str %12]
br label %if.end
if.end:
ret void
}

View File

@@ -1,3 +1,5 @@
var y = 32. var x = "Hello, world!".
var f = [ :x | x * 2 + y ].
var result = f(4). for (ch, cy) in x do
cout put:ch
end