Permalink
Browse files

Cleaned up the method replacement slightly. Now we're using delegates…

… we no longer need the separate that alters the lambda.
  • Loading branch information...
1 parent db2cee5 commit 589e6a684aca9fd6680db96e56313f73fad782bf @ZachBray committed Dec 24, 2012
Showing with 2 additions and 25 deletions.
  1. +0 −22 FunScript.TypeScript.Interop/Interop.fs
  2. +2 −3 FunScript.TypeScript/TypeGenerator.fs
@@ -31,13 +31,6 @@ type Emit() =
let flags = BindingFlags.Public ||| BindingFlags.Static
typeof<Emit>.GetMethod("NewImpl", flags)
- static member ReplaceMethodImpl (isStatic:bool) (name:string) (args:obj[]):obj =
- failwith "never"
-
- static member ReplaceMethod =
- let flags = BindingFlags.Public ||| BindingFlags.Static
- typeof<Emit>.GetMethod("ReplaceMethodImpl", flags)
-
static member CreateObjectImpl (isStatic:bool) (name:string) (args:obj[]):obj =
failwith "never"
@@ -106,24 +99,9 @@ module Components =
| [] when isStatic -> Some([], Object [])
| _ -> None)
- let private replaceMethodReplacement =
- CompilerComponent.generateArityWithCompiler <@ Emit.ReplaceMethodImpl @> (fun (|Split|) compiler ->
- function
- | Patterns.Value(:? bool as isStatic, _)::
- Patterns.Value(:? string as meth, _)::
- Patterns.NewArray(_, [objExpr; Patterns.Coerce(lambda, _)])::[] ->
- match objExpr, lambda with
- | Split(objDecl, objRef), DerivedPatterns.Lambdas(vars, bodyExpr) ->
- let vars = vars |> List.concat
- let replacement = Lambda(vars, Block(compiler.Compile ReturnStrategies.returnFrom bodyExpr))
- Some([objDecl; [Assign(PropertyGet(objRef, meth), replacement)]], Null)
- | _ -> None
- | _ -> None)
-
let all = [
callReplacement
newReplacement
- replaceMethodReplacement
getterReplacement
setterReplacement
createObjectReplacement
@@ -227,7 +227,6 @@ let private exprFor mi callType methName exprs =
let private call callType methName exprs = exprFor Emit.Call callType methName exprs
let private createNew methName exprs = exprFor Emit.New Static methName exprs
-let private replaceMethod methName exprs = exprFor Emit.ReplaceMethod Instance methName exprs
let private propertyGet callType methName exprs = exprFor Emit.PropertyGet callType methName exprs
let private propertySet callType methName exprs = exprFor Emit.PropertySet callType methName exprs
let private createObj() = exprFor Emit.CreateObject Static "boo" []
@@ -285,7 +284,7 @@ let private createMethods defs name (meths:(TSFunction * bool) list) (parent:Mer
else call Instance name exprs) :> MemberInfo
if parent.HasInterface &&
not isStatic &&
- paramReqs.Length < 8 then
+ paramReqs.Length < 17 then
let parameter =
let parameterType = Lambda(paramReqs, returnTSType)
{ Var = { Name = "replacement"; IsOptional = false; Type = parameterType }
@@ -295,7 +294,7 @@ let private createMethods defs name (meths:(TSFunction * bool) list) (parent:Mer
parameters=[createParameter defs parameter],
returnType=typeof<Void>,
IsStaticMethod=false,
- InvokeCode=fun exprs -> replaceMethod name exprs) :> MemberInfo
+ InvokeCode=fun exprs -> propertySet Instance name exprs) :> MemberInfo
})
let rec private findReachableTypes types (mergedType:MergedType) =

0 comments on commit 589e6a6

Please sign in to comment.