Skip to content
This repository has been archived by the owner on Jul 3, 2019. It is now read-only.

Commit

Permalink
stick the AS compiler jar file here, for convienience, create a direc…
Browse files Browse the repository at this point in the history
…tory of test cases, insert some debugging output into avm2.js
  • Loading branch information
David Flanagan committed Jan 7, 2012
1 parent 0ec4f4b commit f3bb55b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
Binary file added src/avm2/asc.jar
Binary file not shown.
24 changes: 17 additions & 7 deletions src/avm2/avm2.js
Expand Up @@ -30,6 +30,7 @@ var Stream = (function () {
}
}
}
print("readU32:", result);
return result;
},
readU30: function() {
Expand Down Expand Up @@ -73,6 +74,7 @@ var Stream = (function () {
result = (result << 25) >> 25;
}

print("readS32:", result);
return result;
},
readWord: function() {
Expand All @@ -88,6 +90,10 @@ var Stream = (function () {
return (u << 8) >> 8;
},
readDouble: function() {
// XXX: this code is not working.
// Should probably treat the data as 8 bytes rather than
// two words. Given that this.bytes is a typed array,
// we can optimize this, if the endianness is right.
if (!decode) {
// Setup the decode buffer for doubles.
var b = ArrayBuffer(8);
Expand All @@ -98,13 +104,16 @@ var Stream = (function () {
decode = ({ i32: i32, f64: f64, bigEndian: i8[0] == 0x11 });
}
if (decode.bigEndian) {
decode.i32[0] = readWord();
decode.i32[1] = readWord();
decode.i32[0] = this.readWord();
decode.i32[1] = this.readWord();
} else {
decode.i32[1] = readWord();
decode.i32[0] = readWord();
decode.i32[1] = this.readWord();
decode.i32[0] = this.readWord();
}
return decode.f64[0];

var result = decode.f64[0];
print("readDouble:", result);
return result;
},
readUTFString: function(length) {
var result = "", end = this.pos + length;
Expand Down Expand Up @@ -138,6 +147,7 @@ var Stream = (function () {
result += String.fromCharCode(code);
} // Otherwise it's an invalid UTF8, skipped.
}
print("readUTFString:", result);
return result;
}
};
Expand Down Expand Up @@ -280,7 +290,7 @@ function parseAbcFile(b) {
}
}

return { int32: int32, uint32: uint32, float64: float64, strings: strings,
return { int32: int32, uint32: uint32, doubles: float64, strings: strings,
names: names, ns: ns };
}
function parseMethodInfo(constants, b) {
Expand Down Expand Up @@ -1083,7 +1093,7 @@ function compileAbc(abc) {
}

try {
var bytes = snarf("tests/bitops-bits-in-byte.abc", "binary");
var bytes = snarf("tests/test.abc", "binary");
var abc = parseAbcFile(new Stream(bytes));
compileAbc(abc);
} catch (e) {
Expand Down
Binary file added src/avm2/tests/test.abc
Binary file not shown.
4 changes: 4 additions & 0 deletions src/avm2/tests/test.as
@@ -0,0 +1,4 @@
var s = "Hello World!"
var d = 1.234;
var n = 123456789;
var m = -123456789;

0 comments on commit f3bb55b

Please sign in to comment.