Mercurial > projects > dang
changeset 163:362265427838
Fixes to types for constructor and also removed DFunction's from DStruct, DClass and DInterface
author | Anders Johnsen <skabet@gmail.com> |
---|---|
date | Tue, 22 Jul 2008 16:50:47 +0200 |
parents | 0f38f1a0f06f |
children | ba94fd563548 |
files | ast/Decl.d sema/ScopeBuilder.d tests/parser/new_1.d tools/AstPrinter.d |
diffstat | 4 files changed, 21 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/ast/Decl.d Tue Jul 22 16:22:58 2008 +0200 +++ b/ast/Decl.d Tue Jul 22 16:50:47 2008 +0200 @@ -184,7 +184,10 @@ return myType; auto t = new DFunction(identifier); - t.returnType = env.findType(returnType.get); + if ( identifier.get == "this" ) + t.returnType = DType.Void; + else + t.returnType = env.findType(returnType.get); SmallArray!(DType) array; foreach (a; funcArgs) array ~= a.type();
--- a/sema/ScopeBuilder.d Tue Jul 22 16:22:58 2008 +0200 +++ b/sema/ScopeBuilder.d Tue Jul 22 16:50:47 2008 +0200 @@ -141,13 +141,14 @@ { type = typeOf(varDecl.varType, varDecl.env); name = varDecl.identifier.get; + st.addMember(type, name); } + /* else if (auto fd = cast(FuncDecl)decl) { type = fd.type; name = fd.identifier.get; - } - st.addMember(type, name); + }*/ } } @@ -167,13 +168,14 @@ { type = typeOf(varDecl.varType, varDecl.env); name = varDecl.identifier.get; + st.addMember(type, name); } + /* else if (auto fd = cast(FuncDecl)decl) { type = fd.type; name = fd.identifier.get; - } - st.addMember(type, name); + }*/ } } @@ -193,13 +195,14 @@ { type = typeOf(varDecl.varType, varDecl.env); name = varDecl.identifier.get; + st.addMember(type, name); } + /* else if (auto fd = cast(FuncDecl)decl) { type = fd.type; name = fd.identifier.get; - } - st.addMember(type, name); + }*/ } }
--- a/tests/parser/new_1.d Tue Jul 22 16:22:58 2008 +0200 +++ b/tests/parser/new_1.d Tue Jul 22 16:50:47 2008 +0200 @@ -1,24 +1,2 @@ - -class A -{ - this(long y) - { - } - - this(int y) - { - } - - int x; -} - -struct B -{ -} - -void main() -{ - B b; - long x; - A a = new A(x); -} +class A{this(int y){}int x;}struct B +{}void main(){B b;long x;A a=new A(x);}
--- a/tools/AstPrinter.d Tue Jul 22 16:22:58 2008 +0200 +++ b/tools/AstPrinter.d Tue Jul 22 16:50:47 2008 +0200 @@ -40,9 +40,12 @@ case DeclType.FuncDecl: auto funcDecl = cast(FuncDecl)decl; printBeginLine(); - if(printAtt) printAttribute(decl.att); - printIdentifier(funcDecl.returnType); - space; + if (printAtt) printAttribute(decl.att); + if (funcDecl.identifier.get != "this") + { + printIdentifier(funcDecl.returnType); + space; + } printIdentifier(funcDecl.identifier); printFuncArgs(funcDecl); printOpenBrace();