@@ -47,7 +47,7 @@ type SymbolGenerator(context:Context,name:string) =
4747 interface IGenerator with
4848 member this.Generate ilGen =
4949 try
50- let ctxval = context.locals.[ name]
50+ let ctxval = context.locals.[ new Symbol ( name) ]
5151 match ctxval with
5252 | Local ( local, _) ->
5353 ilGen.Emit( OpCodes.Ldloc, local)
@@ -56,7 +56,7 @@ type SymbolGenerator(context:Context,name:string) =
5656 with
5757 | :? KeyNotFoundException -> failwithf " Symbol %A not bound." name
5858 member this.ReturnTypes () =
59- match context.locals.[ name] with
59+ match context.locals.[ new Symbol ( name) ] with
6060 | Local (_, t) -> [ t]
6161 | Arg (_, t) -> [ t]
6262
@@ -121,7 +121,7 @@ type LetGenerator(context:Context,typeBuilder:TypeBuilder,bindings:SExp,body:SEx
121121 let generator = gf.MakeGenerator scope_ subctx form
122122 let local_type = List.head ( generator.ReturnTypes())
123123 let local = ilGen.DeclareLocal( local_ type)
124- scope_ subctx.locals.[ name] <- Local ( local, local_ type)
124+ scope_ subctx.locals.[ new Symbol ( name) ] <- Local ( local, local_ type)
125125 generator.Generate ilGen
126126 ilGen.Emit ( OpCodes.Stloc, local)
127127 | other -> failwithf " In let bindings: Expected: (name (form))\n Got: %A \n " other
@@ -137,7 +137,7 @@ type LetGenerator(context:Context,typeBuilder:TypeBuilder,bindings:SExp,body:SEx
137137 match binding with
138138 | List [( Atom ( Symbol name)); form] ->
139139 let generator = gf.MakeGenerator type_ subctx form
140- type_ subctx.locals.[ name] <- Local ( null , generator.ReturnTypes() |> List.head)
140+ type_ subctx.locals.[ new Symbol ( name) ] <- Local ( null , generator.ReturnTypes() |> List.head)
141141 | other -> failwithf " In let bindings: Expected: (name (form))\n Got: %A \n " other
142142 | other -> failwithf " In let form: expected: list of bindings\n Got: %A " other
143143 ( gf.MakeBody type_ subctx body) .ReturnTypes()
@@ -181,7 +181,7 @@ type FullIfGenerator(context:Context,typeBuilder:TypeBuilder,condition:SExp,if_t
181181
182182type FunCallGenerator ( context : Context , typeBuilder : TypeBuilder , fname : string , arguments : SExp list , gf : IGeneratorFactory ) =
183183 let args_seq = gf.MakeSequence context arguments
184- let func = context.functions.[ fname] <| args_ seq.ReturnTypes()
184+ let func = context.functions.[ new Symbol ( fname) ] <| args_ seq.ReturnTypes()
185185 interface IGenerator with
186186 member this.Generate ilGen =
187187 args_ seq.Generate ilGen
@@ -190,15 +190,15 @@ type FunCallGenerator(context:Context,typeBuilder:TypeBuilder,fname:string,argum
190190 [ func.ReturnType]
191191
192192type DefunGenerator ( context : Context , typeBuilder : TypeBuilder , fname : string , parameters : SExp list , body : SExp list , gf : IGeneratorFactory ) =
193- do context.functions.[ fname] <- ( fun arg_types ->
193+ do context.functions.[ new Symbol ( fname) ] <- ( fun arg_types ->
194194 let methodGen = typeBuilder.DefineMethod( fname, MethodAttributes.Public ||| MethodAttributes.Static, typeof< obj>, ( Array.ofList arg_ types))
195195 let methodILGen = ( methodGen.GetILGenerator())
196196 let fun_ctx = new Context( context)
197197 for parm in parameters do
198198 match parm with
199199 | Atom( Symbol parm_ name) ->
200200 let parm_idx = ( List.findIndex ( fun ( p ) -> p = parm) parameters)
201- fun_ ctx.locals.[ parm_ name] <- Arg ( parm_ idx, arg_ types.[ parm_ idx])
201+ fun_ ctx.locals.[ new Symbol ( parm_ name) ] <- Arg ( parm_ idx, arg_ types.[ parm_ idx])
202202 | other -> failwithf " In function %A parameter definition:\n Expected: Atom(Symbol)\n Got: %A " fname parm
203203 let bodyGen = gf.MakeBody fun_ ctx body
204204 bodyGen.Generate methodILGen
@@ -253,21 +253,21 @@ type NewObjGenerator(context : Context, typeBuilder : TypeBuilder, typeName : st
253253 if typeName.StartsWith " System" then
254254 Type.GetType typeName
255255 else
256- context.types.[ typeName]
256+ context.types.[ new Symbol ( typeName) ]
257257 let arg_types = args_ gen.Generate ilGen
258258 ilGen.Emit( OpCodes.Newobj, objType.GetConstructor( Array.ofList argTypes))
259259 member this.ReturnTypes () =
260260 if typeName.StartsWith " System" then
261261 [ Type.GetType typeName]
262262 else
263- [ context.types.[ typeName]]
263+ [ context.types.[ new Symbol ( typeName) ]]
264264
265265type TypeGenerator ( context : Context , typeBuilder : TypeBuilder , typeName : string , parentTypeName : string , members : SExp list , gf : IGeneratorFactory ) =
266266 let newTypeBuilder =
267267 if parentTypeName = " " then
268268 Globals.ModuleBuilder.DefineType( typeName, TypeAttributes.Class ||| TypeAttributes.Public, typeof< obj>)
269269 else
270- Globals.ModuleBuilder.DefineType( typeName, TypeAttributes.Class ||| TypeAttributes.Public, context.types.[ parentTypeName])
270+ Globals.ModuleBuilder.DefineType( typeName, TypeAttributes.Class ||| TypeAttributes.Public, context.types.[ new Symbol ( parentTypeName) ])
271271 let newGeneratorFactory = gf.MakeGeneratorFactory newTypeBuilder
272272 let mutable fields : string list = []
273273
@@ -283,7 +283,7 @@ type TypeGenerator(context : Context, typeBuilder : TypeBuilder, typeName : stri
283283 match parm with
284284 | Atom( Symbol parm_ name) ->
285285 let parm_idx = ( List.findIndex ( fun ( p ) -> p = parm) method_ parms)
286- method_ ctx.locals.[ parm_ name] <- Arg ( parm_ idx, typeof< obj>)
286+ method_ ctx.locals.[ new Symbol ( parm_ name) ] <- Arg ( parm_ idx, typeof< obj>)
287287 | other -> failwithf " In method %A%A parameter definition:\n Expected: Atom(Symbol)\n Got: %A " typeName method_ name parm
288288 let body_gen = newGeneratorFactory.MakeBody method_ ctx method_ body
289289 body_ gen.Generate ( method_ gen.GetILGenerator())
0 commit comments