comparison gen/CodeGen.d @ 116:0cd8d6ab3f89

Add in the types for float and co.
author Anders Halager <halager@gmail.com>
date Sun, 25 May 2008 18:19:09 +0200
parents 244142a21cbc
children 54955003765b
comparison
equal deleted inserted replaced
113:244142a21cbc 116:0cd8d6ab3f89
384 DType t_b = e.right.type; 384 DType t_b = e.right.type;
385 385
386 Value res; 386 Value res;
387 // TODO: do usual type promotions on a and b 387 // TODO: do usual type promotions on a and b
388 // TODO: support floats 388 // TODO: support floats
389 if (t_a.isInteger() && t_b.isInteger()) 389 if (t_a.isArithmetic() && t_b.isArithmetic())
390 { 390 {
391 Operation op = t_a.getOperationWith(op2op(e.op), t_b); 391 Operation op = t_a.getOperationWith(op2op(e.op), t_b);
392 assert(op.isBuiltin(), 392 assert(op.isBuiltin(),
393 "integers should only use builtin ops"); 393 "integers should only use builtin ops");
394 alias BuiltinOperation BO; 394 alias BuiltinOperation BO;
624 case ExpType.Identifier: 624 case ExpType.Identifier:
625 auto identifier = cast(Identifier)exp; 625 auto identifier = cast(Identifier)exp;
626 auto id = exp.env.find(identifier); 626 auto id = exp.env.find(identifier);
627 return LValue(table.find(id.get)); 627 return LValue(table.find(id.get));
628 case ExpType.Deref: 628 case ExpType.Deref:
629 // LValue(*x): x 629 // LValue(*x): load(x)
630 // RValue(*x): load(x) 630 // RValue(*x): load(load(x))
631 // This way *x = *x + 1 will work 631 // This way *x = *x + 1 will work
632 // We get an i32** rather than i32* because it's alloc'd 632 // We need an ekstra load, because we get an i32** rather than
633 // so there needs to be a load 633 // i32* since stuff is alloc'd
634 auto DE = cast(DerefExp)exp; 634 auto DE = cast(DerefExp)exp;
635 return LValue(genExpression(DE.exp).value); 635 return LValue(genExpression(DE.exp).value);
636 case ExpType.Index: 636 case ExpType.Index:
637 auto indexExp = cast(IndexExp)exp; 637 auto indexExp = cast(IndexExp)exp;
638 auto type = indexExp.target.type; 638 auto type = indexExp.target.type;