Skip to content

Commit 4a8a146

Browse files
committed
added captureLocal method to Context
1 parent 6d64f3f commit 4a8a146

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

ngc/Context.fs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,15 @@ type Context =
5454
let types = List.ofArray (asm.GetTypes())
5555
List.iter (fun (t:Type) -> this.types.Add(new Symbol(t.FullName),t)) types
5656

57+
member public this.captureLocal(localName: Symbol, typeBuilder: TypeBuilder) =
58+
let local = this.locals.[localName]
59+
match local with
60+
| Local (_,t) ->
61+
let field = typeBuilder.DefineField(localName.Name,t,FieldAttributes.Static ||| FieldAttributes.Private)
62+
this.locals.[localName] <- Field (field, t)
63+
| Field (fb,_) -> ()
64+
| Arg (_,_) -> failwithf "Unable to capture parameter %A" localName.Name
65+
5766
let create () =
5867
let context = new Context()
5968
context

0 commit comments

Comments
 (0)