Mercurial > projects > dang
comparison ast/Exp.d @ 158:57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
author | Anders Johnsen <skabet@gmail.com> |
---|---|
date | Tue, 22 Jul 2008 00:33:58 +0200 |
parents | a14ac9e5c858 |
children | 6cb2f4201e2a |
comparison
equal
deleted
inserted
replaced
157:bb01c1dc452a | 158:57b0b4464a0b |
---|---|
29 PointerIdentifier, | 29 PointerIdentifier, |
30 AssignExp, | 30 AssignExp, |
31 CallExp, | 31 CallExp, |
32 CastExp, | 32 CastExp, |
33 StringExp, | 33 StringExp, |
34 NewExp, | |
34 } | 35 } |
35 | 36 |
36 abstract class Exp | 37 abstract class Exp |
37 { | 38 { |
38 this(ExpType expType, SLoc loc) | 39 this(ExpType expType, SLoc loc) |
369 | 370 |
370 override Symbol getSymbol() | 371 override Symbol getSymbol() |
371 { | 372 { |
372 auto s = target.getSymbol(); | 373 auto s = target.getSymbol(); |
373 if (s !is null) | 374 if (s !is null) |
374 return s.findMember(child.get); | 375 return s.findMembers(child.get)[0]; |
375 return null; | 376 return null; |
376 } | 377 } |
377 | 378 |
378 override MemberReference simplify() | 379 override MemberReference simplify() |
379 { | 380 { |
487 override DType type() { return null; } | 488 override DType type() { return null; } |
488 | 489 |
489 char[] str; | 490 char[] str; |
490 } | 491 } |
491 | 492 |
493 class NewExp : Exp | |
494 { | |
495 this(Identifier newType, Exp[] a_args, Exp[] c_args) | |
496 { | |
497 super(ExpType.NewExp, newType.loc); | |
498 this.newType = newType; | |
499 this.a_args = a_args; | |
500 this.c_args = c_args; | |
501 } | |
502 | |
503 override DType type() | |
504 { | |
505 return env.findType(this.newType.get); | |
506 } | |
507 | |
508 Exp[] a_args, c_args; | |
509 Identifier newType; | |
510 } | |
511 | |
492 class PointerIdentifier : Identifier | 512 class PointerIdentifier : Identifier |
493 { | 513 { |
494 this(Identifier pointerOf) | 514 this(Identifier pointerOf) |
495 { | 515 { |
496 super(ExpType.PointerIdentifier, pointerOf.loc); | 516 super(ExpType.PointerIdentifier, pointerOf.loc); |