comparison gen/CodeGen.d @ 185:7b274cfdc1dc

Added support for array literals. Codegen is broken, though.
author Anders Johnsen <skabet@gmail.com>
date Fri, 25 Jul 2008 12:18:05 +0200
parents 8ea749b7da91
children 08b6ce45b456
comparison
equal deleted inserted replaced
184:86a2ede00e9a 185:7b274cfdc1dc
352 storeThroughLValue(dst, src, AE.exp.type()); 352 storeThroughLValue(dst, src, AE.exp.type());
353 return src; 353 return src;
354 case ExpType.Index: 354 case ExpType.Index:
355 auto indexExp = cast(IndexExp)exp; 355 auto indexExp = cast(IndexExp)exp;
356 return loadLValue(genLValue(exp)); 356 return loadLValue(genLValue(exp));
357 case ExpType.ArrayLiteralExp:
358 auto arrayLiteralExp = cast(ArrayLiteralExp)exp;
359 Constant[] c;
360 foreach (a ; arrayLiteralExp.exps)
361 c ~= cast(Constant)genExpression(a).value;
362 return RValue(
363 ConstantArray.Get(
364 llvm(arrayLiteralExp.type.asStaticArray.arrayOf), c));
357 case ExpType.NewExp: 365 case ExpType.NewExp:
358 auto newExp = cast(NewExp)exp; 366 auto newExp = cast(NewExp)exp;
359 DClass type = newExp.newType.type().asClass(); 367 DClass type = newExp.newType.type().asClass();
360 auto llvm_type = cast(PointerType)llvm(type); 368 auto llvm_type = cast(PointerType)llvm(type);
361 auto pointer = b.buildMalloc(llvm_type.elementType(), "new"); 369 auto pointer = b.buildMalloc(llvm_type.elementType(), "new");