Skip to content

Commit

Permalink
Removed the Dlr.Ext module
Browse files Browse the repository at this point in the history
  • Loading branch information
fholm committed Apr 25, 2011
1 parent 7beea8b commit 348dea6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 38 deletions.
2 changes: 1 addition & 1 deletion Src/IronJS/Compiler.Function.fs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ module internal Function =
let createTempVars args =
List.foldBack (fun a (temps, args:Dlr.Expr list, ass) ->

if Dlr.Ext.isStatic a then (temps, a :: args, ass)
if Dlr.isStatic a then (temps, a :: args, ass)
else
let tmp = Dlr.param (Dlr.tmpName()) a.Type
let assign = Dlr.assign tmp a
Expand Down
4 changes: 2 additions & 2 deletions Src/IronJS/Compiler.Identifier.fs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ module internal Identifier =
| true -> getValueDynamic ctx name
| _ ->
match ctx |> getVariableStorage name with
| Some(expr, i, _) -> Dlr.Ext.static' (Dlr.indexInt expr i)
| Some(expr, i, _) -> Dlr.indexInt expr i
| _ -> Object.getPropertyReal ctx (Ast.DlrExpr ctx.Globals) name true

///
Expand All @@ -81,4 +81,4 @@ module internal Identifier =

| Some(expr, i, _) ->
let varExpr = (Dlr.indexInt expr i)
Utils.assign (Dlr.Ext.static' varExpr) value
Utils.assign varExpr value
17 changes: 8 additions & 9 deletions Src/IronJS/Compiler.Utils.fs
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,12 @@ module internal Utils =
let setTag expr t =
match t with
| TypeTags.Number -> Dlr.void'
| _ -> let expr = expr |> Dlr.Ext.unwrap in (expr .-> "Tag") .= !!!t
| _ -> (expr .-> "Tag") .= !!!t

let setTagOf expr (of':Dlr.Expr) =
setTag expr (of'.Type |> TypeTag.OfType)

let setValue (expr:Dlr.Expr) (value:Dlr.Expr)=
let expr = Dlr.Ext.unwrap expr
let field = value.Type |> TypeTag.OfType |> BV.FieldOfTag
expr.->field .= value

Expand Down Expand Up @@ -95,7 +94,7 @@ module internal Utils =
let unbox type' (expr:Dlr.Expr) =
if isBoxed expr then
let bf = type' |> TypeTag.OfType |> BV.FieldOfTag
Dlr.field (Dlr.Ext.unwrap expr) bf
Dlr.field expr bf

elif expr.Type |> FSharp.Utils.isType type' then
expr
Expand All @@ -116,7 +115,7 @@ module internal Utils =

///
let tempBlock (value:Dlr.Expr) (body:Dlr.Expr -> Dlr.Expr list) =
if value |> Dlr.Ext.isStatic then
if value |> Dlr.isStatic then
Dlr.blockSimple (body value)

else
Expand All @@ -142,16 +141,16 @@ module internal Utils =
let assign (lexpr:Dlr.Expr) rexpr =

let setBoxClrNull expr =
Dlr.assign (Dlr.field (Dlr.Ext.unwrap expr) BoxFields.Clr) Dlr.null'
Dlr.assign (Dlr.field expr BoxFields.Clr) Dlr.null'

let assignBox (lexpr:Dlr.Expr) (rexpr:Dlr.Expr) =
if isBoxed rexpr then
Dlr.assign (Dlr.Ext.unwrap lexpr) rexpr
Dlr.assign lexpr rexpr

else
let typeCode = rexpr.Type |> TypeTag.OfType
let box = Dlr.Ext.unwrap lexpr
let val' = Dlr.Ext.unwrap rexpr
let box = lexpr
let val' = rexpr
if typeCode <= TypeTags.Number then
Dlr.blockSimple
[setBoxClrNull box; Box.setTagOf box val'; Box.setValue box val']
Expand All @@ -162,7 +161,7 @@ module internal Utils =

if isBoxed lexpr
then assignBox lexpr rexpr
else Dlr.assign (Dlr.Ext.unwrap lexpr) rexpr
else Dlr.assign lexpr rexpr

///
let compileIndex (ctx:Ctx) indexAst =
Expand Down
26 changes: 0 additions & 26 deletions Src/IronJS/Dlr.fs
Original file line number Diff line number Diff line change
Expand Up @@ -609,35 +609,9 @@ module Dlr =
#endif
#endif

module Ext =

//-------------------------------------------------------------------------
// Type that flags a containing expression as static
type Static(expr) =
inherit Expr()

member x.Inner = expr

override x.NodeType = ExprType.Extension
override x.CanReduce = true
override x.Reduce() = expr
override x.Type = expr.Type

let isStatic (expr:Expr) =
expr :? Static || expr :? Parameter || expr :? ConstantExpression

let static' (expr:Expr) =
if isStatic expr
then expr
else (Static expr) :> Expr

let unwrap (expr:Expr) =
if expr :? Static then (expr :?> Static).Inner else expr

module Operators =

let inline (!!!) x = const' x
let inline (!@) x = Ext.unwrap x

// Dot operator for binding field access
let (.->) a b = propertyOrField a b
Expand Down

0 comments on commit 348dea6

Please sign in to comment.