Skip to content
Browse files

support keyed class in 'multi'

  • Loading branch information...
1 parent b0f0d6c commit fc739485cfc4259df0da52bc30bfad8d1c9de0e0 @NotFound NotFound committed
Showing with 52 additions and 4 deletions.
  1. +42 −3 t/advanced/10multi.t
  2. +10 −1 winxedst1.winxed
View
45 t/advanced/10multi.t
@@ -11,9 +11,19 @@ function bar(string a, string b) { return "ss"; }
namespace FooBar
{
+
function foo(string value) { return "FooBar.s-" + value; }
+
+class Foo
+{
+}
+
+class Bar
+{
}
+} // namespace FooBar
+
class Foo
{
function baz(int a, int b) { return "ii"; }
@@ -22,6 +32,10 @@ class Foo
function baz(var a, var b) { return "pp"; }
}
+class Bar
+{
+}
+
//**********************************************************************
// 'multi' modifier
@@ -46,14 +60,39 @@ function mbar [multi(class Foo)](var f)
return "Foo";
}
+function mbar [multi(class ['Bar'])](var f)
+{
+ return "['Bar']";
+}
+
+function mbar [multi(class FooBar.Foo)](var f)
+{
+ return "FooBar.Foo";
+}
+
+function mbar [multi(class ['FooBar','Bar'])](var f)
+{
+ return "['FooBar','Bar']";
+}
+
+function is_mbar(value, string name)
+{
+ is(mbar(value), name, "multimethod multi " + name);
+}
+
function test_multi()
{
var foo = new Foo;
+ var bar = new Bar;
+ var foofoo = new FooBar.Foo;
+ var foobar = new FooBar.Bar;
is(mbar(0), "int", "multimethod int");
- is(mbar(var(0)), "var", "multimethod var");
- is(mbar(var("")), "'String'", "multimethod multi 'String'");
- is(mbar(foo), "Foo", "multimethod multi class Foo");
+ is_mbar(0, "var");
+ is_mbar("", "'String'");
+ is_mbar(bar, "['Bar']");
+ is_mbar(foofoo, "FooBar.Foo");
+ is_mbar(foobar, "['FooBar','Bar']");
}
//**********************************************************************
View
11 winxedst1.winxed
@@ -3571,10 +3571,14 @@ class OpClassExpr : OpExpr
{
var owner = self.owner;
var clspec = self.clspec;
+ var clkey;
// TODO: cover more class specifiers
switch {
case clspec instanceof ClassSpecifierId:
- var clkey = clspec.checknskey(owner);
+ clkey = clspec.checknskey(owner);
+ return clkey != null ? clkey.path : null;
+ case clspec instanceof ClassSpecifierParrotKey:
+ clkey = clspec.checknskey(owner);
return clkey != null ? clkey.path : null;
case clspec instanceof ClassSpecifier:
SyntaxError(string(typeof(clspec)) + " not supported yet here",
@@ -9571,6 +9575,11 @@ class ClassSpecifierParrotKey : ClassSpecifier
return int(self.hll != null);
}
+ function checknskey(from)
+ {
+ var nskey = from.scopesearch(self.key, SEARCH_CLASS);
+ return nskey != null ? nskey.getpath() : null;
+ }
function emit(e, ns)
{
e.print(getparrotkey(self.key));

0 comments on commit fc73948

Please sign in to comment.
Something went wrong with that request. Please try again.