Permalink
Browse files

Fix struct copying.

  • Loading branch information...
1 parent 0d90bab commit da2cb45f7a9d47dfa7fa80e814ba3fc5da0e68fb @mbebenita committed Oct 3, 2012
Showing with 13 additions and 4 deletions.
  1. +5 −4 src/compiler.js
  2. +8 −0 src/types.js
View
@@ -272,7 +272,7 @@
PointerType.prototype.lint = function () {
check(this.base, "pointer without base type");
- check(this.base.size, "cannot take pointer of size 0 type " + quote(Types.tystr(this.base, 0)));
+ // check(this.base.size, "cannot take pointer of size 0 type " + quote(Types.tystr(this.base, 0)));
};
ArrayType.prototype.lint = function () {
@@ -1017,9 +1017,10 @@
mc = scope.MEMCPY(Types.u8ty.size);
size = lty.size;
}
- var left = new UnaryExpression("&", this.left, this.left.loc);
- var right = new UnaryExpression("&", this.right, this.right.loc);
- return cast(new CallExpression(mc, [left, right, literal(size)]), lty, this.loc).transform(o);
+ var memcpyTy = mc.ty.paramTypes[0];
+ var left = cast(new UnaryExpression("&", this.left, this.left.loc), memcpyTy, true);
+ var right = cast(new UnaryExpression("&", this.right, this.right.loc), memcpyTy, true);
+ return cast(new CallExpression(mc, [left, right, literal(size)]), lty).transform(o);
} else {
this.right = cast(this.right, lty);
View
@@ -213,4 +213,12 @@
exports.mallocTy = mallocTy;
exports.freeTy = freeTy;
+ exports.memsetTy = memsetTy;
+ exports.memset2Ty = memset2Ty;
+ exports.memset4Ty = memset4Ty;
+
+ exports.memcpyTy = memcpyTy;
+ exports.memcpy2Ty = memcpy2Ty;
+ exports.memcpy4Ty = memcpy4Ty;
+
}).call(this, typeof exports === "undefined" ? (Types = {}) : exports);

0 comments on commit da2cb45

Please sign in to comment.