Mercurial > projects > dang
annotate sema/TypeCheck.d @ 107:189c049cbfcc new_gen
Cleanup of codegen, better support for operators a few bugfixes
author | Anders Halager <halager@gmail.com> |
---|---|
date | Sun, 25 May 2008 14:40:14 +0200 |
parents | 771ac63898e2 |
children | 3a0cd42de9cc |
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, |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
4 sema.DType; |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
5 |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
6 import tango.io.Stdout; |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
7 |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
87
diff
changeset
|
8 import misc.Error, |
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
87
diff
changeset
|
9 basic.SourceLocation; |
70
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
10 |
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
|
11 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
|
12 { |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
13 private Error error(uint line, char[] msg) |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
14 { |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
15 return new Error(msg); |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
16 } |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
17 |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
18 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
|
19 { |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
20 super.visitBinaryExp(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 if(exp.left.type.byteSize > exp.right.type.byteSize) |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
23 { |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
24 if(!exp.right.type.hasImplicitConversionTo(exp.left.type)) |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
25 throw error(__LINE__, "Cannot make implicit cast"); |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
26 |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
27 auto castExp = new CastExp( |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
87
diff
changeset
|
28 SLoc.Invalid, |
70
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
29 new Identifier(exp.left.type.name), |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
30 exp.right); |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
31 castExp.env = exp.env; |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
32 exp.right = castExp; |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
33 } |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
34 |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
35 if(exp.left.type.byteSize < exp.right.type.byteSize) |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
36 { |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
37 if(!exp.left.type.hasImplicitConversionTo(exp.right.type)) |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
38 throw error(__LINE__, "Cannot make implicit cast"); |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
39 |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
40 auto castExp = new CastExp( |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
87
diff
changeset
|
41 SLoc.Invalid, |
70
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
42 new Identifier(exp.right.type.name), |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
43 exp.left); |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
44 castExp.env = exp.env; |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
45 exp.left = castExp; |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
46 } |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
47 |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
48 } |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
49 |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
50 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
|
51 { |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
52 super.visitCallExp(exp); |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
53 |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
54 Exp[] newArgs; |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
55 |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
56 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
|
57 { |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
58 auto argType = (cast(DFunction)exp.exp.type).params[i]; |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
59 auto expType = arg.type; |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
60 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
|
61 { |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
62 if(!expType.hasImplicitConversionTo(argType)) |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
63 throw error(__LINE__, "Cannot make implicit cast"); |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
64 |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
65 auto castExp = new CastExp( |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
87
diff
changeset
|
66 SLoc.Invalid, |
70
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
67 new Identifier(argType.name), |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
68 arg); |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
69 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
|
70 newArgs ~= castExp; |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
71 } |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
72 else |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
73 newArgs ~= arg; |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
74 } |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
75 |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
76 exp.args = newArgs; |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
77 } |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
78 |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
79 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
|
80 { |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
81 super.visitAssignExp(exp); |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
82 |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
83 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
|
84 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
|
85 |
80
682e20aa224f
Pointers working now - big YAY
Anders Johnsen <skabet@gmail.com>
parents:
70
diff
changeset
|
86 if(identifierType != expType) |
70
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
87 { |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
88 if(!expType.hasImplicitConversionTo(identifierType)) |
80
682e20aa224f
Pointers working now - big YAY
Anders Johnsen <skabet@gmail.com>
parents:
70
diff
changeset
|
89 throw error(__LINE__, "Cannot make implicit cast between"); |
70
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 auto castExp = new CastExp( |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
87
diff
changeset
|
92 SLoc.Invalid, |
107
189c049cbfcc
Cleanup of codegen, better support for operators a few bugfixes
Anders Halager <halager@gmail.com>
parents:
92
diff
changeset
|
93 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
|
94 exp.exp); |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
95 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
|
96 exp.exp = castExp; |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
97 } |
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 |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
100 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
|
101 { |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
102 super.visitReturnStmt(stmt); |
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 if(stmt.exp) |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
105 { |
80
682e20aa224f
Pointers working now - big YAY
Anders Johnsen <skabet@gmail.com>
parents:
70
diff
changeset
|
106 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
|
107 auto expType = stmt.exp.type; |
80
682e20aa224f
Pointers working now - big YAY
Anders Johnsen <skabet@gmail.com>
parents:
70
diff
changeset
|
108 if(returnType != expType) |
70
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
109 { |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
110 if(!expType.hasImplicitConversionTo(returnType)) |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
111 throw error(__LINE__, "Cannot make implicit cast"); |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
112 |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
113 auto castExp = new CastExp( |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
87
diff
changeset
|
114 SLoc.Invalid, |
70
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
115 new Identifier(returnType.name), |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
116 stmt.exp); |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
117 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
|
118 stmt.exp = castExp; |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
119 } |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
120 } |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
121 } |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
122 |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
123 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
|
124 { |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
125 super.visitVarDecl(decl); |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
126 |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
127 if(decl.init) |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
128 { |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
129 auto varType = decl.type; |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
130 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
|
131 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
|
132 { |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
133 if(!expType.hasImplicitConversionTo(varType)) |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
134 throw error(__LINE__, "Cannot make implicit cast"); |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
135 |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
136 auto castExp = new CastExp( |
88
eb5b2c719a39
Major change to locations, tokens and expressions.
Anders Halager <halager@gmail.com>
parents:
87
diff
changeset
|
137 SLoc.Invalid, |
70
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
138 new Identifier(varType.name), |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
139 decl.init); |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
140 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
|
141 decl.init = castExp; |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
142 } |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
143 } |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
144 } |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
145 } |
70a002b3fba4
Added missing files and also cleaned up some Stdout debug-output.
Anders Johnsen <skabet@gmail.com>
parents:
diff
changeset
|
146 |