Created
August 3, 2008 00:59
-
-
Save erichocean/3790 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Account cfgTestCall := block( arg1, arg2, # block, so undefined symbols are lexically-scoped when patched | |
cfg( i32 /* return type*/, i32 arg1, i32 arg2, /* typed arguments */ | |
bb( start, // labeled "start", label only valid within this cfg | |
tail call int32 %sprintf( i32 arg1, i8 arg2 ) | |
%ignored = opaque %dynamicBB // dynamicBB is a method, but we don't have to call it as one in LLVM if there are no args | |
br label block2 | |
) | |
bb( block2, // labeled "block2", label only valid within this cfg | |
%addresult = add i32 1, %AnArg ; <i32> [#uses=1] | |
%list = %List* %dynamicBlock // dynamic call (no need to use intrinsics when there are zero args) | |
ret i32 %addresult | |
) | |
// create "named" block of dynamic code in a cfg by assigning it to a slot/symbol in the CFG's local scope | |
setSlot( dynamicBB, block( | |
"Calling dynamic code from static code is cool!" println // normal Io-style code within an llwm cfg! | |
)) | |
) | |
) | |
Account balance := method( cfg( i64, bb( ret i64 10000 ))) # label is optional, startingBalance => $100, symbols are object-scoped |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment