doc: update simple example with for-loop
This commit is contained in:
46
doc/mie/sample/Simple.mie
Normal file
46
doc/mie/sample/Simple.mie
Normal 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
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user