Mercurial > projects > dang
annotate sema/TypeCheck.d @ 164:ba94fd563548
The symbol for the constructor a "new"-exp is calling is now stored in callSym in NewExp.
author | Anders Johnsen <skabet@gmail.com> |
---|---|
date | Tue, 22 Jul 2008 16:53:47 +0200 |
parents | 6cb2f4201e2a |
children | 7606387b2f0a |
rev | line source |
---|---|
92
771ac63898e2
A few better parser errors plus renaming most of the sema classes to match that they do now. Some have changes a lot.
Anders Johnsen <skabet@gmail.com>
parents:
88
diff
changeset
|
1 module sema.TypeCheck; |
70
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
2 |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
3 import sema.Visitor, |
158
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
4 sema.Symbol, |
70
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
5 sema.DType; |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
6 |
158
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
7 import tango.io.Stdout, |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
8 Integer = tango.text.convert.Integer; |
70
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
9 |
114
3a0cd42de9cc
Removed misc/Error.d and is now using the error system all way through.
Anders Johnsen <skabet@gmail.com>
parents:
107
diff
changeset
|
10 import basic.SourceLocation, |
3a0cd42de9cc
Removed misc/Error.d and is now using the error system all way through.
Anders Johnsen <skabet@gmail.com>
parents:
107
diff
changeset
|
11 basic.Message; |
70
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
12 |
92
771ac63898e2
A few better parser errors plus renaming most of the sema classes to match that they do now. Some have changes a lot.
Anders Johnsen <skabet@gmail.com>
parents:
88
diff
changeset
|
13 class TypeCheck : Visitor!(void) |
70
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
14 { |
114
3a0cd42de9cc
Removed misc/Error.d and is now using the error system all way through.
Anders Johnsen <skabet@gmail.com>
parents:
107
diff
changeset
|
15 this(MessageHandler messages) |
70
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
16 { |
114
3a0cd42de9cc
Removed misc/Error.d and is now using the error system all way through.
Anders Johnsen <skabet@gmail.com>
parents:
107
diff
changeset
|
17 this.messages = messages; |
70
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
18 } |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
19 |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
20 override void visitBinaryExp(BinaryExp exp) |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
21 { |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
22 super.visitBinaryExp(exp); |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
23 |
126
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
24 if(!(exp.left.type is exp.right.type)) |
70
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
25 { |
126
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
26 if (!exp.right.type.hasImplicitConversionTo(exp.left.type) && |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
27 !exp.left.type.hasImplicitConversionTo(exp.right.type)) |
114
3a0cd42de9cc
Removed misc/Error.d and is now using the error system all way through.
Anders Johnsen <skabet@gmail.com>
parents:
107
diff
changeset
|
28 messages.report(InvalidImplicitCast, exp.loc) |
3a0cd42de9cc
Removed misc/Error.d and is now using the error system all way through.
Anders Johnsen <skabet@gmail.com>
parents:
107
diff
changeset
|
29 .arg(exp.right.type.toString) |
3a0cd42de9cc
Removed misc/Error.d and is now using the error system all way through.
Anders Johnsen <skabet@gmail.com>
parents:
107
diff
changeset
|
30 .arg(exp.left.type.toString); |
126
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
31 else |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
32 { |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
33 CastExp castExp; |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
34 if(exp.left.type.isReal && exp.right.type.isReal) |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
35 if(exp.left.type.byteSize > exp.right.type.byteSize) |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
36 castExp = new CastExp( |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
37 SLoc.Invalid, |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
38 new Identifier(exp.left.type.name), |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
39 exp.right); |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
40 else |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
41 castExp = new CastExp( |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
42 SLoc.Invalid, |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
43 new Identifier(exp.right.type.name), |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
44 exp.left); |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
45 else if(exp.left.type.isReal || exp.right.type.isReal) |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
46 if(exp.left.type.isReal) |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
47 castExp = new CastExp( |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
48 SLoc.Invalid, |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
49 new Identifier(exp.left.type.name), |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
50 exp.right); |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
51 else |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
52 castExp = new CastExp( |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
53 SLoc.Invalid, |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
54 new Identifier(exp.right.type.name), |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
55 exp.left); |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
56 else |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
57 if(exp.left.type.byteSize > exp.right.type.byteSize) |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
58 castExp = new CastExp( |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
59 SLoc.Invalid, |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
60 new Identifier(exp.left.type.name), |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
61 exp.right); |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
62 else if(exp.left.type.byteSize > exp.right.type.byteSize) |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
63 castExp = new CastExp( |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
64 SLoc.Invalid, |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
65 new Identifier(exp.right.type.name), |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
66 exp.left); |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
67 else |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
68 castExp = new CastExp( |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
69 SLoc.Invalid, |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
70 new Identifier(exp.left.type.name), |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
71 exp.right); |
70
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
72 |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
73 |
126
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
74 if(castExp) |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
75 { |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
76 castExp.env = exp.env; |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
77 if(castExp.exp == exp.right) |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
78 exp.right = castExp; |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
79 else |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
80 exp.left = castExp; |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
81 |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
82 } |
c3b24e7e8cf8
Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
Anders Johnsen <skabet@gmail.com>
parents:
114
diff
changeset
|
83 } |
70
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
84 } |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
85 } |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
86 |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
87 override void visitCallExp(CallExp exp) |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
88 { |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
89 super.visitCallExp(exp); |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
90 |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
91 Exp[] newArgs; |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
92 |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
93 foreach(i, arg; exp.args) |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
94 { |
158
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
95 auto argType = exp.exp.type.asFunction.params[i]; |
70
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
96 auto expType = arg.type; |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
97 if(argType.byteSize != expType.byteSize) |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
98 { |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
99 if(!expType.hasImplicitConversionTo(argType)) |
114
3a0cd42de9cc
Removed misc/Error.d and is now using the error system all way through.
Anders Johnsen <skabet@gmail.com>
parents:
107
diff
changeset
|
100 messages.report(InvalidImplicitCast, exp.loc) |
3a0cd42de9cc
Removed misc/Error.d and is now using the error system all way through.
Anders Johnsen <skabet@gmail.com>
parents:
107
diff
changeset
|
101 .arg(expType.toString) |
3a0cd42de9cc
Removed misc/Error.d and is now using the error system all way through.
Anders Johnsen <skabet@gmail.com>
parents:
107
diff
changeset
|
102 .arg(argType.toString); |
70
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
103 |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
104 auto castExp = new CastExp( |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
87
diff
changeset
|
105 SLoc.Invalid, |
70
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
106 new Identifier(argType.name), |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
107 arg); |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
108 castExp.env = exp.exp.env; |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
109 newArgs ~= castExp; |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
110 } |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
111 else |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
112 newArgs ~= arg; |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
113 } |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
114 |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
115 exp.args = newArgs; |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
116 } |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
117 |
158
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
118 override void visitNewExp(NewExp exp) |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
119 { |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
120 super.visitNewExp(exp); |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
121 |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
122 Exp[] newArgs; |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
123 |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
124 Symbol[] methods = exp.newType.getSymbol.findMembers("this"); |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
125 |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
126 if ( exp.c_args.length ) |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
127 { |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
128 if ( !methods.length ) |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
129 { |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
130 messages.report(NoConstructor, exp.newType.loc); |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
131 return; |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
132 } |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
133 |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
134 Symbol[] possible; |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
135 Symbol perfect; |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
136 |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
137 foreach( s ; methods ) |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
138 { |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
139 bool per = true; |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
140 |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
141 foreach(i, arg; exp.c_args) |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
142 { |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
143 auto argType = s.type.asFunction.params[i]; |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
144 auto expType = arg.type; |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
145 if(argType != expType) |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
146 { |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
147 per = false; |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
148 if( !expType.hasImplicitConversionTo(argType) ) |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
149 break; |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
150 } |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
151 |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
152 if ( i == exp.c_args.length-1 |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
153 && i == s.type.asFunction.params.length-1) |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
154 if (per) |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
155 perfect = s; |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
156 else |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
157 possible ~= s; |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
158 } |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
159 } |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
160 |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
161 Symbol sel; |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
162 |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
163 if ( perfect ) |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
164 sel = perfect; |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
165 else |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
166 if ( possible.length ) |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
167 sel = possible[0]; |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
168 |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
169 if ( sel ) |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
170 { |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
171 foreach(i, arg; exp.c_args) |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
172 { |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
173 auto argType = sel.type.asFunction.params[i]; |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
174 auto expType = arg.type; |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
175 if(argType.byteSize != expType.byteSize) |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
176 { |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
177 if(!expType.hasImplicitConversionTo(argType)) |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
178 messages.report(InvalidImplicitCast, exp.loc) |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
179 .arg(expType.toString) |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
180 .arg(argType.toString); |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
181 |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
182 auto castExp = new CastExp( |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
183 SLoc.Invalid, |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
184 new Identifier(argType.name), |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
185 arg); |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
186 castExp.env = exp.newType.env; |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
187 newArgs ~= castExp; |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
188 } |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
189 else |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
190 newArgs ~= arg; |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
191 } |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
192 exp.c_args = newArgs; |
164
ba94fd563548
The symbol for the constructor a "new"-exp is calling is now stored in callSym in NewExp.
Anders Johnsen <skabet@gmail.com>
parents:
160
diff
changeset
|
193 exp.callSym = sel; |
158
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
194 } |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
195 else |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
196 { |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
197 messages.report(NoMachingCon, exp.newType.loc); |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
198 foreach( i, s ; methods ) |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
199 { |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
200 messages.report(CandidateNr, |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
201 (cast(FuncDecl)s.decl).identifier.loc) |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
202 .arg(Integer.toString(i+1)); |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
203 } |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
204 } |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
205 } |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
206 } |
57b0b4464a0b
Parsing "new", putting it in AST and performs some tests on it. Eg. if the contructor exists and the params matches.
Anders Johnsen <skabet@gmail.com>
parents:
126
diff
changeset
|
207 |
70
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
208 override void visitAssignExp(AssignExp exp) |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
209 { |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
210 super.visitAssignExp(exp); |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
211 |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
212 auto identifierType = exp.identifier.type; |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
213 auto expType = exp.exp.type; |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
214 |
80
682e20aa224f
Pointers working now - big YAY
Anders Johnsen <skabet@gmail.com>
parents:
70
diff
changeset
|
215 if(identifierType != expType) |
70
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
216 { |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
217 if(!expType.hasImplicitConversionTo(identifierType)) |
114
3a0cd42de9cc
Removed misc/Error.d and is now using the error system all way through.
Anders Johnsen <skabet@gmail.com>
parents:
107
diff
changeset
|
218 messages.report(InvalidImplicitCast, exp.loc) |
3a0cd42de9cc
Removed misc/Error.d and is now using the error system all way through.
Anders Johnsen <skabet@gmail.com>
parents:
107
diff
changeset
|
219 .arg(expType.toString) |
3a0cd42de9cc
Removed misc/Error.d and is now using the error system all way through.
Anders Johnsen <skabet@gmail.com>
parents:
107
diff
changeset
|
220 .arg(identifierType.toString); |
70
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
221 |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
222 auto castExp = new CastExp( |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
87
diff
changeset
|
223 SLoc.Invalid, |
107
189c049cbfcc
Cleanup of codegen, better support for operators a few bugfixes
Anders Halager <halager@gmail.com>
parents:
92
diff
changeset
|
224 new Identifier(identifierType.name), |
70
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
225 exp.exp); |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
226 castExp.env = exp.exp.env; |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
227 exp.exp = castExp; |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
228 } |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
229 } |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
230 |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
231 override void visitReturnStmt(ReturnStmt stmt) |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
232 { |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
233 super.visitReturnStmt(stmt); |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
234 |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
235 if(stmt.exp) |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
236 { |
80
682e20aa224f
Pointers working now - big YAY
Anders Johnsen <skabet@gmail.com>
parents:
70
diff
changeset
|
237 auto returnType = stmt.env.parentFunction.type.asFunction.returnType; |
70
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
238 auto expType = stmt.exp.type; |
80
682e20aa224f
Pointers working now - big YAY
Anders Johnsen <skabet@gmail.com>
parents:
70
diff
changeset
|
239 if(returnType != expType) |
70
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
240 { |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
241 if(!expType.hasImplicitConversionTo(returnType)) |
114
3a0cd42de9cc
Removed misc/Error.d and is now using the error system all way through.
Anders Johnsen <skabet@gmail.com>
parents:
107
diff
changeset
|
242 messages.report(InvalidImplicitCast, stmt.exp.loc) |
3a0cd42de9cc
Removed misc/Error.d and is now using the error system all way through.
Anders Johnsen <skabet@gmail.com>
parents:
107
diff
changeset
|
243 .arg(expType.toString) |
3a0cd42de9cc
Removed misc/Error.d and is now using the error system all way through.
Anders Johnsen <skabet@gmail.com>
parents:
107
diff
changeset
|
244 .arg(returnType.toString); |
70
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
245 |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
246 auto castExp = new CastExp( |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
87
diff
changeset
|
247 SLoc.Invalid, |
70
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
248 new Identifier(returnType.name), |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
249 stmt.exp); |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
250 castExp.env = stmt.exp.env; |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
251 stmt.exp = castExp; |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
252 } |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
253 } |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
254 } |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
255 |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
256 override void visitVarDecl(VarDecl decl) |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
257 { |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
258 super.visitVarDecl(decl); |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
259 |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
260 if(decl.init) |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
261 { |
160 | 262 auto varType = decl.identifier.type; |
70
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
263 auto expType = decl.init.type; |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
264 if(varType.byteSize != expType.byteSize) |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
265 { |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
266 if(!expType.hasImplicitConversionTo(varType)) |
114
3a0cd42de9cc
Removed misc/Error.d and is now using the error system all way through.
Anders Johnsen <skabet@gmail.com>
parents:
107
diff
changeset
|
267 messages.report(InvalidImplicitCast, decl.init.loc) |
3a0cd42de9cc
Removed misc/Error.d and is now using the error system all way through.
Anders Johnsen <skabet@gmail.com>
parents:
107
diff
changeset
|
268 .arg(expType.toString) |
3a0cd42de9cc
Removed misc/Error.d and is now using the error system all way through.
Anders Johnsen <skabet@gmail.com>
parents:
107
diff
changeset
|
269 .arg(varType.toString); |
70
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
270 |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
271 auto castExp = new CastExp( |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
87
diff
changeset
|
272 SLoc.Invalid, |
70
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
273 new Identifier(varType.name), |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
274 decl.init); |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
275 castExp.env = decl.init.env; |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
276 decl.init = castExp; |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
277 } |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
278 } |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
279 } |
114
3a0cd42de9cc
Removed misc/Error.d and is now using the error system all way through.
Anders Johnsen <skabet@gmail.com>
parents:
107
diff
changeset
|
280 |
3a0cd42de9cc
Removed misc/Error.d and is now using the error system all way through.
Anders Johnsen <skabet@gmail.com>
parents:
107
diff
changeset
|
281 MessageHandler messages; |
70
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
282 } |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
283 |