<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -89,10 +89,10 @@ withCC ct proc =
 
 returnCont :: ContType -&gt; Value -&gt; Evaluate Value
 returnCont ct value =
-    do debug $ &quot;returnCont: &quot; ++ show ct ++ &quot; &quot; ++ show value
-       cont &lt;- popCont
+    do cont &lt;- popCont
        if contType cont == ct
-          then do modifyScope $ contScope cont
+          then do debug $ &quot;returnCont: &quot; ++ show ct ++ &quot; &quot; ++ show value
+                  modifyScope $ contScope cont
                   (contRecv cont) value
           else returnCont ct value
 </diff>
      <filename>Context.hs</filename>
    </modified>
    <modified>
      <diff>@@ -4,11 +4,11 @@
     Haskell&#20869;&#37096;&#12398;&#22411;
 -}
 
-module DataTypes (module DataTypes, Control.Monad.Trans.liftIO) where
+module DataTypes (module DataTypes, liftIO) where
 import Data.Map (Map, assocs)
 import qualified Data.Map as Map
 import Data.IORef
-import System.IO.Unsafe
+import System.IO.Unsafe (unsafePerformIO)
 import Control.Monad.Trans (liftIO)
 import Control.Monad.State
 import Control.Monad.Cont hiding (Cont)
@@ -36,18 +36,16 @@ type Evaluate a
     = ContT Value (StateT Env IO) a
 
 data Env
-    = Env { envFrames :: [Frame], envContStack :: [Cont], envFlags :: [Flag], envEvaluatee :: Expression }
+    = Env { envFrames :: [Frame], envContStack :: [Cont], envFlags :: [Flag] }
 
 instance Show Env where
-    show (Env { envFrames = frames, envContStack = conts, envFlags = flags, envEvaluatee = evaluatee }) =
+    show (Env { envFrames = frames, envContStack = conts, envFlags = flags }) =
         &quot;  Frames:\n&quot; ++
         (unlines $ map (&quot;    &quot; ++) $ map show frames) ++
         &quot;  Cont:\n&quot; ++
         (unlines $ map (&quot;    &quot; ++) $ map show conts) ++
         &quot;  Flags:\n    &quot; ++
-        (unwords $ map show flags) ++
-        &quot;  Evaluatee:\n    &quot; ++
-        show evaluatee
+        (unwords $ map show flags)
 
 data Frame
     = GlobalFrame { frObject :: Value, frThis :: Value }
@@ -233,9 +231,9 @@ instance Eq Number where
     NaN == _ = False
     _ == NaN = False
     (Integer n) == (Integer m) = n == m
-    (Double n) == (Double m) = n == m
-    (Integer n) == (Double m) = (toEnum $ fromEnum n) == m
-    (Double n) == (Integer m) = n == (toEnum $ fromEnum m)
+    (Double n)  == (Double m)  = n == m
+    (Integer n) == (Double m)  = (toEnum $ fromEnum n) == m
+    (Double n)  == (Integer m) = n == (toEnum $ fromEnum m)
 
 data PropertyPair
     = PropertyPair { propValue :: Value, propAttr :: [PropertyAttribute] }
@@ -321,7 +319,7 @@ nullFunction = Function {
 nullNativeFunc :: NativeObject
 nullNativeFunc = NativeFunction {
         funcArity     = 0,
-        funcNatCode   = undefined
+        funcNatCode   = error &quot;nullNativeFunc: undefined funcNatCode&quot;
     }
 
 nativeFunc :: String -&gt; Int -&gt; NativeCode -&gt; Value
@@ -431,7 +429,7 @@ getName _ = &quot;&quot;
 toDouble :: Number -&gt; Double
 toDouble (Integer n) = fromIntegral n
 toDouble (Double n)  = n
-toDouble NaN = undefined
+toDouble NaN = error &quot;toDouble: NaN&quot;
 
 instance ToValue Int where
     toValue n = Number $ Integer $ toEnum n
@@ -566,6 +564,15 @@ instance Show Expression where
               else showParen True
                              (foldl1 (\x y -&gt; x . showString &quot;,&quot; . y) $ map shows args))
 
+    showsPrec p (Operator op@&quot;?:&quot; [x, y, z])
+        = showParen (prec &lt; p)
+        $ showsPrec prec x
+        . showString &quot; ? &quot;
+        . showsPrec prec y
+        . showString &quot; : &quot;
+        . showsPrec prec z
+        where prec = fromMaybe (length opPrecedence) (findIndex (op `elem`) opPrecedence)
+
     showsPrec p (Operator op [x, y])
         = showParen (prec &lt; p)
         $ showsPrec prec x
@@ -575,23 +582,44 @@ instance Show Expression where
         . showsPrec prec y
         where prec = fromMaybe (length opPrecedence) (findIndex (op `elem`) opPrecedence)
 
+    showsPrec p (Operator op [x])
+        = showParen (prec &lt; p)
+        $ showString op
+        . showString &quot; &quot;
+        . showsPrec prec x
+        where prec = fromMaybe (length opPrecedence) (findIndex (op `elem`) opPrecedence)
+
+    showsPrec _ (Operator _ _)
+        = error &quot;showPrec: unknown operator&quot;
+
+    {-
     showsPrec p (Operator op xs)
         = showParen (prec &lt; p)
         $ showString op
         . showString &quot; &quot;
         . showList xs
         where prec = fromMaybe (length opPrecedence) (findIndex (op `elem`) opPrecedence)
+    -}
 
     showsPrec _ (Let left right) = showString $ show left ++ &quot; = &quot; ++ show right
 
 opPrecedence :: [[String]]
-opPrecedence = [
+opPrecedence = reverse [
         [&quot;[]&quot;, &quot;new&quot;],
         [&quot;()&quot;],
         [&quot;_++&quot;, &quot;_--&quot;],
         [&quot;delete&quot;, &quot;void&quot;, &quot;typeof&quot;, &quot;++&quot;, &quot;--&quot;, &quot;+&quot;, &quot;-&quot;, &quot;~&quot;, &quot;!&quot;],
         [&quot;*&quot;, &quot;/&quot;, &quot;%&quot;],
-        [&quot;+&quot;, &quot;-&quot;]
+        [&quot;+&quot;, &quot;-&quot;],
+        [&quot;&lt;&lt;&quot;, &quot;&gt;&gt;&quot;, &quot;&gt;&gt;&gt;&quot;],
+        [&quot;&lt;&quot;, &quot;&gt;&quot;, &quot;&lt;=&quot;, &quot;&gt;=&quot;, &quot;instanceof&quot;, &quot;in&quot;],
+        [&quot;==&quot;, &quot;!=&quot;, &quot;===&quot;, &quot;!==&quot;],
+        [&quot;&amp;&quot;],
+        [&quot;^&quot;],
+        [&quot;|&quot;],
+        [&quot;&amp;&amp;&quot;],
+        [&quot;||&quot;],
+        [&quot;?:&quot;]
     ]
 
 showObjPair (p, v) = show p ++ &quot;: &quot; ++ show v
@@ -765,7 +793,7 @@ instance Inspect Statement where
         = &quot;STThrow &quot; ++ inspect expr
 
     inspect (STTry { tryClause = clause, tryCatchClause = catch, tryFinallyClause = finally })
-        = &quot;STTry &quot; ++ inspect clause ++ inspect catch ++ inspect finally
+        = &quot;STTry &quot; ++ inspect clause ++ &quot; &quot; ++ inspect catch ++ &quot; &quot; ++ inspect finally
 
 inspectShallow :: Value -&gt; String
 inspectShallow (Object { objName = &quot;&quot; })   = &quot;&lt;Object ...&gt;&quot;</diff>
      <filename>DataTypes.hs</filename>
    </modified>
    <modified>
      <diff>@@ -11,8 +11,6 @@ import List
 import Maybe
 import qualified Data.Map as Map
 import Control.Monad.Cont hiding (Cont)
-import Control.Monad.State (put)
-import System.IO.Unsafe
 
 import DataTypes
 import {-# SOURCE #-} Operator
@@ -29,7 +27,7 @@ evalProgram program =
        if null program || ParseOnly `elem` envFlags env
           then return Void
           else if (Debug `elem` envFlags env)
-                  then liftM last $ mapM (\e -&gt; do { liftIO $ ePutStrLn $ inspect e; eval e }) program
+                  then liftM last $ mapM (\e -&gt; do { liftIO $ ePutStrLn $ &quot;parsed: &quot; ++ inspect e; eval e }) program
                   else liftM last $ mapM eval program
 
 instance Eval Statement where
@@ -192,10 +190,8 @@ evalValue x = getValue =&lt;&lt; eval x
 -- Reference (Ref baseRef, p) &#12398;&#24418;&#12395;&#12394;&#12427;&#12414;&#12391;&#35413;&#20385;&#12377;&#12427;
 instance Eval Expression where
     eval expr =
-        do env &lt;- getEnv
-           unless (isLiteral expr)
-                  (do put env { envEvaluatee = expr }
-                      debug $ show expr)
+        do unless (isLiteral expr)
+                  (debug $ &quot;eval: &quot; ++ show expr)
            eval' expr
         where
             eval' (Identifier name) =
@@ -363,18 +359,19 @@ callWithThis this ref@Ref { } args =
 
 callWithThis this ref@Reference { } args =
     do callee &lt;- getValue ref
-       evaluatee &lt;- liftM envEvaluatee getEnv
        ifM (toBoolean callee)
            (callWithThis this callee args)
-           (throw &quot;TypeError&quot; $ show evaluatee ++ &quot; is not a function&quot;)
+           (throw &quot;TypeError&quot; $ show callee ++ &quot; is not a function&quot;)
+
+callWithThis _ value _ =
+    throw &quot;TypeError&quot; $ show value ++ &quot; is not a function&quot;
 
 callMethod :: Value -&gt; String -&gt; [Value] -&gt; Evaluate Value
 callMethod object name args =
     do method &lt;- readRef =&lt;&lt; getProp object name
-       evaluatee &lt;- liftM envEvaluatee getEnv
        if isFunction method || isNativeFunction method
           then callWithThis object method args
-          else throw &quot;TypeError&quot; $ show evaluatee ++ &quot; is not a function&quot;
+          else throw &quot;TypeError&quot; $ show method ++ &quot; is not a function&quot;
 
 -- &#26411;&#23614;&#20877;&#24112;&#29992;
 jumpToFunc :: Value -&gt; [Value] -&gt; Evaluate Value</diff>
      <filename>Eval.hs</filename>
    </modified>
    <modified>
      <diff>@@ -30,7 +30,7 @@ import Repl
 nullEnv :: [Flag] -&gt; IO Env
 nullEnv flags =
     do global &lt;- liftM Ref $ newIORef $ nullObject { objClass = &quot;Global&quot;, objPrototype = Object.prototypeObject }
-       return $ Env { envFrames = [GlobalFrame global global], envContStack = [], envFlags = flags, envEvaluatee = undefined }
+       return $ Env { envFrames = [GlobalFrame global global], envContStack = [], envFlags = flags }
 
 setupEnv :: Evaluate ()
 setupEnv =</diff>
      <filename>Init.hs</filename>
    </modified>
    <modified>
      <diff>@@ -353,5 +353,5 @@ p `ifFail` x = option x p
 
 pushArg :: Expression -&gt; Expression -&gt; Expression
 pushArg expr (Operator op args) = Operator op (expr:args)
-pushArg _ _ = undefined
+pushArg _ _ = error &quot;pushArg: non operator pushed&quot;
 -- }}}</diff>
      <filename>ParserUtil.hs</filename>
    </modified>
    <modified>
      <diff>@@ -33,7 +33,7 @@ runRepl' =
                   liftIO $ putStrLn string
                   env &lt;- getEnv
                   when (Debug `elem` envFlags env)
-                       (liftIO $ putStrLn $ inspect value))
+                       (liftIO $ putStrLn $ &quot;-&gt; &quot; ++ inspect value))
        runRepl'
        where evalWithMoreInput input =
                  case parse input of</diff>
      <filename>Repl.hs</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>9ba0770fed4b34720868e9a993884eccc148b746</id>
    </parent>
  </parents>
  <author>
    <name>motemen</name>
    <email>motemen@3e12a315-d43c-0410-9d47-cb5f01d91701</email>
  </author>
  <url>http://github.com/motemen/jusk/commit/d5e0226e6a64e0b769411876cd37d7dd1bba796f</url>
  <id>d5e0226e6a64e0b769411876cd37d7dd1bba796f</id>
  <committed-date>2007-12-30T03:02:49-08:00</committed-date>
  <authored-date>2007-12-30T03:02:49-08:00</authored-date>
  <message>removed envEvaluatee; added debug messages.

git-svn-id: svn+ssh://192.168.0.2/svn/public/jusk/trunk@205 3e12a315-d43c-0410-9d47-cb5f01d91701</message>
  <tree>f58a8018e7cd46b07f9d6f758b50e1c7d35f151b</tree>
  <committer>
    <name>motemen</name>
    <email>motemen@3e12a315-d43c-0410-9d47-cb5f01d91701</email>
  </committer>
</commit>
