Permalink
Browse files

allow qualified functions in cast to var

  • Loading branch information...
NotFound committed Jun 21, 2012
1 parent ab02fb8 commit f4190cdeace4a72203849fc8b58f663319d6e9a5
Showing with 34 additions and 0 deletions.
  1. +1 −0 Makefile
  2. +16 −0 t/base/02varcast.t
  3. +17 −0 winxedxx.winxed
View
@@ -112,6 +112,7 @@ winxedxc.pbc: winxedxc.pir
TESTS = t/base/00test.t \
t/base/02opadd.t t/base/02opmul.t t/base/02opsub.t \
t/base/02bitwiseops.t \
+ t/base/02varcast.t \
t/base/03pmc.t t/base/03class.t \
t/base/06localfunctions.t \
t/base/features.t
View
@@ -0,0 +1,16 @@
+#! winxed
+
+// winxedxx base tests
+// var cast
+
+using extern Test.More plan;
+
+namespace Test { namespace More { } }
+
+function main [main] (var args)
+{
+ plan(1);
+ var (Test.More.ok)(1, "cast to var avoid parse as method cal");
+}
+
+// End
View
@@ -31,6 +31,7 @@ class ClassSpecifierId;
class NullExpr;
class CastExpr;
+class VarCastExpr;
class IdentifierExpr;
class MemberExpr;
@@ -731,6 +732,22 @@ function emitExpr(var out, :CastExpr expr)
}
}
+function emitExpr(var out, :VarCastExpr expr)
+{
+ var arg = expr.arg;
+ switch {
+ case arg instanceof MemberExpr:
+ string key[];
+ arg.buildkey(key);
+ string name = key.pop();
+ emit_namespacefromroot(out, key);
+ out.print(".get(\"", name, "\")");
+ break;
+ default:
+ throw WxxUnsupported(expr);
+ }
+}
+
//**********************************************************************
function emit_callargs(out, args)

0 comments on commit f4190cd

Please sign in to comment.