comparison dmd/BinExp.d @ 178:e3afd1303184

Many small bugs fixed Made all classes derive from TObject to detect memory leaks (functionality is disabled for now) Began work on overriding backend memory allocations (to avoid memory leaks)
author korDen
date Sun, 17 Oct 2010 07:42:00 +0400
parents fa9a71a9f5a8
children cd48cb899aee
comparison
equal deleted inserted replaced
177:1475fd394c9e 178:e3afd1303184
392 Expression e1; 392 Expression e1;
393 Expression e2; 393 Expression e2;
394 394
395 this(Loc loc, TOK op, int size, Expression e1, Expression e2) 395 this(Loc loc, TOK op, int size, Expression e1, Expression e2)
396 { 396 {
397 register();
398
397 super(loc, op, size); 399 super(loc, op, size);
398 this.e1 = e1; 400 this.e1 = e1;
399 this.e2 = e2; 401 this.e2 = e2;
400 } 402 }
401 403
1483 buf.writeByte(0); 1485 buf.writeByte(0);
1484 immutable(char)* name = cast(immutable(char)*)buf.extractData(); 1486 immutable(char)* name = cast(immutable(char)*)buf.extractData();
1485 1487
1486 /* Look up name in hash table 1488 /* Look up name in hash table
1487 */ 1489 */
1488 StringValue* sv = global.arrayfuncs.update(name[0..namelen]); 1490 auto s = name[0..namelen];
1489 FuncDeclaration fd = cast(FuncDeclaration)sv.ptrvalue; 1491 Object* sv = global.arrayfuncs.update(s);
1492 FuncDeclaration fd = cast(FuncDeclaration)*sv;
1490 if (!fd) 1493 if (!fd)
1491 { 1494 {
1492 /* Some of the array op functions are written as library functions, 1495 /* Some of the array op functions are written as library functions,
1493 * presumably to optimize them with special CPU vector instructions. 1496 * presumably to optimize them with special CPU vector instructions.
1494 * List those library functions here, in alpha order. 1497 * List those library functions here, in alpha order.
1699 1702
1700 /* Construct the function 1703 /* Construct the function
1701 */ 1704 */
1702 TypeFunction ftype = new TypeFunction(fparams, type, 0, LINKc); 1705 TypeFunction ftype = new TypeFunction(fparams, type, 0, LINKc);
1703 //printf("ftype: %s\n", ftype.toChars()); 1706 //printf("ftype: %s\n", ftype.toChars());
1704 fd = new FuncDeclaration(Loc(0), Loc(0), Lexer.idPool(name[0..namelen]), STCundefined, ftype); 1707 fd = new FuncDeclaration(Loc(0), Loc(0), Lexer.idPool(s), STCundefined, ftype);
1705 fd.fbody = fbody; 1708 fd.fbody = fbody;
1706 fd.protection = PROT.PROTpublic; 1709 fd.protection = PROT.PROTpublic;
1707 fd.linkage = LINKc; 1710 fd.linkage = LINKc;
1708 1711
1709 sc.module_.importedFrom.members.push(fd); 1712 sc.module_.importedFrom.members.push(fd);
1718 sc.pop(); 1721 sc.pop();
1719 } 1722 }
1720 else 1723 else
1721 { /* In library, refer to it. 1724 { /* In library, refer to it.
1722 */ 1725 */
1723 fd = FuncDeclaration.genCfunc(type, name[0..namelen]); 1726 fd = FuncDeclaration.genCfunc(type, s);
1724 } 1727 }
1725 sv.ptrvalue = cast(void*)fd; // cache symbol in hash table 1728 *sv = fd; // cache symbol in hash table
1726 } 1729 }
1727 1730
1728 /* Call the function fd(arguments) 1731 /* Call the function fd(arguments)
1729 */ 1732 */
1730 Expression ec = new VarExp(Loc(0), fd); 1733 Expression ec = new VarExp(Loc(0), fd);