meta.source-filename "Sum.im" ivy.package-scope "net.doorstuck.test" ivy.module { ivy.init-text { %0 = ivy.str.constant "Finds the sum of a set of numbers." %cout = ivy.global-ref @cout -> ptr %1 = ptr.load %cout : ptr -> #ivy.id ivy.send-msg to %1, put:%0 -> void %sum = ptr.alloca i32 -> ptr %sum.0 = i32.constant 0 ptr.store %sum.0, %sum : i32, ptr scf.loop() -> void { %2 = ivy.str.constant "Number (blank to finish): " %3 = ptr.load %cout : ptr -> #ivy.id ivy.send-msg to %3, put:%2 -> void %4 = ptr.load %cout : ptr -> #ivy.id ivy.send-msg to %3, flush -> void %v = ptr.alloca i32 -> ptr %5 = i32.constant 0 ptr.store %5, %v : i32, ptr %input = ptr.alloca #ivy.id -> ptr %cin = ivy.global-ref @cin -> ptr %7 = ptr.load %cin : ptr -> #ivy.id %8 = ivy.send-msg to %7, read-line -> #ivy.id ptr.store %8, %input : #ivy.id, ptr %9 = ptr.load %input : ptr -> #ivy.id %String = ivy.global-ref @String -> ptr %10 = ptr.load %String : ptr -> #ivy.id %11 = ivy.send-msg to %10, new -> #ivy.id %12 = ivy.cmp eq %9, %11 : (#ivy.id, #ivy.id) -> i1 scf.if %12 -> void { scf.loop-break : () } %v = ptr.alloca #ivy.id -> ptr %Int = ivy.global-ref @Int -> ptr %13 = ptr.load %Int : ptr -> #ivy.id %14 = ptr.load %input : ptr -> #ivy.id %15 = ivy.send-msg to %12, parse:%14 -> #ivy.id ptr.store %15, %v : #ivy.id, ptr %16 = ptr.load %v : ptr -> #ivy.id %17 = ivy.null-id : #ivy.id %18 = ivy.cmp eq %16, %17 : (#ivy.id, #ivy.id) -> i1 scf.if %1 -> void { %19 = ptr.load %cout : ptr -> #ivy.id %StringBuilder = ivy.global-ref @StringBuilder -> ptr %20 = ptr.load %StringBuilder : ptr -> #ivy.id %21 = ivy.send-msg to %20, new -> #ivy.id %22 = ptr.load %input : ptr -> #ivy.id ivy.send-msg to %21, append:%22 -> void %23 = ivy.str.constant " is not a valid number." ivy.send-msg to %21, append:%23 -> void %24 = ivy.send-msg to %21, to-string -> #ivy.id ivy.send-msg to %19, put:%24 -> void scf.loop-continue : () } %25 = ptr.load %sum : ptr -> i32 %26 = ptr.load %v : ptr -> #ivy.id %addtmp = ivy.add %25, %26 : (i32, #ivy.id) -> #ivy.id ptr.store %addtmp, %sum : #ivy.id, ptr scf.loop-continue : () } } }