public
Description: Haskell implemented JavaScript interpreter
Homepage:
Clone URL: git://github.com/motemen/jusk.git
jusk / JSBoolean.hs
100644 33 lines (27 sloc) 0.831 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
{-
JSBoolean.hs
Booleanオブジェクト
http://www2u.biglobe.ne.jp/~oz-07ams/prog/ecma262r3/15-6_Boolean_Objects.html
-}
 
module JSBoolean where
import Monad
 
import DataTypes
import Internal
 
-- Boolean.prototype
prototype :: Evaluate Value
prototype = return $ Object { properties = [("constructor", NativeFunction JSBoolean.new)] }
 
-- Boolean()
function :: [Value] -> Evaluate Value
function [] = return $ toValue False
function (x:_) = liftM Boolean $ toBoolean x
 
-- new Boolean()
new :: [Value] -> Evaluate Value
new args =
    do prototype <- JSBoolean.prototype
       value <- function args
       return $ Object {
                    properties = [],
                    DataTypes.prototype = prototype,
                    className = "Boolean",
                    delegate = value
                }