Permalink
Browse files

parse values for constants in the context of the ConstStatement, fix …

…a bug with const in namespace scope
  • Loading branch information...
1 parent b48a54a commit e16bea6f38c6bb2449708a6df2b59e4d419d72d2 @NotFound committed Nov 26, 2013
Showing with 14 additions and 15 deletions.
  1. +8 −3 t/advanced/01constant.t
  2. +3 −6 winxedst1.winxed
  3. +3 −6 winxedst2.winxed
@@ -2,7 +2,10 @@
// constants
-using extern Test.More done_testing, is;
+using extern Test.More plan, is;
+
+const string s0 = "hi";
+const string s1 = upcase(s0) + ".";
namespace Foo
{
@@ -16,12 +19,14 @@ namespace Foo2
function main [main](args)
{
+ plan(3);
+
+ is(s1, "HI.", "const string evaluation with builtins");
+
is(Foo.BAR, 42, "scoped constant");
using namespace Foo2;
is(BAR2, 7, "using namespace");
-
- done_testing();
}
// End
View
@@ -7763,13 +7763,12 @@ class ConstStatement : Statement
var data;
var value;
- function ConstStatement(var name, var owner,
- string type, var value)
+ function ConstStatement(var name, var tk, var owner, string type)
{
self.Statement(name, owner);
self.type = type;
self.name = name;
- self.value = value;
+ self.value = parseExpr(tk, self);
self.data = self.createconst(name, type);
}
function optimize()
@@ -7813,9 +7812,7 @@ function parseConst(var start, var tk, var owner)
var name = tk.get();
RequireIdentifier(name);
ExpectOp("=", tk);
- var value = parseExpr(tk, owner);
- multi = addtomulti(multi,
- new ConstStatement(name, owner, type, value));
+ multi = addtomulti(multi, new ConstStatement(name, tk, owner, type));
} while ((t = tk.get()).isop(","));
RequireOp(";", t);
return multi;
View
@@ -10197,13 +10197,12 @@ class ConstStatement : Statement
var data;
var value;
- function ConstStatement(var name, var owner,
- string type, var value)
+ function ConstStatement(var name, var tk, var owner, string type)
{
self.Statement(name, owner);
self.type = type;
self.name = name;
- self.value = value;
+ self.value = parseExpr(tk, self);
self.data = self.createconst(name, type);
}
function optimize()
@@ -10263,9 +10262,7 @@ function parseConst(var start, var tk, var owner)
var name = tk.get();
RequireIdentifier(name);
ExpectOp("=", tk);
- var value = parseExpr(tk, owner);
- multi = addtomulti(multi,
- new ConstStatement(name, owner, type, value));
+ multi = addtomulti(multi, new ConstStatement(name, tk, owner, type));
} while ((t = tk.get()).isop(","));
RequireOp(";", t);
return multi;

0 comments on commit e16bea6

Please sign in to comment.