lib/minjs/statement.rb in minjs-0.1.10 vs lib/minjs/statement.rb in minjs-0.2.0
- old
+ new
@@ -99,10 +99,12 @@
#10.5
vl.each do |v|
dn = v[0]
context.var_env.record.create_mutable_binding(dn, nil)
context.var_env.record.set_mutable_binding(dn, :undefined, nil)
+ context.lex_env.record.create_mutable_binding(dn, nil)
+ context.lex_env.record.set_mutable_binding(dn, :undefined, nil)
end
ECMA262::StVar.new(context, vl)
else
raise Minjs::ParseError.new("var_statement", lex)
end
@@ -144,21 +146,26 @@
#
#12.3
#
def empty_statement(lex, context)
lex.eval_lit{
- a = lex.fwd_lit(:nolt => true)
+ a = lex.fwd_lit
if a == ECMA262::PUNC_SEMICOLON
ECMA262::StEmpty.new
- elsif a == ECMA262::LIT_LINE_FEED
- ECMA262::StEmpty.new
- elsif a.lt?
- ECMA262::StEmpty.new
else
nil
end
- }
+ }# || lex.eval_lit {
+# a = lex.fwd_lit(:nolt => true)
+# if a == ECMA262::LIT_LINE_FEED
+# ECMA262::StEmpty.new
+# elsif a.lt?
+# ECMA262::StEmpty.new
+# else
+# nil
+# end
+# }
end
#
#12.4
#
def exp_statement(lex, context)
@@ -224,10 +231,12 @@
next nil unless lex.match_lit(ECMA262::PUNC_LPARENTHESIS)
if lex.match_lit(ECMA262::ID_VAR) and v=var_decl(lex, context, :no_in => true) and lex.match_lit(ECMA262::ID_IN) and e=exp(lex, context, {}) and lex.match_lit(ECMA262::PUNC_RPARENTHESIS) and s=statement(lex, context)
#10.5
context.var_env.record.create_mutable_binding(v[0], nil)
context.var_env.record.set_mutable_binding(v[0], :undefined, nil)
+ context.lex_env.record.create_mutable_binding(v[0], nil)
+ context.lex_env.record.set_mutable_binding(v[0], :undefined, nil)
ECMA262::StForInVar.new(context, v, e, s)
else
nil
end
} or lex.eval_lit {
@@ -239,10 +248,12 @@
#10.5
vl.each do |v|
dn = v[0]
context.var_env.record.create_mutable_binding(dn, nil)
context.var_env.record.set_mutable_binding(dn, :undefined, nil)
+ context.lex_env.record.create_mutable_binding(dn, nil)
+ context.lex_env.record.set_mutable_binding(dn, :undefined, nil)
end
ECMA262::StForVar.new(context, vl, e, e2, s)
else
nil
end
@@ -402,11 +413,14 @@
#
def try_statement(lex, context)
return nil unless lex.match_lit(ECMA262::ID_TRY)
lex.eval_lit {
catch_context = ECMA262::Context.new
- catch_env = context.lex_env.new_declarative_env()
+ #
+ # catch context must be executable lexical environment
+ #
+ catch_env = context.var_env.new_declarative_env()
catch_context.lex_env = catch_env
catch_context.var_env = context.var_env
t = block(lex, context)
break nil unless t
@@ -414,23 +428,27 @@
lex.eval_lit{
c = try_catch(lex, catch_context)
break nil unless c
f = try_finally(lex, context)
- ECMA262::StTry.new(context, catch_context, t, c, f)
+ ECMA262::StTry.new(context, t, c, f)
} || lex.eval_lit{
f = try_finally(lex, context)
break nil unless f
- ECMA262::StTry.new(context, catch_context, t, nil, f)
+ ECMA262::StTry.new(context, t, nil, f)
}
}
end
def try_catch(lex, catch_context)
return nil unless lex.match_lit(ECMA262::ID_CATCH)
if lex.match_lit(ECMA262::PUNC_LPARENTHESIS) and i=identifier(lex, catch_context) and lex.match_lit(ECMA262::PUNC_RPARENTHESIS) and b=block(lex, catch_context)
catch_context.lex_env.record.create_mutable_binding(i, nil)
- catch_context.lex_env.record.set_mutable_binding(i, :undefined, nil)
+ catch_context.lex_env.record.set_mutable_binding(i, :undefined, nil, {:_parameter_list => true})
+ catch_context.var_env.record.create_mutable_binding(i, nil)
+ catch_context.var_env.record.set_mutable_binding(i, :undefined, nil, {:_parameter_list => true})
+ catch_context.var_env.record.binding.each do|k, v|
+ end
[i, b]
else
nil
end
end