Handle nested classes

This commit is contained in:
Andrew Noyes 2019-09-10 13:25:58 -07:00
parent c487f021f0
commit 9d531db985
3 changed files with 19 additions and 3 deletions

View File

@ -1273,4 +1273,20 @@ ACTOR Future<int> Foo4::fooActor(Foo4* self) {
return self->x;
}
struct Outer {
class Foo5 : Super {
public:
explicit Foo5(int x) : x(x) {}
Future<int> foo() { return fooActor(this); }
ACTOR static Future<int> fooActor(Foo5* self);
private:
int x;
};
};
ACTOR Future<int> Outer::Foo5::fooActor(Outer::Foo5* self) {
wait(Future<Void>());
return self->x;
}
ACTOR static Future<Void> shouldNotHaveFriends2();

View File

@ -304,8 +304,8 @@ namespace actorcompiler
actor.name.Substring(0, 1).ToUpper(),
actor.name.Substring(1),
i != 0 ? i.ToString() : "",
actor.enclosingClass != null ? actor.enclosingClass + "_"
: actor.nameSpace != null ? actor.nameSpace + "_"
actor.enclosingClass != null ? actor.enclosingClass.Replace("::", "_") + "_"
: actor.nameSpace != null ? actor.nameSpace.Replace("::", "_") + "_"
: "");
if (actor.isForwardDeclaration || usedClassNames.Add(className))
break;

View File

@ -344,7 +344,7 @@ namespace actorcompiler
var actor = ParseActor(i, out end);
if (classContextStack.Count > 0)
{
actor.enclosingClass = classContextStack.Peek().name;
actor.enclosingClass = String.Join("::", classContextStack.Reverse().Select(t => t.name));
}
var actorWriter = new System.IO.StringWriter();
actorWriter.NewLine = "\n";