equal
deleted
inserted
replaced
39 // llc -filetype=obj in_file.ll |
39 // llc -filetype=obj in_file.ll |
40 // gcc in_file.o -o a.out |
40 // gcc in_file.o -o a.out |
41 // ./a.out |
41 // ./a.out |
42 |
42 |
43 |
43 |
44 import $file.fun_tokens, fun_tokens._ |
44 //> using toolkit 0.5.0 |
45 import $file.fun_parser, fun_parser._ |
45 // > using file fun_tokens.scala |
|
46 // > using file fun_parser.scala |
|
47 |
|
48 //import $file.fun_tokens, fun_tokens._ |
|
49 //import $file.fun_parser, fun_parser._ |
46 |
50 |
47 |
51 |
48 // for generating new labels |
52 // for generating new labels |
49 var counter = -1 |
53 var counter = -1 |
50 |
54 |
265 l"\n$else_br" ++ |
269 l"\n$else_br" ++ |
266 compile_exp(e2) |
270 compile_exp(e2) |
267 } |
271 } |
268 } |
272 } |
269 |
273 |
270 print("%d\n", i) |
|
271 val prelude = """ |
274 val prelude = """ |
272 @.str = private constant [4 x i8] c"%d\0A\00" |
275 @.str = private constant [4 x i8] c"%d\0A\00" |
273 |
276 |
274 declare i32 @printf(i8*, ...) |
277 declare i32 @printf(i8*, ...) |
275 |
278 |
358 |
361 |
359 fibC(10, x => {println(s"Result: $x") ; 1}) |
362 fibC(10, x => {println(s"Result: $x") ; 1}) |
360 |
363 |
361 |
364 |
362 */ |
365 */ |
|
366 /* |
363 factC(6, x => x) |
367 factC(6, x => x) |
364 factC(6, x => {println(s"The final Result is $x") ; 0}) |
368 factC(6, x => {println(s"The final Result is $x") ; 0}) |
365 factC(6, _ + 1) |
369 factC(6, _ + 1) |
366 |
370 |
367 def fib(n: Int) : Int = { |
371 def fib(n: Int) : Int = { |
372 |
376 |
373 def fibC(n: Int, ret: Int => Int) : Int = { |
377 def fibC(n: Int, ret: Int => Int) : Int = { |
374 if (n == 0 || n == 1) ret(1) |
378 if (n == 0 || n == 1) ret(1) |
375 else fibC(n - 1, x => fibC(n - 2, y => ret(x + y))) |
379 else fibC(n - 1, x => fibC(n - 2, y => ret(x + y))) |
376 } |
380 } |
|
381 */ |