comparison sema/DType.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 09b4d74cb3f5
children 0cd8d6ab3f89
comparison
equal deleted inserted replaced
103:09b4d74cb3f5 107:189c049cbfcc
1 module sema.DType; 1 module sema.DType;
2 2
3 import lexer.Token, 3 import lexer.Token,
4 ast.Exp; 4 ast.Exp;
5 5
6 import tango.io.Stdout; 6 public
7 import sema.Operation;
7 8
8 class DType 9 class DType
9 { 10 {
10 private char[] id; 11 private char[] id;
11 private SourceLocation loc; 12 private SourceLocation loc;
82 /** 83 /**
83 Can this type legally be converted to that type with no casts? 84 Can this type legally be converted to that type with no casts?
84 True for short -> int etc. 85 True for short -> int etc.
85 */ 86 */
86 bool hasImplicitConversionTo(DType that) { return false; } 87 bool hasImplicitConversionTo(DType that) { return false; }
88
89 /**
90 Get an Operation describing how to use the supplied operator on the two
91 types given.
92 */
93 Operation getOperationWith(Operator op, DType other)
94 {
95 Operation res;
96 return res;
97 }
87 98
88 /** 99 /**
89 Get a type representing a pointer to this type (from int to int*) 100 Get a type representing a pointer to this type (from int to int*)
90 */ 101 */
91 DPointer getPointerTo() 102 DPointer getPointerTo()
186 } 197 }
187 198
188 override bool isInteger() { return true; } 199 override bool isInteger() { return true; }
189 override DInteger asInteger() { return this; } 200 override DInteger asInteger() { return this; }
190 201
202 override Operation getOperationWith(Operator op, DType that)
203 {
204 Operation operation;
205 if (this is that)
206 operation = Operation.builtin(op, unsigned, false);
207 return operation;
208 }
209
191 override char[] mangle() 210 override char[] mangle()
192 { 211 {
193 return mangle_types[this]; 212 return mangle_types[this];
194 } 213 }
195 214