use of suite.primitive.Bytes in project suite by stupidsing.
the class ImperativeCompilerTest method testDeclare.
@Test
public void testDeclare() {
Bytes bytes = imperativeCompiler.compile(0, "declare v = 1; {v} = 2;");
assertNotNull(bytes);
System.out.println(bytes);
}
use of suite.primitive.Bytes in project suite by stupidsing.
the class ImperativeCompilerTest method testJump.
@Test
public void testJump() {
Bytes bytes = imperativeCompiler.compile(0, "if (1 < 2) then 1 else 0;");
assertNotNull(bytes);
System.out.println(bytes);
}
use of suite.primitive.Bytes in project suite by stupidsing.
the class ImperativeCompilerTest method testDataStructure.
@Test
public void testDataStructure() {
String s = //
"" + //
"constant p = fix :p struct ( | pointer::p next);" + //
"declare pnext = function [pointer:p e,] e/*/next;" + //
"declare object = new p (next = null,);" + //
"{object/next} = pnext [& object,];" + "0";
Bytes bytes = imperativeCompiler.compile(0, s);
assertNotNull(bytes);
System.out.println(bytes);
}
use of suite.primitive.Bytes in project suite by stupidsing.
the class CompareZipMain method run.
@Override
protected boolean run(String[] args) throws IOException {
String filename0 = "/tmp/a";
String filename1 = "/tmp/b";
ZipFile zf0 = new ZipFile(filename0);
ZipFile zf1 = new ZipFile(filename1);
Set<String> names = Set_.union(FileUtil.listZip(zf0), FileUtil.listZip(zf1));
boolean isChanged = false;
for (String name : names) {
ZipEntry e0 = zf0.getEntry(name);
ZipEntry e1 = zf1.getEntry(name);
boolean b = e0 != null && e1 != null;
if (b) {
Bytes bytes0 = To.bytes(zf0.getInputStream(e0));
Bytes bytes1 = To.bytes(zf1.getInputStream(e1));
b = !textUtil.isDiff(textUtil.diff(bytes0, bytes1));
if (!b)
System.out.println(name + " differs");
} else if (e0 == null)
System.out.println(name + " not exist in " + filename0);
else if (e1 == null)
System.out.println(name + " not exist in " + filename1);
isChanged |= !b;
}
return !isChanged;
}
use of suite.primitive.Bytes in project suite by stupidsing.
the class As method utf8encode.
public static Outlet<Bytes> utf8encode(Outlet<Chars> charsOutlet) {
Source<Chars> source = charsOutlet.source();
return Outlet.of(new Source<>() {
public Bytes source() {
Chars chars = source.source();
if (chars != null) {
BytesBuilder bb = new BytesBuilder();
for (int i = 0; i < chars.size(); i++) {
char ch = chars.get(i);
if (ch < 0x80)
bb.append((byte) ch);
else if (ch < 0x800) {
bb.append((byte) (0xC0 + ((ch >> 6) & 0x1F)));
bb.append((byte) (0x80 + ((ch >> 0) & 0x3F)));
} else if (ch < 0x10000) {
bb.append((byte) (0xE0 + ((ch >> 12) & 0x0F)));
bb.append((byte) (0x80 + ((ch >> 6) & 0x3F)));
bb.append((byte) (0x80 + ((ch >> 0) & 0x3F)));
} else {
bb.append((byte) (0xF0 + ((ch >> 18) & 0x07)));
bb.append((byte) (0x80 + ((ch >> 12) & 0x3F)));
bb.append((byte) (0x80 + ((ch >> 6) & 0x3F)));
bb.append((byte) (0x80 + ((ch >> 0) & 0x3F)));
}
}
return bb.toBytes();
} else
return null;
}
});
}
Aggregations