id
int32
0
12.9k
code
sequencelengths
2
264k
7,900
[ "<s>", "package", "erjang", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "nio", ".", "ByteBuffer", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "MethodVisitor", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "Opcodes", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "Type", ";", "import", "erjang", ".", "m", ".", "ets", ".", "EMatchContext", ";", "import", "erjang", ".", "m", ".", "ets", ".", "EPattern", ";", "import", "erjang", ".", "m", ".", "ets", ".", "ETermPattern", ";", "public", "class", "EBitString", "extends", "EObject", "{", "public", "static", "final", "Type", "EBITSTRING_TYPE", "=", "Type", ".", "getType", "(", "EBitString", ".", "class", ")", ";", "public", "static", "final", "String", "EBITSTRING_NAME", "=", "EBITSTRING_TYPE", ".", "getInternalName", "(", ")", ";", "protected", "final", "byte", "[", "]", "data", ";", "private", "final", "int", "data_offset", ";", "private", "final", "int", "byte_size", ";", "protected", "final", "int", "extra_bits", ";", "protected", "EBitString", "(", "byte", "[", "]", "data", ")", "{", "this", "(", "data", ".", "clone", "(", ")", ",", "0", ",", "data", ".", "length", ",", "0", ")", ";", "}", "@", "Override", "public", "int", "hashCode", "(", ")", "{", "int", "h", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "byte_size", ";", "i", "++", ")", "{", "h", "=", "h", "*", "31", "+", "data", "[", "data_offset", "+", "i", "]", ";", "}", "if", "(", "extra_bits", "!=", "0", ")", "{", "int", "val", "=", "data", "[", "data_offset", "+", "byte_size", "]", ">>>", "(", "8", "-", "extra_bits", ")", ";", "h", "=", "h", "*", "31", "+", "val", ";", "}", "return", "h", ";", "}", "public", "long", "bitSize", "(", ")", "{", "return", "byteSize", "(", ")", "*", "8L", "+", "extra_bits", ";", "}", "protected", "int", "dataByteSize", "(", ")", "{", "return", "byteSize", "(", ")", "+", "(", "extra_bits", ">", "0", "?", "1", ":", "0", ")", ";", "}", "public", "EBitString", "testBitString", "(", ")", "{", "return", "this", ";", "}", "public", "boolean", "match", "(", "ETermPattern", "matcher", ",", "EMatchContext", "r", ")", "{", "return", "matcher", ".", "match", "(", "this", ",", "r", ")", ";", "}", "public", "EBinary", "testBinary", "(", ")", "{", "if", "(", "isBinary", "(", ")", ")", "{", "assert", "false", ":", "\"\"", ";", "return", "new", "EBinary", "(", "toByteArray", "(", ")", ")", ";", "}", "return", "null", ";", "}", "@", "Override", "int", "cmp_order", "(", ")", "{", "return", "CMP_ORDER_BITSTRING", ";", "}", "@", "Override", "public", "Type", "emit_const", "(", "MethodVisitor", "fa", ")", "{", "char", "[", "]", "chs", "=", "new", "char", "[", "dataByteSize", "(", ")", "]", ";", "for", "(", "int", "byteIdx", "=", "0", ";", "byteIdx", "<", "byteSize", "(", ")", ";", "byteIdx", "+=", "1", ")", "{", "chs", "[", "byteIdx", "]", "=", "(", "char", ")", "(", "data", "[", "byteIdx", "]", "&", "0xff", ")", ";", "}", "if", "(", "extra_bits", "!=", "0", ")", "{", "int", "rest", "=", "intBitsAt", "(", "byteSize", "(", ")", "*", "8", ",", "extra_bits", ")", ";", "rest", "<<=", "(", "8", "-", "extra_bits", ")", ";", "chs", "[", "byteSize", "(", ")", "]", "=", "(", "char", ")", "rest", ";", "}", "String", "str", "=", "new", "String", "(", "chs", ")", ";", "fa", ".", "visitLdcInsn", "(", "str", ")", ";", "fa", ".", "visitLdcInsn", "(", "new", "Integer", "(", "extra_bits", ")", ")", ";", "fa", ".", "visitMethodInsn", "(", "Opcodes", ".", "INVOKESTATIC", ",", "EBITSTRING_NAME", ",", "\"make\"", ",", "\"\"", "+", "EBITSTRING_NAME", "+", "\";\"", ")", ";", "return", "EBITSTRING_TYPE", ";", "}", "public", "static", "EBitString", "make", "(", "String", "str", ",", "int", "extra", ")", "{", "int", "in_len", "=", "str", ".", "length", "(", ")", ";", "byte", "[", "]", "data", "=", "new", "byte", "[", "in_len", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "in_len", ";", "i", "++", ")", "{", "data", "[", "i", "]", "=", "(", "byte", ")", "str", ".", "charAt", "(", "i", ")", ";", "}", "int", "data_len", "=", "in_len", "-", "(", "extra", ">", "0", "?", "1", ":", "0", ")", ";", "return", "EBitString", ".", "make", "(", "data", ",", "0", ",", "data_len", ",", "extra", ")", ";", "}", "@", "Override", "public", "boolean", "equalsExactly", "(", "EObject", "rhs", ")", "{", "if", "(", "rhs", ".", "cmp_order", "(", ")", "!=", "CMP_ORDER_BITSTRING", ")", "return", "false", ";", "EBitString", "ebs", "=", "(", "EBitString", ")", "rhs", ";", "if", "(", "byteSize", "(", ")", "!=", "ebs", ".", "byteSize", "(", ")", ")", "return", "false", ";", "if", "(", "extra_bits", "!=", "ebs", ".", "extra_bits", ")", "return", "false", ";", "int", "byteOffset", "=", "byteOffset", "(", ")", ";", "int", "ebsByteOffset", "=", "ebs", ".", "byteOffset", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "byte_size", ";", "i", "++", ")", "{", "if", "(", "data", "[", "byteOffset", "+", "i", "]", "!=", "ebs", ".", "data", "[", "ebsByteOffset", "+", "i", "]", ")", "return", "false", ";", "}", "if", "(", "extra_bits", "!=", "0", ")", "{", "int", "myExtraBits", "=", "intBitsAt", "(", "8L", "*", "byte_size", ",", "extra_bits", ")", ";", "int", "hisExtraBits", "=", "ebs", ".", "intBitsAt", "(", "8L", "*", "byte_size", ",", "extra_bits", ")", ";", "return", "myExtraBits", "==", "hisExtraBits", ";", "}", "else", "{", "return", "true", ";", "}", "}", "@", "Override", "int", "compare_same", "(", "EObject", "rhs", ")", "{", "EBitString", "ebs", "=", "(", "EBitString", ")", "rhs", ";", "long", "bc1", "=", "bitSize", "(", ")", ";", "long", "bc2", "=", "ebs", ".", "bitSize", "(", ")", ";", "long", "limit", "=", "Math", ".", "min", "(", "bc1", ",", "bc2", ")", ";", "for", "(", "int", "pos", "=", "0", ";", "pos", "<", "limit", ";", "pos", "+=", "8", ")", "{", "int", "rest", "=", "limit", "-", "pos", ">", "8", "?", "8", ":", "(", "int", ")", "(", "limit", "-", "pos", ")", ";", "int", "oc1", "=", "0xff", "&", "intBitsAt", "(", "pos", ",", "rest", ")", ";", "int", "oc2", "=", "0xff", "&", "ebs", ".", "intBitsAt", "(", "pos", ",", "rest", ")", ";", "if", "(", "oc1", "==", "oc2", ")", "continue", ";", "if", "(", "oc1", "<", "oc2", ")", "return", "-", "1", ";", "if", "(", "oc1", ">", "oc2", ")", "return", "1", ";", "}", "if", "(", "bc1", "==", "bc2", ")", "return", "0", ";", "if", "(", "bc1", "<", "bc2", ")", "return", "-", "1", ";", "else", "return", "1", ";", "}", "public", "static", "EBitString", "make", "(", "byte", "[", "]", "data", ",", "int", "byteOff", ",", "int", "byteLength", ",", "int", "extra_bits", ")", "{", "if", "(", "extra_bits", "==", "0", ")", "{", "return", "new", "EBinary", "(", "data", ",", "byteOff", ",", "byteLength", ")", ";", "}", "else", "{", "return", "new", "EBitString", "(", "data", ",", "byteOff", ",", "byteLength", ",", "extra_bits", ")", ";", "}", "}", "public", "static", "EBitString", "makeByteOffsetTail", "(", "EBitString", "org", ",", "int", "byteOff", ")", "{", "return", "EBitString", ".", "make", "(", "org", ".", "data", ",", "org", ".", "data_offset", "+", "byteOff", ",", "org", ".", "byte_size", "-", "byteOff", ",", "org", ".", "extra_bits", ")", ";", "}", "protected", "EBitString", "(", "byte", "[", "]", "data", ",", "int", "byte_off", ",", "int", "byte_len", ",", "int", "extra_bits", ")", "{", "this", ".", "data", "=", "data", ";", "this", ".", "data_offset", "=", "byte_off", ";", "this", ".", "byte_size", "=", "byte_len", ";", "this", ".", "extra_bits", "=", "extra_bits", ";", "if", "(", "data", ".", "length", "<", "byte_off", "+", "byte_len", "+", "(", "extra_bits", ">", "0", "?", "1", ":", "0", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", ")", ";", "}", "if", "(", "extra_bits", "<", "0", "||", "extra_bits", ">=", "8", ")", "{", "throw", "new", "IllegalArgumentException", "(", ")", ";", "}", "}", "public", "boolean", "isBinary", "(", ")", "{", "return", "extra_bits", "==", "0", ";", "}", "public", "int", "octetAt", "(", "int", "byteIndex", ")", "{", "return", "data", "[", "byteOffset", "(", ")", "+", "byteIndex", "]", "&", "0xff", ";", "}", "public", "int", "uint16_at", "(", "int", "byteIndex", ",", "int", "flags", ")", "{", "int", "b1", "=", "data", "[", "byteOffset", "(", ")", "+", "byteIndex", "]", "&", "0xff", ";", "int", "b2", "=", "data", "[", "byteOffset", "(", ")", "+", "byteIndex", "+", "1", "]", "&", "0xff", ";", "if", "(", "(", "flags", "&", "EBinMatchState", ".", "BSF_LITTLE", ")", ">", "0", ")", "return", "b1", "+", "(", "b2", "<<", "8", ")", ";", "else", "return", "(", "b1", "<<", "8", ")", "+", "b2", ";", "}", "public", "int", "int32_at", "(", "int", "byteIndex", ",", "int", "flags", ")", "{", "int", "b1", "=", "data", "[", "byteOffset", "(", ")", "+", "byteIndex", "]", "&", "0xff", ";", "int", "b2", "=", "data", "[", "byteOffset", "(", ")", "+", "byteIndex", "+", "1", "]", "&", "0xff", ";", "int", "b3", "=", "data", "[", "byteOffset", "(", ")", "+", "byteIndex", "+", "2", "]", "&", "0xff", ";", "int", "b4", "=", "data", "[", "byteOffset", "(", ")", "+", "byteIndex", "+", "3", "]", "&", "0xff", ";", "if", "(", "(", "flags", "&", "EBinMatchState", ".", "BSF_LITTLE", ")", ">", "0", ")", "return", "b1", "+", "(", "b2", "<<", "8", ")", "+", "(", "b3", "<<", "16", ")", "+", "(", "b4", "<<", "24", ")", ";", "else", "return", "(", "b1", "<<", "24", ")", "+", "(", "b2", "<<", "16", ")", "+", "(", "b3", "<<", "8", ")", "+", "b4", ";", "}", "public", "EBitString", "substring", "(", "long", "bitOff", ")", "{", "return", "substring", "(", "bitOff", ",", "bitSize", "(", ")", "-", "bitOff", ")", ";", "}", "public", "EBitString", "substring", "(", "long", "bitOff", ",", "long", "bit_len", ")", "{", "if", "(", "bitOff", "<", "0", "||", "bitOff", "+", "bit_len", ">", "bitSize", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"\"", ")", ";", "}", "bitOff", "+=", "byteOffset", "(", ")", "*", "8", ";", "int", "out_full_bytes", "=", "(", "int", ")", "(", "bit_len", "/", "8", ")", ";", "int", "extra", "=", "(", "int", ")", "(", "bit_len", "%", "8", ")", ";", "if", "(", "0", "==", "(", "bitOff", "%", "8", ")", ")", "{", "return", "EBitString", ".", "make", "(", "data", ",", "(", "int", ")", "(", "bitOff", "/", "8", ")", ",", "out_full_bytes", ",", "extra", ")", ";", "}", "int", "out_bytes", "=", "(", "int", ")", "(", "out_full_bytes", "+", "(", "extra", "==", "0", "?", "0", ":", "1", ")", ")", ";", "byte", "[", "]", "res", "=", "new", "byte", "[", "out_bytes", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "out_full_bytes", ";", "i", "++", ")", "{", "res", "[", "i", "]", "=", "(", "byte", ")", "intBitsAt", "(", "bitOff", "+", "i", "*", "8", ",", "8", ")", ";", "}", "if", "(", "extra", "!=", "0", ")", "{", "res", "[", "(", "int", ")", "out_full_bytes", "]", "=", "(", "byte", ")", "(", "intBitsAt", "(", "bitOff", "+", "bit_len", "-", "extra", ",", "extra", ")", "<<", "(", "8", "-", "extra", ")", ")", ";", "}", "return", "EBitString", ".", "make", "(", "res", ",", "0", ",", "(", "int", ")", "out_full_bytes", ",", "extra", ")", ";", "}", "public", "int", "bitAt", "(", "long", "bitPos", ")", "{", "if", "(", "bitPos", "<", "0", "||", "bitPos", ">=", "bitSize", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"\"", ")", ";", "}", "bitPos", "+=", "byteOffset", "(", ")", "*", "8", ";", "int", "data_byte", "=", "(", "int", ")", "data", "[", "(", "int", ")", "(", "bitPos", ">>>", "3", ")", "]", ";", "int", "shift", "=", "7", "-", "(", "int", ")", "(", "bitPos", "&", "0x07", ")", ";", "int", "bit", "=", "0x01", "&", "(", "data_byte", ">>", "shift", ")", ";", "return", "bit", ";", "}", "public", "int", "intBitsAt", "(", "long", "bitPos", ",", "int", "bitLength", ")", "{", "if", "(", "bitPos", "+", "bitLength", ">", "this", ".", "bitSize", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"\"", ")", ";", "}", "if", "(", "bitLength", "<", "0", "||", "bitLength", ">", "32", ")", "throw", "new", "IllegalArgumentException", "(", "\"\"", ")", ";", "bitPos", "+=", "byteOffset", "(", ")", "*", "8", ";", "int", "res", "=", "0", ";", "if", "(", "(", "bitPos", "&", "0x07", ")", "!=", "0", ")", "{", "int", "len", "=", "8", "-", "(", "int", ")", "(", "bitPos", "&", "0x07", ")", ";", "int", "val", "=", "0x0ff", "&", "(", "int", ")", "data", "[", "(", "int", ")", "(", "bitPos", ">>", "3", ")", "]", ";", "res", "=", "val", "&", "(", "(", "1", "<<", "len", ")", "-", "1", ")", ";", "if", "(", "bitLength", "<", "len", ")", "{", "res", ">>>=", "(", "len", "-", "bitLength", ")", ";", "return", "res", ";", "}", "bitLength", "-=", "len", ";", "bitPos", "+=", "len", ";", "}", "assert", "(", "(", "bitPos", "&", "0x07", ")", "==", "0", ")", ";", "int", "pos", "=", "(", "int", ")", "(", "bitPos", ">>", "3", ")", ";", "while", "(", "bitLength", ">", "7", ")", "{", "res", "<<=", "8", ";", "res", "|=", "0x0ff", "&", "(", "int", ")", "data", "[", "pos", "++", "]", ";", "bitPos", "+=", "8", ";", "bitLength", "-=", "8", ";", "}", "assert", "(", "bitLength", "<", "8", ")", ";", "if", "(", "bitLength", "!=", "0", ")", "{", "int", "len", "=", "bitLength", ";", "int", "val", "=", "0x0ff", "&", "(", "int", ")", "data", "[", "pos", "]", ";", "res", "<<=", "bitLength", ";", "res", "|=", "val", ">>", "(", "8", "-", "len", ")", ";", "bitLength", "-=", "len", ";", "bitPos", "+=", "len", ";", "}", "assert", "(", "bitLength", "==", "0", ")", ";", "return", "res", ";", "}", "public", "int", "intLittleEndianBitsAt", "(", "long", "bitPos", ",", "int", "bitLength", ")", "{", "if", "(", "bitPos", "+", "bitLength", ">", "this", ".", "bitSize", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"\"", ")", ";", "}", "if", "(", "bitLength", "<", "0", "||", "bitLength", ">", "32", ")", "throw", "new", "IllegalArgumentException", "(", "\"\"", ")", ";", "bitPos", "+=", "byteOffset", "(", ")", "*", "8", ";", "int", "res", "=", "0", ";", "int", "res_offset", "=", "0", ";", "if", "(", "(", "bitPos", "&", "0x07", ")", "!=", "0", ")", "{", "int", "len", "=", "8", "-", "(", "int", ")", "(", "bitPos", "&", "0x07", ")", ";", "int", "val", "=", "data", "[", "(", "int", ")", "(", "bitPos", ">>", "3", ")", "]", "&", "0x0ff", ";", "res", "=", "val", "&", "(", "(", "1", "<<", "len", ")", "-", "1", ")", ";", "if", "(", "bitLength", "<", "len", ")", "{", "res", ">>>=", "(", "len", "-", "bitLength", ")", ";", "return", "res", ";", "}", "res_offset", "+=", "len", ";", "bitLength", "-=", "len", ";", "bitPos", "+=", "len", ";", "}", "assert", "(", "(", "bitPos", "&", "0x07", ")", "==", "0", ")", ";", "int", "pos", "=", "(", "int", ")", "(", "bitPos", ">>", "3", ")", ";", "while", "(", "bitLength", ">", "7", ")", "{", "res", "|=", "(", "data", "[", "pos", "++", "]", "&", "0x0ff", ")", "<<", "res_offset", ";", "res_offset", "+=", "8", ";", "bitPos", "+=", "8", ";", "bitLength", "-=", "8", ";", "}", "assert", "(", "bitLength", "<", "8", ")", ";", "if", "(", "bitLength", "!=", "0", ")", "{", "int", "len", "=", "bitLength", ";", "int", "val", "=", "0x0ff", "&", "(", "int", ")", "data", "[", "(", "int", ")", "(", "bitPos", ">>", "3", ")", "]", ";", "res", "|=", "(", "val", ">>", "(", "8", "-", "len", ")", ")", "<<", "res_offset", ";", "res_offset", "+=", "len", ";", "bitLength", "-=", "len", ";", "bitPos", "+=", "len", ";", "}", "assert", "(", "bitLength", "==", "0", ")", ";", "return", "res", ";", "}", "static", "int", "signExtend", "(", "int", "val", ",", "int", "bits", ")", "{", "if", "(", "bits", "==", "32", ")", "return", "val", ";", "int", "r", ";", "int", "m", "=", "1", "<<", "(", "bits", "-", "1", ")", ";", "r", "=", "(", "val", "^", "m", ")", "-", "m", ";", "return", "r", ";", "}", "static", "long", "signExtend", "(", "long", "val", ",", "int", "bits", ")", "{", "if", "(", "bits", "==", "64", ")", "return", "val", ";", "long", "r", ";", "long", "m", "=", "1L", "<<", "(", "bits", "-", "1", ")", ";", "r", "=", "(", "val", "^", "m", ")", "-", "m", ";", "return", "r", ";", "}", "public", "byte", "byteAt", "(", "int", "bitPos", ")", "{", "return", "(", "byte", ")", "intBitsAt", "(", "bitPos", ",", "8", ")", ";", "}", "public", "double", "doubleAt", "(", "int", "bitPos", ")", "{", "return", "Double", ".", "longBitsToDouble", "(", "longBitsAt", "(", "bitPos", ",", "64", ")", ")", ";", "}", "public", "double", "floatAt", "(", "int", "bitPos", ")", "{", "return", "Float", ".", "intBitsToFloat", "(", "intBitsAt", "(", "bitPos", ",", "32", ")", ")", ";", "}", "public", "long", "longBitsAt", "(", "long", "bitPos", ",", "int", "bitLength", ")", "{", "if", "(", "bitPos", "+", "bitLength", ">", "this", ".", "bitSize", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"\"", ")", ";", "}", "if", "(", "bitLength", "<", "0", "||", "bitLength", ">", "64", ")", "throw", "new", "IllegalArgumentException", "(", "\"\"", ")", ";", "long", "res", "=", "0", ";", "bitPos", "+=", "byteOffset", "(", ")", "*", "8", ";", "if", "(", "(", "bitPos", "&", "0x07", ")", "!=", "0", ")", "{", "int", "len", "=", "8", "-", "(", "int", ")", "(", "bitPos", "&", "0x07", ")", ";", "int", "val", "=", "0x0ff", "&", "(", "int", ")", "data", "[", "(", "int", ")", "(", "bitPos", ">>", "3", ")", "]", ";", "res", "=", "val", "&", "(", "(", "1", "<<", "len", ")", "-", "1", ")", ";", "if", "(", "bitLength", "<", "len", ")", "{", "res", ">>>=", "(", "len", "-", "bitLength", ")", ";", "return", "res", ";", "}", "bitLength", "-=", "len", ";", "bitPos", "+=", "len", ";", "}", "assert", "(", "(", "bitPos", "&", "0x07", ")", "==", "0", ")", ";", "int", "pos", "=", "(", "int", ")", "(", "bitPos", ">>", "3", ")", ";", "while", "(", "bitLength", ">", "7", ")", "{", "res", "<<=", "8", ";", "res", "|=", "0x0ff", "&", "(", "int", ")", "data", "[", "pos", "++", "]", ";", "bitPos", "+=", "8", ";", "bitLength", "-=", "8", ";", "}", "assert", "(", "bitLength", "<", "8", ")", ";", "assert", "(", "(", "bitPos", "&", "0x07", ")", "==", "0", ")", ";", "if", "(", "bitLength", "!=", "0", ")", "{", "int", "len", "=", "bitLength", ";", "int", "val", "=", "0x0ff", "&", "(", "int", ")", "data", "[", "(", "int", ")", "(", "bitPos", ">>", "3", ")", "]", ";", "res", "<<=", "bitLength", ";", "res", "|=", "val", ">>", "(", "8", "-", "len", ")", ";", "bitLength", "-=", "len", ";", "bitPos", "+=", "len", ";", "}", "assert", "(", "bitLength", "==", "0", ")", ";", "return", "res", ";", "}", "public", "long", "longLittleEndianBitsAt", "(", "long", "bitPos", ",", "int", "bitLength", ")", "{", "if", "(", "bitPos", "+", "bitLength", ">", "this", ".", "bitSize", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"\"", ")", ";", "}", "if", "(", "bitLength", "<", "0", "||", "bitLength", ">", "64", ")", "throw", "new", "IllegalArgumentException", "(", "\"\"", ")", ";", "long", "res", "=", "0", ";", "int", "res_offset", "=", "0", ";", "bitPos", "+=", "byteOffset", "(", ")", "*", "8", ";", "if", "(", "(", "bitPos", "&", "0x07", ")", "!=", "0", ")", "{", "int", "len", "=", "8", "-", "(", "int", ")", "(", "bitPos", "&", "0x07", ")", ";", "int", "val", "=", "data", "[", "(", "int", ")", "(", "bitPos", ">>", "3", ")", "]", "&", "0x0ff", ";", "res", "=", "val", "&", "(", "(", "1", "<<", "len", ")", "-", "1", ")", ";", "if", "(", "bitLength", "<", "len", ")", "{", "res", ">>>=", "(", "len", "-", "bitLength", ")", ";", "return", "res", ";", "}", "res_offset", "+=", "len", ";", "bitLength", "-=", "len", ";", "bitPos", "+=", "len", ";", "}", "assert", "(", "(", "bitPos", "&", "0x07", ")", "==", "0", ")", ";", "int", "pos", "=", "(", "int", ")", "(", "bitPos", ">>", "3", ")", ";", "while", "(", "bitLength", ">=", "8", ")", "{", "res", "|=", "(", "(", "long", ")", "(", "data", "[", "pos", "++", "]", "&", "0x0ff", ")", ")", "<<", "res_offset", ";", "res_offset", "+=", "8", ";", "bitPos", "+=", "8", ";", "bitLength", "-=", "8", ";", "}", "assert", "(", "bitLength", "<", "8", ")", ";", "assert", "(", "(", "bitPos", "&", "0x07", ")", "==", "0", ")", ";", "if", "(", "bitLength", "!=", "0", ")", "{", "int", "len", "=", "bitLength", ";", "int", "val", "=", "data", "[", "pos", "]", "&", "0x0ff", ";", "res", "|=", "(", "long", ")", "(", "val", ">>", "(", "8", "-", "len", ")", ")", "<<", "res_offset", ";", "res_offset", "+=", "len", ";", "bitLength", "-=", "len", ";", "bitPos", "+=", "len", ";", "}", "assert", "(", "bitLength", "==", "0", ")", ";", "return", "res", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "foo", ":", "if", "(", "extra_bits", "==", "0", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "\"<<\\\"\"", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "bitSize", "(", ")", ";", "i", "+=", "8", ")", "{", "char", "ch", "=", "(", "char", ")", "(", "0xff", "&", "intBitsAt", "(", "i", ",", "8", ")", ")", ";", "if", "(", "ch", "<", "'", "'", "||", "ch", ">", "'~'", ")", "break", "foo", ";", "sb", ".", "append", "(", "(", "char", ")", "ch", ")", ";", "}", "sb", ".", "append", "(", "\"\\\">>\"", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "\"<<\"", ")", ";", "int", "i", "=", "0", ";", "long", "max", "=", "Math", ".", "min", "(", "bitSize", "(", ")", "-", "8", ",", "20", "*", "8", ")", ";", "for", "(", ";", "i", "<", "max", ";", "i", "+=", "8", ")", "{", "sb", ".", "append", "(", "0xff", "&", "intBitsAt", "(", "i", ",", "8", ")", ")", ";", "sb", ".", "append", "(", "','", ")", ";", "}", "if", "(", "max", "!=", "bitSize", "(", ")", "-", "8", ")", "{", "sb", ".", "append", "(", "\"...,\"", ")", ";", "i", "=", "(", "int", ")", "(", "bitSize", "(", ")", "-", "8", ")", ";", "}", "int", "lastBitLength", "=", "(", "int", ")", "(", "bitSize", "(", ")", "-", "i", ")", ";", "sb", ".", "append", "(", "0xff", "&", "intBitsAt", "(", "i", ",", "lastBitLength", ")", ")", ";", "if", "(", "lastBitLength", "!=", "8", ")", "{", "sb", ".", "append", "(", "':'", ")", ".", "append", "(", "lastBitLength", ")", ";", "}", "sb", ".", "append", "(", "\">>\"", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}", "public", "byte", "[", "]", "toByteArray", "(", ")", "{", "byte", "[", "]", "result", "=", "new", "byte", "[", "dataByteSize", "(", ")", "]", ";", "System", ".", "arraycopy", "(", "data", ",", "byteOffset", "(", ")", ",", "result", ",", "0", ",", "dataByteSize", "(", ")", ")", ";", "return", "result", ";", "}", "@", "Override", "public", "boolean", "collectIOList", "(", "List", "<", "ByteBuffer", ">", "out", ")", "{", "if", "(", "extra_bits", "!=", "0", ")", "return", "false", ";", "if", "(", "byteSize", "(", ")", ">", "0", ")", "{", "out", ".", "add", "(", "ByteBuffer", ".", "wrap", "(", "data", ",", "byteOffset", "(", ")", ",", "byteSize", "(", ")", ")", ")", ";", "}", "return", "true", ";", "}", "public", "static", "EBitString", "read", "(", "EInputStream", "eInputStream", ")", "throws", "IOException", "{", "int", "[", "]", "pad_bits", "=", "new", "int", "[", "1", "]", ";", "byte", "[", "]", "data", "=", "eInputStream", ".", "read_bitstr", "(", "pad_bits", ")", ";", "int", "extra_bits", "=", "8", "-", "pad_bits", "[", "0", "]", ";", "if", "(", "extra_bits", "==", "8", ")", "{", "return", "new", "EBinary", "(", "data", ")", ";", "}", "else", "{", "int", "len", "=", "data", ".", "length", "-", "1", ";", "return", "make", "(", "data", ",", "0", ",", "data", ".", "length", "-", "1", ",", "extra_bits", ")", ";", "}", "}", "protected", "int", "byteOffset", "(", ")", "{", "return", "data_offset", ";", "}", "public", "int", "byteSize", "(", ")", "{", "return", "byte_size", ";", "}", "public", "int", "totalByteSize", "(", ")", "{", "return", "byte_size", "+", "(", "extra_bits", ">", "0", "?", "1", ":", "0", ")", ";", "}", "@", "Override", "public", "void", "collectCharList", "(", "CharCollector", "out", ")", "throws", "CharCollector", ".", "CollectingException", ",", "CharCollector", ".", "InvalidElementException", ",", "IOException", "{", "if", "(", "extra_bits", "!=", "0", ")", "throw", "new", "CharCollector", ".", "InvalidElementException", "(", ")", ";", "try", "{", "out", ".", "addBinary", "(", "data", ",", "data_offset", ",", "byte_size", ")", ";", "}", "catch", "(", "CharCollector", ".", "PartialDecodingException", "e", ")", "{", "int", "n", "=", "e", ".", "inputPos", ";", "throw", "new", "CharCollector", ".", "CollectingException", "(", "EBitString", ".", "make", "(", "data", ",", "data_offset", "+", "n", ",", "byte_size", "-", "n", ",", "extra_bits", ")", ")", ";", "}", "}", "@", "Override", "public", "void", "encode", "(", "EOutputStream", "eos", ")", "{", "eos", ".", "write_bitstr", "(", "toByteArray", "(", ")", ",", "extra_bits", "==", "0", "?", "0", ":", "8", "-", "extra_bits", ")", ";", "}", "@", "Override", "public", "ETermPattern", "compileMatch", "(", "Set", "<", "Integer", ">", "out", ")", "{", "return", "EPattern", ".", "compilePattern", "(", "this", ",", "out", ")", ";", "}", "}", "</s>" ]
7,901
[ "<s>", "package", "erjang", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileOutputStream", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "ClassAdapter", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "ClassWriter", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "Label", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "MethodVisitor", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "Opcodes", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "Type", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "util", ".", "CheckClassAdapter", ";", "import", "erjang", ".", "m", ".", "ets", ".", "EMatchContext", ";", "import", "erjang", ".", "m", ".", "ets", ".", "EPattern", ";", "import", "erjang", ".", "m", ".", "ets", ".", "ETermPattern", ";", "public", "abstract", "class", "ETuple", "extends", "EObject", "implements", "Cloneable", "{", "@", "Override", "int", "cmp_order", "(", ")", "{", "return", "CMP_ORDER_TUPLE", ";", "}", "@", "Override", "int", "compare_same", "(", "EObject", "rhs", ")", "{", "ETuple", "other", "=", "(", "ETuple", ")", "rhs", ";", "if", "(", "arity", "(", ")", "<", "other", ".", "arity", "(", ")", ")", "return", "-", "1", ";", "if", "(", "arity", "(", ")", ">", "other", ".", "arity", "(", ")", ")", "return", "1", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "arity", "(", ")", ";", "i", "++", ")", "{", "int", "cmp", "=", "elm", "(", "i", ")", ".", "erlangCompareTo", "(", "other", ".", "elm", "(", "i", ")", ")", ";", "if", "(", "cmp", "!=", "0", ")", "return", "cmp", ";", "}", "return", "0", ";", "}", "public", "ETuple", "testTuple", "(", ")", "{", "return", "this", ";", "}", "public", "boolean", "match", "(", "ETermPattern", "matcher", ",", "EMatchContext", "r", ")", "{", "return", "matcher", ".", "match", "(", "this", ",", "r", ")", ";", "}", "@", "Override", "public", "ETermPattern", "compileMatch", "(", "Set", "<", "Integer", ">", "out", ")", "{", "return", "EPattern", ".", "compilePattern", "(", "this", ",", "out", ")", ";", "}", "public", "abstract", "int", "arity", "(", ")", ";", "public", "abstract", "EObject", "elm", "(", "int", "i", ")", ";", "public", "static", "ETuple", "make", "(", "int", "len", ")", "{", "switch", "(", "len", ")", "{", "case", "0", ":", "return", "new", "ETuple0", "(", ")", ";", "case", "1", ":", "return", "new", "ETuple1", "(", ")", ";", "case", "2", ":", "return", "new", "ETuple2", "(", ")", ";", "case", "3", ":", "return", "new", "ETuple3", "(", ")", ";", "case", "4", ":", "return", "new", "ETuple4", "(", ")", ";", "default", ":", "return", "make_big", "(", "len", ")", ";", "}", "}", "public", "static", "ETuple", "make", "(", "EObject", "...", "array", ")", "{", "ETuple", "res", "=", "make", "(", "array", ".", "length", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "array", ".", "length", ";", "i", "++", ")", "{", "res", ".", "set", "(", "i", "+", "1", ",", "array", "[", "i", "]", ")", ";", "}", "return", "res", ";", "}", "@", "Override", "public", "ETuple", "clone", "(", ")", "{", "try", "{", "return", "(", "ETuple", ")", "super", ".", "clone", "(", ")", ";", "}", "catch", "(", "CloneNotSupportedException", "e", ")", "{", "throw", "new", "Error", "(", ")", ";", "}", "}", "public", "ETuple", "setelement", "(", "int", "index", ",", "EObject", "term", ")", "{", "ETuple", "t", "=", "clone", "(", ")", ";", "t", ".", "set", "(", "index", ",", "term", ")", ";", "return", "t", ";", "}", "public", "abstract", "void", "set", "(", "int", "index", ",", "EObject", "term", ")", ";", "public", "abstract", "ETuple", "blank", "(", ")", ";", "private", "static", "final", "Type", "ETUPLE_TYPE", "=", "Type", ".", "getType", "(", "ETuple", ".", "class", ")", ";", "private", "static", "final", "String", "ETUPLE_NAME", "=", "ETUPLE_TYPE", ".", "getInternalName", "(", ")", ";", "private", "static", "final", "Type", "ETERM_TYPE", "=", "Type", ".", "getType", "(", "EObject", ".", "class", ")", ";", "private", "static", "Map", "<", "Integer", ",", "ETuple", ">", "protos", "=", "new", "HashMap", "<", "Integer", ",", "ETuple", ">", "(", ")", ";", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "static", "ETuple", "make_big", "(", "int", "size", ")", "{", "ETuple", "proto", "=", "protos", ".", "get", "(", "size", ")", ";", "if", "(", "proto", "==", "null", ")", "{", "try", "{", "Class", "<", "?", "extends", "ETuple", ">", "c", "=", "get_tuple_class", "(", "size", ")", ";", "protos", ".", "put", "(", "size", ",", "proto", "=", "c", ".", "newInstance", "(", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}", "return", "proto", ".", "blank", "(", ")", ";", "}", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "static", "public", "Class", "get_tuple_class", "(", "int", "num_cells", ")", "{", "try", "{", "return", "Class", ".", "forName", "(", "ETuple", ".", "class", ".", "getName", "(", ")", "+", "num_cells", ")", ";", "}", "catch", "(", "ClassNotFoundException", "e", ")", "{", "}", "byte", "[", "]", "data", "=", "make_tuple_class_data", "(", "num_cells", ")", ";", "String", "name", "=", "(", "ETUPLE_NAME", "+", "num_cells", ")", ".", "replace", "(", "'/'", ",", "'.'", ")", ";", "return", "ERT", ".", "defineClass", "(", "ETuple", ".", "class", ".", "getClassLoader", "(", ")", ",", "name", ",", "data", ")", ";", "}", "static", "byte", "[", "]", "make_tuple_class_data", "(", "int", "num_cells", ")", "{", "ClassWriter", "cww", "=", "new", "ClassWriter", "(", "true", ")", ";", "CheckClassAdapter", "cw", "=", "new", "CheckClassAdapter", "(", "cww", ")", ";", "String", "this_class_name", "=", "ETUPLE_NAME", "+", "num_cells", ";", "String", "super_class_name", "=", "ETUPLE_NAME", ";", "cw", ".", "visit", "(", "Opcodes", ".", "V1_4", ",", "Opcodes", ".", "ACC_PUBLIC", "|", "Opcodes", ".", "ACC_SUPER", ",", "this_class_name", ",", "null", ",", "super_class_name", ",", "null", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "num_cells", ";", "i", "++", ")", "{", "cw", ".", "visitField", "(", "Opcodes", ".", "ACC_PUBLIC", ",", "\"elem\"", "+", "i", ",", "ETERM_TYPE", ".", "getDescriptor", "(", ")", ",", "null", ",", "null", ")", ";", "}", "create_count", "(", "cw", ",", "num_cells", ")", ";", "create_cast", "(", "cw", ",", "num_cells", ")", ";", "create_cast2", "(", "cw", ",", "num_cells", ")", ";", "create_constructor", "(", "cw", ",", "super_class_name", ")", ";", "create_tuple_copy", "(", "num_cells", ",", "cw", ",", "this_class_name", ",", "super_class_name", ")", ";", "create_tuple_nth", "(", "num_cells", ",", "cw", ",", "this_class_name", ")", ";", "create_tuple_set", "(", "num_cells", ",", "cw", ",", "this_class_name", ")", ";", "cw", ".", "visitEnd", "(", ")", ";", "byte", "[", "]", "data", "=", "cww", ".", "toByteArray", "(", ")", ";", "return", "data", ";", "}", "private", "static", "void", "create_tuple_copy", "(", "int", "i", ",", "ClassAdapter", "cw", ",", "String", "this_class_name", ",", "String", "super_class_name", ")", "{", "MethodVisitor", "mv", ";", "make_blank_bridge", "(", "cw", ",", "this_class_name", ",", "super_class_name", ")", ";", "mv", "=", "cw", ".", "visitMethod", "(", "Opcodes", ".", "ACC_PUBLIC", ",", "\"blank\"", ",", "\"()L\"", "+", "this_class_name", "+", "\";\"", ",", "null", ",", "null", ")", ";", "mv", ".", "visitCode", "(", ")", ";", "mv", ".", "visitTypeInsn", "(", "Opcodes", ".", "NEW", ",", "this_class_name", ")", ";", "mv", ".", "visitInsn", "(", "Opcodes", ".", "DUP", ")", ";", "mv", ".", "visitMethodInsn", "(", "Opcodes", ".", "INVOKESPECIAL", ",", "this_class_name", ",", "\"<init>\"", ",", "\"()V\"", ")", ";", "mv", ".", "visitInsn", "(", "Opcodes", ".", "ARETURN", ")", ";", "mv", ".", "visitMaxs", "(", "3", ",", "3", ")", ";", "mv", ".", "visitEnd", "(", ")", ";", "}", "private", "static", "void", "make_blank_bridge", "(", "ClassAdapter", "cw", ",", "String", "this_class_name", ",", "String", "super_class_name", ")", "{", "MethodVisitor", "mv", ";", "mv", "=", "cw", ".", "visitMethod", "(", "Opcodes", ".", "ACC_PUBLIC", "|", "Opcodes", ".", "ACC_SYNTHETIC", "|", "Opcodes", ".", "ACC_BRIDGE", ",", "\"blank\"", ",", "\"()L\"", "+", "super_class_name", "+", "\";\"", ",", "null", ",", "null", ")", ";", "mv", ".", "visitCode", "(", ")", ";", "mv", ".", "visitVarInsn", "(", "Opcodes", ".", "ALOAD", ",", "0", ")", ";", "mv", ".", "visitMethodInsn", "(", "Opcodes", ".", "INVOKEVIRTUAL", ",", "this_class_name", ",", "\"blank\"", ",", "\"()L\"", "+", "this_class_name", "+", "\";\"", ")", ";", "mv", ".", "visitInsn", "(", "Opcodes", ".", "ARETURN", ")", ";", "mv", ".", "visitMaxs", "(", "1", ",", "1", ")", ";", "mv", ".", "visitEnd", "(", ")", ";", "}", "private", "static", "void", "create_tuple_nth", "(", "int", "n_cells", ",", "ClassAdapter", "cw", ",", "String", "this_class_name", ")", "{", "MethodVisitor", "mv", ";", "mv", "=", "cw", ".", "visitMethod", "(", "Opcodes", ".", "ACC_PUBLIC", ",", "\"elm\"", ",", "\"(I)\"", "+", "ETERM_TYPE", ".", "getDescriptor", "(", ")", ",", "null", ",", "null", ")", ";", "mv", ".", "visitCode", "(", ")", ";", "Label", "dflt", "=", "new", "Label", "(", ")", ";", "Label", "[", "]", "labels", "=", "new", "Label", "[", "n_cells", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "n_cells", ";", "i", "++", ")", "{", "labels", "[", "i", "]", "=", "new", "Label", "(", ")", ";", "}", "mv", ".", "visitVarInsn", "(", "Opcodes", ".", "ILOAD", ",", "1", ")", ";", "mv", ".", "visitTableSwitchInsn", "(", "1", ",", "n_cells", ",", "dflt", ",", "labels", ")", ";", "for", "(", "int", "zbase", "=", "0", ";", "zbase", "<", "n_cells", ";", "zbase", "++", ")", "{", "mv", ".", "visitLabel", "(", "labels", "[", "zbase", "]", ")", ";", "mv", ".", "visitVarInsn", "(", "Opcodes", ".", "ALOAD", ",", "0", ")", ";", "String", "field", "=", "\"elem\"", "+", "(", "zbase", "+", "1", ")", ";", "mv", ".", "visitFieldInsn", "(", "Opcodes", ".", "GETFIELD", ",", "this_class_name", ",", "field", ",", "ETERM_TYPE", ".", "getDescriptor", "(", ")", ")", ";", "mv", ".", "visitInsn", "(", "Opcodes", ".", "ARETURN", ")", ";", "}", "mv", ".", "visitLabel", "(", "dflt", ")", ";", "mv", ".", "visitVarInsn", "(", "Opcodes", ".", "ALOAD", ",", "0", ")", ";", "mv", ".", "visitVarInsn", "(", "Opcodes", ".", "ILOAD", ",", "1", ")", ";", "mv", ".", "visitMethodInsn", "(", "Opcodes", ".", "INVOKEVIRTUAL", ",", "ETUPLE_NAME", ",", "\"bad_nth\"", ",", "\"(I)\"", "+", "ETERM_TYPE", ".", "getDescriptor", "(", ")", ")", ";", "mv", ".", "visitInsn", "(", "Opcodes", ".", "ARETURN", ")", ";", "mv", ".", "visitMaxs", "(", "3", ",", "2", ")", ";", "mv", ".", "visitEnd", "(", ")", ";", "}", "private", "static", "void", "create_tuple_set", "(", "int", "n_cells", ",", "ClassAdapter", "cw", ",", "String", "this_class_name", ")", "{", "MethodVisitor", "mv", ";", "mv", "=", "cw", ".", "visitMethod", "(", "Opcodes", ".", "ACC_PUBLIC", ",", "\"set\"", ",", "\"(I\"", "+", "ETERM_TYPE", ".", "getDescriptor", "(", ")", "+", "\")V\"", ",", "null", ",", "null", ")", ";", "mv", ".", "visitCode", "(", ")", ";", "Label", "dflt", "=", "new", "Label", "(", ")", ";", "Label", "[", "]", "labels", "=", "new", "Label", "[", "n_cells", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "n_cells", ";", "i", "++", ")", "{", "labels", "[", "i", "]", "=", "new", "Label", "(", ")", ";", "}", "mv", ".", "visitVarInsn", "(", "Opcodes", ".", "ILOAD", ",", "1", ")", ";", "mv", ".", "visitTableSwitchInsn", "(", "1", ",", "n_cells", ",", "dflt", ",", "labels", ")", ";", "for", "(", "int", "zbase", "=", "0", ";", "zbase", "<", "n_cells", ";", "zbase", "++", ")", "{", "mv", ".", "visitLabel", "(", "labels", "[", "zbase", "]", ")", ";", "mv", ".", "visitVarInsn", "(", "Opcodes", ".", "ALOAD", ",", "0", ")", ";", "mv", ".", "visitVarInsn", "(", "Opcodes", ".", "ALOAD", ",", "2", ")", ";", "String", "field", "=", "\"elem\"", "+", "(", "zbase", "+", "1", ")", ";", "mv", ".", "visitFieldInsn", "(", "Opcodes", ".", "PUTFIELD", ",", "this_class_name", ",", "field", ",", "ETERM_TYPE", ".", "getDescriptor", "(", ")", ")", ";", "mv", ".", "visitInsn", "(", "Opcodes", ".", "RETURN", ")", ";", "}", "mv", ".", "visitLabel", "(", "dflt", ")", ";", "mv", ".", "visitVarInsn", "(", "Opcodes", ".", "ALOAD", ",", "0", ")", ";", "mv", ".", "visitVarInsn", "(", "Opcodes", ".", "ILOAD", ",", "1", ")", ";", "mv", ".", "visitMethodInsn", "(", "Opcodes", ".", "INVOKEVIRTUAL", ",", "ETUPLE_NAME", ",", "\"bad_nth\"", ",", "\"(I)\"", "+", "ETERM_TYPE", ".", "getDescriptor", "(", ")", ")", ";", "mv", ".", "visitInsn", "(", "Opcodes", ".", "POP", ")", ";", "mv", ".", "visitInsn", "(", "Opcodes", ".", "RETURN", ")", ";", "mv", ".", "visitMaxs", "(", "3", ",", "3", ")", ";", "mv", ".", "visitEnd", "(", ")", ";", "}", "protected", "final", "EObject", "bad_nth", "(", "int", "i", ")", "{", "throw", "ERT", ".", "badarg", "(", "this", ")", ";", "}", "private", "static", "void", "create_count", "(", "ClassAdapter", "cw", ",", "int", "n", ")", "{", "MethodVisitor", "mv", "=", "cw", ".", "visitMethod", "(", "Opcodes", ".", "ACC_PUBLIC", ",", "\"arity\"", ",", "\"()I\"", ",", "null", ",", "null", ")", ";", "mv", ".", "visitCode", "(", ")", ";", "if", "(", "n", "<=", "5", ")", "{", "mv", ".", "visitInsn", "(", "Opcodes", ".", "ICONST_0", "+", "n", ")", ";", "}", "else", "{", "mv", ".", "visitLdcInsn", "(", "new", "Integer", "(", "n", ")", ")", ";", "}", "mv", ".", "visitInsn", "(", "Opcodes", ".", "IRETURN", ")", ";", "mv", ".", "visitMaxs", "(", "1", ",", "1", ")", ";", "mv", ".", "visitEnd", "(", ")", ";", "}", "private", "static", "void", "create_cast", "(", "ClassAdapter", "cw", ",", "int", "n", ")", "{", "MethodVisitor", "mv", "=", "cw", ".", "visitMethod", "(", "Opcodes", ".", "ACC_PUBLIC", "|", "Opcodes", ".", "ACC_STATIC", ",", "\"cast\"", ",", "\"(L\"", "+", "ETUPLE_NAME", "+", "\";)L\"", "+", "ETUPLE_NAME", "+", "n", "+", "\";\"", ",", "null", ",", "null", ")", ";", "mv", ".", "visitCode", "(", ")", ";", "mv", ".", "visitVarInsn", "(", "Opcodes", ".", "ALOAD", ",", "0", ")", ";", "mv", ".", "visitMethodInsn", "(", "Opcodes", ".", "INVOKEVIRTUAL", ",", "ETUPLE_NAME", ",", "\"arity\"", ",", "\"()I\"", ")", ";", "if", "(", "n", "<=", "5", ")", "{", "mv", ".", "visitInsn", "(", "Opcodes", ".", "ICONST_0", "+", "n", ")", ";", "}", "else", "{", "mv", ".", "visitLdcInsn", "(", "new", "Integer", "(", "n", ")", ")", ";", "}", "Label", "fail", "=", "new", "Label", "(", ")", ";", "mv", ".", "visitJumpInsn", "(", "Opcodes", ".", "IF_ICMPNE", ",", "fail", ")", ";", "mv", ".", "visitVarInsn", "(", "Opcodes", ".", "ALOAD", ",", "0", ")", ";", "mv", ".", "visitTypeInsn", "(", "Opcodes", ".", "CHECKCAST", ",", "ETUPLE_NAME", "+", "n", ")", ";", "mv", ".", "visitInsn", "(", "Opcodes", ".", "ARETURN", ")", ";", "mv", ".", "visitLabel", "(", "fail", ")", ";", "mv", ".", "visitInsn", "(", "Opcodes", ".", "ACONST_NULL", ")", ";", "mv", ".", "visitInsn", "(", "Opcodes", ".", "ARETURN", ")", ";", "mv", ".", "visitMaxs", "(", "2", ",", "2", ")", ";", "mv", ".", "visitEnd", "(", ")", ";", "}", "private", "static", "void", "create_cast2", "(", "ClassAdapter", "cw", ",", "int", "n", ")", "{", "MethodVisitor", "mv", "=", "cw", ".", "visitMethod", "(", "Opcodes", ".", "ACC_PUBLIC", "|", "Opcodes", ".", "ACC_STATIC", ",", "\"cast\"", ",", "\"(L\"", "+", "Type", ".", "getInternalName", "(", "EObject", ".", "class", ")", "+", "\";)L\"", "+", "ETUPLE_NAME", "+", "n", "+", "\";\"", ",", "null", ",", "null", ")", ";", "mv", ".", "visitCode", "(", ")", ";", "mv", ".", "visitVarInsn", "(", "Opcodes", ".", "ALOAD", ",", "0", ")", ";", "mv", ".", "visitInsn", "(", "Opcodes", ".", "DUP", ")", ";", "mv", ".", "visitTypeInsn", "(", "Opcodes", ".", "INSTANCEOF", ",", "ETUPLE_NAME", "+", "n", ")", ";", "Label", "fail", "=", "new", "Label", "(", ")", ";", "mv", ".", "visitJumpInsn", "(", "Opcodes", ".", "IFEQ", ",", "fail", ")", ";", "mv", ".", "visitVarInsn", "(", "Opcodes", ".", "ALOAD", ",", "0", ")", ";", "mv", ".", "visitTypeInsn", "(", "Opcodes", ".", "CHECKCAST", ",", "ETUPLE_NAME", "+", "n", ")", ";", "mv", ".", "visitInsn", "(", "Opcodes", ".", "ARETURN", ")", ";", "mv", ".", "visitLabel", "(", "fail", ")", ";", "mv", ".", "visitInsn", "(", "Opcodes", ".", "ACONST_NULL", ")", ";", "mv", ".", "visitInsn", "(", "Opcodes", ".", "ARETURN", ")", ";", "mv", ".", "visitMaxs", "(", "2", ",", "2", ")", ";", "mv", ".", "visitEnd", "(", ")", ";", "}", "private", "static", "void", "create_constructor", "(", "ClassAdapter", "cw", ",", "String", "super_class_name", ")", "{", "MethodVisitor", "mv", "=", "cw", ".", "visitMethod", "(", "Opcodes", ".", "ACC_PUBLIC", ",", "\"<init>\"", ",", "\"()V\"", ",", "null", ",", "null", ")", ";", "mv", ".", "visitCode", "(", ")", ";", "mv", ".", "visitVarInsn", "(", "Opcodes", ".", "ALOAD", ",", "0", ")", ";", "mv", ".", "visitMethodInsn", "(", "Opcodes", ".", "INVOKESPECIAL", ",", "super_class_name", ",", "\"<init>\"", ",", "\"()V\"", ")", ";", "mv", ".", "visitInsn", "(", "Opcodes", ".", "RETURN", ")", ";", "mv", ".", "visitMaxs", "(", "1", ",", "1", ")", ";", "mv", ".", "visitEnd", "(", ")", ";", "}", "static", "void", "dump", "(", "String", "name", ",", "byte", "[", "]", "data", ")", "{", "String", "pkg", "=", "name", ".", "substring", "(", "0", ",", "name", ".", "lastIndexOf", "(", "'/'", ")", ")", ";", "File", "out_dir", "=", "new", "File", "(", "new", "File", "(", "\"target/woven\"", ")", ",", "pkg", ")", ";", "out_dir", ".", "mkdirs", "(", ")", ";", "FileOutputStream", "fo", ";", "try", "{", "String", "fname", "=", "\"\"", "+", "name", "+", "\".class\"", ";", "fo", "=", "new", "FileOutputStream", "(", "fname", ")", ";", "fo", ".", "write", "(", "data", ")", ";", "fo", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "\"{\"", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "this", ".", "arity", "(", ")", ";", "i", "++", ")", "{", "if", "(", "i", "!=", "1", ")", "sb", ".", "append", "(", "','", ")", ";", "sb", ".", "append", "(", "elm", "(", "i", ")", ")", ";", "}", "sb", ".", "append", "(", "\"}\"", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}", "@", "Override", "public", "int", "hashCode", "(", ")", "{", "int", "arity", "=", "arity", "(", ")", ";", "int", "result", "=", "arity", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "arity", ";", "i", "++", ")", "{", "result", "*=", "3", ";", "result", "+=", "elm", "(", "i", "+", "1", ")", ".", "hashCode", "(", ")", ";", "}", "return", "result", ";", "}", "@", "Override", "public", "boolean", "equalsExactly", "(", "EObject", "obj", ")", "{", "if", "(", "obj", "instanceof", "ETuple", ")", "{", "ETuple", "ot", "=", "(", "ETuple", ")", "obj", ";", "if", "(", "arity", "(", ")", "!=", "ot", ".", "arity", "(", ")", ")", "return", "false", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "arity", "(", ")", ";", "i", "++", ")", "{", "if", "(", "!", "elm", "(", "i", "+", "1", ")", ".", "equalsExactly", "(", "ot", ".", "elm", "(", "i", "+", "1", ")", ")", ")", "return", "false", ";", "}", "return", "true", ";", "}", "return", "false", ";", "}", "@", "Override", "public", "Type", "emit_const", "(", "MethodVisitor", "fa", ")", "{", "Type", "type", "=", "Type", ".", "getType", "(", "this", ".", "getClass", "(", ")", ")", ";", "fa", ".", "visitTypeInsn", "(", "Opcodes", ".", "NEW", ",", "type", ".", "getInternalName", "(", ")", ")", ";", "fa", ".", "visitInsn", "(", "Opcodes", ".", "DUP", ")", ";", "fa", ".", "visitMethodInsn", "(", "Opcodes", ".", "INVOKESPECIAL", ",", "type", ".", "getInternalName", "(", ")", ",", "\"<init>\"", ",", "\"()V\"", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "arity", "(", ")", ";", "i", "++", ")", "{", "fa", ".", "visitInsn", "(", "Opcodes", ".", "DUP", ")", ";", "(", "(", "EObject", ")", "elm", "(", "i", "+", "1", ")", ")", ".", "emit_const", "(", "fa", ")", ";", "fa", ".", "visitFieldInsn", "(", "Opcodes", ".", "PUTFIELD", ",", "type", ".", "getInternalName", "(", ")", ",", "\"elem\"", "+", "(", "i", "+", "1", ")", ",", "ETERM_TYPE", ".", "getDescriptor", "(", ")", ")", ";", "}", "return", "type", ";", "}", "public", "static", "ETuple", "read", "(", "EInputStream", "buf", ")", "throws", "IOException", "{", "final", "int", "arity", "=", "buf", ".", "read_tuple_head", "(", ")", ";", "ETuple", "res", "=", "ETuple", ".", "make", "(", "arity", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "arity", ";", "i", "++", ")", "{", "res", ".", "set", "(", "i", "+", "1", ",", "buf", ".", "read_any", "(", ")", ")", ";", "}", "return", "res", ";", "}", "@", "Override", "public", "void", "encode", "(", "EOutputStream", "eos", ")", "{", "int", "arity", "=", "arity", "(", ")", ";", "eos", ".", "write_tuple_head", "(", "arity", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "arity", ";", "i", "++", ")", "{", "eos", ".", "write_any", "(", "elm", "(", "i", ")", ")", ";", "}", "}", "}", "</s>" ]
7,902
[ "<s>", "package", "erjang", ";", "public", "class", "ErlangHalt", "extends", "java", ".", "lang", ".", "Error", "{", "}", "</s>" ]
7,903
[ "<s>", "package", "erjang", ";", "public", "class", "ETuple3", "extends", "ETuple", "{", "public", "EObject", "elem1", ";", "public", "EObject", "elem2", ";", "public", "EObject", "elem3", ";", "static", "public", "ETuple3", "cast", "(", "ETuple", "value", ")", "{", "if", "(", "value", ".", "arity", "(", ")", "==", "3", ")", "return", "(", "ETuple3", ")", "value", ";", "return", "null", ";", "}", "@", "Override", "public", "ETuple3", "blank", "(", ")", "{", "ETuple3", "res", "=", "new", "ETuple3", "(", ")", ";", "return", "res", ";", "}", "@", "Override", "public", "int", "arity", "(", ")", "{", "return", "3", ";", "}", "@", "Override", "public", "EObject", "elm", "(", "int", "i", ")", "{", "switch", "(", "i", ")", "{", "case", "1", ":", "return", "elem1", ";", "case", "2", ":", "return", "elem2", ";", "case", "3", ":", "return", "elem3", ";", "default", ":", "return", "bad_nth", "(", "i", ")", ";", "}", "}", "@", "Override", "public", "void", "set", "(", "int", "i", ",", "EObject", "term", ")", "{", "switch", "(", "i", ")", "{", "case", "1", ":", "elem1", "=", "term", ";", "break", ";", "case", "2", ":", "elem2", "=", "term", ";", "break", ";", "case", "3", ":", "elem3", "=", "term", ";", "break", ";", "default", ":", "bad_nth", "(", "i", ")", ";", "}", "}", "public", "static", "ETuple3", "cast", "(", "EObject", "msg", ")", "{", "if", "(", "msg", "instanceof", "ETuple3", ")", "{", "return", "(", "ETuple3", ")", "msg", ";", "}", "else", "{", "return", "null", ";", "}", "}", "}", "</s>" ]
7,904
[ "<s>", "package", "erjang", ";", "public", "class", "EExternal", "{", "private", "EExternal", "(", ")", "{", "}", "public", "static", "final", "int", "smallIntTag", "=", "97", ";", "public", "static", "final", "int", "intTag", "=", "98", ";", "public", "static", "final", "int", "floatTag", "=", "99", ";", "public", "static", "final", "int", "newFloatTag", "=", "70", ";", "public", "static", "final", "int", "atomTag", "=", "100", ";", "public", "static", "final", "int", "refTag", "=", "101", ";", "public", "static", "final", "int", "portTag", "=", "102", ";", "public", "static", "final", "int", "pidTag", "=", "103", ";", "public", "static", "final", "int", "smallTupleTag", "=", "104", ";", "public", "static", "final", "int", "largeTupleTag", "=", "105", ";", "public", "static", "final", "int", "nilTag", "=", "106", ";", "public", "static", "final", "int", "stringTag", "=", "107", ";", "public", "static", "final", "int", "listTag", "=", "108", ";", "public", "static", "final", "int", "binTag", "=", "109", ";", "public", "static", "final", "int", "bitBinTag", "=", "77", ";", "public", "static", "final", "int", "smallBigTag", "=", "110", ";", "public", "static", "final", "int", "largeBigTag", "=", "111", ";", "public", "static", "final", "int", "newFunTag", "=", "112", ";", "public", "static", "final", "int", "externalFunTag", "=", "113", ";", "public", "static", "final", "int", "newRefTag", "=", "114", ";", "public", "static", "final", "int", "smallAtomTag", "=", "115", ";", "public", "static", "final", "int", "funTag", "=", "117", ";", "public", "static", "final", "int", "compressedTag", "=", "80", ";", "public", "static", "final", "int", "atomCacheRef", "=", "82", ";", "public", "static", "final", "int", "versionTag", "=", "131", ";", "public", "static", "final", "int", "erlMax", "=", "(", "1", "<<", "27", ")", "-", "1", ";", "public", "static", "final", "int", "erlMin", "=", "-", "(", "1", "<<", "27", ")", ";", "public", "static", "final", "int", "maxAtomLength", "=", "255", ";", "}", "</s>" ]
7,905
[ "<s>", "package", "erjang", ";", "public", "class", "NotImplemented", "extends", "ErlangError", "{", "static", "EAtom", "am_not_implemented", "=", "EAtom", ".", "intern", "(", "\"\"", ")", ";", "EObject", "reason", ";", "private", "String", "message", ";", "public", "NotImplemented", "(", ")", "{", "super", "(", "ETuple", ".", "make", "(", "am_not_implemented", ",", "ERT", ".", "NIL", ",", "not_implemented_trace", "(", "new", "Throwable", "(", ")", ".", "getStackTrace", "(", ")", ")", ")", ")", ";", "this", ".", "message", "=", "\"\"", ";", "}", "public", "NotImplemented", "(", "String", "message", ")", "{", "super", "(", "ETuple", ".", "make", "(", "am_not_implemented", ",", "EString", ".", "fromString", "(", "message", ")", ",", "not_implemented_trace", "(", "new", "Throwable", "(", ")", ".", "getStackTrace", "(", ")", ")", ")", ")", ";", "this", ".", "message", "=", "message", ";", "}", "static", "ESeq", "not_implemented_trace", "(", "StackTraceElement", "[", "]", "elm", ")", "{", "if", "(", "elm", ".", "length", "<=", "1", ")", "return", "ERT", ".", "NIL", ";", "return", "EString", ".", "fromString", "(", "elm", "[", "1", "]", ".", "toString", "(", ")", ")", ";", "}", "public", "EObject", "reason", "(", ")", "{", "return", "reason", ";", "}", "@", "Override", "public", "String", "getMessage", "(", ")", "{", "return", "message", ";", "}", "}", "</s>" ]
7,906
[ "<s>", "package", "erjang", ";", "public", "class", "ErjangHibernateException", "extends", "RuntimeException", "{", "public", "static", "final", "ErjangHibernateException", "INSTANCE", "=", "new", "ErjangHibernateException", "(", ")", ";", "private", "ErjangHibernateException", "(", ")", "{", "}", "}", "</s>" ]
7,907
[ "<s>", "package", "erjang", ";", "import", "java", ".", "lang", ".", "annotation", ".", "ElementType", ";", "import", "java", ".", "lang", ".", "annotation", ".", "Retention", ";", "import", "java", ".", "lang", ".", "annotation", ".", "RetentionPolicy", ";", "import", "java", ".", "lang", ".", "annotation", ".", "Target", ";", "@", "Retention", "(", "RetentionPolicy", ".", "RUNTIME", ")", "@", "Target", "(", "ElementType", ".", "FIELD", ")", "public", "@", "interface", "Export", "{", "String", "module", "(", ")", ";", "String", "fun", "(", ")", ";", "int", "arity", "(", ")", ";", "}", "</s>" ]
7,908
[ "<s>", "package", "erjang", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "java", ".", "util", ".", "concurrent", ".", "ConcurrentHashMap", ";", "import", "java", ".", "util", ".", "regex", ".", "Pattern", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "MethodVisitor", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "Opcodes", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "Type", ";", "import", "erjang", ".", "driver", ".", "IO", ";", "import", "erjang", ".", "m", ".", "ets", ".", "EMatchContext", ";", "import", "erjang", ".", "m", ".", "ets", ".", "EPattern", ";", "import", "erjang", ".", "m", ".", "ets", ".", "ETermPattern", ";", "public", "final", "class", "EAtom", "extends", "EObject", "implements", "CharSequence", "{", "public", "EAtom", "testAtom", "(", ")", "{", "return", "this", ";", "}", "@", "Override", "public", "boolean", "match", "(", "ETermPattern", "matcher", ",", "EMatchContext", "r", ")", "{", "return", "matcher", ".", "match", "(", "this", ",", "r", ")", ";", "}", "@", "Override", "public", "ETermPattern", "compileMatch", "(", "Set", "<", "Integer", ">", "out", ")", "{", "return", "EPattern", ".", "compilePattern", "(", "this", ",", "out", ")", ";", "}", "public", "EAtom", "testBoolean", "(", ")", "{", "if", "(", "this", "==", "ERT", ".", "TRUE", "||", "this", "==", "ERT", ".", "FALSE", ")", "return", "this", ";", "return", "null", ";", "}", "private", "final", "String", "value", ";", "public", "final", "int", "hash", ";", "@", "Override", "int", "compare_same", "(", "EObject", "rhs", ")", "{", "return", "compareTo", "(", "(", "EAtom", ")", "rhs", ")", ";", "}", "private", "static", "ConcurrentHashMap", "<", "String", ",", "EAtom", ">", "interns", "=", "new", "ConcurrentHashMap", "<", "String", ",", "EAtom", ">", "(", ")", ";", "private", "EAtom", "(", "String", "name", ")", "{", "this", ".", "value", "=", "name", ";", "this", ".", "hash", "=", "name", ".", "hashCode", "(", ")", ";", "}", "@", "Override", "int", "cmp_order", "(", ")", "{", "return", "CMP_ORDER_ATOM", ";", "}", "static", "Pattern", "ATOM", "=", "Pattern", ".", "compile", "(", "\"\"", ")", ";", "@", "Override", "public", "String", "toString", "(", ")", "{", "if", "(", "ATOM", ".", "matcher", "(", "value", ")", ".", "matches", "(", ")", ")", "{", "return", "value", ";", "}", "else", "{", "return", "\"'\"", "+", "encode_escapes", "(", "value", ")", "+", "\"'\"", ";", "}", "}", "private", "String", "encode_escapes", "(", "CharSequence", "seq", ")", "{", "StringBuffer", "sb", "=", "new", "StringBuffer", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "seq", ".", "length", "(", ")", ";", "i", "++", ")", "{", "char", "ch", "=", "seq", ".", "charAt", "(", "i", ")", ";", "if", "(", "(", "ch", ">=", "0x20", "&&", "ch", "<=", "0x7f", ")", "&&", "ch", "!=", "'\\''", "&&", "ch", "!=", "0x7f", ")", "{", "sb", ".", "append", "(", "ch", ")", ";", "}", "else", "{", "switch", "(", "ch", ")", "{", "case", "'\\t'", ":", "sb", ".", "append", "(", "\"\\\\t\"", ")", ";", "break", ";", "case", "'\\n'", ":", "sb", ".", "append", "(", "\"\\\\n\"", ")", ";", "break", ";", "case", "'\\r'", ":", "sb", ".", "append", "(", "\"\\\\r\"", ")", ";", "break", ";", "case", "'\\f'", ":", "sb", ".", "append", "(", "\"\\\\f\"", ")", ";", "break", ";", "case", "'\\b'", ":", "sb", ".", "append", "(", "\"\\\\b\"", ")", ";", "break", ";", "case", "'\\''", ":", "sb", ".", "append", "(", "\"\\\\'\"", ")", ";", "break", ";", "default", ":", "sb", ".", "append", "(", "\"\\\\\"", ")", ";", "sb", ".", "append", "(", "'x'", ")", ";", "if", "(", "ch", "<", "0x10", ")", "sb", ".", "append", "(", "'0'", ")", ";", "sb", ".", "append", "(", "Integer", ".", "toHexString", "(", "ch", ")", ".", "toUpperCase", "(", ")", ")", ";", "}", "}", "}", "return", "sb", ".", "toString", "(", ")", ";", "}", "public", "boolean", "isAtom", "(", "String", "name", ")", "{", "return", "interns", ".", "contains", "(", "name", ")", ";", "}", "@", "Override", "public", "boolean", "equals", "(", "Object", "obj", ")", "{", "return", "this", "==", "obj", ";", "}", "@", "Override", "public", "int", "hashCode", "(", ")", "{", "return", "hash", ";", "}", "public", "static", "EAtom", "intern", "(", "String", "name", ")", "{", "EAtom", "res", "=", "interns", ".", "get", "(", "name", ")", ";", "if", "(", "res", "==", "null", ")", "{", "boolean", "changed", "=", "false", ";", "char", "[", "]", "data", "=", "name", ".", "toCharArray", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "data", ".", "length", ";", "i", "++", ")", "{", "if", "(", "(", "data", "[", "i", "]", "&", "0xff00", ")", "!=", "0", ")", "changed", "=", "true", ";", "data", "[", "i", "]", "=", "(", "char", ")", "(", "data", "[", "i", "]", "&", "0xff", ")", ";", "}", "if", "(", "changed", ")", "name", "=", "new", "String", "(", "data", ")", ";", "EAtom", "new_val", "=", "new", "EAtom", "(", "name", ")", ";", "do", "{", "res", "=", "interns", ".", "putIfAbsent", "(", "name", ",", "new_val", ")", ";", "}", "while", "(", "res", "==", "null", ")", ";", "}", "return", "res", ";", "}", "public", "static", "EAtom", "existing_atom", "(", "String", "name", ")", "{", "EAtom", "res", "=", "interns", ".", "get", "(", "name", ")", ";", "if", "(", "res", "==", "null", ")", "{", "throw", "ERT", ".", "badarg", "(", "EString", ".", "fromString", "(", "name", ")", ")", ";", "}", "return", "res", ";", "}", "@", "Override", "public", "char", "charAt", "(", "int", "index", ")", "{", "return", "value", ".", "charAt", "(", "index", ")", ";", "}", "@", "Override", "public", "int", "length", "(", ")", "{", "return", "value", ".", "length", "(", ")", ";", "}", "@", "Override", "public", "CharSequence", "subSequence", "(", "int", "start", ",", "int", "end", ")", "{", "return", "value", ".", "subSequence", "(", "start", ",", "end", ")", ";", "}", "public", "String", "getName", "(", ")", "{", "return", "value", ";", "}", "private", "static", "final", "Type", "EATOM_TYPE", "=", "Type", ".", "getType", "(", "EAtom", ".", "class", ")", ";", "private", "static", "final", "Type", "STRING_TYPE", "=", "Type", ".", "getType", "(", "String", ".", "class", ")", ";", "@", "Override", "public", "org", ".", "objectweb", ".", "asm", ".", "Type", "emit_const", "(", "MethodVisitor", "fa", ")", "{", "Type", "type", "=", "EATOM_TYPE", ";", "fa", ".", "visitLdcInsn", "(", "value", ")", ";", "fa", ".", "visitMethodInsn", "(", "Opcodes", ".", "INVOKESTATIC", ",", "type", ".", "getInternalName", "(", ")", ",", "\"intern\"", ",", "\"(\"", "+", "STRING_TYPE", ".", "getDescriptor", "(", ")", "+", "\")\"", "+", "type", ".", "getDescriptor", "(", ")", ")", ";", "return", "type", ";", "}", "public", "int", "compareTo", "(", "EAtom", "other", ")", "{", "if", "(", "this", "==", "other", ")", "return", "0", ";", "return", "value", ".", "compareTo", "(", "other", ".", "value", ")", ";", "}", "@", "Override", "public", "boolean", "equalsExactly", "(", "EObject", "rhs", ")", "{", "return", "rhs", "==", "this", ";", "}", "public", "static", "EAtom", "intern", "(", "byte", "[", "]", "buf", ")", "{", "char", "[", "]", "data", "=", "new", "char", "[", "buf", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "data", ".", "length", ";", "i", "++", ")", "{", "data", "[", "i", "]", "=", "(", "char", ")", "(", "buf", "[", "i", "]", "&", "0xff", ")", ";", "}", "String", "str", "=", "new", "String", "(", "data", ")", ";", "return", "intern", "(", "str", ")", ";", "}", "public", "static", "EAtom", "read", "(", "EInputStream", "ei", ")", "throws", "IOException", "{", "return", "ei", ".", "read_atom", "(", ")", ";", "}", "@", "Override", "public", "void", "encode", "(", "EOutputStream", "eos", ")", "{", "eos", ".", "write_atom", "(", "this", ".", "value", ")", ";", "}", "}", "</s>" ]
7,909
[ "<s>", "package", "erjang", ";", "public", "class", "ETuple4", "extends", "ETuple", "{", "public", "EObject", "elem1", ";", "public", "EObject", "elem2", ";", "public", "EObject", "elem3", ";", "public", "EObject", "elem4", ";", "static", "public", "ETuple4", "cast", "(", "ETuple", "value", ")", "{", "if", "(", "value", ".", "arity", "(", ")", "==", "4", ")", "return", "(", "ETuple4", ")", "value", ";", "return", "null", ";", "}", "static", "public", "ETuple4", "cast", "(", "EObject", "value", ")", "{", "if", "(", "value", "instanceof", "ETuple4", ")", "return", "(", "ETuple4", ")", "value", ";", "return", "null", ";", "}", "@", "Override", "public", "ETuple4", "blank", "(", ")", "{", "ETuple4", "res", "=", "new", "ETuple4", "(", ")", ";", "return", "res", ";", "}", "@", "Override", "public", "int", "arity", "(", ")", "{", "return", "4", ";", "}", "@", "Override", "public", "EObject", "elm", "(", "int", "i", ")", "{", "switch", "(", "i", ")", "{", "case", "1", ":", "return", "elem1", ";", "case", "2", ":", "return", "elem2", ";", "case", "3", ":", "return", "elem3", ";", "case", "4", ":", "return", "elem4", ";", "default", ":", "return", "bad_nth", "(", "i", ")", ";", "}", "}", "@", "Override", "public", "void", "set", "(", "int", "i", ",", "EObject", "term", ")", "{", "switch", "(", "i", ")", "{", "case", "1", ":", "elem1", "=", "term", ";", "break", ";", "case", "2", ":", "elem2", "=", "term", ";", "break", ";", "case", "3", ":", "elem3", "=", "term", ";", "break", ";", "case", "4", ":", "elem4", "=", "term", ";", "break", ";", "default", ":", "bad_nth", "(", "i", ")", ";", "}", "}", "}", "</s>" ]
7,910
[ "<s>", "package", "erjang", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "concurrent", ".", "ConcurrentHashMap", ";", "import", "java", ".", "util", ".", "concurrent", ".", "atomic", ".", "AtomicReference", ";", "import", "java", ".", "util", ".", "logging", ".", "Level", ";", "import", "java", ".", "util", ".", "logging", ".", "Logger", ";", "import", "kilim", ".", "Mailbox", ";", "import", "kilim", ".", "Pausable", ";", "import", "com", ".", "trifork", ".", "clj_ds", ".", "IPersistentSet", ";", "import", "com", ".", "trifork", ".", "clj_ds", ".", "PersistentHashSet", ";", "public", "abstract", "class", "ETask", "<", "H", "extends", "EHandle", ">", "extends", "kilim", ".", "Task", "{", "static", "Logger", "log", "=", "Logger", ".", "getLogger", "(", "\"erjang.proc\"", ")", ";", "public", "static", "final", "EAtom", "am_normal", "=", "EAtom", ".", "intern", "(", "\"normal\"", ")", ";", "protected", "static", "final", "EAtom", "am_java_exception", "=", "EAtom", ".", "intern", "(", "\"\"", ")", ";", "private", "static", "final", "EAtom", "am_DOWN", "=", "EAtom", ".", "intern", "(", "\"DOWN\"", ")", ";", "private", "static", "final", "EAtom", "am_process", "=", "EAtom", ".", "intern", "(", "\"process\"", ")", ";", "public", "abstract", "H", "self_handle", "(", ")", ";", "private", "AtomicReference", "<", "PersistentHashSet", "<", "EHandle", ">", ">", "linksref", "=", "new", "AtomicReference", "<", "PersistentHashSet", "<", "EHandle", ">", ">", "(", "PersistentHashSet", ".", "EMPTY", ")", ";", "protected", "Map", "<", "ERef", ",", "EHandle", ">", "monitors", "=", "new", "ConcurrentHashMap", "<", "ERef", ",", "EHandle", ">", "(", ")", ";", "public", "void", "unlink", "(", "EHandle", "other", ")", "throws", "Pausable", "{", "unlink_oneway", "(", "other", ")", ";", "other", ".", "unlink_oneway", "(", "self_handle", "(", ")", ")", ";", "}", "public", "void", "unlink_oneway", "(", "EHandle", "handle", ")", "{", "PersistentHashSet", "old", ",", "links", ";", "try", "{", "do", "{", "old", "=", "linksref", ".", "get", "(", ")", ";", "links", "=", "(", "PersistentHashSet", ")", "old", ".", "disjoin", "(", "handle", ")", ";", "}", "while", "(", "!", "linksref", ".", "weakCompareAndSet", "(", "old", ",", "links", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}", "protected", "boolean", "has_no_links", "(", ")", "{", "IPersistentSet", "<", "EHandle", ">", "links", "=", "linksref", ".", "get", "(", ")", ";", "return", "links", ".", "count", "(", ")", "==", "0", ";", "}", "public", "void", "link_to", "(", "ETask", "<", "?", ">", "task", ")", "throws", "Pausable", "{", "link_to", "(", "task", ".", "self_handle", "(", ")", ")", ";", "}", "public", "void", "link_to", "(", "EHandle", "handle", ")", "throws", "Pausable", "{", "if", "(", "!", "link_oneway", "(", "handle", ")", "||", "!", "handle", ".", "link_oneway", "(", "(", "EHandle", ")", "self_handle", "(", ")", ")", ")", "{", "link_failure", "(", "handle", ")", ";", "}", "}", "public", "boolean", "link_oneway", "(", "EHandle", "h", ")", "{", "if", "(", "h", ".", "exists", "(", ")", ")", "{", "PersistentHashSet", "old", ",", "links", ";", "try", "{", "do", "{", "old", "=", "linksref", ".", "get", "(", ")", ";", "links", "=", "(", "PersistentHashSet", ")", "old", ".", "cons", "(", "h", ")", ";", "}", "while", "(", "!", "linksref", ".", "weakCompareAndSet", "(", "old", ",", "links", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}", "public", "ESeq", "links", "(", ")", "{", "ESeq", "res", "=", "ERT", ".", "NIL", ";", "for", "(", "EHandle", "h", ":", "linksref", ".", "get", "(", ")", ")", "{", "res", "=", "res", ".", "cons", "(", "h", ")", ";", "}", "return", "res", ";", "}", "protected", "void", "link_failure", "(", "EHandle", "h", ")", "throws", "Pausable", "{", "throw", "new", "ErlangError", "(", "ERT", ".", "am_noproc", ")", ";", "}", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "protected", "void", "do_proc_termination", "(", "EObject", "exit_reason", ")", "throws", "Pausable", "{", "this", ".", "exit_reason", "=", "exit_reason", ";", "H", "me", "=", "self_handle", "(", ")", ";", "EAtom", "name", "=", "me", ".", "name", ";", "for", "(", "EHandle", "handle", ":", "linksref", ".", "get", "(", ")", ")", "{", "try", "{", "handle", ".", "exit_signal", "(", "me", ",", "exit_reason", ",", "false", ")", ";", "}", "catch", "(", "Error", "e", ")", "{", "log", ".", "severe", "(", "\"\"", ")", ";", "log", ".", "log", "(", "Level", ".", "FINE", ",", "\"details:", "\"", ",", "e", ")", ";", "throw", "e", ";", "}", "catch", "(", "RuntimeException", "e", ")", "{", "log", ".", "severe", "(", "\"\"", ")", ";", "log", ".", "log", "(", "Level", ".", "FINE", ",", "\"details:", "\"", ",", "e", ")", ";", "throw", "e", ";", "}", "}", "for", "(", "Map", ".", "Entry", "<", "ERef", ",", "EHandle", ">", "ent", ":", "monitors", ".", "entrySet", "(", ")", ")", "{", "EHandle", "pid", "=", "ent", ".", "getValue", "(", ")", ";", "ERef", "ref", "=", "ent", ".", "getKey", "(", ")", ";", "pid", ".", "send_monitor_exit", "(", "(", "EHandle", ")", "me", ",", "ref", ",", "exit_reason", ")", ";", "}", "if", "(", "name", "!=", "null", ")", "{", "ERT", ".", "unregister", "(", "name", ")", ";", "}", "}", "public", "void", "send_monitor_exit", "(", "EHandle", "from", ",", "ERef", "ref", ",", "EObject", "reason", ")", "throws", "Pausable", "{", "ETuple2", "pair", "=", "is_monitoring", ".", "get", "(", "ref", ")", ";", "if", "(", "pair", "!=", "null", ")", "{", "mbox_send", "(", "ETuple", ".", "make", "(", "am_DOWN", ",", "ref", ",", "am_process", ",", "pair", ".", "elem2", ",", "reason", ")", ")", ";", "}", "}", "Map", "<", "ERef", ",", "ETuple2", ">", "is_monitoring", "=", "new", "HashMap", "<", "ERef", ",", "ETuple2", ">", "(", ")", ";", "public", "boolean", "monitor", "(", "EHandle", "observed", ",", "EObject", "object", ",", "ERef", "ref", ")", "throws", "Pausable", "{", "if", "(", "!", "observed", ".", "add_monitor", "(", "self_handle", "(", ")", ",", "ref", ")", ")", "{", "return", "false", ";", "}", "this", ".", "is_monitoring", ".", "put", "(", "ref", ",", "new", "ETuple2", "(", "observed", ",", "object", ")", ")", ";", "return", "true", ";", "}", "public", "boolean", "monitor", "(", "EObject", "object", ",", "ERef", "ref", ")", "throws", "Pausable", "{", "this", ".", "is_monitoring", ".", "put", "(", "ref", ",", "new", "ETuple2", "(", "object", ",", "object", ")", ")", ";", "return", "true", ";", "}", "public", "EObject", "demonitor", "(", "ERef", "r", ")", "throws", "Pausable", "{", "ETuple2", "pair", "=", "is_monitoring", ".", "remove", "(", "r", ")", ";", "if", "(", "pair", "==", "null", ")", "{", "return", "null", ";", "}", "return", "pair", ".", "elem1", ";", "}", "public", "boolean", "add_monitor", "(", "EHandle", "target", ",", "ERef", "ref", ")", "{", "monitors", ".", "put", "(", "ref", ",", "target", ")", ";", "return", "true", ";", "}", "public", "void", "remove_monitor", "(", "ERef", "r", ",", "boolean", "flush", ")", "{", "EHandle", "val", "=", "monitors", ".", "remove", "(", "r", ")", ";", "if", "(", "flush", ")", "{", "}", "}", "public", "EHandle", "get_monitored_process", "(", "ERef", "monitor", ")", "{", "ETuple2", "tup", "=", "is_monitoring", ".", "get", "(", "monitor", ")", ";", "if", "(", "tup", "==", "null", ")", "return", "null", ";", "return", "tup", ".", "elem1", ".", "testHandle", "(", ")", ";", "}", "public", "EObject", "get_monitored_object", "(", "ERef", "monitor", ")", "{", "ETuple2", "tup", "=", "is_monitoring", ".", "get", "(", "monitor", ")", ";", "return", "tup", ".", "elem2", ";", "}", "static", "final", "int", "MAX_MAILBOX_SIZE", "=", "1000", ";", "protected", "final", "Mailbox", "<", "EObject", ">", "mbox", "=", "new", "Mailbox", "<", "EObject", ">", "(", "10", ",", "MAX_MAILBOX_SIZE", ")", ";", "public", "static", "final", "int", "STATE_INIT", "=", "0", ";", "public", "static", "final", "int", "STATE_RUNNING", "=", "1", ";", "public", "static", "final", "int", "STATE_EXIT_SIG", "=", "2", ";", "public", "static", "final", "int", "STATE_SENDING_EXIT", "=", "3", ";", "public", "static", "final", "int", "STATE_DONE", "=", "4", ";", "protected", "volatile", "int", "pstate", "=", "STATE_INIT", ";", "protected", "EObject", "exit_reason", ";", "public", "int", "reds", ";", "public", "void", "mbox_wait", "(", ")", "throws", "Pausable", "{", "mbox", ".", "untilHasMessage", "(", ")", ";", "}", "public", "boolean", "mbox_wait", "(", "long", "timeoutMillis", ")", "throws", "Pausable", "{", "return", "mbox", ".", "untilHasMessage", "(", "timeoutMillis", ")", ";", "}", "public", "void", "mbox_send", "(", "EObject", "msg", ")", "throws", "Pausable", "{", "mbox", ".", "put", "(", "msg", ")", ";", "}", "public", "void", "mbox_remove_one", "(", ")", "throws", "Pausable", "{", "mbox", ".", "get", "(", ")", ";", "}", "public", "final", "void", "send_exit", "(", "EHandle", "from", ",", "EObject", "reason", ",", "boolean", "is_erlang_exit2", ")", "throws", "Pausable", "{", "if", "(", "log", ".", "isLoggable", "(", "Level", ".", "FINE", ")", ")", "{", "log", ".", "log", "(", "Level", ".", "FINE", ",", "\"exit", "\"", "+", "from", "+", "\"", "->", "\"", "+", "this", "+", "\",", "reason=\"", "+", "reason", ",", "new", "Throwable", "(", "\"trace\"", ")", ")", ";", "}", "if", "(", "from", "==", "self_handle", "(", ")", ")", "{", "return", ";", "}", "if", "(", "!", "is_erlang_exit2", ")", "unlink_oneway", "(", "from", ")", ";", "synchronized", "(", "this", ")", "{", "switch", "(", "pstate", ")", "{", "case", "STATE_DONE", ":", "return", ";", "case", "STATE_EXIT_SIG", ":", "case", "STATE_SENDING_EXIT", ":", "return", ";", "case", "STATE_INIT", ":", "if", "(", "reason", "==", "EProc", ".", "am_kill", ")", "{", "this", ".", "exit_reason", "=", "EProc", ".", "am_killed", ";", "}", "else", "{", "this", ".", "exit_reason", "=", "reason", ";", "}", "this", ".", "pstate", "=", "STATE_EXIT_SIG", ";", "return", ";", "default", ":", "throw", "new", "Error", "(", "\"\"", "+", "pstate", ")", ";", "case", "STATE_RUNNING", ":", "}", "}", "process_incoming_exit", "(", "from", ",", "reason", ",", "is_erlang_exit2", ")", ";", "}", "protected", "abstract", "void", "process_incoming_exit", "(", "EHandle", "from", ",", "EObject", "reason", ",", "boolean", "is_erlang_exit2", ")", "throws", "Pausable", ";", "public", "final", "void", "check_exit", "(", ")", "{", "if", "(", "this", ".", "pstate", "==", "STATE_EXIT_SIG", ")", "{", "do_check_exit", "(", ")", ";", "}", "}", "private", "void", "do_check_exit", "(", ")", "throws", "ErlangExitSignal", "{", "if", "(", "exit_reason", "!=", "null", ")", "{", "this", ".", "pstate", "=", "STATE_SENDING_EXIT", ";", "EObject", "reason", "=", "exit_reason", ";", "throw", "new", "ErlangExitSignal", "(", "reason", ")", ";", "}", "}", "@", "Override", "public", "void", "checkKill", "(", ")", "{", "check_exit", "(", ")", ";", "}", "public", "Mailbox", "<", "EObject", ">", "mbox", "(", ")", "{", "return", "mbox", ";", "}", "public", "boolean", "exists", "(", ")", "{", "return", "pstate", "==", "STATE_INIT", "||", "pstate", "==", "STATE_RUNNING", ";", "}", "}", "</s>" ]
7,911
[ "<s>", "package", "erjang", ";", "public", "class", "ErlangThrow", "extends", "ErlangException", "{", "public", "EAtom", "getExClass", "(", ")", "{", "return", "am_throw", ";", "}", "public", "ErlangThrow", "(", "EObject", "reason", ")", "{", "super", "(", "reason", ")", ";", "}", "@", "Override", "public", "EObject", "getCatchValue", "(", ")", "{", "return", "super", ".", "reason", "(", ")", ";", "}", "}", "</s>" ]
7,912
[ "<s>", "package", "erjang", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "com", ".", "ericsson", ".", "otp", ".", "erlang", ".", "OtpAuthException", ";", "import", "erjang", ".", "beam", ".", "Compiler", ";", "import", "erjang", ".", "beam", ".", "JarClassRepo", ";", "import", "erjang", ".", "beam", ".", "BeamLoader", ";", "import", "erjang", ".", "beam", ".", "loader", ".", "ErjangBeamDisLoader", ";", "public", "class", "ErjC", "{", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "throws", "OtpAuthException", ",", "IOException", "{", "BeamLoader", "beamParser", "=", "new", "ErjangBeamDisLoader", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "args", ".", "length", ";", "i", "++", ")", "{", "if", "(", "args", "[", "i", "]", ".", "endsWith", "(", "\".beam\"", ")", ")", "{", "File", "in", "=", "ERT", ".", "newFile", "(", "args", "[", "i", "]", ")", ";", "int", "idx", "=", "args", "[", "i", "]", ".", "lastIndexOf", "(", "'.'", ")", ";", "File", "out", "=", "ERT", ".", "newFile", "(", "args", "[", "i", "]", ".", "substring", "(", "0", ",", "idx", ")", "+", "\".jar\"", ")", ";", "JarClassRepo", "jcp", "=", "new", "JarClassRepo", "(", "out", ")", ";", "System", ".", "out", ".", "println", "(", "\"compiling", "\"", "+", "in", "+", "\"", "->", "\"", "+", "out", "+", "\"", "...\"", ")", ";", "new", "Compiler", "(", "jcp", ")", ".", "compile", "(", "in", ",", "beamParser", ")", ";", "jcp", ".", "close", "(", ")", ";", "}", "}", "}", "}", "</s>" ]
7,913
[ "<s>", "package", "erjang", ";", "public", "class", "EN", "{", "static", "EDouble", "box", "(", "double", "d", ")", "{", "return", "new", "EDouble", "(", "d", ")", ";", "}", "static", "EInteger", "box", "(", "long", "l", ")", "{", "long", "offset_from_int_min", "=", "l", "-", "(", "long", ")", "Integer", ".", "MIN_VALUE", ";", "long", "unsigned_offset", "=", "offset_from_int_min", "&", "Long", ".", "MAX_VALUE", ";", "if", "(", "unsigned_offset", ">=", "0x100000000L", ")", "{", "return", "new", "EBig", "(", "l", ")", ";", "}", "else", "{", "return", "new", "ESmall", "(", "(", "int", ")", "l", ")", ";", "}", "}", "static", "ENumber", "add", "(", "int", "i1", ",", "int", "i2", ")", "{", "long", "l", "=", "(", "long", ")", "i1", "+", "(", "long", ")", "i2", ";", "return", "box", "(", "l", ")", ";", "}", "static", "ENumber", "mult", "(", "int", "i1", ",", "int", "i2", ")", "{", "long", "l", "=", "(", "long", ")", "i1", "*", "(", "long", ")", "i2", ";", "return", "box", "(", "l", ")", ";", "}", "}", "</s>" ]
7,914
[ "<s>", "package", "erjang", ";", "import", "java", ".", "util", ".", "logging", ".", "Level", ";", "import", "kilim", ".", "Pausable", ";", "import", "kilim", ".", "Task", ";", "public", "abstract", "class", "EHandle", "extends", "EObject", "{", "protected", "final", "EAbstractNode", "node", ";", "protected", "EAtom", "name", "=", "null", ";", "protected", "EHandle", "(", "EAbstractNode", "node", ")", "{", "if", "(", "node", "==", "null", ")", "throw", "new", "IllegalArgumentException", "(", "\"\"", ")", ";", "this", ".", "node", "=", "node", ";", "}", "public", "EHandle", "testHandle", "(", ")", "{", "return", "this", ";", "}", "ETask", "<", "?", ">", "task", "(", ")", "{", "throw", "new", "Error", "(", "\"\"", ")", ";", "}", "public", "boolean", "exists", "(", ")", "{", "ETask", "<", "?", ">", "task", "=", "task", "(", ")", ";", "return", "task", "!=", "null", "&&", "task", ".", "exists", "(", ")", ";", "}", "public", "int", "send", "(", "EHandle", "sender", ",", "EObject", "msg", ")", "throws", "Pausable", "{", "ETask", "<", "?", ">", "task", "=", "task", "(", ")", ";", "if", "(", "task", "!=", "null", ")", "{", "task", ".", "mbox", ".", "put", "(", "msg", ")", ";", "return", "task", ".", "mbox", ".", "size", "(", ")", ";", "}", "else", "{", "if", "(", "ERT", ".", "ipclog", ".", "isLoggable", "(", "Level", ".", "FINE", ")", ")", "{", "ERT", ".", "ipclog", ".", "fine", "(", "\"\"", "+", "this", "+", "\"", "!", "\"", "+", "msg", ")", ";", "}", "return", "0", ";", "}", "}", "public", "void", "sendb", "(", "EObject", "msg", ")", "{", "ETask", "<", "?", ">", "task", "=", "task", "(", ")", ";", "if", "(", "task", "!=", "null", ")", "{", "task", ".", "mbox", "(", ")", ".", "putb", "(", "msg", ")", ";", "}", "}", "public", "void", "exit_signal", "(", "EHandle", "from", ",", "EObject", "reason", ",", "boolean", "is_erlang_exit2", ")", "throws", "Pausable", "{", "ETask", "<", "?", ">", "task", "=", "task", "(", ")", ";", "if", "(", "task", "!=", "null", ")", "{", "task", ".", "send_exit", "(", "from", ",", "reason", ",", "is_erlang_exit2", ")", ";", "}", "}", "public", "abstract", "boolean", "link_oneway", "(", "EHandle", "other", ")", "throws", "Pausable", ";", "public", "abstract", "void", "unlink_oneway", "(", "EHandle", "other", ")", "throws", "Pausable", ";", "public", "abstract", "boolean", "add_monitor", "(", "EHandle", "observer", ",", "ERef", "ref", ")", "throws", "Pausable", ";", "public", "static", "EHandle", "cast", "(", "EObject", "other", ")", "{", "EHandle", "h", "=", "other", ".", "testHandle", "(", ")", ";", "if", "(", "h", "==", "null", ")", "{", "h", "=", "ERT", ".", "whereis", "(", "other", ")", ".", "testHandle", "(", ")", ";", "}", "return", "h", ";", "}", "public", "void", "setName", "(", "EAtom", "aname", ")", "{", "this", ".", "name", "=", "aname", ";", "}", "public", "ELocalHandle", "testLocalHandle", "(", ")", "{", "return", "null", ";", "}", "public", "EAtom", "node", "(", ")", "{", "return", "node", ".", "node", "(", ")", ";", "}", "public", "abstract", "void", "remove_monitor", "(", "EHandle", "sender", ",", "ERef", "r", ",", "boolean", "flush", ")", "throws", "Pausable", ";", "public", "abstract", "void", "send_monitor_exit", "(", "EHandle", "from", ",", "ERef", "ref", ",", "EObject", "reason", ")", "throws", "Pausable", ";", "}", "</s>" ]
7,915
[ "<s>", "package", "erjang", ";", "import", "java", ".", "io", ".", "ByteArrayOutputStream", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "UnsupportedEncodingException", ";", "import", "java", ".", "math", ".", "BigDecimal", ";", "import", "java", ".", "math", ".", "BigInteger", ";", "import", "java", ".", "nio", ".", "ByteBuffer", ";", "import", "java", ".", "text", ".", "DecimalFormat", ";", "import", "java", ".", "util", ".", "zip", ".", "Deflater", ";", "import", "erjang", ".", "driver", ".", "IO", ";", "public", "class", "EOutputStream", "extends", "ByteArrayOutputStream", "{", "public", "static", "final", "int", "DEFAULT_INITIAL_BUFFER_SIZE", "=", "512", ";", "public", "static", "final", "int", "DEFAULT_BUFFER_INCREMENT", "=", "2048", ";", "private", "static", "final", "DecimalFormat", "eform", "=", "new", "DecimalFormat", "(", "\"e+00;e-00\"", ")", ";", "private", "static", "final", "BigDecimal", "ten", "=", "new", "BigDecimal", "(", "10.0", ")", ";", "private", "static", "final", "BigDecimal", "one", "=", "new", "BigDecimal", "(", "1.0", ")", ";", "private", "int", "flags", ";", "public", "EOutputStream", "(", ")", "{", "this", "(", "DEFAULT_INITIAL_BUFFER_SIZE", ")", ";", "}", "public", "EOutputStream", "(", "final", "int", "size", ")", "{", "super", "(", "size", ")", ";", "}", "public", "EOutputStream", "(", "final", "int", "size", ",", "int", "flags", ")", "{", "super", "(", "size", ")", ";", "this", ".", "flags", "=", "flags", ";", "}", "public", "EOutputStream", "(", "final", "EObject", "o", ")", "{", "this", "(", ")", ";", "write_any", "(", "o", ")", ";", "}", "EInputStream", "getEInputStream", "(", "final", "int", "offset", ")", "{", "return", "new", "EInputStream", "(", "super", ".", "buf", ",", "offset", ",", "super", ".", "count", "-", "offset", ",", "0", ")", ";", "}", "public", "EBinary", "getBinaryContent", "(", ")", "{", "return", "new", "EBinary", "(", "super", ".", "buf", ",", "0", ",", "super", ".", "count", ")", ";", "}", "public", "int", "getPos", "(", ")", "{", "return", "super", ".", "count", ";", "}", "public", "void", "write", "(", "final", "byte", "b", ")", "{", "if", "(", "super", ".", "count", ">=", "super", ".", "buf", ".", "length", ")", "{", "final", "byte", "[", "]", "tmp", "=", "new", "byte", "[", "super", ".", "buf", ".", "length", "+", "DEFAULT_BUFFER_INCREMENT", "]", ";", "System", ".", "arraycopy", "(", "super", ".", "buf", ",", "0", ",", "tmp", ",", "0", ",", "super", ".", "count", ")", ";", "super", ".", "buf", "=", "tmp", ";", "}", "super", ".", "buf", "[", "super", ".", "count", "++", "]", "=", "b", ";", "}", "@", "Override", "public", "void", "write", "(", "final", "byte", "[", "]", "buf", ")", "{", "if", "(", "super", ".", "count", "+", "buf", ".", "length", ">", "super", ".", "buf", ".", "length", ")", "{", "final", "byte", "[", "]", "tmp", "=", "new", "byte", "[", "super", ".", "buf", ".", "length", "+", "buf", ".", "length", "+", "DEFAULT_BUFFER_INCREMENT", "]", ";", "System", ".", "arraycopy", "(", "super", ".", "buf", ",", "0", ",", "tmp", ",", "0", ",", "super", ".", "count", ")", ";", "super", ".", "buf", "=", "tmp", ";", "}", "System", ".", "arraycopy", "(", "buf", ",", "0", ",", "super", ".", "buf", ",", "super", ".", "count", ",", "buf", ".", "length", ")", ";", "super", ".", "count", "+=", "buf", ".", "length", ";", "}", "public", "void", "ensureSpace", "(", "int", "space", ")", "{", "if", "(", "super", ".", "count", "+", "space", ">", "super", ".", "buf", ".", "length", ")", "{", "final", "byte", "[", "]", "tmp", "=", "new", "byte", "[", "super", ".", "buf", ".", "length", "+", "space", "+", "DEFAULT_BUFFER_INCREMENT", "]", ";", "System", ".", "arraycopy", "(", "super", ".", "buf", ",", "0", ",", "tmp", ",", "0", ",", "super", ".", "count", ")", ";", "super", ".", "buf", "=", "tmp", ";", "}", "}", "public", "void", "raw_write", "(", "final", "byte", "b", ")", "{", "super", ".", "buf", "[", "super", ".", "count", "++", "]", "=", "b", ";", "}", "public", "void", "raw_write", "(", "int", "b", ")", "{", "super", ".", "buf", "[", "super", ".", "count", "++", "]", "=", "(", "byte", ")", "b", ";", "}", "public", "void", "write1", "(", "final", "long", "n", ")", "{", "write", "(", "(", "byte", ")", "(", "n", "&", "0xff", ")", ")", ";", "}", "public", "void", "writeN", "(", "final", "byte", "[", "]", "bytes", ")", "{", "write", "(", "bytes", ")", ";", "}", "public", "void", "writeN", "(", "final", "byte", "[", "]", "bytes", ",", "int", "off", ",", "int", "len", ")", "{", "write", "(", "bytes", ",", "off", ",", "len", ")", ";", "}", "public", "int", "length", "(", ")", "{", "return", "super", ".", "buf", ".", "length", ";", "}", "@", "Deprecated", "public", "int", "count", "(", ")", "{", "return", "count", ";", "}", "public", "void", "write2BE", "(", "final", "long", "n", ")", "{", "write", "(", "(", "byte", ")", "(", "(", "n", ")", ">>", "8", ")", ")", ";", "write", "(", "(", "byte", ")", "(", "n", ")", ")", ";", "}", "public", "void", "raw_write2BE", "(", "final", "long", "n", ")", "{", "raw_write", "(", "(", "byte", ")", "(", "(", "n", ")", ">>", "8", ")", ")", ";", "raw_write", "(", "(", "byte", ")", "(", "n", ")", ")", ";", "}", "public", "void", "write4BE", "(", "final", "long", "n", ")", "{", "write", "(", "(", "byte", ")", "(", "(", "n", ")", ">>", "24", ")", ")", ";", "write", "(", "(", "byte", ")", "(", "(", "n", ")", ">>", "16", ")", ")", ";", "write", "(", "(", "byte", ")", "(", "(", "n", ")", ">>", "8", ")", ")", ";", "write", "(", "(", "byte", ")", "(", "n", ")", ")", ";", "}", "public", "void", "raw_write4BE", "(", "int", "n", ")", "{", "raw_write", "(", "(", "byte", ")", "(", "(", "n", ")", ">>", "24", ")", ")", ";", "raw_write", "(", "(", "byte", ")", "(", "(", "n", ")", ">>", "16", ")", ")", ";", "raw_write", "(", "(", "byte", ")", "(", "(", "n", ")", ">>", "8", ")", ")", ";", "raw_write", "(", "(", "byte", ")", "(", "n", ")", ")", ";", "}", "public", "void", "write8BE", "(", "final", "long", "n", ")", "{", "write", "(", "(", "byte", ")", "(", "n", ">>", "56", ")", ")", ";", "write", "(", "(", "byte", ")", "(", "n", ">>", "48", ")", ")", ";", "write", "(", "(", "byte", ")", "(", "n", ">>", "40", ")", ")", ";", "write", "(", "(", "byte", ")", "(", "n", ">>", "32", ")", ")", ";", "write", "(", "(", "byte", ")", "(", "n", ">>", "24", ")", ")", ";", "write", "(", "(", "byte", ")", "(", "n", ">>", "16", ")", ")", ";", "write", "(", "(", "byte", ")", "(", "n", ">>", "8", ")", ")", ";", "write", "(", "(", "byte", ")", "(", "n", ")", ")", ";", "}", "public", "void", "writeLE", "(", "long", "n", ",", "final", "int", "b", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "b", ";", "i", "++", ")", "{", "write", "(", "(", "byte", ")", "(", "n", "&", "0xff", ")", ")", ";", "n", ">>=", "8", ";", "}", "}", "public", "void", "write2LE", "(", "final", "long", "n", ")", "{", "write", "(", "(", "byte", ")", "(", "n", ")", ")", ";", "write", "(", "(", "byte", ")", "(", "(", "n", ")", ">>", "8", ")", ")", ";", "}", "public", "void", "write4LE", "(", "final", "long", "n", ")", "{", "write", "(", "(", "byte", ")", "(", "n", ")", ")", ";", "write", "(", "(", "byte", ")", "(", "(", "n", ")", ">>", "8", ")", ")", ";", "write", "(", "(", "byte", ")", "(", "(", "n", ")", ">>", "16", ")", ")", ";", "write", "(", "(", "byte", ")", "(", "(", "n", ")", ">>", "24", ")", ")", ";", "}", "public", "void", "write8LE", "(", "final", "long", "n", ")", "{", "write", "(", "(", "byte", ")", "(", "n", ")", ")", ";", "write", "(", "(", "byte", ")", "(", "n", ">>", "8", ")", ")", ";", "write", "(", "(", "byte", ")", "(", "n", ">>", "16", ")", ")", ";", "write", "(", "(", "byte", ")", "(", "n", ">>", "24", ")", ")", ";", "write", "(", "(", "byte", ")", "(", "n", ">>", "32", ")", ")", ";", "write", "(", "(", "byte", ")", "(", "n", ">>", "40", ")", ")", ";", "write", "(", "(", "byte", ")", "(", "n", ">>", "48", ")", ")", ";", "write", "(", "(", "byte", ")", "(", "n", ">>", "56", ")", ")", ";", "}", "public", "void", "poke4BE", "(", "final", "int", "offset", ",", "final", "long", "n", ")", "{", "if", "(", "offset", "<", "super", ".", "count", ")", "{", "buf", "[", "offset", "+", "0", "]", "=", "(", "byte", ")", "(", "(", "n", "&", "0xff000000", ")", ">>", "24", ")", ";", "buf", "[", "offset", "+", "1", "]", "=", "(", "byte", ")", "(", "(", "n", "&", "0xff0000", ")", ">>", "16", ")", ";", "buf", "[", "offset", "+", "2", "]", "=", "(", "byte", ")", "(", "(", "n", "&", "0xff00", ")", ">>", "8", ")", ";", "buf", "[", "offset", "+", "3", "]", "=", "(", "byte", ")", "(", "n", "&", "0xff", ")", ";", "}", "}", "public", "void", "write_atom", "(", "final", "String", "atom", ")", "{", "int", "len", "=", "Math", ".", "min", "(", "EExternal", ".", "maxAtomLength", ",", "atom", ".", "length", "(", ")", ")", ";", "if", "(", "len", "<", "256", "&&", "(", "flags", "&", "EAbstractNode", ".", "dFlagSmallAtoms", ")", "!=", "0", ")", "{", "ensureSpace", "(", "1", "+", "1", "+", "len", ")", ";", "raw_write", "(", "EExternal", ".", "smallAtomTag", ")", ";", "raw_write", "(", "len", ")", ";", "}", "else", "{", "ensureSpace", "(", "1", "+", "2", "+", "len", ")", ";", "raw_write", "(", "EExternal", ".", "atomTag", ")", ";", "raw_write2BE", "(", "atom", ".", "length", "(", ")", ")", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "len", ";", "i", "++", ")", "{", "raw_write", "(", "(", "byte", ")", "atom", ".", "charAt", "(", "i", ")", ")", ";", "}", "}", "public", "void", "write_binary", "(", "final", "byte", "[", "]", "bin", ")", "{", "write1", "(", "EExternal", ".", "binTag", ")", ";", "write4BE", "(", "bin", ".", "length", ")", ";", "writeN", "(", "bin", ")", ";", "}", "public", "void", "write_bitstr", "(", "final", "byte", "[", "]", "bin", ",", "final", "int", "pad_bits", ")", "{", "if", "(", "pad_bits", "==", "0", ")", "{", "write_binary", "(", "bin", ")", ";", "return", ";", "}", "write1", "(", "EExternal", ".", "bitBinTag", ")", ";", "write4BE", "(", "bin", ".", "length", ")", ";", "write1", "(", "8", "-", "pad_bits", ")", ";", "writeN", "(", "bin", ")", ";", "}", "public", "void", "write_boolean", "(", "final", "boolean", "b", ")", "{", "write_atom", "(", "String", ".", "valueOf", "(", "b", ")", ")", ";", "}", "public", "void", "write_byte", "(", "final", "byte", "b", ")", "{", "this", ".", "write_long", "(", "b", "&", "0xffL", ",", "true", ")", ";", "}", "public", "void", "write_char", "(", "final", "char", "c", ")", "{", "this", ".", "write_long", "(", "c", "&", "0xffffL", ",", "true", ")", ";", "}", "public", "void", "write_double", "(", "final", "double", "d", ")", "{", "write1", "(", "EExternal", ".", "newFloatTag", ")", ";", "write8BE", "(", "Double", ".", "doubleToLongBits", "(", "d", ")", ")", ";", "}", "public", "void", "write_float", "(", "final", "float", "f", ")", "{", "write_double", "(", "f", ")", ";", "}", "public", "void", "write_big_integer", "(", "BigInteger", "v", ")", "{", "if", "(", "v", ".", "bitLength", "(", ")", "<", "64", ")", "{", "this", ".", "write_long", "(", "v", ".", "longValue", "(", ")", ",", "false", ")", ";", "return", ";", "}", "final", "int", "signum", "=", "v", ".", "signum", "(", ")", ";", "if", "(", "signum", "<", "0", ")", "{", "v", "=", "v", ".", "negate", "(", ")", ";", "}", "final", "byte", "[", "]", "magnitude", "=", "v", ".", "toByteArray", "(", ")", ";", "final", "int", "n", "=", "magnitude", ".", "length", ";", "for", "(", "int", "i", "=", "0", ",", "j", "=", "n", ";", "i", "<", "j", "--", ";", "i", "++", ")", "{", "final", "byte", "b", "=", "magnitude", "[", "i", "]", ";", "magnitude", "[", "i", "]", "=", "magnitude", "[", "j", "]", ";", "magnitude", "[", "j", "]", "=", "b", ";", "}", "if", "(", "(", "n", "&", "0xFF", ")", "==", "n", ")", "{", "write1", "(", "EExternal", ".", "smallBigTag", ")", ";", "write1", "(", "n", ")", ";", "}", "else", "{", "write1", "(", "EExternal", ".", "largeBigTag", ")", ";", "write4BE", "(", "n", ")", ";", "}", "write1", "(", "signum", "<", "0", "?", "1", ":", "0", ")", ";", "writeN", "(", "magnitude", ")", ";", "}", "void", "write_long", "(", "final", "long", "v", ",", "final", "boolean", "unsigned", ")", "{", "if", "(", "(", "v", "&", "0xffL", ")", "==", "v", ")", "{", "ensureSpace", "(", "2", ")", ";", "raw_write", "(", "EExternal", ".", "smallIntTag", ")", ";", "raw_write", "(", "(", "int", ")", "v", ")", ";", "}", "else", "{", "if", "(", "v", "<", "0", "&&", "unsigned", "||", "v", "<", "EExternal", ".", "erlMin", "||", "v", ">", "EExternal", ".", "erlMax", ")", "{", "final", "long", "abs", "=", "unsigned", "?", "v", ":", "v", "<", "0", "?", "-", "v", ":", "v", ";", "final", "int", "sign", "=", "unsigned", "?", "0", ":", "v", "<", "0", "?", "1", ":", "0", ";", "int", "n", ";", "long", "mask", ";", "for", "(", "mask", "=", "0xFFFFffffL", ",", "n", "=", "4", ";", "(", "abs", "&", "mask", ")", "!=", "abs", ";", "n", "++", ",", "mask", "=", "mask", "<<", "8", "|", "0xffL", ")", "{", ";", "}", "write1", "(", "EExternal", ".", "smallBigTag", ")", ";", "write1", "(", "n", ")", ";", "write1", "(", "sign", ")", ";", "writeLE", "(", "abs", ",", "n", ")", ";", "}", "else", "{", "ensureSpace", "(", "5", ")", ";", "raw_write", "(", "EExternal", ".", "intTag", ")", ";", "raw_write4BE", "(", "(", "int", ")", "v", ")", ";", "}", "}", "}", "public", "void", "write_long", "(", "final", "long", "l", ")", "{", "this", ".", "write_long", "(", "l", ",", "false", ")", ";", "}", "public", "void", "write_ulong", "(", "final", "long", "ul", ")", "{", "this", ".", "write_long", "(", "ul", ",", "true", ")", ";", "}", "public", "void", "write_int", "(", "final", "int", "i", ")", "{", "this", ".", "write_long", "(", "i", ",", "false", ")", ";", "}", "public", "void", "write_uint", "(", "final", "int", "ui", ")", "{", "this", ".", "write_long", "(", "ui", "&", "0xFFFFffffL", ",", "true", ")", ";", "}", "public", "void", "write_short", "(", "final", "short", "s", ")", "{", "this", ".", "write_long", "(", "s", ",", "false", ")", ";", "}", "public", "void", "write_ushort", "(", "final", "short", "us", ")", "{", "this", ".", "write_long", "(", "us", "&", "0xffffL", ",", "true", ")", ";", "}", "public", "void", "write_list_head", "(", "final", "int", "arity", ")", "{", "if", "(", "arity", "==", "0", ")", "{", "write_nil", "(", ")", ";", "}", "else", "{", "write1", "(", "EExternal", ".", "listTag", ")", ";", "write4BE", "(", "arity", ")", ";", "}", "}", "public", "void", "write_nil", "(", ")", "{", "write1", "(", "EExternal", ".", "nilTag", ")", ";", "}", "public", "void", "write_tuple_head", "(", "final", "int", "arity", ")", "{", "if", "(", "arity", "<", "0xff", ")", "{", "write1", "(", "EExternal", ".", "smallTupleTag", ")", ";", "write1", "(", "arity", ")", ";", "}", "else", "{", "write1", "(", "EExternal", ".", "largeTupleTag", ")", ";", "write4BE", "(", "arity", ")", ";", "}", "}", "public", "void", "write_pid", "(", "final", "EAtom", "node", ",", "final", "int", "id", ",", "final", "int", "serial", ",", "final", "int", "creation", ")", "{", "write1", "(", "EExternal", ".", "pidTag", ")", ";", "write_atom", "(", "node", ".", "getName", "(", ")", ")", ";", "write4BE", "(", "id", "&", "0x7fff", ")", ";", "write4BE", "(", "serial", "&", "0x1fff", ")", ";", "write1", "(", "creation", "&", "0x3", ")", ";", "}", "public", "void", "write_port", "(", "final", "String", "node", ",", "final", "int", "id", ",", "final", "int", "creation", ")", "{", "write1", "(", "EExternal", ".", "portTag", ")", ";", "write_atom", "(", "node", ")", ";", "write4BE", "(", "id", "&", "0xfffffff", ")", ";", "write1", "(", "creation", "&", "0x3", ")", ";", "}", "public", "void", "write_ref", "(", "final", "String", "node", ",", "final", "int", "id", ",", "final", "int", "creation", ")", "{", "write1", "(", "EExternal", ".", "refTag", ")", ";", "write_atom", "(", "node", ")", ";", "write4BE", "(", "id", "&", "0x3ffff", ")", ";", "write1", "(", "creation", "&", "0x3", ")", ";", "}", "public", "void", "write_ref", "(", "final", "String", "node", ",", "final", "int", "[", "]", "ids", ",", "final", "int", "creation", ")", "{", "int", "arity", "=", "ids", ".", "length", ";", "if", "(", "arity", ">", "3", ")", "{", "arity", "=", "3", ";", "}", "if", "(", "arity", "==", "1", ")", "{", "this", ".", "write_ref", "(", "node", ",", "ids", "[", "0", "]", ",", "creation", ")", ";", "}", "else", "{", "write1", "(", "EExternal", ".", "newRefTag", ")", ";", "write2BE", "(", "arity", ")", ";", "write_atom", "(", "node", ")", ";", "write1", "(", "creation", "&", "0x3", ")", ";", "write4BE", "(", "ids", "[", "0", "]", "&", "0x3ffff", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "arity", ";", "i", "++", ")", "{", "write4BE", "(", "ids", "[", "i", "]", ")", ";", "}", "}", "}", "public", "void", "write_string", "(", "final", "String", "s", ")", "{", "final", "int", "len", "=", "s", ".", "length", "(", ")", ";", "switch", "(", "len", ")", "{", "case", "0", ":", "write_nil", "(", ")", ";", "break", ";", "default", ":", "if", "(", "len", "<=", "65535", "&&", "is8bitString", "(", "s", ")", ")", "{", "try", "{", "final", "byte", "[", "]", "bytebuf", "=", "s", ".", "getBytes", "(", "\"ISO-8859-1\"", ")", ";", "write1", "(", "EExternal", ".", "stringTag", ")", ";", "write2BE", "(", "len", ")", ";", "writeN", "(", "bytebuf", ")", ";", "}", "catch", "(", "final", "UnsupportedEncodingException", "e", ")", "{", "write_nil", "(", ")", ";", "}", "}", "else", "{", "final", "char", "[", "]", "charbuf", "=", "s", ".", "toCharArray", "(", ")", ";", "final", "int", "[", "]", "codePoints", "=", "EString", ".", "stringToCodePoints", "(", "s", ")", ";", "write_list_head", "(", "codePoints", ".", "length", ")", ";", "for", "(", "final", "int", "codePoint", ":", "codePoints", ")", "{", "write_int", "(", "codePoint", ")", ";", "}", "write_nil", "(", ")", ";", "}", "}", "}", "public", "void", "write_string", "(", "byte", "[", "]", "data", ",", "int", "off", ",", "int", "len", ")", "{", "if", "(", "len", "<=", "65535", ")", "{", "ensureSpace", "(", "1", "+", "2", "+", "len", ")", ";", "raw_write", "(", "EExternal", ".", "stringTag", ")", ";", "raw_write2BE", "(", "len", ")", ";", "writeN", "(", "data", ",", "off", ",", "len", ")", ";", "}", "else", "{", "write_list_head", "(", "len", ")", ";", "for", "(", "int", "i", "=", "off", ";", "i", "<", "off", "+", "len", ";", "i", "++", ")", "{", "write_int", "(", "data", "[", "i", "]", ")", ";", "}", "write_nil", "(", ")", ";", "}", "}", "private", "boolean", "is8bitString", "(", "final", "String", "s", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "s", ".", "length", "(", ")", ";", "++", "i", ")", "{", "final", "char", "c", "=", "s", ".", "charAt", "(", "i", ")", ";", "if", "(", "c", "<", "0", "||", "c", ">", "255", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}", "public", "void", "write_compressed", "(", "final", "EObject", "o", ",", "int", "level", ")", "{", "final", "EOutputStream", "oos", "=", "new", "EOutputStream", "(", "o", ")", ";", "write1", "(", "EExternal", ".", "compressedTag", ")", ";", "write4BE", "(", "oos", ".", "size", "(", ")", ")", ";", "final", "java", ".", "io", ".", "FilterOutputStream", "fos", "=", "new", "java", ".", "io", ".", "FilterOutputStream", "(", "this", ")", ";", "final", "java", ".", "util", ".", "zip", ".", "DeflaterOutputStream", "dos", "=", "new", "java", ".", "util", ".", "zip", ".", "DeflaterOutputStream", "(", "fos", ",", "new", "Deflater", "(", "level", ")", ")", ";", "try", "{", "oos", ".", "writeTo", "(", "dos", ")", ";", "dos", ".", "close", "(", ")", ";", "}", "catch", "(", "final", "IOException", "e", ")", "{", "throw", "new", "java", ".", "lang", ".", "IllegalArgumentException", "(", "\"\"", "+", "o", ")", ";", "}", "}", "public", "void", "write_any", "(", "final", "EObject", "o", ")", "{", "o", ".", "encode", "(", "this", ")", ";", "}", "public", "void", "write_fun", "(", "final", "EPID", "pid", ",", "final", "String", "module", ",", "final", "long", "old_index", ",", "final", "int", "arity", ",", "final", "EBinary", "md5", ",", "final", "long", "index", ",", "final", "long", "uniq", ",", "final", "EObject", "[", "]", "freeVars", ")", "{", "if", "(", "(", "flags", "&", "EAbstractNode", ".", "dflagNewFunTags", ")", "==", "0", ")", "{", "write1", "(", "EExternal", ".", "funTag", ")", ";", "write4BE", "(", "freeVars", ".", "length", ")", ";", "pid", ".", "encode", "(", "this", ")", ";", "write_atom", "(", "module", ")", ";", "write_long", "(", "index", "&", "0xffffffffL", ")", ";", "write_long", "(", "uniq", "&", "0xffffffffL", ")", ";", "for", "(", "final", "EObject", "fv", ":", "freeVars", ")", "{", "fv", ".", "encode", "(", "this", ")", ";", "}", "}", "else", "{", "write1", "(", "EExternal", ".", "newFunTag", ")", ";", "final", "int", "saveSizePos", "=", "getPos", "(", ")", ";", "write4BE", "(", "0", ")", ";", "write1", "(", "arity", ")", ";", "writeN", "(", "md5", ".", "getByteArray", "(", ")", ")", ";", "write4BE", "(", "index", ")", ";", "write4BE", "(", "freeVars", ".", "length", ")", ";", "write_atom", "(", "module", ")", ";", "write_long", "(", "old_index", "&", "0xffffffffL", ")", ";", "write_long", "(", "uniq", "&", "0xffffffffL", ")", ";", "pid", ".", "encode", "(", "this", ")", ";", "for", "(", "final", "EObject", "fv", ":", "freeVars", ")", "{", "fv", ".", "encode", "(", "this", ")", ";", "}", "poke4BE", "(", "saveSizePos", ",", "getPos", "(", ")", "-", "saveSizePos", ")", ";", "}", "}", "public", "void", "write_external_fun", "(", "final", "EAtom", "module", ",", "final", "EAtom", "function", ",", "final", "int", "arity", ")", "{", "write_external_fun", "(", "module", ".", "getName", "(", ")", ",", "function", ".", "getName", "(", ")", ",", "arity", ")", ";", "}", "public", "void", "write_external_fun", "(", "final", "String", "module", ",", "final", "String", "function", ",", "final", "int", "arity", ")", "{", "write1", "(", "EExternal", ".", "externalFunTag", ")", ";", "write_atom", "(", "module", ")", ";", "write_atom", "(", "function", ")", ";", "write_long", "(", "arity", ")", ";", "}", "public", "ByteBuffer", "toByteBuffer", "(", ")", "{", "return", "ByteBuffer", ".", "wrap", "(", "super", ".", "buf", ",", "0", ",", "super", ".", "count", ")", ";", "}", "}", "</s>" ]
7,916
[ "<s>", "package", "erjang", ";", "public", "class", "ErlangUndefined", "extends", "ErlangError", "{", "private", "final", "EAtom", "module", ";", "private", "final", "EAtom", "function", ";", "private", "final", "ESmall", "arity", ";", "@", "Override", "public", "String", "getMessage", "(", ")", "{", "return", "\"undefined:", "\"", "+", "module", "+", "\":\"", "+", "function", "+", "\"/\"", "+", "arity", ";", "}", "public", "ErlangUndefined", "(", "EAtom", "module", ",", "EAtom", "function", ",", "ESmall", "arity", ")", "{", "super", "(", "ERT", ".", "am_undef", ")", ";", "this", ".", "module", "=", "module", ";", "this", ".", "function", "=", "function", ";", "this", ".", "arity", "=", "arity", ";", "this", ".", "printStackTrace", "(", ")", ";", "}", "public", "ErlangUndefined", "(", "EAtom", "mod", ",", "EAtom", "fun", ",", "int", "length", ")", "{", "this", "(", "mod", ",", "fun", ",", "new", "ESmall", "(", "length", ")", ")", ";", "}", "@", "Override", "public", "ESeq", "getTrace", "(", ")", "{", "return", "super", ".", "getTrace", "(", ")", ".", "cons", "(", "ETuple", ".", "make", "(", "module", ",", "function", ",", "arity", ")", ")", ";", "}", "}", "</s>" ]
7,917
[ "<s>", "package", "erjang", ";", "import", "java", ".", "util", ".", "logging", ".", "Logger", ";", "public", "abstract", "class", "ENative", "{", "protected", "static", "Logger", "log", "=", "Logger", ".", "getLogger", "(", "\"\"", ")", ";", "public", "Class", "<", "?", ">", "[", "]", "getNativeClasses", "(", ")", "{", "return", "new", "Class", "[", "]", "{", "getClass", "(", ")", "}", ";", "}", "}", "</s>" ]
7,918
[ "<s>", "package", "erjang", ";", "public", "class", "ErlangExit", "extends", "ErlangException", "{", "public", "ErlangExit", "(", "EObject", "reason", ")", "{", "super", "(", "reason", ")", ";", "}", "public", "ErlangExit", "(", "Throwable", "e", ")", "{", "super", "(", "ETuple", ".", "make", "(", "EString", ".", "fromString", "(", "e", ".", "getMessage", "(", ")", ")", ",", "decodeTrace", "(", "e", ".", "getStackTrace", "(", ")", ")", ")", ")", ";", "}", "public", "EAtom", "getExClass", "(", ")", "{", "return", "am_exit", ";", "}", "}", "</s>" ]
7,919
[ "<s>", "package", "erjang", ";", "public", "class", "ETuple2", "extends", "ETuple", "{", "public", "EObject", "elem1", ";", "public", "EObject", "elem2", ";", "public", "ETuple2", "(", "EObject", "elem1", ",", "EObject", "elem2", ")", "{", "this", ".", "elem1", "=", "elem1", ";", "this", ".", "elem2", "=", "elem2", ";", "}", "public", "ETuple2", "(", ")", "{", "}", "static", "public", "ETuple2", "cast", "(", "ETuple", "value", ")", "{", "if", "(", "value", ".", "arity", "(", ")", "==", "2", ")", "return", "(", "ETuple2", ")", "value", ";", "return", "null", ";", "}", "static", "public", "ETuple2", "cast", "(", "EObject", "value", ")", "{", "ETuple", "t", ";", "if", "(", "(", "t", "=", "value", ".", "testTuple", "(", ")", ")", "!=", "null", ")", "{", "if", "(", "t", ".", "arity", "(", ")", "==", "2", ")", "return", "(", "ETuple2", ")", "t", ";", "}", "return", "null", ";", "}", "@", "Override", "public", "ETuple2", "blank", "(", ")", "{", "ETuple2", "res", "=", "new", "ETuple2", "(", ")", ";", "return", "res", ";", "}", "@", "Override", "public", "int", "arity", "(", ")", "{", "return", "2", ";", "}", "@", "Override", "public", "EObject", "elm", "(", "int", "i", ")", "{", "if", "(", "i", "==", "1", ")", "{", "return", "elem1", ";", "}", "else", "if", "(", "i", "==", "2", ")", "{", "return", "elem2", ";", "}", "else", "{", "return", "bad_nth", "(", "i", ")", ";", "}", "}", "@", "Override", "public", "void", "set", "(", "int", "i", ",", "EObject", "term", ")", "{", "if", "(", "i", "==", "1", ")", "{", "elem1", "=", "term", ";", "}", "else", "if", "(", "i", "==", "2", ")", "{", "elem2", "=", "term", ";", "}", "else", "{", "bad_nth", "(", "i", ")", ";", "}", "}", "}", "</s>" ]
7,920
[ "<s>", "package", "erjang", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileOutputStream", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "util", ".", "Collections", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "LinkedList", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "Queue", ";", "import", "java", ".", "util", ".", "jar", ".", "JarOutputStream", ";", "import", "java", ".", "util", ".", "logging", ".", "Logger", ";", "import", "java", ".", "util", ".", "zip", ".", "ZipEntry", ";", "import", "erjang", ".", "beam", ".", "BeamLoader", ";", "import", "erjang", ".", "beam", ".", "Compiler", ";", "import", "erjang", ".", "beam", ".", "RamClassRepo", ";", "public", "class", "ErjangCodeCache", "{", "static", "final", "Logger", "log", "=", "Logger", ".", "getLogger", "(", "\"\"", ")", ";", "static", "final", "String", "ERJ_CACHE_DIR", ";", "static", "final", "boolean", "useAsyncPersisting", ";", "static", "final", "boolean", "useSyncPersisting", ";", "static", "final", "Persister", "persister", ";", "static", "{", "String", "cacheDir", "=", "System", ".", "getenv", "(", "\"\"", ")", ";", "if", "(", "cacheDir", "==", "null", ")", "cacheDir", "=", "System", ".", "getProperty", "(", "\"user.home\"", ")", ";", "ERJ_CACHE_DIR", "=", "cacheDir", ";", "String", "mode", "=", "System", ".", "getProperty", "(", "\"\"", ")", ";", "if", "(", "\"async\"", ".", "equals", "(", "mode", ")", ")", "{", "useAsyncPersisting", "=", "true", ";", "useSyncPersisting", "=", "false", ";", "}", "else", "if", "(", "\"sync\"", ".", "equals", "(", "mode", ")", ")", "{", "useAsyncPersisting", "=", "false", ";", "useSyncPersisting", "=", "true", ";", "}", "else", "if", "(", "\"off\"", ".", "equals", "(", "mode", ")", ")", "{", "useAsyncPersisting", "=", "false", ";", "useSyncPersisting", "=", "false", ";", "}", "else", "{", "useAsyncPersisting", "=", "true", ";", "useSyncPersisting", "=", "false", ";", "}", "if", "(", "useAsyncPersisting", ")", "{", "persister", "=", "new", "Persister", "(", ")", ";", "Thread", "t", "=", "new", "Thread", "(", "persister", ",", "\"\"", ")", ";", "t", ".", "setDaemon", "(", "true", ")", ";", "t", ".", "setPriority", "(", "Thread", ".", "MIN_PRIORITY", ")", ";", "t", ".", "start", "(", ")", ";", "}", "else", "persister", "=", "null", ";", "}", "private", "static", "Map", "<", "String", ",", "RamClassRepo", ">", "cache", "=", "Collections", ".", "synchronizedMap", "(", "new", "HashMap", "<", "String", ",", "RamClassRepo", ">", "(", ")", ")", ";", "public", "static", "EModuleClassLoader", "getModuleClassLoader", "(", "String", "moduleName", ",", "EBinary", "beam_data", ",", "BeamLoader", "beam_parser", ")", "throws", "IOException", "{", "long", "crc", "=", "beam_data", ".", "crc", "(", ")", ";", "File", "jarFile", "=", "new", "File", "(", "erjdir", "(", ")", ",", "moduleJarFileName", "(", "moduleName", ",", "crc", ")", ")", ";", "if", "(", "jarFile", ".", "exists", "(", ")", ")", "{", "return", "new", "EModuleClassLoader", "(", "jarFile", ".", "toURI", "(", ")", ".", "toURL", "(", ")", ")", ";", "}", "RamClassRepo", "repo", "=", "new", "RamClassRepo", "(", ")", ";", "try", "{", "Compiler", ".", "compile", "(", "beam_parser", ".", "load", "(", "beam_data", ".", "getByteArray", "(", ")", ")", ",", "repo", ")", ";", "repo", ".", "close", "(", ")", ";", "cache", ".", "put", "(", "moduleName", ",", "repo", ")", ";", "if", "(", "useAsyncPersisting", ")", "persister", ".", "enqueue", "(", "jarFile", ",", "repo", ")", ";", "else", "if", "(", "useSyncPersisting", ")", "persister", ".", "persist", "(", "jarFile", ",", "repo", ")", ";", "}", "finally", "{", "try", "{", "repo", ".", "close", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "}", "}", "return", "new", "EModuleClassLoader", "(", "jarFile", ".", "toURI", "(", ")", ".", "toURL", "(", ")", ",", "repo", ")", ";", "}", "static", "File", "erjdir", "(", ")", "throws", "IOException", "{", "File", "home", "=", "ERT", ".", "newFile", "(", "ERJ_CACHE_DIR", ")", ";", "File", "dir", "=", "new", "File", "(", "home", ",", "\".erjang\"", ")", ";", "if", "(", "!", "dir", ".", "exists", "(", ")", ")", "{", "if", "(", "!", "dir", ".", "mkdirs", "(", ")", ")", "throw", "new", "IOException", "(", "\"\"", "+", "dir", ")", ";", "}", "else", "if", "(", "!", "dir", ".", "canWrite", "(", ")", ")", "{", "throw", "new", "IOException", "(", "\"\"", "+", "dir", ")", ";", "}", "return", "dir", ";", "}", "public", "static", "String", "moduleJarFileName", "(", "String", "moduleName", ",", "long", "crc", ")", "{", "return", "moduleFileName", "(", "moduleName", ",", "crc", ",", "\"jar\"", ")", ";", "}", "static", "String", "moduleFileName", "(", "String", "moduleName", ",", "long", "crc", ",", "String", "extension", ")", "{", "return", "mangle", "(", "moduleName", ")", "+", "\"-\"", "+", "Long", ".", "toHexString", "(", "crc", ")", "+", "\".\"", "+", "extension", ";", "}", "static", "String", "mangle", "(", "String", "s", ")", "{", "StringBuffer", "sb", "=", "new", "StringBuffer", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "s", ".", "length", "(", ")", ";", "i", "++", ")", "{", "char", "c", "=", "s", ".", "charAt", "(", "i", ")", ";", "if", "(", "(", "'a'", "<=", "c", "&&", "c", "<=", "'z'", ")", "||", "(", "'0'", "<=", "c", "&&", "c", "<=", "'9'", ")", "||", "c", "==", "'_'", ")", "sb", ".", "append", "(", "c", ")", ";", "else", "sb", ".", "append", "(", "'$'", ")", ".", "append", "(", "Integer", ".", "toHexString", "(", "c", ")", ")", ".", "append", "(", "'$'", ")", ";", "}", "return", "sb", ".", "toString", "(", ")", ";", "}", "static", "class", "PersistRequest", "{", "final", "File", "file", ";", "final", "RamClassRepo", "repo", ";", "public", "PersistRequest", "(", "File", "file", ",", "RamClassRepo", "repo", ")", "{", "this", ".", "file", "=", "file", ";", "this", ".", "repo", "=", "repo", ";", "}", "}", "static", "class", "Persister", "implements", "Runnable", "{", "final", "Queue", "<", "PersistRequest", ">", "queue", "=", "new", "LinkedList", "<", "PersistRequest", ">", "(", ")", ";", "public", "void", "run", "(", ")", "{", "while", "(", "true", ")", "{", "PersistRequest", "request", ";", "synchronized", "(", "queue", ")", "{", "while", "(", "(", "request", "=", "queue", ".", "poll", "(", ")", ")", "==", "null", ")", "{", "try", "{", "queue", ".", "wait", "(", ")", ";", "}", "catch", "(", "InterruptedException", "ie", ")", "{", "}", "}", "}", "persist", "(", "request", ".", "file", ",", "request", ".", "repo", ")", ";", "}", "}", "void", "enqueue", "(", "File", "file", ",", "RamClassRepo", "repo", ")", "{", "synchronized", "(", "queue", ")", "{", "queue", ".", "add", "(", "new", "PersistRequest", "(", "file", ",", "repo", ")", ")", ";", "queue", ".", "notify", "(", ")", ";", "}", "}", "static", "void", "persist", "(", "File", "file", ",", "RamClassRepo", "repo", ")", "{", "try", "{", "File", "tmpFile", "=", "File", ".", "createTempFile", "(", "file", ".", "getName", "(", ")", ",", "\"tmp\"", ",", "file", ".", "getParentFile", "(", ")", ")", ";", "JarOutputStream", "jo", "=", "new", "JarOutputStream", "(", "new", "FileOutputStream", "(", "tmpFile", ")", ")", ";", "for", "(", "Map", ".", "Entry", "<", "String", ",", "byte", "[", "]", ">", "e", ":", "repo", ".", "entrySet", "(", ")", ")", "{", "String", "classFilename", "=", "e", ".", "getKey", "(", ")", "+", "\".class\"", ";", "byte", "[", "]", "classContents", "=", "e", ".", "getValue", "(", ")", ";", "jo", ".", "putNextEntry", "(", "new", "ZipEntry", "(", "classFilename", ")", ")", ";", "jo", ".", "write", "(", "classContents", ")", ";", "jo", ".", "closeEntry", "(", ")", ";", "}", "jo", ".", "close", "(", ")", ";", "tmpFile", ".", "renameTo", "(", "file", ")", ";", "}", "catch", "(", "IOException", "ioe", ")", "{", "log", ".", "warning", "(", "\"\"", "+", "file", ")", ";", "}", "}", "}", "}", "</s>" ]
7,921
[ "<s>", "package", "erjang", ";", "import", "java", ".", "nio", ".", "ByteBuffer", ";", "import", "kilim", ".", "Pausable", ";", "import", "erjang", ".", "driver", ".", "EDriverTask", ";", "public", "class", "EInternalPort", "extends", "EPort", "implements", "ELocalHandle", "{", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "\"<port:\"", "+", "task", ".", "id", "+", "\">\"", ";", "}", "private", "final", "EDriverTask", "task", ";", "public", "EInternalPort", "(", "EDriverTask", "task", ")", "{", "super", "(", "ERT", ".", "getLocalNode", "(", ")", ")", ";", "this", ".", "task", "=", "task", ";", "}", "@", "Override", "public", "EInternalPort", "testInternalPort", "(", ")", "{", "return", "this", ";", "}", "public", "ELocalHandle", "testLocalHandle", "(", ")", "{", "return", "this", ";", "}", "@", "Override", "public", "boolean", "exists", "(", ")", "{", "return", "task", ".", "exists", "(", ")", ";", "}", "@", "Override", "public", "boolean", "link_oneway", "(", "EHandle", "other", ")", "throws", "Pausable", "{", "return", "task", ".", "link_oneway", "(", "other", ")", ";", "}", "@", "Override", "public", "void", "unlink_oneway", "(", "EHandle", "other", ")", "throws", "Pausable", "{", "task", ".", "unlink_oneway", "(", "other", ")", ";", "}", "public", "boolean", "add_monitor", "(", "EHandle", "target", ",", "ERef", "ref", ")", "throws", "Pausable", "{", "return", "task", ".", "add_monitor", "(", "target", ",", "ref", ")", ";", "}", "@", "Override", "public", "void", "remove_monitor", "(", "EHandle", "sender", ",", "ERef", "r", ",", "boolean", "flush", ")", "throws", "Pausable", "{", "task", ".", "remove_monitor", "(", "r", ",", "flush", ")", ";", "}", "@", "Override", "public", "void", "send_monitor_exit", "(", "EHandle", "from", ",", "ERef", "ref", ",", "EObject", "reason", ")", "throws", "Pausable", "{", "EDriverTask", "task", "=", "this", ".", "task", ";", "if", "(", "task", "!=", "null", ")", "{", "task", ".", "send_monitor_exit", "(", "from", ",", "ref", ",", "reason", ")", ";", "}", "}", "@", "Override", "public", "EDriverTask", "task", "(", ")", "{", "return", "task", ";", "}", "public", "int", "internal_port_number", "(", ")", "{", "throw", "new", "NotImplemented", "(", ")", ";", "}", "public", "EObject", "control", "(", "EProc", "caller", ",", "int", "op", ",", "ByteBuffer", "cmd", ")", "throws", "Pausable", "{", "return", "task", ".", "control", "(", "caller", ",", "op", ",", "cmd", ")", ";", "}", "public", "EObject", "call", "(", "EProc", "caller", ",", "int", "op", ",", "EObject", "data", ")", "throws", "Pausable", "{", "return", "task", ".", "call", "(", "caller", ",", "op", ",", "data", ")", ";", "}", "public", "void", "command", "(", "EHandle", "caller", ",", "ByteBuffer", "[", "]", "out", ")", "throws", "Pausable", "{", "task", ".", "command", "(", "caller", ",", "out", ")", ";", "}", "@", "Override", "public", "boolean", "isOpen", "(", ")", "{", "return", "!", "task", ".", "isDone", "(", ")", ";", "}", "@", "Override", "public", "EObject", "port_info", "(", "EAtom", "spec", ")", "{", "if", "(", "task", ".", "isDone", "(", ")", ")", "return", "ERT", ".", "am_undefined", ";", "return", "task", ".", "port_info", "(", "spec", ")", ";", "}", "@", "Override", "public", "EObject", "get_data", "(", ")", "{", "EDriverTask", "dt", "=", "task", ";", "if", "(", "dt", "==", "null", ")", "return", "ERT", ".", "am_undefined", ";", "return", "dt", ".", "port_data", ";", "}", "@", "Override", "public", "void", "set_data", "(", "EObject", "data", ")", "{", "EDriverTask", "dt", "=", "task", ";", "if", "(", "dt", "!=", "null", ")", "dt", ".", "port_data", "=", "data", ";", "}", "public", "void", "set_owner", "(", "EInternalPID", "ipid", ")", "{", "EDriverTask", "dt", "=", "task", ";", "if", "(", "dt", "!=", "null", ")", "dt", ".", "owner", "(", "ipid", ")", ";", "}", "@", "Override", "public", "void", "close", "(", ")", "throws", "Pausable", "{", "EDriverTask", "dt", "=", "task", ";", "if", "(", "dt", "!=", "null", ")", "dt", ".", "close", "(", ")", ";", "}", "}", "</s>" ]
7,922
[ "<s>", "package", "erjang", ";", "import", "java", ".", "nio", ".", "ByteBuffer", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "concurrent", ".", "atomic", ".", "AtomicInteger", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "MethodVisitor", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "Opcodes", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "Type", ";", "public", "class", "EStringList", "extends", "ESeq", "{", "static", "class", "PrependableBytes", "{", "AtomicInteger", "start_pos", ";", "byte", "[", "]", "data", ";", "PrependableBytes", "(", "int", "size", ")", "{", "this", ".", "data", "=", "new", "byte", "[", "size", "]", ";", "this", ".", "start_pos", "=", "new", "AtomicInteger", "(", "data", ".", "length", ")", ";", "}", "PrependableBytes", "(", "int", "size", ",", "byte", "v", ")", "{", "this", ".", "data", "=", "new", "byte", "[", "size", "]", ";", "data", "[", "size", "-", "1", "]", "=", "v", ";", "this", ".", "start_pos", "=", "new", "AtomicInteger", "(", "data", ".", "length", "-", "1", ")", ";", "}", "PrependableBytes", "(", "byte", "[", "]", "org", ",", "int", "extra", ")", "{", "this", "(", "org", ",", "0", ",", "org", ".", "length", ",", "extra", ")", ";", "}", "PrependableBytes", "(", "byte", "[", "]", "org", ",", "int", "off", ",", "int", "len", ",", "int", "extra", ")", "{", "this", "(", "org", ".", "length", "+", "extra", ")", ";", "System", ".", "arraycopy", "(", "org", ",", "off", ",", "data", ",", "data", ".", "length", "-", "len", ",", "len", ")", ";", "}", "PrependableBytes", "prepend", "(", "int", "old_start", ",", "byte", "b", ")", "{", "assert", "(", "old_start", ">", "0", ")", ";", "int", "new_start", "=", "old_start", "-", "1", ";", "if", "(", "start_pos", ".", "compareAndSet", "(", "old_start", ",", "new_start", ")", ")", "{", "data", "[", "new_start", "]", "=", "b", ";", "return", "this", ";", "}", "else", "return", "null", ";", "}", "boolean", "prepend2", "(", "int", "old_start", ",", "byte", "b", ")", "{", "assert", "(", "old_start", ">", "0", ")", ";", "int", "new_start", "=", "old_start", "-", "1", ";", "if", "(", "start_pos", ".", "compareAndSet", "(", "old_start", ",", "new_start", ")", ")", "{", "data", "[", "new_start", "]", "=", "b", ";", "return", "true", ";", "}", "else", "return", "false", ";", "}", "PrependableBytes", "prepend", "(", "int", "old_start", ",", "byte", "[", "]", "org", ",", "int", "off", ",", "int", "len", ")", "{", "assert", "(", "old_start", ">", "0", ")", ";", "int", "new_start", "=", "old_start", "-", "len", ";", "if", "(", "start_pos", ".", "compareAndSet", "(", "old_start", ",", "new_start", ")", ")", "{", "System", ".", "arraycopy", "(", "org", ",", "off", ",", "data", ",", "new_start", ",", "len", ")", ";", "return", "this", ";", "}", "else", "return", "null", ";", "}", "}", "private", "static", "final", "int", "INITIAL_BUFFER_SIZE", "=", "10", ";", "final", "PrependableBytes", "bytes", ";", "final", "int", "off", ";", "final", "int", "len", ";", "final", "ESeq", "tail", ";", "private", "EStringList", "(", "PrependableBytes", "bytes", ",", "int", "off", ",", "int", "len", ",", "ESeq", "tail", ")", "{", "assert", "len", ">", "0", ";", "this", ".", "bytes", "=", "bytes", ";", "this", ".", "off", "=", "off", ";", "this", ".", "len", "=", "len", ";", "this", ".", "tail", "=", "tail", ";", "}", "public", "EStringList", "(", "byte", "value", ",", "ESeq", "tail", ")", "{", "this", "(", "new", "PrependableBytes", "(", "INITIAL_BUFFER_SIZE", ",", "value", ")", ",", "INITIAL_BUFFER_SIZE", "-", "1", ",", "1", ",", "tail", ")", ";", "}", "public", "EStringList", "(", "byte", "[", "]", "header", ",", "ESeq", "tail", ")", "{", "this", "(", "new", "PrependableBytes", "(", "header", ",", "INITIAL_BUFFER_SIZE", ")", ",", "INITIAL_BUFFER_SIZE", ",", "header", ".", "length", ",", "tail", ")", ";", "}", "public", "ECons", "testNonEmptyList", "(", ")", "{", "if", "(", "len", "==", "0", ")", "return", "tail", ".", "testNonEmptyList", "(", ")", ";", "return", "this", ";", "}", "public", "ESeq", "testSeq", "(", ")", "{", "return", "this", ";", "}", "@", "Override", "public", "ESeq", "cons", "(", "EObject", "h", ")", "{", "ESmall", "sm", "=", "h", ".", "testSmall", "(", ")", ";", "if", "(", "sm", "!=", "null", ")", "{", "int", "value", "=", "sm", ".", "value", ";", "if", "(", "(", "value", "&", "~", "0xff", ")", "==", "0", ")", "{", "if", "(", "off", "==", "0", ")", "return", "new", "EStringList", "(", "(", "byte", ")", "value", ",", "this", ")", ";", "if", "(", "bytes", ".", "prepend2", "(", "this", ".", "off", ",", "(", "byte", ")", "value", ")", ")", "{", "return", "new", "EStringList", "(", "bytes", ",", "off", "-", "1", ",", "len", "+", "1", ",", "tail", ")", ";", "}", "else", "{", "return", "new", "EStringList", "(", "(", "byte", ")", "value", ",", "this", ")", ";", "}", "}", "}", "return", "new", "EList", "(", "h", ",", "this", ")", ";", "}", "public", "EObject", "drop", "(", "int", "n", ")", "{", "if", "(", "n", ">", "len", ")", "throw", "new", "IllegalArgumentException", "(", ")", ";", "if", "(", "n", "==", "len", ")", "return", "tail", ";", "return", "new", "EStringList", "(", "bytes", ",", "off", "+", "n", ",", "len", "-", "n", ",", "tail", ")", ";", "}", "@", "Override", "public", "ESmall", "head", "(", ")", "{", "return", "ESmall", ".", "little", "[", "(", "bytes", ".", "data", "[", "off", "]", "&", "0xff", ")", "]", ";", "}", "@", "Override", "public", "ESeq", "tail", "(", ")", "{", "if", "(", "len", "==", "1", ")", "return", "tail", ";", "return", "new", "EStringList", "(", "bytes", ",", "off", "+", "1", ",", "len", "-", "1", ",", "tail", ")", ";", "}", "@", "Override", "public", "boolean", "isNil", "(", ")", "{", "assert", "len", "!=", "0", ";", "return", "false", ";", "}", "@", "Override", "public", "ENil", "testNil", "(", ")", "{", "if", "(", "isNil", "(", ")", ")", "return", "ERT", ".", "NIL", ";", "return", "null", ";", "}", "public", "EString", "testString", "(", ")", "{", "EString", "st", "=", "tail", ".", "testString", "(", ")", ";", "if", "(", "st", "==", "null", ")", "{", "return", "null", ";", "}", "byte", "[", "]", "out_bin", "=", "new", "byte", "[", "len", "+", "st", ".", "length", "(", ")", "]", ";", "System", ".", "arraycopy", "(", "this", ".", "bytes", ".", "data", ",", "this", ".", "off", ",", "out_bin", ",", "0", ",", "this", ".", "len", ")", ";", "System", ".", "arraycopy", "(", "st", ".", "data", ",", "st", ".", "off", ",", "out_bin", ",", "len", ",", "st", ".", "length", "(", ")", ")", ";", "return", "new", "EString", "(", "out_bin", ",", "0", ")", ";", "}", "private", "ESeq", "seq", "(", ")", "{", "return", "new", "Seq", "(", ")", ";", "}", "private", "class", "Seq", "extends", "ESeq", "{", "@", "Override", "public", "ECons", "testNonEmptyList", "(", ")", "{", "return", "EStringList", ".", "this", ".", "testNonEmptyList", "(", ")", ";", "}", "@", "Override", "public", "ESeq", "cons", "(", "EObject", "h", ")", "{", "return", "EStringList", ".", "this", ".", "cons", "(", "h", ")", ";", "}", "@", "Override", "public", "ESeq", "tail", "(", ")", "{", "return", "EStringList", ".", "this", ".", "tail", "(", ")", ";", "}", "@", "Override", "public", "EObject", "head", "(", ")", "{", "return", "EStringList", ".", "this", ".", "head", "(", ")", ";", "}", "@", "Override", "public", "void", "encode", "(", "EOutputStream", "eos", ")", "{", "EStringList", ".", "this", ".", "encode", "(", "eos", ")", ";", "}", "}", "private", "boolean", "all_printable", "(", ")", "{", "byte", "val", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "len", ";", "i", "++", ")", "{", "val", "=", "bytes", ".", "data", "[", "off", "+", "i", "]", ";", "if", "(", "val", "<", "'", "'", "||", "val", ">=", "127", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "if", "(", "tail", ".", "isNil", "(", ")", "&&", "all_printable", "(", ")", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "\"\\\"\"", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "len", ";", "i", "++", ")", "{", "byte", "val", "=", "bytes", ".", "data", "[", "off", "+", "i", "]", ";", "sb", ".", "append", "(", "(", "char", ")", "val", ")", ";", "}", "sb", ".", "append", "(", "'\"'", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "\"[\"", ")", ";", "int", "max", "=", "Math", ".", "min", "(", "len", ",", "40", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "max", ";", "i", "++", ")", "{", "if", "(", "i", "!=", "0", ")", "{", "sb", ".", "append", "(", "\",\"", ")", ";", "}", "byte", "val", "=", "bytes", ".", "data", "[", "off", "+", "i", "]", ";", "if", "(", "val", ">", "'", "'", "&&", "val", "<", "127", ")", "{", "sb", ".", "append", "(", "'$'", ")", ";", "sb", ".", "append", "(", "(", "char", ")", "val", ")", ";", "}", "else", "{", "sb", ".", "append", "(", "val", "&", "0xFF", ")", ";", "}", "}", "if", "(", "max", "!=", "len", ")", "{", "sb", ".", "append", "(", "\"...\"", ")", ";", "}", "if", "(", "!", "tail", ".", "isNil", "(", ")", ")", "{", "sb", ".", "append", "(", "'|'", ")", ";", "sb", ".", "append", "(", "tail", ")", ";", "}", "sb", ".", "append", "(", "\"]\"", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}", "@", "Override", "public", "boolean", "collectIOList", "(", "List", "<", "ByteBuffer", ">", "out", ")", "{", "out", ".", "add", "(", "ByteBuffer", ".", "wrap", "(", "bytes", ".", "data", ",", "off", ",", "len", ")", ")", ";", "return", "tail", ".", "collectIOList", "(", "out", ")", ";", "}", "@", "Override", "public", "void", "collectCharList", "(", "CharCollector", "out", ")", "throws", "CharCollector", ".", "CollectingException", ",", "CharCollector", ".", "InvalidElementException", ",", "IOException", "{", "try", "{", "out", ".", "addBinary", "(", "bytes", ".", "data", ",", "off", ",", "len", ")", ";", "}", "catch", "(", "CharCollector", ".", "PartialDecodingException", "e", ")", "{", "throw", "new", "CharCollector", ".", "CollectingException", "(", "drop", "(", "e", ".", "inputPos", "-", "off", ")", ")", ";", "}", "if", "(", "tail", ".", "testNumber", "(", ")", "!=", "null", ")", "{", "throw", "new", "CharCollector", ".", "InvalidElementException", "(", ")", ";", "}", "else", "tail", ".", "collectCharList", "(", "out", ")", ";", "}", "@", "Override", "public", "void", "encode", "(", "EOutputStream", "eos", ")", "{", "if", "(", "tail", ".", "isNil", "(", ")", ")", "{", "eos", ".", "write_string", "(", "bytes", ".", "data", ",", "off", ",", "len", ")", ";", "}", "else", "{", "eos", ".", "write_list_head", "(", "len", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "len", ";", "i", "++", ")", "{", "eos", ".", "write_int", "(", "bytes", ".", "data", "[", "off", "+", "i", "]", ")", ";", "}", "eos", ".", "write_any", "(", "tail", ")", ";", "}", "}", "public", "static", "EStringList", "fromString", "(", "String", "c", ",", "ESeq", "tail", ")", "{", "byte", "[", "]", "data", "=", "new", "byte", "[", "c", ".", "length", "(", ")", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "data", ".", "length", ";", "i", "++", ")", "{", "data", "[", "i", "]", "=", "(", "byte", ")", "c", ".", "charAt", "(", "i", ")", ";", "}", "return", "new", "EStringList", "(", "data", ",", "tail", ")", ";", "}", "private", "static", "final", "Type", "ESTRINGLIST_TYPE", "=", "Type", ".", "getType", "(", "EStringList", ".", "class", ")", ";", "private", "static", "final", "Type", "STRING_TYPE", "=", "Type", ".", "getType", "(", "String", ".", "class", ")", ";", "private", "static", "final", "String", "ESEQ_DESC", "=", "Type", ".", "getDescriptor", "(", "ESeq", ".", "class", ")", ";", "@", "Override", "public", "Type", "emit_const", "(", "MethodVisitor", "fa", ")", "{", "Type", "type", "=", "ESTRINGLIST_TYPE", ";", "char", "[", "]", "ch", "=", "new", "char", "[", "len", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "len", ";", "i", "++", ")", "{", "ch", "[", "i", "]", "=", "(", "char", ")", "(", "0xff", "&", "(", "int", ")", "bytes", ".", "data", "[", "off", "+", "i", "]", ")", ";", "}", "fa", ".", "visitLdcInsn", "(", "new", "String", "(", "ch", ")", ")", ";", "tail", ".", "emit_const", "(", "fa", ")", ";", "fa", ".", "visitMethodInsn", "(", "Opcodes", ".", "INVOKESTATIC", ",", "type", ".", "getInternalName", "(", ")", ",", "\"fromString\"", ",", "\"(\"", "+", "STRING_TYPE", ".", "getDescriptor", "(", ")", "+", "ESEQ_DESC", "+", "\")\"", "+", "type", ".", "getDescriptor", "(", ")", ")", ";", "return", "type", ";", "}", "}", "</s>" ]
7,923
[ "<s>", "package", "erjang", ";", "public", "class", "ErlangRaise", "extends", "ErlangException", "{", "private", "final", "EAtom", "exClass", ";", "private", "final", "ESeq", "trace", ";", "public", "ErlangRaise", "(", "EAtom", "ex_class", ",", "EObject", "reason", ",", "ESeq", "trace", ")", "{", "super", "(", "reason", ")", ";", "this", ".", "exClass", "=", "ex_class", ";", "this", ".", "trace", "=", "trace", ";", "}", "@", "Override", "public", "EObject", "reason", "(", ")", "{", "if", "(", "exClass", "==", "am_error", ")", "{", "return", "ETuple", ".", "make", "(", "super", ".", "reason", "(", ")", ",", "getTrace", "(", ")", ")", ";", "}", "else", "{", "return", "super", ".", "reason", "(", ")", ";", "}", "}", "@", "Override", "public", "EAtom", "getExClass", "(", ")", "{", "return", "exClass", ";", "}", "@", "Override", "public", "ESeq", "getTrace", "(", ")", "{", "return", "trace", ";", "}", "@", "Override", "public", "EObject", "getCatchValue", "(", ")", "{", "if", "(", "exClass", "==", "am_throw", ")", "return", "reason", "(", ")", ";", "else", "return", "ETuple", ".", "make", "(", "ERT", ".", "am_EXIT", ",", "reason", "(", ")", ")", ";", "}", "}", "</s>" ]
7,924
[ "<s>", "package", "erjang", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Method", ";", "import", "java", ".", "util", ".", "Collections", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "WeakHashMap", ";", "import", "java", ".", "util", ".", "regex", ".", "Matcher", ";", "import", "java", ".", "util", ".", "regex", ".", "Pattern", ";", "import", "erjang", ".", "beam", ".", "EUtil", ";", "public", "abstract", "class", "ErlangException", "extends", "RuntimeException", "{", "public", "static", "final", "EAtom", "am_java_exception", "=", "EAtom", ".", "intern", "(", "\"\"", ")", ";", "static", "final", "EAtom", "am_error", "=", "EAtom", ".", "intern", "(", "\"error\"", ")", ";", "static", "final", "EAtom", "am_throw", "=", "EAtom", ".", "intern", "(", "\"throw\"", ")", ";", "static", "final", "EAtom", "am_exit", "=", "EAtom", ".", "intern", "(", "\"exit\"", ")", ";", "private", "EObject", "reason", ";", "public", "abstract", "EAtom", "getExClass", "(", ")", ";", "public", "ErlangException", "(", "EObject", "reason", ")", "{", "this", ".", "reason", "=", "reason", ";", "}", "public", "ErlangException", "(", "EObject", "reason", ",", "Throwable", "cause", ")", "{", "super", "(", "cause", ")", ";", "this", ".", "reason", "=", "reason", ";", "}", "public", "ErlangException", "(", "Throwable", "cause", ")", "{", "super", "(", "cause", ")", ";", "this", ".", "reason", "=", "am_java_exception", ";", "}", "public", "EObject", "reason", "(", ")", "{", "return", "reason", ";", "}", "@", "Override", "public", "String", "getMessage", "(", ")", "{", "return", "String", ".", "valueOf", "(", "reason", "(", ")", ")", ";", "}", "public", "EObject", "getCatchValue", "(", ")", "{", "return", "new", "ExceptionTuple", "(", "this", ")", ";", "}", "private", "static", "final", "class", "ExceptionTuple", "extends", "ETuple", "{", "private", "final", "ErlangException", "e", ";", "private", "ETuple", "instance", ";", "protected", "ETuple", "instantiate", "(", ")", "{", "if", "(", "instance", "==", "null", ")", "{", "if", "(", "e", "instanceof", "ErlangThrow", ")", "{", "instance", "=", "new", "ETuple2", "(", "ERT", ".", "am_EXIT", ",", "e", ".", "reason", ")", ";", "}", "else", "if", "(", "e", "instanceof", "ErlangExit", ")", "{", "instance", "=", "new", "ETuple2", "(", "ERT", ".", "am_EXIT", ",", "e", ".", "reason", ")", ";", "}", "else", "{", "ETuple2", "reason_plus_trace", "=", "new", "ETuple2", "(", "e", ".", "reason", ",", "e", ".", "getTrace", "(", ")", ")", ";", "instance", "=", "new", "ETuple2", "(", "ERT", ".", "am_EXIT", ",", "reason_plus_trace", ")", ";", "}", "}", "return", "instance", ";", "}", "public", "int", "arity", "(", ")", "{", "return", "instantiate", "(", ")", ".", "arity", "(", ")", ";", "}", "public", "EObject", "elm", "(", "int", "i", ")", "{", "return", "instantiate", "(", ")", ".", "elm", "(", "i", ")", ";", "}", "public", "void", "set", "(", "int", "index", ",", "EObject", "term", ")", "{", "throw", "new", "IllegalStateException", "(", ")", ";", "}", "public", "ETuple", "blank", "(", ")", "{", "return", "instantiate", "(", ")", ".", "blank", "(", ")", ";", "}", "private", "ExceptionTuple", "(", "ErlangException", "e", ")", "{", "this", ".", "e", "=", "e", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "testTuple", "(", ")", ".", "toString", "(", ")", ";", "}", "@", "Override", "int", "cmp_order", "(", ")", "{", "return", "testTuple", "(", ")", ".", "cmp_order", "(", ")", ";", "}", "@", "Override", "int", "compare_same", "(", "EObject", "rhs", ")", "{", "return", "testTuple", "(", ")", ".", "compare_same", "(", "rhs", ")", ";", "}", "@", "Override", "public", "ETuple", "testTuple", "(", ")", "{", "return", "instantiate", "(", ")", ";", "}", "}", "static", "Map", "<", "StackTraceElement", ",", "ETuple3", ">", "cache", "=", "Collections", ".", "synchronizedMap", "(", "new", "WeakHashMap", "<", "StackTraceElement", ",", "ETuple3", ">", "(", ")", ")", ";", "public", "ESeq", "getTrace", "(", ")", "{", "return", "decodeTrace", "(", "getStackTrace", "(", ")", ")", ";", "}", "public", "ESeq", "getLazyTrace", "(", ")", "{", "return", "new", "ELazySeq", "(", ")", "{", "@", "Override", "protected", "ESeq", "initialValue", "(", ")", "{", "return", "getTrace", "(", ")", ";", "}", "}", ";", "}", "public", "static", "ESeq", "decodeTrace", "(", "StackTraceElement", "[", "]", "st", ")", "{", "ESeq", "trace", "=", "ERT", ".", "NIL", ";", "for", "(", "int", "i", "=", "st", ".", "length", "-", "1", ";", "i", ">", "0", ";", "i", "--", ")", "{", "StackTraceElement", "st2", "=", "st", "[", "i", "]", ";", "ETuple3", "elem", ";", "if", "(", "(", "elem", "=", "cache", ".", "get", "(", "st2", ")", ")", "!=", "null", ")", "{", "trace", "=", "trace", ".", "cons", "(", "elem", ")", ";", "continue", ";", "}", "if", "(", "(", "elem", "=", "decodeTraceElem", "(", "st2", ")", ")", "!=", "null", ")", "{", "trace", "=", "trace", ".", "cons", "(", "elem", ")", ";", "}", "}", "return", "trace", ";", "}", "public", "static", "final", "String", "ERJANG_MODULES_DOT", "=", "\"erjang.m.\"", ";", "private", "static", "ETuple3", "decodeTraceElem", "(", "StackTraceElement", "st", ")", "{", "String", "cname", "=", "st", ".", "getClassName", "(", ")", ";", "String", "mname", "=", "st", ".", "getMethodName", "(", ")", ";", "EAtom", "module", "=", "null", ";", "if", "(", "cname", ".", "startsWith", "(", "ERJANG_MODULES_DOT", ")", ")", "{", "int", "last", "=", "cname", ".", "lastIndexOf", "(", "'.'", ")", ";", "module", "=", "EAtom", ".", "intern", "(", "cname", ".", "substring", "(", "ERJANG_MODULES_DOT", ".", "length", "(", ")", ",", "last", ")", ")", ";", "}", "EAtom", "function", "=", "null", ";", "int", "arity", "=", "-", "1", ";", "{", "int", "i", ";", "char", "c", ";", "int", "w", "=", "1", ";", "int", "a", "=", "0", ";", "for", "(", "i", "=", "mname", ".", "length", "(", ")", "-", "1", ";", "i", ">=", "2", "&&", "(", "c", "=", "mname", ".", "charAt", "(", "i", ")", ")", ">=", "'0'", "&&", "c", "<=", "'9'", ";", "i", "--", ",", "w", "*=", "10", ")", "{", "a", "+=", "w", "*", "(", "c", "-", "'0'", ")", ";", "}", "if", "(", "w", ">", "1", "&&", "mname", ".", "charAt", "(", "i", ")", "==", "'_'", "&&", "mname", ".", "charAt", "(", "i", "-", "1", ")", "==", "'_'", ")", "{", "String", "method_name", "=", "mname", ".", "substring", "(", "0", ",", "i", "-", "1", ")", ";", "function", "=", "EAtom", ".", "intern", "(", "EUtil", ".", "decodeJavaName", "(", "method_name", ")", ")", ";", "arity", "=", "a", ";", "}", "}", "if", "(", "module", "!=", "null", "&&", "function", "!=", "null", "&&", "arity", "!=", "-", "1", ")", "{", "ETuple3", "res", "=", "new", "ETuple3", "(", ")", ";", "res", ".", "elem1", "=", "module", ";", "res", ".", "elem2", "=", "function", ";", "res", ".", "elem3", "=", "new", "ESmall", "(", "arity", ")", ";", "return", "res", ";", "}", "if", "(", "mname", ".", "endsWith", "(", "\"$call\"", ")", "||", "mname", ".", "equals", "(", "\"go\"", ")", "||", "mname", ".", "equals", "(", "\"invoke\"", ")", ")", "return", "null", ";", "Class", "clazz", "=", "null", ";", "try", "{", "clazz", "=", "Class", ".", "forName", "(", "cname", ")", ";", "}", "catch", "(", "ClassNotFoundException", "e", ")", "{", "return", "null", ";", "}", "Method", "m", "=", "find_method", "(", "clazz", ",", "mname", ")", ";", "if", "(", "m", "==", "null", ")", "return", "null", ";", "BIF", "bif", "=", "m", ".", "getAnnotation", "(", "BIF", ".", "class", ")", ";", "if", "(", "bif", "==", "null", ")", "return", "null", ";", "return", "resolve", "(", "clazz", ",", "m", ",", "bif", ")", ";", "}", "private", "static", "ETuple3", "resolve", "(", "Class", "<", "?", ">", "c", ",", "Method", "m", ",", "BIF", "ann1", ")", "{", "if", "(", "ann1", "==", "null", ")", "return", "null", ";", "String", "module", "=", "get_class_module", "(", "c", ")", ";", "String", "fun", "=", "null", ";", "if", "(", "ann1", "!=", "null", "&&", "!", "(", "\"__SELFNAME__\"", ".", "equals", "(", "ann1", ".", "name", "(", ")", ")", ")", ")", "{", "fun", "=", "ann1", ".", "name", "(", ")", ";", "}", "if", "(", "fun", "==", "null", ")", "{", "fun", "=", "m", ".", "getName", "(", ")", ";", "}", "Class", "<", "?", ">", "[", "]", "parameterTypes", "=", "m", ".", "getParameterTypes", "(", ")", ";", "int", "arity", "=", "parameterTypes", ".", "length", ";", "if", "(", "arity", ">", "0", ")", "{", "if", "(", "parameterTypes", "[", "0", "]", ".", "equals", "(", "EProc", ".", "class", ")", ")", "arity", "-=", "1", ";", "}", "if", "(", "module", "!=", "null", "&&", "fun", "!=", "null", ")", "{", "ETuple3", "res", "=", "new", "ETuple3", "(", ")", ";", "res", ".", "elem1", "=", "EAtom", ".", "intern", "(", "module", ")", ";", "res", ".", "elem2", "=", "EAtom", ".", "intern", "(", "fun", ")", ";", "res", ".", "elem3", "=", "ESmall", ".", "make", "(", "arity", ")", ";", "return", "res", ";", "}", "else", "{", "return", "null", ";", "}", "}", "private", "static", "String", "get_class_module", "(", "Class", "<", "?", ">", "c", ")", "{", "Module", "m", "=", "c", ".", "getAnnotation", "(", "Module", ".", "class", ")", ";", "if", "(", "m", "!=", "null", ")", "{", "return", "m", ".", "value", "(", ")", ";", "}", "else", "{", "String", "cname", "=", "c", ".", "getName", "(", ")", ";", "if", "(", "cname", ".", "startsWith", "(", "ERJANG_MODULES_DOT", ")", ")", "{", "int", "last", "=", "cname", ".", "lastIndexOf", "(", "'.'", ")", ";", "return", "cname", ".", "substring", "(", "ERJANG_MODULES_DOT", ".", "length", "(", ")", ",", "last", ")", ";", "}", "}", "return", "null", ";", "}", "private", "static", "Method", "find_method", "(", "Class", "<", "?", ">", "c", ",", "String", "mname", ")", "{", "Method", "[", "]", "methods", "=", "c", ".", "getDeclaredMethods", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "methods", ".", "length", ";", "i", "++", ")", "{", "if", "(", "methods", "[", "i", "]", ".", "getName", "(", ")", ".", "equals", "(", "mname", ")", ")", "return", "methods", "[", "i", "]", ";", "}", "return", "null", ";", "}", "private", "static", "final", "EAtom", "UNKNOWN", "=", "EAtom", ".", "intern", "(", "\"unknown\"", ")", ";", "private", "EObject", "erl_value", "(", "Object", "val", ")", "{", "if", "(", "val", "instanceof", "EObject", ")", "return", "(", "EObject", ")", "val", ";", "if", "(", "val", "instanceof", "String", ")", "return", "EString", ".", "fromString", "(", "(", "String", ")", "val", ")", ";", "if", "(", "val", "instanceof", "Integer", ")", "return", "ESmall", ".", "make", "(", "(", "(", "Integer", ")", "val", ")", ".", "intValue", "(", ")", ")", ";", "throw", "new", "Error", "(", ")", ";", "}", "public", "ETuple3", "getTryValue", "(", ")", "{", "ETuple3", "result", "=", "new", "ETuple3", "(", ")", ";", "result", ".", "elem1", "=", "getExClass", "(", ")", ";", "result", ".", "elem2", "=", "reason", ";", "result", ".", "elem3", "=", "wrapAsObject", "(", ")", ";", "return", "result", ";", "}", "public", "ExceptionAsObject", "wrapAsObject", "(", ")", "{", "return", "new", "ExceptionAsObject", "(", ")", ";", "}", "public", "class", "ExceptionAsObject", "extends", "EPseudoTerm", "{", "public", "ErlangException", "getException", "(", ")", "{", "return", "ErlangException", ".", "this", ";", "}", "@", "Override", "public", "int", "hashCode", "(", ")", "{", "return", "System", ".", "identityHashCode", "(", "this", ")", ";", "}", "}", "}", "</s>" ]
7,925
[ "<s>", "package", "erjang", ";", "import", "java", ".", "util", ".", "Properties", ";", "import", "java", ".", "util", ".", "logging", ".", "Level", ";", "import", "java", ".", "util", ".", "logging", ".", "Logger", ";", "import", "java", ".", "io", ".", "FileInputStream", ";", "import", "java", ".", "io", ".", "IOException", ";", "public", "class", "ErjangConfig", "{", "static", "final", "Logger", "log", "=", "Logger", ".", "getLogger", "(", "\"\"", ")", ";", "static", "{", "String", "configFileName", "=", "System", ".", "getProperty", "(", "\"\"", ")", ";", "if", "(", "configFileName", "!=", "null", "&&", "configFileName", ".", "trim", "(", ")", ".", "length", "(", ")", ">", "0", ")", "{", "try", "{", "FileInputStream", "in", "=", "new", "FileInputStream", "(", "configFileName", ".", "trim", "(", ")", ")", ";", "try", "{", "Properties", "properties", "=", "new", "Properties", "(", ")", ";", "properties", ".", "load", "(", "in", ")", ";", "for", "(", "String", "name", ":", "properties", ".", "stringPropertyNames", "(", ")", ")", "{", "if", "(", "name", ".", "startsWith", "(", "\"erjang.\"", ")", "&&", "System", ".", "getProperty", "(", "name", ")", "==", "null", ")", "{", "System", ".", "setProperty", "(", "name", ",", "properties", ".", "getProperty", "(", "name", ")", ")", ";", "}", "}", "}", "finally", "{", "in", ".", "close", "(", ")", ";", "}", "}", "catch", "(", "IOException", "ioe", ")", "{", "log", ".", "warning", "(", "\"\"", "+", "configFileName", "+", "\":", "\"", "+", "ioe", ".", "getMessage", "(", ")", ")", ";", "log", ".", "log", "(", "Level", ".", "FINE", ",", "\"details:", "\"", ",", "ioe", ")", ";", "}", "}", "}", "public", "static", "void", "init", "(", ")", "{", "}", "public", "static", "boolean", "getBoolean", "(", "String", "propname", ")", "{", "return", "Boolean", ".", "getBoolean", "(", "propname", ")", ";", "}", "public", "static", "int", "getInteger", "(", "String", "propname", ")", "{", "return", "Integer", ".", "getInteger", "(", "propname", ")", ";", "}", "public", "static", "String", "getString", "(", "String", "propname", ")", "{", "return", "System", ".", "getProperty", "(", "propname", ")", ";", "}", "public", "static", "String", "getString", "(", "String", "propname", ",", "String", "fallback", ")", "{", "return", "System", ".", "getProperty", "(", "propname", ",", "fallback", ")", ";", "}", "public", "static", "boolean", "hasString", "(", "String", "propname", ")", "{", "return", "(", "System", ".", "getProperty", "(", "propname", ")", "!=", "null", ")", ";", "}", "}", "</s>" ]
7,926
[ "<s>", "package", "erjang", ";", "import", "java", ".", "math", ".", "BigInteger", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "MethodVisitor", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "Opcodes", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "Type", ";", "public", "final", "class", "EBig", "extends", "EInteger", "{", "private", "static", "final", "BigInteger", "BIG_32", "=", "BigInteger", ".", "valueOf", "(", "32", ")", ";", "private", "static", "final", "BigInteger", "BIG_MAX_INT", "=", "BigInteger", ".", "valueOf", "(", "Integer", ".", "MAX_VALUE", ")", ";", "private", "static", "final", "BigInteger", "BIG_MIN_INT", "=", "BigInteger", ".", "valueOf", "(", "Integer", ".", "MIN_VALUE", ")", ";", "final", "BigInteger", "value", ";", "public", "EBig", "(", "BigInteger", "value", ")", "{", "this", ".", "value", "=", "value", ";", "assert", "(", "value", ".", "compareTo", "(", "BIG_MAX_INT", ")", ">", "0", "||", "value", ".", "compareTo", "(", "BIG_MIN_INT", ")", "<", "0", ")", ";", "}", "public", "EInteger", "dec", "(", ")", "{", "return", "(", "EInteger", ")", "ESmall", ".", "MINUS_ONE", ".", "add", "(", "this", ")", ";", "}", "public", "EBig", "testBig", "(", ")", "{", "return", "this", ";", "}", "@", "Override", "int", "compare_same", "(", "EObject", "rhs", ")", "{", "return", "rhs", ".", "r_compare_same", "(", "this", ")", ";", "}", "int", "r_compare_same", "(", "ESmall", "lhs", ")", "{", "return", "-", "value", ".", "signum", "(", ")", ";", "}", "int", "r_compare_same", "(", "EBig", "lhs", ")", "{", "return", "lhs", ".", "value", ".", "compareTo", "(", "value", ")", ";", "}", "int", "r_compare_same", "(", "EDouble", "lhs", ")", "{", "double", "doubleValue", "=", "value", ".", "doubleValue", "(", ")", ";", "return", "lhs", ".", "value", "<", "doubleValue", "?", "-", "1", ":", "lhs", ".", "value", "==", "doubleValue", "?", "0", ":", "1", ";", "}", "@", "Override", "public", "boolean", "equalsExactly", "(", "EObject", "rhs", ")", "{", "return", "rhs", ".", "r_equals_exactly", "(", "this", ")", ";", "}", "boolean", "r_equals_exactly", "(", "EBig", "lhs", ")", "{", "return", "lhs", ".", "value", ".", "equals", "(", "value", ")", ";", "}", "@", "Override", "public", "int", "hashCode", "(", ")", "{", "return", "value", ".", "hashCode", "(", ")", ";", "}", "public", "EBig", "(", "long", "res", ")", "{", "this", ".", "value", "=", "BigInteger", ".", "valueOf", "(", "res", ")", ";", "}", "@", "Override", "public", "int", "intValue", "(", ")", "{", "return", "value", ".", "intValue", "(", ")", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "value", ".", "toString", "(", ")", ";", "}", "public", "static", "EBig", "fromString", "(", "String", "value", ")", "{", "return", "new", "EBig", "(", "new", "BigInteger", "(", "value", ")", ")", ";", "}", "private", "static", "final", "Type", "EBIG_TYPE", "=", "Type", ".", "getType", "(", "EBig", ".", "class", ")", ";", "private", "static", "final", "Type", "STRING_TYPE", "=", "Type", ".", "getType", "(", "String", ".", "class", ")", ";", "@", "Override", "public", "org", ".", "objectweb", ".", "asm", ".", "Type", "emit_const", "(", "MethodVisitor", "fa", ")", "{", "Type", "type", "=", "EBIG_TYPE", ";", "fa", ".", "visitLdcInsn", "(", "value", ".", "toString", "(", ")", ")", ";", "fa", ".", "visitMethodInsn", "(", "Opcodes", ".", "INVOKESTATIC", ",", "type", ".", "getInternalName", "(", ")", ",", "\"fromString\"", ",", "\"(\"", "+", "STRING_TYPE", ".", "getDescriptor", "(", ")", "+", "\")\"", "+", "type", ".", "getDescriptor", "(", ")", ")", ";", "return", "type", ";", "}", "@", "Override", "public", "EBig", "abs", "(", ")", "{", "return", "new", "EBig", "(", "value", ".", "abs", "(", ")", ")", ";", "}", "public", "ENumber", "add", "(", "EObject", "other", ",", "boolean", "guard", ")", "{", "return", "other", ".", "add", "(", "value", ",", "guard", ")", ";", "}", "public", "ENumber", "add", "(", "int", "lhs", ",", "boolean", "guard", ")", "{", "return", "ERT", ".", "box", "(", "BigInteger", ".", "valueOf", "(", "lhs", ")", ".", "add", "(", "value", ")", ")", ";", "}", "public", "ENumber", "add", "(", "double", "lhs", ",", "boolean", "guard", ")", "{", "return", "ERT", ".", "box", "(", "lhs", "+", "value", ".", "doubleValue", "(", ")", ")", ";", "}", "public", "ENumber", "add", "(", "BigInteger", "lhs", ",", "boolean", "guard", ")", "{", "return", "ERT", ".", "box", "(", "lhs", ".", "add", "(", "value", ")", ")", ";", "}", "public", "EInteger", "subtract", "(", "int", "rhs", ")", "{", "return", "ERT", ".", "box", "(", "value", ".", "subtract", "(", "BigInteger", ".", "valueOf", "(", "rhs", ")", ")", ")", ";", "}", "public", "ENumber", "subtract", "(", "EObject", "other", ",", "boolean", "guard", ")", "{", "return", "other", ".", "r_subtract", "(", "value", ",", "guard", ")", ";", "}", "ENumber", "r_subtract", "(", "int", "lhs", ",", "boolean", "guard", ")", "{", "return", "ERT", ".", "box", "(", "BigInteger", ".", "valueOf", "(", "lhs", ")", ".", "subtract", "(", "value", ")", ")", ";", "}", "ENumber", "r_subtract", "(", "double", "lhs", ",", "boolean", "guard", ")", "{", "return", "ERT", ".", "box", "(", "lhs", "-", "value", ".", "doubleValue", "(", ")", ")", ";", "}", "ENumber", "r_subtract", "(", "BigInteger", "lhs", ",", "boolean", "guard", ")", "{", "return", "ERT", ".", "box", "(", "lhs", ".", "subtract", "(", "value", ")", ")", ";", "}", "public", "EInteger", "idiv", "(", "EObject", "other", ")", "{", "return", "other", ".", "r_idiv", "(", "value", ")", ";", "}", "public", "EInteger", "idiv", "(", "int", "rhs", ")", "{", "return", "ERT", ".", "box", "(", "value", ".", "divide", "(", "BigInteger", ".", "valueOf", "(", "rhs", ")", ")", ")", ";", "}", "EInteger", "r_idiv", "(", "int", "lhs", ")", "{", "return", "ERT", ".", "box", "(", "BigInteger", ".", "valueOf", "(", "lhs", ")", ".", "divide", "(", "value", ")", ")", ";", "}", "EInteger", "r_idiv", "(", "BigInteger", "lhs", ")", "{", "return", "ERT", ".", "box", "(", "lhs", ".", "divide", "(", "value", ")", ")", ";", "}", "public", "EInteger", "irem", "(", "EObject", "other", ")", "{", "return", "other", ".", "r_irem", "(", "value", ")", ";", "}", "EInteger", "r_irem", "(", "int", "lhs", ")", "{", "return", "ERT", ".", "box", "(", "BigInteger", ".", "valueOf", "(", "lhs", ")", ".", "remainder", "(", "value", ")", ")", ";", "}", "EInteger", "r_irem", "(", "BigInteger", "lhs", ")", "{", "return", "ERT", ".", "box", "(", "lhs", ".", "remainder", "(", "value", ")", ")", ";", "}", "public", "EDouble", "divide", "(", "EObject", "other", ")", "{", "return", "other", ".", "r_divide", "(", "value", ")", ";", "}", "EDouble", "r_divide", "(", "int", "lhs", ")", "{", "return", "ERT", ".", "box", "(", "lhs", "/", "value", ".", "doubleValue", "(", ")", ")", ";", "}", "EDouble", "r_divide", "(", "double", "lhs", ")", "{", "return", "ERT", ".", "box", "(", "lhs", "/", "value", ".", "doubleValue", "(", ")", ")", ";", "}", "EDouble", "r_divide", "(", "BigInteger", "lhs", ")", "{", "return", "ERT", ".", "box", "(", "lhs", ".", "doubleValue", "(", ")", "/", "value", ".", "doubleValue", "(", ")", ")", ";", "}", "public", "ENumber", "multiply", "(", "EObject", "other", ")", "{", "return", "other", ".", "r_multiply", "(", "value", ")", ";", "}", "public", "ENumber", "r_multiply", "(", "int", "lhs", ")", "{", "return", "ERT", ".", "box", "(", "BigInteger", ".", "valueOf", "(", "lhs", ")", ".", "multiply", "(", "value", ")", ")", ";", "}", "public", "EDouble", "r_multiply", "(", "double", "lhs", ")", "{", "return", "ERT", ".", "box", "(", "lhs", "*", "value", ".", "doubleValue", "(", ")", ")", ";", "}", "public", "ENumber", "r_multiply", "(", "BigInteger", "lhs", ")", "{", "return", "ERT", ".", "box", "(", "lhs", ".", "multiply", "(", "value", ")", ")", ";", "}", "public", "EInteger", "bsr", "(", "EObject", "other", ")", "{", "return", "other", ".", "r_bsr", "(", "value", ")", ";", "}", "EInteger", "r_bsr", "(", "int", "lhs", ")", "{", "if", "(", "BIG_32", ".", "compareTo", "(", "value", ")", "<=", "0", ")", "{", "if", "(", "lhs", "<", "0", ")", "return", "ESmall", ".", "MINUS_ONE", ";", "else", "return", "ESmall", ".", "ZERO", ";", "}", "else", "{", "return", "ERT", ".", "box", "(", "lhs", ">>", "value", ".", "intValue", "(", ")", ")", ";", "}", "}", "EInteger", "r_bsr", "(", "BigInteger", "lhs", ")", "{", "if", "(", "BIG_MAX_INT", ".", "compareTo", "(", "value", ")", "<", "0", ")", "{", "if", "(", "BigInteger", ".", "ZERO", ".", "compareTo", "(", "lhs", ")", ">", "0", ")", "return", "ESmall", ".", "MINUS_ONE", ";", "else", "return", "ESmall", ".", "ZERO", ";", "}", "else", "{", "return", "ERT", ".", "box", "(", "lhs", ".", "shiftRight", "(", "value", ".", "intValue", "(", ")", ")", ")", ";", "}", "}", "public", "EInteger", "bsl", "(", "EObject", "other", ")", "{", "return", "other", ".", "r_bsl", "(", "value", ")", ";", "}", "EInteger", "r_bsl", "(", "int", "lhs", ")", "{", "return", "ERT", ".", "box", "(", "BigInteger", ".", "valueOf", "(", "lhs", ")", ".", "shiftLeft", "(", "value", ".", "intValue", "(", ")", ")", ")", ";", "}", "EInteger", "r_bsl", "(", "BigInteger", "lhs", ")", "{", "return", "ERT", ".", "box", "(", "lhs", ".", "shiftLeft", "(", "value", ".", "intValue", "(", ")", ")", ")", ";", "}", "public", "EInteger", "band", "(", "EObject", "other", ")", "{", "return", "other", ".", "band", "(", "value", ")", ";", "}", "public", "EInteger", "band", "(", "int", "lhs", ")", "{", "return", "ERT", ".", "box", "(", "BigInteger", ".", "valueOf", "(", "lhs", ")", ".", "and", "(", "value", ")", ")", ";", "}", "public", "EInteger", "band", "(", "BigInteger", "lhs", ")", "{", "return", "ERT", ".", "box", "(", "lhs", ".", "and", "(", "value", ")", ")", ";", "}", "public", "EInteger", "bor", "(", "EObject", "other", ")", "{", "return", "other", ".", "bor", "(", "value", ")", ";", "}", "public", "EInteger", "bor", "(", "int", "lhs", ")", "{", "return", "ERT", ".", "box", "(", "BigInteger", ".", "valueOf", "(", "lhs", ")", ".", "or", "(", "value", ")", ")", ";", "}", "public", "EInteger", "bor", "(", "BigInteger", "lhs", ")", "{", "return", "ERT", ".", "box", "(", "lhs", ".", "or", "(", "value", ")", ")", ";", "}", "public", "EInteger", "bxor", "(", "EObject", "other", ")", "{", "return", "other", ".", "bxor", "(", "value", ")", ";", "}", "public", "EInteger", "bxor", "(", "int", "lhs", ")", "{", "return", "ERT", ".", "box", "(", "BigInteger", ".", "valueOf", "(", "lhs", ")", ".", "xor", "(", "value", ")", ")", ";", "}", "public", "EInteger", "bxor", "(", "BigInteger", "lhs", ")", "{", "return", "ERT", ".", "box", "(", "lhs", ".", "xor", "(", "value", ")", ")", ";", "}", "public", "EInteger", "bnot", "(", ")", "{", "return", "ERT", ".", "box", "(", "value", ".", "not", "(", ")", ")", ";", "}", "@", "Override", "public", "ENumber", "negate", "(", ")", "{", "return", "ERT", ".", "box", "(", "value", ".", "negate", "(", ")", ")", ";", "}", "@", "Override", "BigInteger", "bigintValue", "(", ")", "{", "return", "value", ";", "}", "@", "Override", "public", "double", "doubleValue", "(", ")", "{", "return", "value", ".", "doubleValue", "(", ")", ";", "}", "@", "Override", "public", "void", "encode", "(", "EOutputStream", "eos", ")", "{", "eos", ".", "write_big_integer", "(", "value", ")", ";", "}", "}", "</s>" ]
7,927
[ "<s>", "package", "erjang", ";", "import", "java", ".", "io", ".", "ByteArrayOutputStream", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "nio", ".", "ByteBuffer", ";", "import", "java", ".", "nio", ".", "charset", ".", "Charset", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "MethodVisitor", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "Opcodes", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "Type", ";", "public", "class", "EString", "extends", "ESeq", "implements", "CharSequence", "{", "private", "static", "final", "Charset", "ISO_LATIN_1", "=", "Charset", ".", "forName", "(", "\"ISO-8859-1\"", ")", ";", "private", "static", "final", "EString", "EMPTY", "=", "new", "EString", "(", "\"\"", ")", ";", "final", "byte", "[", "]", "data", ";", "final", "int", "off", ";", "private", "int", "hash", "=", "-", "1", ";", "public", "EString", "(", "String", "value", ")", "{", "this", ".", "hash", "=", "value", ".", "hashCode", "(", ")", ";", "this", ".", "data", "=", "value", ".", "getBytes", "(", "ISO_LATIN_1", ")", ";", "this", ".", "off", "=", "0", ";", "}", "public", "EString", "testString", "(", ")", "{", "return", "this", ";", "}", "EString", "(", "byte", "[", "]", "data", ",", "int", "off", ")", "{", "this", ".", "data", "=", "data", ";", "this", ".", "off", "=", "off", ";", "}", "EString", "(", "byte", "[", "]", "data", ",", "int", "off", ",", "int", "len", ")", "{", "if", "(", "data", ".", "length", "==", "off", "+", "len", ")", "{", "this", ".", "data", "=", "data", ";", "this", ".", "off", "=", "off", ";", "}", "else", "{", "this", ".", "data", "=", "new", "byte", "[", "len", "]", ";", "this", ".", "off", "=", "0", ";", "System", ".", "arraycopy", "(", "data", ",", "off", ",", "this", ".", "data", ",", "0", ",", "len", ")", ";", "}", "}", "public", "static", "EString", "make", "(", "byte", "[", "]", "array", ",", "int", "arrayOffset", ",", "int", "len", ")", "{", "if", "(", "len", "==", "array", ".", "length", "-", "arrayOffset", ")", "{", "return", "new", "EString", "(", "array", ",", "arrayOffset", ")", ";", "}", "else", "{", "byte", "[", "]", "copy", "=", "new", "byte", "[", "len", "]", ";", "System", ".", "arraycopy", "(", "array", ",", "arrayOffset", ",", "copy", ",", "0", ",", "len", ")", ";", "return", "new", "EString", "(", "copy", ",", "0", ")", ";", "}", "}", "public", "static", "ESeq", "make", "(", "ECons", "list", ")", "{", "EString", "s", ";", "if", "(", "(", "s", "=", "list", ".", "testString", "(", ")", ")", "!=", "null", ")", "{", "return", "s", ";", "}", "else", "if", "(", "list", ".", "isNil", "(", ")", ")", "{", "return", "EString", ".", "EMPTY", ";", "}", "else", "{", "ByteArrayOutputStream", "barr", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "EObject", "tail", "=", "list", ";", "while", "(", "(", "list", "=", "tail", ".", "testNonEmptyList", "(", ")", ")", "!=", "null", ")", "{", "EObject", "head", "=", "list", ".", "head", "(", ")", ";", "ESmall", "intval", ";", "if", "(", "(", "intval", "=", "head", ".", "testSmall", "(", ")", ")", "==", "null", ")", "{", "throw", "ERT", ".", "badarg", "(", ")", ";", "}", "int", "byteValue", "=", "intval", ".", "value", "&", "0xff", ";", "if", "(", "intval", ".", "value", "!=", "byteValue", ")", "{", "throw", "ERT", ".", "badarg", "(", ")", ";", "}", "barr", ".", "write", "(", "byteValue", ")", ";", "tail", "=", "list", ".", "tail", "(", ")", ";", "}", "return", "new", "EString", "(", "barr", ".", "toByteArray", "(", ")", ",", "0", ")", ";", "}", "}", "@", "Override", "public", "int", "hashCode", "(", ")", "{", "if", "(", "hash", "==", "-", "1", ")", "{", "hash", "=", "stringValue", "(", ")", ".", "hashCode", "(", ")", ";", "}", "return", "hash", ";", "}", "public", "String", "stringValue", "(", ")", "{", "return", "new", "String", "(", "data", ",", "off", ",", "data", ".", "length", "-", "off", ",", "ISO_LATIN_1", ")", ";", "}", "public", "boolean", "equalsExactly", "(", "EObject", "rhs", ")", "{", "int", "length", "=", "length", "(", ")", ";", "if", "(", "(", "rhs", ".", "testNil", "(", ")", ")", "!=", "null", ")", "{", "return", "length", "==", "0", ";", "}", "EString", "str", ";", "if", "(", "(", "str", "=", "rhs", ".", "testString", "(", ")", ")", "!=", "null", ")", "{", "EString", "es", "=", "str", ";", "if", "(", "length", "!=", "es", ".", "length", "(", ")", ")", "return", "false", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "length", ";", "i", "++", ")", "{", "if", "(", "charAt", "(", "i", ")", "!=", "es", ".", "charAt", "(", "i", ")", ")", "return", "false", ";", "}", "return", "true", ";", "}", "ESeq", "seq", ";", "if", "(", "(", "seq", "=", "rhs", ".", "testSeq", "(", ")", ")", "!=", "null", ")", "{", "int", "i", "=", "0", ";", "while", "(", "i", "<", "length", ")", "{", "if", "(", "seq", ".", "testNil", "(", ")", "!=", "null", ")", "return", "false", ";", "if", "(", "!", "seq", ".", "head", "(", ")", ".", "equalsExactly", "(", "new", "ESmall", "(", "charAt", "(", "i", ")", ")", ")", ")", "{", "return", "false", ";", "}", "seq", "=", "seq", ".", "tail", "(", ")", ";", "}", "}", "return", "false", ";", "}", "@", "Override", "public", "boolean", "equals", "(", "Object", "obj", ")", "{", "if", "(", "obj", "instanceof", "String", ")", "{", "return", "(", "(", "String", ")", "obj", ")", ".", "equals", "(", "stringValue", "(", ")", ")", ";", "}", "if", "(", "!", "(", "obj", "instanceof", "EObject", ")", ")", "{", "return", "false", ";", "}", "return", "equalsExactly", "(", "(", "EObject", ")", "obj", ")", ";", "}", "@", "Override", "public", "char", "charAt", "(", "int", "index", ")", "{", "return", "(", "char", ")", "(", "data", "[", "off", "+", "index", "]", "&", "0xff", ")", ";", "}", "@", "Override", "public", "int", "length", "(", ")", "{", "return", "data", ".", "length", "-", "off", ";", "}", "@", "Override", "public", "CharSequence", "subSequence", "(", "final", "int", "start", ",", "final", "int", "end", ")", "{", "if", "(", "end", "==", "length", "(", ")", ")", "return", "new", "EString", "(", "data", ",", "off", "+", "start", ")", ";", "return", "new", "SubSequence", "(", "start", ",", "end", "-", "start", ")", ";", "}", "public", "class", "SubSequence", "implements", "CharSequence", "{", "private", "final", "int", "offset", ";", "private", "final", "int", "length", ";", "public", "SubSequence", "(", "int", "start", ",", "int", "length", ")", "{", "this", ".", "offset", "=", "start", ";", "this", ".", "length", "=", "length", ";", "EString", ".", "this", ".", "check_subseq", "(", "offset", ",", "length", ")", ";", "}", "@", "Override", "public", "char", "charAt", "(", "int", "index", ")", "{", "return", "EString", ".", "this", ".", "charAt", "(", "offset", "+", "index", ")", ";", "}", "@", "Override", "public", "int", "length", "(", ")", "{", "return", "length", ";", "}", "@", "Override", "public", "CharSequence", "subSequence", "(", "int", "start", ",", "int", "end", ")", "{", "return", "new", "SubSequence", "(", "this", ".", "offset", "+", "start", ",", "end", "-", "start", ")", ";", "}", "}", "void", "check_subseq", "(", "int", "offset", ",", "int", "length", ")", "{", "if", "(", "offset", "<", "0", "||", "length", "<", "0", "||", "(", "offset", "+", "length", ")", ">", "length", "(", ")", ")", "throw", "new", "IllegalArgumentException", "(", ")", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "\"\\\"\"", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "length", "(", ")", ";", "i", "++", ")", "{", "char", "c", "=", "charAt", "(", "i", ")", ";", "appendChar", "(", "sb", ",", "c", ")", ";", "}", "sb", ".", "append", "(", "'\"'", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}", "static", "void", "appendChar", "(", "StringBuilder", "sb", ",", "char", "c", ")", "{", "if", "(", "c", "<", "0x20", "||", "c", ">", "0x7e", "||", "c", "==", "'\"'", "||", "c", "==", "'\\\\'", ")", "{", "sb", ".", "append", "(", "'\\\\'", ")", ";", "switch", "(", "c", ")", "{", "case", "'\\t'", ":", "sb", ".", "append", "(", "'t'", ")", ";", "break", ";", "case", "'\\r'", ":", "sb", ".", "append", "(", "'r'", ")", ";", "break", ";", "case", "'\\n'", ":", "sb", ".", "append", "(", "'n'", ")", ";", "break", ";", "case", "'\\b'", ":", "sb", ".", "append", "(", "'b'", ")", ";", "break", ";", "case", "'\"'", ":", "sb", ".", "append", "(", "'\"'", ")", ";", "break", ";", "case", "'\\\\'", ":", "sb", ".", "append", "(", "'\\\\'", ")", ";", "break", ";", "default", ":", "sb", ".", "append", "(", "'x'", ")", ";", "if", "(", "c", "<", "0x10", ")", "sb", ".", "append", "(", "'0'", ")", ";", "sb", ".", "append", "(", "Integer", ".", "toHexString", "(", "c", ")", ".", "toUpperCase", "(", ")", ")", ";", "}", "}", "else", "{", "sb", ".", "append", "(", "c", ")", ";", "}", "}", "public", "static", "EString", "fromString", "(", "String", "s", ")", "{", "return", "new", "EString", "(", "s", ")", ";", "}", "private", "static", "final", "Type", "ESTRING_TYPE", "=", "Type", ".", "getType", "(", "EString", ".", "class", ")", ";", "private", "static", "final", "Type", "STRING_TYPE", "=", "Type", ".", "getType", "(", "String", ".", "class", ")", ";", "@", "Override", "public", "Type", "emit_const", "(", "MethodVisitor", "fa", ")", "{", "Type", "type", "=", "ESTRING_TYPE", ";", "fa", ".", "visitLdcInsn", "(", "this", ".", "stringValue", "(", ")", ")", ";", "fa", ".", "visitMethodInsn", "(", "Opcodes", ".", "INVOKESTATIC", ",", "type", ".", "getInternalName", "(", ")", ",", "\"fromString\"", ",", "\"(\"", "+", "STRING_TYPE", ".", "getDescriptor", "(", ")", "+", "\")\"", "+", "type", ".", "getDescriptor", "(", ")", ")", ";", "return", "type", ";", "}", "@", "Override", "public", "ESeq", "cons", "(", "EObject", "h", ")", "{", "return", "new", "EList", "(", "h", ",", "this", ")", ";", "}", "@", "Override", "public", "ESeq", "tail", "(", ")", "{", "if", "(", "off", "==", "data", ".", "length", "-", "1", ")", "return", "ERT", ".", "NIL", ";", "return", "new", "EString", "(", "data", ",", "off", "+", "1", ")", ";", "}", "@", "Override", "public", "ESmall", "head", "(", ")", "{", "return", "ESmall", ".", "little", "[", "(", "data", "[", "off", "]", "&", "0xff", ")", "]", ";", "}", "@", "Override", "public", "ENil", "testNil", "(", ")", "{", "return", "length", "(", ")", "==", "0", "?", "ERT", ".", "NIL", ":", "null", ";", "}", "@", "Override", "public", "ESeq", "testSeq", "(", ")", "{", "return", "this", ";", "}", "public", "ECons", "testNonEmptyList", "(", ")", "{", "return", "length", "(", ")", "==", "0", "?", "null", ":", "this", ";", "}", "public", "ECons", "testCons", "(", ")", "{", "return", "this", ";", "}", "@", "Override", "int", "compare_same", "(", "EObject", "rhs", ")", "{", "if", "(", "rhs", ".", "isNil", "(", ")", ")", "return", "isNil", "(", ")", "?", "0", ":", "1", ";", "int", "length", "=", "length", "(", ")", ";", "EString", "str", ";", "if", "(", "(", "str", "=", "rhs", ".", "testString", "(", ")", ")", "!=", "null", ")", "{", "EString", "es", "=", "str", ";", "int", "length2", "=", "str", ".", "length", "(", ")", ";", "int", "limit", "=", "Math", ".", "min", "(", "length", ",", "length2", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "limit", ";", "i", "++", ")", "{", "char", "ch1", "=", "charAt", "(", "i", ")", ";", "char", "ch2", "=", "es", ".", "charAt", "(", "i", ")", ";", "if", "(", "ch1", "<", "ch2", ")", "return", "-", "1", ";", "if", "(", "ch1", ">", "ch2", ")", "return", "1", ";", "}", "if", "(", "length", ">", "length2", ")", "return", "1", ";", "if", "(", "length", "<", "length2", ")", "return", "-", "1", ";", "return", "0", ";", "}", "ECons", "rseq", ";", "if", "(", "(", "rseq", "=", "rhs", ".", "testCons", "(", ")", ")", "!=", "null", ")", "{", "int", "i", "=", "0", ";", "while", "(", "i", "<", "length", ")", "{", "if", "(", "(", "rseq", ".", "testNil", "(", ")", ")", "!=", "null", ")", "{", "return", "1", ";", "}", "int", "cmp", "=", "(", "new", "ESmall", "(", "charAt", "(", "i", "++", ")", ")", ")", ".", "erlangCompareTo", "(", "rseq", ".", "head", "(", ")", ")", ";", "if", "(", "cmp", "!=", "0", ")", "return", "cmp", ";", "EObject", "res", "=", "rseq", ".", "tail", "(", ")", ";", "if", "(", "(", "rseq", "=", "res", ".", "testCons", "(", ")", ")", "!=", "null", ")", "{", "continue", ";", "}", "return", "-", "res", ".", "erlangCompareTo", "(", "new", "EString", "(", "data", ",", "i", ")", ")", ";", "}", "}", "return", "-", "rhs", ".", "erlangCompareTo", "(", "this", ")", ";", "}", "@", "Override", "public", "ESeq", "prepend", "(", "ESeq", "list", ")", "{", "EString", "other", "=", "list", ".", "testString", "(", ")", ";", "if", "(", "other", "!=", "null", ")", "{", "byte", "[", "]", "out", "=", "new", "byte", "[", "length", "(", ")", "+", "other", ".", "length", "(", ")", "]", ";", "System", ".", "arraycopy", "(", "other", ".", "data", ",", "other", ".", "off", ",", "out", ",", "0", ",", "other", ".", "length", "(", ")", ")", ";", "System", ".", "arraycopy", "(", "this", ".", "data", ",", "this", ".", "off", ",", "out", ",", "other", ".", "length", "(", ")", ",", "this", ".", "length", "(", ")", ")", ";", "return", "EString", ".", "make", "(", "out", ",", "0", ",", "out", ".", "length", ")", ";", "}", "else", "{", "return", "super", ".", "prepend", "(", "list", ")", ";", "}", "}", "public", "EBinary", "asBitString", "(", ")", "{", "return", "new", "EBinary", "(", "data", ",", "off", ",", "length", "(", ")", ")", ";", "}", "public", "static", "EString", "make", "(", "CharSequence", "seq", ",", "int", "start", ",", "int", "end", ")", "{", "return", "fromString", "(", "seq", ".", "subSequence", "(", "start", ",", "end", ")", ".", "toString", "(", ")", ")", ";", "}", "public", "static", "ESeq", "make", "(", "EObject", "eObject", ")", "{", "ESeq", "str", ";", "if", "(", "(", "str", "=", "eObject", ".", "testSeq", "(", ")", ")", "!=", "null", ")", "return", "make", "(", "str", ")", ";", "EAtom", "am", "=", "eObject", ".", "testAtom", "(", ")", ";", "if", "(", "am", "!=", "null", ")", "{", "return", "fromString", "(", "am", ".", "toString", "(", ")", ")", ";", "}", "throw", "ERT", ".", "badarg", "(", ")", ";", "}", "public", "static", "EString", "make", "(", "EBinary", "bin", ")", "{", "return", "new", "EString", "(", "bin", ".", "data", ",", "bin", ".", "byteOffset", "(", ")", ",", "bin", ".", "byteSize", "(", ")", ")", ";", "}", "public", "static", "EString", "make", "(", "EBinary", "bin", ",", "int", "offset", ",", "int", "length", ")", "{", "return", "new", "EString", "(", "bin", ".", "data", ",", "bin", ".", "byteOffset", "(", ")", "+", "offset", ",", "length", ")", ";", "}", "public", "boolean", "collectIOList", "(", "List", "<", "ByteBuffer", ">", "out", ")", "{", "if", "(", "length", "(", ")", "!=", "0", ")", "{", "out", ".", "add", "(", "ByteBuffer", ".", "wrap", "(", "data", ",", "off", ",", "data", ".", "length", "-", "off", ")", ")", ";", "}", "return", "true", ";", "}", "public", "void", "collectCharList", "(", "CharCollector", "out", ")", "throws", "CharCollector", ".", "CollectingException", ",", "IOException", "{", "try", "{", "out", ".", "addIntegers", "(", "data", ",", "off", ",", "data", ".", "length", "-", "off", ")", ";", "}", "catch", "(", "CharCollector", ".", "PartialDecodingException", "e", ")", "{", "int", "n", "=", "e", ".", "inputPos", ";", "throw", "new", "CharCollector", ".", "CollectingException", "(", "new", "EString", "(", "data", ",", "off", "+", "n", ")", ")", ";", "}", "}", "public", "static", "ESeq", "make", "(", "ByteBuffer", "data", ")", "{", "if", "(", "data", "==", "null", "||", "data", ".", "remaining", "(", ")", "==", "0", ")", "return", "ERT", ".", "NIL", ";", "return", "EString", ".", "make", "(", "data", ".", "array", "(", ")", ",", "data", ".", "arrayOffset", "(", ")", "+", "data", ".", "position", "(", ")", ",", "data", ".", "remaining", "(", ")", ")", ";", "}", "public", "static", "EString", "make", "(", "byte", "[", "]", "strbuf", ")", "{", "return", "make", "(", "strbuf", ",", "0", ",", "strbuf", ".", "length", ")", ";", "}", "public", "static", "boolean", "isValidCodePoint", "(", "int", "cp", ")", "{", "return", "(", "cp", ">>>", "16", ")", "<=", "0x10", "&&", "(", "cp", "&", "~", "0x7FF", ")", "!=", "0xD800", "&&", "(", "cp", "&", "~", "1", ")", "!=", "0xFFFE", ";", "}", "public", "static", "ESeq", "read", "(", "EInputStream", "ei", ")", "throws", "IOException", "{", "return", "ei", ".", "read_string", "(", ")", ";", "}", "public", "static", "int", "[", "]", "stringToCodePoints", "(", "final", "String", "s", ")", "{", "final", "int", "m", "=", "s", ".", "codePointCount", "(", "0", ",", "s", ".", "length", "(", ")", ")", ";", "final", "int", "[", "]", "codePoints", "=", "new", "int", "[", "m", "]", ";", "for", "(", "int", "i", "=", "0", ",", "j", "=", "0", ";", "j", "<", "m", ";", "i", "=", "s", ".", "offsetByCodePoints", "(", "i", ",", "1", ")", ",", "j", "++", ")", "{", "codePoints", "[", "j", "]", "=", "s", ".", "codePointAt", "(", "i", ")", ";", "}", "return", "codePoints", ";", "}", "@", "Override", "public", "void", "encode", "(", "EOutputStream", "eos", ")", "{", "eos", ".", "write_string", "(", "stringValue", "(", ")", ")", ";", "}", "}", "</s>" ]
7,928
[ "<s>", "package", "erjang", ".", "util", ";", "import", "java", ".", "lang", ".", "ref", ".", "ReferenceQueue", ";", "import", "java", ".", "lang", ".", "ref", ".", "WeakReference", ";", "import", "java", ".", "util", ".", "AbstractSet", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "NoSuchElementException", ";", "import", "java", ".", "util", ".", "concurrent", ".", "ConcurrentHashMap", ";", "public", "class", "WeakHashSet", "<", "T", ">", "extends", "AbstractSet", "<", "T", ">", "{", "Map", "<", "WO", ",", "WO", ">", "elementSet", "=", "new", "ConcurrentHashMap", "<", "WO", ",", "WO", ">", "(", ")", ";", "ReferenceQueue", "<", "T", ">", "referenceQueue", "=", "new", "ReferenceQueue", "<", "T", ">", "(", ")", ";", "private", "static", "Object", "NULL", "=", "new", "Object", "(", ")", ";", "protected", "int", "hashCode", "(", "T", "val", ")", "{", "return", "val", ".", "hashCode", "(", ")", ";", "}", "protected", "boolean", "equals", "(", "T", "v1", ",", "T", "v2", ")", "{", "return", "v1", ".", "equals", "(", "v2", ")", ";", "}", "class", "WO", "extends", "WeakReference", "<", "T", ">", "{", "private", "int", "hashCode", ";", "public", "WO", "(", "T", "referent", ",", "int", "hash", ",", "ReferenceQueue", "<", "?", "super", "T", ">", "q", ")", "{", "super", "(", "referent", ",", "q", ")", ";", "this", ".", "hashCode", "=", "hash", ";", "}", "@", "Override", "public", "int", "hashCode", "(", ")", "{", "return", "hashCode", ";", "}", "@", "Override", "public", "boolean", "equals", "(", "Object", "obj", ")", "{", "if", "(", "this", "==", "obj", ")", "return", "true", ";", "WO", "other", "=", "(", "WO", ")", "obj", ";", "if", "(", "hashCode", "!=", "other", ".", "hashCode", ")", "{", "return", "false", ";", "}", "T", "v1", "=", "this", ".", "get", "(", ")", ";", "T", "v2", "=", "other", ".", "get", "(", ")", ";", "if", "(", "v1", "==", "null", "||", "v2", "==", "null", ")", "return", "false", ";", "return", "v1", ".", "equals", "(", "v2", ")", ";", "}", "}", "private", "void", "cleanup", "(", ")", "{", "WO", "weak", ";", "while", "(", "(", "weak", "=", "(", "WO", ")", "referenceQueue", ".", "poll", "(", ")", ")", "!=", "null", ")", "{", "elementSet", ".", "remove", "(", "weak", ")", ";", "}", "}", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "@", "Override", "public", "boolean", "contains", "(", "Object", "e", ")", "{", "cleanup", "(", ")", ";", "WO", "o", "=", "new", "WO", "(", "(", "T", ")", "(", "e", "==", "null", "?", "NULL", ":", "e", ")", ",", "hashCode", "(", "(", "T", ")", "e", ")", ",", "referenceQueue", ")", ";", "return", "elementSet", ".", "containsKey", "(", "o", ")", ";", "}", ";", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "boolean", "add", "(", "T", "e", ")", "{", "cleanup", "(", ")", ";", "WO", "o", "=", "new", "WO", "(", "(", "T", ")", "(", "e", "==", "null", "?", "NULL", ":", "e", ")", ",", "hashCode", "(", "e", ")", ",", "referenceQueue", ")", ";", "if", "(", "elementSet", ".", "containsKey", "(", "o", ")", ")", "return", "false", ";", "elementSet", ".", "put", "(", "o", ",", "o", ")", ";", "return", "true", ";", "}", ";", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "@", "Override", "public", "boolean", "remove", "(", "Object", "e", ")", "{", "try", "{", "WO", "o", "=", "new", "WO", "(", "(", "T", ")", "(", "e", "==", "null", "?", "NULL", ":", "e", ")", ",", "hashCode", "(", "(", "T", ")", "e", ")", ",", "referenceQueue", ")", ";", "return", "elementSet", ".", "remove", "(", "o", ")", "!=", "null", ";", "}", "finally", "{", "cleanup", "(", ")", ";", "}", "}", "@", "Override", "public", "Iterator", "<", "T", ">", "iterator", "(", ")", "{", "return", "new", "Iterator", "<", "T", ">", "(", ")", "{", "final", "Iterator", "<", "WO", ">", "iter", "=", "elementSet", ".", "keySet", "(", ")", ".", "iterator", "(", ")", ";", "private", "T", "next", ";", "@", "Override", "public", "boolean", "hasNext", "(", ")", "{", "while", "(", "iter", ".", "hasNext", "(", ")", ")", "{", "WO", "weak", "=", "iter", ".", "next", "(", ")", ";", "T", "obj", "=", "null", ";", "if", "(", "weak", "!=", "null", "&&", "(", "obj", "=", "weak", ".", "get", "(", ")", ")", "==", "null", ")", "{", "continue", ";", "}", "next", "=", "obj", ";", "return", "true", ";", "}", "return", "false", ";", "}", "@", "Override", "public", "T", "next", "(", ")", "{", "if", "(", "(", "next", "==", "null", ")", "&&", "!", "hasNext", "(", ")", ")", "{", "throw", "new", "NoSuchElementException", "(", ")", ";", "}", "T", "obj", "=", "next", ";", "next", "=", "null", ";", "return", "(", "obj", "==", "NULL", "?", "null", ":", "obj", ")", ";", "}", "@", "Override", "public", "void", "remove", "(", ")", "{", "iter", ".", "remove", "(", ")", ";", "}", "}", ";", "}", "@", "Override", "public", "int", "size", "(", ")", "{", "cleanup", "(", ")", ";", "return", "elementSet", ".", "size", "(", ")", ";", "}", "}", "</s>" ]
7,929
[ "<s>", "package", "erjang", ".", "util", ";", "public", "interface", "ProgressListener", "{", "void", "progress", "(", "String", "msg", ")", ";", "}", "</s>" ]
7,930
[ "<s>", "package", "erjang", ".", "util", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "util", ".", "concurrent", ".", "atomic", ".", "AtomicInteger", ";", "import", "erjang", ".", "ERT", ";", "public", "class", "Progress", "{", "static", "ProgressListener", "listener", ";", "public", "static", "void", "setListener", "(", "ProgressListener", "listener", ")", "{", "Progress", ".", "listener", "=", "listener", ";", "}", "static", "AtomicInteger", "step", "=", "new", "AtomicInteger", "(", ")", ";", "static", "byte", "[", "]", "[", "]", "wheel", "=", "new", "byte", "[", "]", "[", "]", "{", "new", "byte", "[", "]", "{", "'|'", ",", "'\\b'", "}", ",", "new", "byte", "[", "]", "{", "'/'", ",", "'\\b'", "}", ",", "new", "byte", "[", "]", "{", "'-'", ",", "'\\b'", "}", ",", "new", "byte", "[", "]", "{", "'\\\\'", ",", "'\\b'", "}", ",", "}", ";", "static", "public", "void", "activity", "(", "String", "string", ")", "{", "if", "(", "listener", "!=", "null", ")", "{", "listener", ".", "progress", "(", "string", ")", ";", "}", "else", "{", "int", "next", "=", "step", ".", "incrementAndGet", "(", ")", ";", "try", "{", "String", "suppress", "=", "System", ".", "getProperty", "(", "\"\"", ")", ";", "if", "(", "suppress", "==", "null", ")", "{", "suppress", "=", "\"false\"", ";", "}", "if", "(", "!", "Boolean", ".", "parseBoolean", "(", "suppress", ")", ")", "{", "ERT", ".", "getErrorStream", "(", ")", ".", "write", "(", "wheel", "[", "next", "%", "4", "]", ")", ";", "}", "}", "catch", "(", "IOException", "e", ")", "{", "}", "}", "}", "public", "static", "void", "done", "(", ")", "{", "}", "}", "</s>" ]
7,931
[ "<s>", "package", "erjang", ";", "public", "class", "ErlangExitSignal", "extends", "ThreadDeath", "{", "private", "final", "EObject", "exitReason", ";", "public", "ErlangExitSignal", "(", "EObject", "exitReason", ")", "{", "this", ".", "exitReason", "=", "exitReason", ";", "}", "public", "EObject", "reason", "(", ")", "{", "return", "exitReason", ";", "}", "@", "Override", "public", "String", "getMessage", "(", ")", "{", "return", "exitReason", ".", "toString", "(", ")", ";", "}", "}", "</s>" ]
7,932
[ "<s>", "package", "erjang", ";", "import", "java", ".", "lang", ".", "annotation", ".", "ElementType", ";", "import", "java", ".", "lang", ".", "annotation", ".", "Retention", ";", "import", "java", ".", "lang", ".", "annotation", ".", "RetentionPolicy", ";", "import", "java", ".", "lang", ".", "annotation", ".", "Target", ";", "@", "Retention", "(", "RetentionPolicy", ".", "RUNTIME", ")", "@", "Target", "(", "ElementType", ".", "METHOD", ")", "public", "@", "interface", "BIF", "{", "String", "name", "(", ")", "default", "\"__SELFNAME__\"", ";", "Type", "type", "(", ")", "default", "Type", ".", "DEFAULT", ";", "public", "enum", "Type", "{", "DEFAULT", "{", "public", "boolean", "export", "(", ")", "{", "return", "true", ";", "}", "}", ",", "GUARD", "{", "public", "boolean", "export", "(", ")", "{", "return", "false", ";", "}", "}", ",", "ARITHBIF", "{", "public", "boolean", "export", "(", ")", "{", "return", "false", ";", "}", "}", ";", "abstract", "public", "boolean", "export", "(", ")", ";", "}", "}", "</s>" ]
7,933
[ "<s>", "package", "erjang", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "concurrent", ".", "ConcurrentHashMap", ";", "import", "java", ".", "util", ".", "logging", ".", "Level", ";", "import", "java", ".", "util", ".", "logging", ".", "Logger", ";", "import", "kilim", ".", "Pausable", ";", "import", "erjang", ".", "m", ".", "erlang", ".", "ErlFun", ";", "import", "erjang", ".", "m", ".", "erlang", ".", "ErlProc", ";", "import", "erjang", ".", "m", ".", "java", ".", "JavaObject", ";", "public", "final", "class", "EProc", "extends", "ETask", "<", "EInternalPID", ">", "{", "static", "Logger", "log", "=", "Logger", ".", "getLogger", "(", "\"erjang.proc\"", ")", ";", "public", "static", "final", "EObject", "TAIL_MARKER", "=", "new", "ETailMarker", "(", ")", ";", "public", "static", "final", "EAtom", "am_trap_exit", "=", "EAtom", ".", "intern", "(", "\"trap_exit\"", ")", ";", "public", "static", "final", "EAtom", "am_sensitive", "=", "EAtom", ".", "intern", "(", "\"sensitive\"", ")", ";", "public", "static", "final", "EAtom", "am_messages", "=", "EAtom", ".", "intern", "(", "\"messages\"", ")", ";", "public", "static", "final", "EAtom", "am_message_queue_len", "=", "EAtom", ".", "intern", "(", "\"\"", ")", ";", "public", "static", "final", "EAtom", "am_dictionary", "=", "EAtom", ".", "intern", "(", "\"dictionary\"", ")", ";", "public", "static", "final", "EAtom", "am_group_leader", "=", "EAtom", ".", "intern", "(", "\"group_leader\"", ")", ";", "public", "static", "final", "EAtom", "am_links", "=", "EAtom", ".", "intern", "(", "\"links\"", ")", ";", "public", "static", "final", "EAtom", "am_heap_size", "=", "EAtom", ".", "intern", "(", "\"heap_size\"", ")", ";", "public", "static", "final", "EAtom", "am_stack_size", "=", "EAtom", ".", "intern", "(", "\"stack_size\"", ")", ";", "public", "static", "final", "EAtom", "am_reductions", "=", "EAtom", ".", "intern", "(", "\"reductions\"", ")", ";", "public", "static", "final", "EAtom", "am_initial_call", "=", "EAtom", ".", "intern", "(", "\"initial_call\"", ")", ";", "public", "static", "final", "EAtom", "am_current_function", "=", "EAtom", ".", "intern", "(", "\"\"", ")", ";", "public", "static", "final", "EAtom", "am_priority", "=", "EAtom", ".", "intern", "(", "\"priority\"", ")", ";", "public", "static", "final", "EAtom", "am_memory", "=", "EAtom", ".", "intern", "(", "\"memory\"", ")", ";", "public", "static", "final", "EAtom", "am_monitor_nodes", "=", "EAtom", ".", "intern", "(", "\"\"", ")", ";", "public", "static", "final", "EAtom", "am_registered_name", "=", "EAtom", ".", "intern", "(", "\"\"", ")", ";", "public", "static", "final", "EAtom", "am_max", "=", "EAtom", ".", "intern", "(", "\"max\"", ")", ";", "public", "static", "final", "EAtom", "am_normal", "=", "EAtom", ".", "intern", "(", "\"normal\"", ")", ";", "public", "static", "final", "EAtom", "am_low", "=", "EAtom", ".", "intern", "(", "\"low\"", ")", ";", "public", "static", "final", "EAtom", "am_high", "=", "EAtom", ".", "intern", "(", "\"high\"", ")", ";", "static", "final", "EObject", "am_kill", "=", "EAtom", ".", "intern", "(", "\"kill\"", ")", ";", "static", "final", "EObject", "am_killed", "=", "EAtom", ".", "intern", "(", "\"killed\"", ")", ";", "private", "static", "final", "EObject", "am_status", "=", "EAtom", ".", "intern", "(", "\"status\"", ")", ";", "private", "static", "final", "EObject", "am_waiting", "=", "EAtom", ".", "intern", "(", "\"waiting\"", ")", ";", "private", "static", "final", "EObject", "am_running", "=", "EAtom", ".", "intern", "(", "\"running\"", ")", ";", "private", "static", "final", "EObject", "am_runnable", "=", "EAtom", ".", "intern", "(", "\"runnable\"", ")", ";", "private", "static", "final", "EAtom", "am_error_logger", "=", "EAtom", ".", "intern", "(", "\"error_logger\"", ")", ";", "private", "static", "final", "EAtom", "am_info_report", "=", "EAtom", ".", "intern", "(", "\"info_report\"", ")", ";", "private", "static", "final", "EObject", "am_DOWN", "=", "EAtom", ".", "intern", "(", "\"DOWN\"", ")", ";", "private", "static", "final", "EObject", "am_noproc", "=", "EAtom", ".", "intern", "(", "\"noproc\"", ")", ";", "public", "EFun", "tail", ";", "public", "EObject", "arg0", ",", "arg1", ",", "arg2", ",", "arg3", ",", "arg4", ",", "arg5", ",", "arg6", ",", "arg7", ",", "arg8", ",", "arg9", ",", "arg10", ",", "arg11", ",", "arg12", ",", "arg13", ",", "arg14", ",", "arg15", ",", "arg16", ",", "arg17", ";", "public", "ErlangException", "last_exception", ";", "private", "EInternalPID", "self", ";", "private", "EPID", "group_leader", ";", "private", "EAtom", "spawn_mod", ";", "private", "EAtom", "spawn_fun", ";", "private", "int", "spawn_args", ";", "public", "EObject", "[", "]", "stack", "=", "new", "EObject", "[", "10", "]", ";", "public", "int", "sp", "=", "0", ";", "public", "EDouble", "[", "]", "fregs", "=", "new", "EDouble", "[", "16", "]", ";", "public", "EProc", "(", "EPID", "group_leader", ",", "EAtom", "m", ",", "EAtom", "f", ",", "Object", "[", "]", "a", ")", "{", "self", "=", "new", "EInternalPID", "(", "this", ")", ";", "this", ".", "group_leader", "=", "group_leader", "==", "null", "?", "self", ":", "group_leader", ";", "setTarget", "(", "m", ",", "f", ",", "a", ")", ";", "all_tasks", ".", "put", "(", "key", "(", ")", ",", "this", ")", ";", "}", "public", "EProc", "(", "EPID", "group_leader", ",", "EAtom", "m", ",", "EAtom", "f", ",", "ESeq", "a", ")", "{", "self", "=", "new", "EInternalPID", "(", "this", ")", ";", "this", ".", "group_leader", "=", "group_leader", "==", "null", "?", "self", ":", "group_leader", ";", "setTarget", "(", "m", ",", "f", ",", "a", ")", ";", "all_tasks", ".", "put", "(", "key", "(", ")", ",", "this", ")", ";", "}", "protected", "void", "setTarget", "(", "EAtom", "m", ",", "EAtom", "f", ",", "Object", "[", "]", "args", ")", "{", "EObject", "[", "]", "eargs", "=", "new", "EObject", "[", "args", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "args", ".", "length", ";", "i", "++", ")", "{", "Object", "arg", "=", "args", "[", "i", "]", ";", "if", "(", "arg", "instanceof", "EObject", ")", "{", "EObject", "earg", "=", "(", "EObject", ")", "arg", ";", "eargs", "[", "i", "]", "=", "earg", ";", "}", "else", "{", "eargs", "[", "i", "]", "=", "JavaObject", ".", "box", "(", "this", ",", "arg", ")", ";", "}", "}", "setTarget", "(", "m", ",", "f", ",", "ESeq", ".", "fromArray", "(", "eargs", ")", ")", ";", "}", "protected", "void", "setTarget", "(", "EAtom", "m", ",", "EAtom", "f", ",", "ESeq", "a", ")", "{", "this", ".", "spawn_mod", "=", "m", ";", "this", ".", "spawn_fun", "=", "f", ";", "this", ".", "spawn_args", "=", "a", ".", "length", "(", ")", ";", "int", "arity", "=", "spawn_args", ";", "EFun", "target", "=", "EModuleManager", ".", "resolve", "(", "new", "FunID", "(", "m", ",", "f", ",", "arity", ")", ")", ";", "if", "(", "target", "==", "null", ")", "{", "throw", "new", "ErlangUndefined", "(", "m", ",", "f", ",", "new", "ESmall", "(", "arity", ")", ")", ";", "}", "this", ".", "tail", "=", "target", ";", "a", "=", "a", ".", "reverse", "(", ")", ";", "switch", "(", "arity", ")", "{", "default", ":", "throw", "new", "NotImplemented", "(", ")", ";", "case", "7", ":", "this", ".", "arg6", "=", "a", ".", "head", "(", ")", ";", "a", "=", "a", ".", "tail", "(", ")", ";", "case", "6", ":", "this", ".", "arg5", "=", "a", ".", "head", "(", ")", ";", "a", "=", "a", ".", "tail", "(", ")", ";", "case", "5", ":", "this", ".", "arg4", "=", "a", ".", "head", "(", ")", ";", "a", "=", "a", ".", "tail", "(", ")", ";", "case", "4", ":", "this", ".", "arg3", "=", "a", ".", "head", "(", ")", ";", "a", "=", "a", ".", "tail", "(", ")", ";", "case", "3", ":", "this", ".", "arg2", "=", "a", ".", "head", "(", ")", ";", "a", "=", "a", ".", "tail", "(", ")", ";", "case", "2", ":", "this", ".", "arg1", "=", "a", ".", "head", "(", ")", ";", "a", "=", "a", ".", "tail", "(", ")", ";", "case", "1", ":", "this", ".", "arg0", "=", "a", ".", "head", "(", ")", ";", "a", "=", "a", ".", "tail", "(", ")", ";", "case", "0", ":", "}", "}", "private", "int", "key", "(", ")", "{", "int", "key", "=", "(", "self", ".", "serial", "(", ")", "<<", "15", ")", "|", "(", "self", ".", "id", "(", ")", "&", "0x7fff", ")", ";", "return", "key", ";", "}", "public", "EInternalPID", "self_handle", "(", ")", "{", "return", "self", ";", "}", "Map", "<", "EObject", ",", "EObject", ">", "pdict", "=", "new", "HashMap", "<", "EObject", ",", "EObject", ">", "(", ")", ";", "private", "EAtom", "trap_exit", "=", "ERT", ".", "FALSE", ";", "private", "EAtom", "sensitive", "=", "ERT", ".", "FALSE", ";", "public", "int", "midx", "=", "0", ";", "protected", "void", "link_failure", "(", "EHandle", "h", ")", "throws", "Pausable", "{", "if", "(", "trap_exit", "==", "ERT", ".", "TRUE", "||", "h", ".", "testLocalHandle", "(", ")", "==", "null", ")", "{", "send_exit", "(", "h", ",", "ERT", ".", "am_noproc", ",", "false", ")", ";", "}", "else", "{", "throw", "new", "ErlangError", "(", "ERT", ".", "am_noproc", ")", ";", "}", "}", "static", "ExitHook", "[", "]", "NO_HOOKS", "=", "new", "ExitHook", "[", "0", "]", ";", "@", "Override", "protected", "void", "do_proc_termination", "(", "EObject", "result", ")", "throws", "Pausable", "{", "ExitHook", "[", "]", "hooks", "=", "NO_HOOKS", ";", "synchronized", "(", "exit_hooks", ")", "{", "if", "(", "exit_hooks", "==", "null", "||", "exit_hooks", ".", "isEmpty", "(", ")", ")", "{", "}", "else", "{", "hooks", "=", "exit_hooks", ".", "toArray", "(", "new", "ExitHook", "[", "exit_hooks", ".", "size", "(", ")", "]", ")", ";", "}", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "hooks", ".", "length", ";", "i", "++", ")", "{", "hooks", "[", "i", "]", ".", "on_exit", "(", "self", ")", ";", "}", "super", ".", "do_proc_termination", "(", "result", ")", ";", "self", ".", "done", "(", ")", ";", "all_tasks", ".", "remove", "(", "this", ".", "key", "(", ")", ")", ";", "}", "protected", "void", "process_incoming_exit", "(", "EHandle", "from", ",", "EObject", "reason", ",", "boolean", "is_erlang_exit2", ")", "throws", "Pausable", "{", "if", "(", "pstate", "==", "STATE_EXIT_SIG", "||", "pstate", "==", "STATE_SENDING_EXIT", ")", "{", "if", "(", "log", ".", "isLoggable", "(", "Level", ".", "FINE", ")", ")", "{", "log", ".", "fine", "(", "\"\"", "+", "reason", "+", "\"\"", "+", "exit_reason", ")", ";", "}", "}", "if", "(", "log", ".", "isLoggable", "(", "Level", ".", "FINE", ")", ")", "{", "log", ".", "log", "(", "Level", ".", "FINE", ",", "\"\"", "+", "this", "+", "\"", "from", "\"", "+", "from", "+", "\"", "reason=\"", "+", "reason", "+", "\";", "is_exit2=\"", "+", "is_erlang_exit2", ")", ";", "}", "if", "(", "is_erlang_exit2", ")", "{", "if", "(", "reason", "==", "am_kill", ")", "{", "exit_reason", "=", "am_killed", ";", "}", "else", "if", "(", "trap_exit", "==", "ERT", ".", "TRUE", ")", "{", "ETuple", "msg", "=", "ETuple", ".", "make", "(", "ERT", ".", "am_EXIT", ",", "from", ",", "reason", ")", ";", "mbox", ".", "put", "(", "msg", ")", ";", "return", ";", "}", "else", "{", "this", ".", "exit_reason", "=", "reason", ";", "}", "this", ".", "pstate", "=", "STATE_EXIT_SIG", ";", "this", ".", "resume", "(", ")", ";", "return", ";", "}", "if", "(", "from", "==", "self_handle", "(", ")", ")", "{", "return", ";", "}", "if", "(", "trap_exit", "==", "ERT", ".", "TRUE", ")", "{", "ETuple", "msg", "=", "ETuple", ".", "make", "(", "ERT", ".", "am_EXIT", ",", "from", ",", "reason", ")", ";", "mbox", ".", "put", "(", "msg", ")", ";", "}", "else", "if", "(", "reason", "==", "am_kill", ")", "{", "this", ".", "exit_reason", "=", "am_killed", ";", "this", ".", "pstate", "=", "STATE_EXIT_SIG", ";", "this", ".", "resume", "(", ")", ";", "}", "else", "if", "(", "reason", "!=", "am_normal", ")", "{", "this", ".", "exit_reason", "=", "reason", ";", "this", ".", "pstate", "=", "STATE_EXIT_SIG", ";", "this", ".", "resume", "(", ")", ";", "}", "}", "public", "EObject", "put", "(", "EObject", "key", ",", "EObject", "value", ")", "{", "EObject", "res", "=", "pdict", ".", "put", "(", "key", ",", "value", ")", ";", "if", "(", "res", "==", "null", ")", "return", "ERT", ".", "am_undefined", ";", "return", "res", ";", "}", "public", "EObject", "get", "(", "EObject", "key", ")", "{", "EObject", "res", "=", "pdict", ".", "get", "(", "key", ")", ";", "return", "(", "res", "==", "null", ")", "?", "ERT", ".", "am_undefined", ":", "res", ";", "}", "public", "ESeq", "get", "(", ")", "{", "ESeq", "res", "=", "ERT", ".", "NIL", ";", "for", "(", "Map", ".", "Entry", "<", "EObject", ",", "EObject", ">", "ent", ":", "pdict", ".", "entrySet", "(", ")", ")", "{", "res", "=", "res", ".", "cons", "(", "ETuple", ".", "make", "(", "ent", ".", "getKey", "(", ")", ",", "ent", ".", "getValue", "(", ")", ")", ")", ";", "}", "return", "res", ";", "}", "public", "EObject", "erase", "(", "EObject", "key", ")", "{", "EObject", "res", "=", "pdict", ".", "remove", "(", "key", ")", ";", "if", "(", "res", "==", "null", ")", "res", "=", "ERT", ".", "am_undefined", ";", "return", "res", ";", "}", "public", "EObject", "erase", "(", ")", "{", "EObject", "res", "=", "get", "(", ")", ";", "pdict", ".", "clear", "(", ")", ";", "return", "res", ";", "}", "public", "EPID", "group_leader", "(", ")", "{", "return", "group_leader", ";", "}", "void", "set_group_leader", "(", "EPID", "group_leader", ")", "{", "this", ".", "group_leader", "=", "group_leader", ";", "}", "public", "ErlangException", "getLastException", "(", ")", "{", "return", "last_exception", ";", "}", "public", "ELocalNode", "getLocalNode", "(", ")", "{", "return", "ERT", ".", "getLocalNode", "(", ")", ";", "}", "static", "final", "EAtom", "[", "]", "priorities", "=", "new", "EAtom", "[", "]", "{", "EAtom", ".", "intern", "(", "\"max\"", ")", ",", "EAtom", ".", "intern", "(", "\"high\"", ")", ",", "EAtom", ".", "intern", "(", "\"normal\"", ")", ",", "EAtom", ".", "intern", "(", "\"low\"", ")", ",", "}", ";", "public", "EObject", "process_flag", "(", "EAtom", "flag", ",", "EObject", "value", ")", "{", "if", "(", "flag", "==", "am_trap_exit", ")", "{", "EAtom", "old", "=", "this", ".", "trap_exit", ";", "trap_exit", "=", "value", ".", "testBoolean", "(", ")", ";", "return", "ERT", ".", "box", "(", "old", "==", "ERT", ".", "TRUE", ")", ";", "}", "if", "(", "flag", "==", "am_priority", ")", "{", "EAtom", "old", "=", "priorities", "[", "getPriority", "(", ")", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "priorities", ".", "length", ";", "i", "++", ")", "{", "if", "(", "value", "==", "priorities", "[", "i", "]", ")", "{", "setPriority", "(", "i", ")", ";", "return", "old", ";", "}", "}", "throw", "ERT", ".", "badarg", "(", "flag", ",", "value", ")", ";", "}", "if", "(", "flag", "==", "am_monitor_nodes", ")", "{", "if", "(", "!", "value", ".", "isBoolean", "(", ")", ")", "throw", "ERT", ".", "badarg", "(", "flag", ",", "value", ")", ";", "boolean", "activate", "=", "value", "==", "ERT", ".", "TRUE", ";", "Boolean", "old", "=", "EAbstractNode", ".", "monitor_nodes", "(", "self_handle", "(", ")", ",", "activate", ",", "ERT", ".", "NIL", ")", ";", "if", "(", "old", "==", "null", ")", "throw", "ERT", ".", "badarg", "(", "flag", ",", "value", ")", ";", "return", "ERT", ".", "box", "(", "old", ".", "booleanValue", "(", ")", ")", ";", "}", "if", "(", "flag", "==", "am_trap_exit", ")", "{", "EAtom", "old", "=", "this", ".", "trap_exit", ";", "trap_exit", "=", "value", ".", "testBoolean", "(", ")", ";", "return", "ERT", ".", "box", "(", "old", "==", "ERT", ".", "TRUE", ")", ";", "}", "if", "(", "flag", "==", "am_sensitive", ")", "{", "EAtom", "old", "=", "this", ".", "sensitive", ";", "sensitive", "=", "value", ".", "testBoolean", "(", ")", ";", "return", "ERT", ".", "box", "(", "old", "==", "ERT", ".", "TRUE", ")", ";", "}", "ETuple2", "tup", ";", "if", "(", "(", "tup", "=", "ETuple2", ".", "cast", "(", "flag", ")", ")", "!=", "null", "&&", "tup", ".", "elem1", "==", "am_monitor_nodes", ")", "{", "ESeq", "opts", "=", "tup", ".", "elem2", ".", "testSeq", "(", ")", ";", "if", "(", "opts", "==", "null", ")", "throw", "ERT", ".", "badarg", "(", "flag", ",", "value", ")", ";", "if", "(", "!", "value", ".", "isBoolean", "(", ")", ")", "throw", "ERT", ".", "badarg", "(", "flag", ",", "value", ")", ";", "boolean", "activate", "=", "value", ".", "testBoolean", "(", ")", "==", "ERT", ".", "TRUE", ";", "Boolean", "old", "=", "EAbstractNode", ".", "monitor_nodes", "(", "self_handle", "(", ")", ",", "activate", ",", "opts", ")", ";", "if", "(", "old", "==", "null", ")", "throw", "ERT", ".", "badarg", "(", "flag", ",", "value", ")", ";", "return", "ERT", ".", "box", "(", "old", ".", "booleanValue", "(", ")", ")", ";", "}", "throw", "new", "NotImplemented", "(", "\"\"", "+", "flag", "+", "\",", "value=\"", "+", "value", ")", ";", "}", "@", "Override", "public", "void", "execute", "(", ")", "throws", "Pausable", "{", "Throwable", "death", "=", "null", ";", "EObject", "result", "=", "null", ";", "try", "{", "try", "{", "this", ".", "check_exit", "(", ")", ";", "this", ".", "pstate", "=", "STATE_RUNNING", ";", "boolean", "live", "=", "true", ";", "while", "(", "live", ")", "{", "try", "{", "while", "(", "this", ".", "tail", ".", "go", "(", "this", ")", "==", "TAIL_MARKER", ")", "{", "}", "live", "=", "false", ";", "}", "catch", "(", "ErjangHibernateException", "e", ")", "{", "}", "if", "(", "live", "==", "true", ")", "{", "mbox_wait", "(", ")", ";", "}", "}", "result", "=", "am_normal", ";", "}", "catch", "(", "NotImplemented", "e", ")", "{", "log", ".", "log", "(", "Level", ".", "SEVERE", ",", "\"\"", "+", "self_handle", "(", ")", ",", "e", ")", ";", "result", "=", "e", ".", "reason", "(", ")", ";", "death", "=", "e", ";", "}", "catch", "(", "ErlangException", "e", ")", "{", "log", ".", "log", "(", "Level", ".", "FINE", ",", "\"\"", "+", "self_handle", "(", ")", ",", "e", ")", ";", "last_exception", "=", "e", ";", "result", "=", "e", ".", "reason", "(", ")", ";", "death", "=", "e", ";", "}", "catch", "(", "ErlangExitSignal", "e", ")", "{", "log", ".", "log", "(", "Level", ".", "FINE", ",", "\"\"", "+", "self_handle", "(", ")", ",", "e", ")", ";", "result", "=", "e", ".", "reason", "(", ")", ";", "death", "=", "e", ";", "}", "catch", "(", "ErlangHalt", "e", ")", "{", "throw", "e", ";", "}", "catch", "(", "Throwable", "e", ")", "{", "log", ".", "log", "(", "Level", ".", "SEVERE", ",", "\"\"", "+", "self_handle", "(", ")", "+", "\"", "with:", "\"", ",", "e", ")", ";", "ESeq", "erl_trace", "=", "ErlangError", ".", "decodeTrace", "(", "e", ".", "getStackTrace", "(", ")", ")", ";", "ETuple", "java_ex", "=", "ETuple", ".", "make", "(", "am_java_exception", ",", "EString", ".", "fromString", "(", "ERT", ".", "describe_exception", "(", "e", ")", ")", ")", ";", "result", "=", "ETuple", ".", "make", "(", "java_ex", ",", "erl_trace", ")", ";", "death", "=", "e", ";", "}", "finally", "{", "this", ".", "pstate", "=", "STATE_DONE", ";", "}", "if", "(", "result", "!=", "am_normal", "&&", "monitors", ".", "isEmpty", "(", ")", "&&", "has_no_links", "(", ")", "&&", "!", "(", "death", "instanceof", "ErlangExitSignal", ")", ")", "{", "EFun", "fun", "=", "EModuleManager", ".", "resolve", "(", "new", "FunID", "(", "am_error_logger", ",", "am_info_report", ",", "1", ")", ")", ";", "String", "msg", "=", "\"Process", "\"", "+", "self_handle", "(", ")", "+", "\"\"", "+", "\"\"", "+", "result", "+", "\"n\"", "+", "(", "death", "==", "null", "?", "\"\"", ":", "ERT", ".", "describe_exception", "(", "death", ")", ")", ";", "try", "{", "fun", ".", "invoke", "(", "this", ",", "new", "EObject", "[", "]", "{", "EString", ".", "fromString", "(", "msg", ")", "}", ")", ";", "}", "catch", "(", "ErlangHalt", "e", ")", "{", "throw", "e", ";", "}", "catch", "(", "ThreadDeath", "e", ")", "{", "throw", "e", ";", "}", "catch", "(", "Throwable", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "do_proc_termination", "(", "result", ")", ";", "}", "catch", "(", "ErlangHalt", "e", ")", "{", "throw", "e", ";", "}", "catch", "(", "ThreadDeath", "e", ")", "{", "throw", "e", ";", "}", "catch", "(", "Throwable", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "public", "EObject", "process_info", "(", ")", "{", "ESeq", "res", "=", "ERT", ".", "NIL", ";", "res", "=", "res", ".", "cons", "(", "process_info", "(", "am_trap_exit", ")", ")", ";", "res", "=", "res", ".", "cons", "(", "process_info", "(", "am_messages", ")", ")", ";", "res", "=", "res", ".", "cons", "(", "process_info", "(", "am_message_queue_len", ")", ")", ";", "res", "=", "res", ".", "cons", "(", "process_info", "(", "am_dictionary", ")", ")", ";", "res", "=", "res", ".", "cons", "(", "process_info", "(", "am_group_leader", ")", ")", ";", "res", "=", "res", ".", "cons", "(", "process_info", "(", "am_links", ")", ")", ";", "res", "=", "res", ".", "cons", "(", "process_info", "(", "am_heap_size", ")", ")", ";", "res", "=", "res", ".", "cons", "(", "process_info", "(", "am_initial_call", ")", ")", ";", "res", "=", "res", ".", "cons", "(", "process_info", "(", "am_reductions", ")", ")", ";", "EObject", "reg_name", "=", "self_handle", "(", ")", ".", "name", ";", "if", "(", "reg_name", "!=", "null", ")", "res", "=", "res", ".", "cons", "(", "new", "ETuple2", "(", "am_registered_name", ",", "reg_name", ")", ")", ";", "if", "(", "res", "==", "ERT", ".", "NIL", ")", "return", "ERT", ".", "am_undefined", ";", "return", "res", ";", "}", "public", "EObject", "process_info", "(", "EObject", "spec", ")", "{", "if", "(", "spec", "==", "am_registered_name", ")", "{", "return", "self_handle", "(", ")", ".", "name", "==", "null", "?", "ERT", ".", "NIL", ":", "new", "ETuple2", "(", "am_registered_name", ",", "self_handle", "(", ")", ".", "name", ")", ";", "}", "else", "if", "(", "spec", "==", "am_trap_exit", ")", "{", "return", "new", "ETuple2", "(", "am_trap_exit", ",", "trap_exit", ")", ";", "}", "else", "if", "(", "spec", "==", "am_message_queue_len", ")", "{", "return", "new", "ETuple2", "(", "am_message_queue_len", ",", "new", "ESmall", "(", "mbox", ".", "size", "(", ")", ")", ")", ";", "}", "else", "if", "(", "spec", "==", "am_messages", ")", "{", "ESeq", "messages", "=", "EList", ".", "make", "(", "(", "Object", "[", "]", ")", "mbox", ".", "messages", "(", ")", ")", ";", "return", "new", "ETuple2", "(", "am_messages", ",", "messages", ")", ";", "}", "else", "if", "(", "spec", "==", "am_dictionary", ")", "{", "return", "new", "ETuple2", "(", "am_dictionary", ",", "get", "(", ")", ")", ";", "}", "else", "if", "(", "spec", "==", "am_group_leader", ")", "{", "return", "new", "ETuple2", "(", "am_group_leader", ",", "group_leader", ")", ";", "}", "else", "if", "(", "spec", "==", "am_links", ")", "{", "ESeq", "links", "=", "links", "(", ")", ";", "return", "new", "ETuple2", "(", "am_links", ",", "links", ")", ";", "}", "else", "if", "(", "spec", "==", "am_status", ")", "{", "if", "(", "this", ".", "running", ")", "{", "return", "new", "ETuple2", "(", "am_status", ",", "am_running", ")", ";", "}", "else", "if", "(", "this", ".", "pauseReason", "!=", "null", ")", "{", "return", "new", "ETuple2", "(", "am_status", ",", "am_waiting", ")", ";", "}", "else", "{", "return", "new", "ETuple2", "(", "am_status", ",", "am_runnable", ")", ";", "}", "}", "else", "if", "(", "spec", "==", "am_heap_size", ")", "{", "return", "new", "ETuple2", "(", "am_heap_size", ",", "ERT", ".", "box", "(", "Runtime", ".", "getRuntime", "(", ")", ".", "totalMemory", "(", ")", "-", "Runtime", ".", "getRuntime", "(", ")", ".", "freeMemory", "(", ")", ")", ")", ";", "}", "else", "if", "(", "spec", "==", "am_stack_size", ")", "{", "return", "new", "ETuple2", "(", "am_stack_size", ",", "ERT", ".", "box", "(", "0", ")", ")", ";", "}", "else", "if", "(", "spec", "==", "am_reductions", ")", "{", "return", "new", "ETuple2", "(", "am_reductions", ",", "ERT", ".", "box", "(", "this", ".", "reds", ")", ")", ";", "}", "else", "if", "(", "spec", "==", "am_initial_call", ")", "{", "return", "new", "ETuple2", "(", "am_initial_call", ",", "ETuple", ".", "make", "(", "spawn_mod", ",", "spawn_fun", ",", "ERT", ".", "box", "(", "spawn_args", ")", ")", ")", ";", "}", "else", "if", "(", "spec", "==", "am_current_function", ")", "{", "return", "new", "ETuple2", "(", "am_current_function", ",", "ETuple", ".", "make", "(", "spawn_mod", ",", "spawn_fun", ",", "ERT", ".", "box", "(", "spawn_args", ")", ")", ")", ";", "}", "else", "if", "(", "spec", "==", "am_memory", ")", "{", "return", "new", "ETuple2", "(", "am_memory", ",", "ERT", ".", "box", "(", "50000", ")", ")", ";", "}", "else", "{", "log", ".", "warning", "(", "\"\"", "+", "spec", "+", "\")\"", ")", ";", "throw", "new", "NotImplemented", "(", "\"\"", "+", "spec", "+", "\")\"", ")", ";", "}", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "self", ".", "toString", "(", ")", "+", "super", ".", "toString", "(", ")", "+", "\"::\"", "+", "spawn_mod", "+", "\":\"", "+", "spawn_fun", "+", "\"/\"", "+", "spawn_args", ";", "}", "private", "static", "ConcurrentHashMap", "<", "Integer", ",", "EProc", ">", "all_tasks", "=", "new", "ConcurrentHashMap", "<", "Integer", ",", "EProc", ">", "(", ")", ";", "public", "static", "ESeq", "processes", "(", ")", "{", "ESeq", "res", "=", "ERT", ".", "NIL", ";", "for", "(", "EProc", "proc", ":", "all_tasks", ".", "values", "(", ")", ")", "{", "if", "(", "proc", ".", "is_alive", "(", ")", ")", "{", "res", "=", "res", ".", "cons", "(", "proc", ".", "self_handle", "(", ")", ")", ";", "}", "}", "return", "res", ";", "}", "public", "static", "int", "process_count", "(", ")", "{", "int", "count", "=", "0", ";", "for", "(", "EProc", "proc", ":", "all_tasks", ".", "values", "(", ")", ")", "{", "if", "(", "proc", ".", "is_alive", "(", ")", ")", "{", "count", "+=", "1", ";", "}", "}", "return", "count", ";", "}", "public", "boolean", "is_alive", "(", ")", "{", "int", "ps", "=", "pstate", ";", "return", "ps", "==", "STATE_INIT", "||", "ps", "==", "STATE_RUNNING", ";", "}", "List", "<", "ExitHook", ">", "exit_hooks", "=", "new", "ArrayList", "<", "ExitHook", ">", "(", ")", ";", "public", "long", "timeout_start", ";", "public", "boolean", "in_receive", ";", "public", "EObject", "[", "]", "regs", ";", "public", "void", "add_exit_hook", "(", "ExitHook", "hook", ")", "{", "synchronized", "(", "exit_hooks", ")", "{", "exit_hooks", ".", "add", "(", "hook", ")", ";", "}", "}", "public", "void", "remove_exit_hook", "(", "ExitHook", "hook", ")", "{", "synchronized", "(", "exit_hooks", ")", "{", "exit_hooks", ".", "remove", "(", "hook", ")", ";", "}", "}", "public", "Map", "<", "Integer", ",", "EAtom", ">", "getAtomCacheMap", "(", ")", "{", "return", "null", ";", "}", "public", "static", "EInternalPID", "find", "(", "int", "id", ",", "int", "serial", ")", "{", "int", "key", "=", "(", "serial", "<<", "15", ")", "|", "(", "id", "&", "0x7fff", ")", ";", "EProc", "task", "=", "all_tasks", ".", "get", "(", "key", ")", ";", "if", "(", "task", "!=", "null", ")", "return", "task", ".", "self_handle", "(", ")", ";", "return", "null", ";", "}", "static", "{", "if", "(", "ErjangConfig", ".", "getBoolean", "(", "\"\"", ")", ")", "Runtime", ".", "getRuntime", "(", ")", ".", "addShutdownHook", "(", "new", "Thread", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "log", ".", "warning", "(", "\"\"", ")", ";", "for", "(", "EProc", "task", ":", "all_tasks", ".", "values", "(", ")", ")", "{", "log", ".", "warning", "(", "\"==\"", "+", "task", ")", ";", "log", ".", "warning", "(", "task", ".", "fiber", ".", "toString", "(", ")", ")", ";", "}", "log", ".", "warning", "(", "\"=====\"", ")", ";", "}", "}", ")", ";", "}", "}", "class", "ETailMarker", "extends", "EPseudoTerm", "{", "@", "Override", "int", "compare_same", "(", "EObject", "rhs", ")", "{", "if", "(", "rhs", "==", "EProc", ".", "TAIL_MARKER", ")", "return", "0", ";", "return", "-", "1", ";", "}", "@", "Override", "public", "int", "hashCode", "(", ")", "{", "return", "0", ";", "}", "}", "</s>" ]
7,934
[ "<s>", "package", "erjang", ";", "import", "kilim", ".", "Pausable", ";", "public", "abstract", "class", "EPort", "extends", "EHandle", "{", "int", "id", ";", "int", "creation", ";", "public", "EPort", "(", "ENode", "node", ")", "{", "super", "(", "node", ")", ";", "this", ".", "id", "=", "node", ".", "createPortID", "(", ")", ";", "this", ".", "creation", "=", "node", ".", "creation", "(", ")", ";", "}", "@", "Override", "int", "cmp_order", "(", ")", "{", "return", "CMP_ORDER_PORT", ";", "}", "public", "EString", "getName", "(", ")", "{", "return", "EString", ".", "fromString", "(", "toString", "(", ")", ")", ";", "}", "@", "Override", "int", "compare_same", "(", "EObject", "rhs", ")", "{", "return", "toString", "(", ")", ".", "compareTo", "(", "rhs", ".", "toString", "(", ")", ")", ";", "}", "@", "Override", "public", "int", "hashCode", "(", ")", "{", "return", "(", "10000019", "*", "node", ".", "hashCode", "(", ")", "+", "20000003", "*", "id", "+", "30000001", "*", "creation", ")", ";", "}", "@", "Override", "public", "EPort", "testPort", "(", ")", "{", "return", "this", ";", "}", "public", "static", "EAtom", "am_fd", "=", "EAtom", ".", "intern", "(", "\"fd\"", ")", ";", "public", "static", "EAtom", "am_packet", "=", "EAtom", ".", "intern", "(", "\"packet\"", ")", ";", "public", "static", "EAtom", "am_stream", "=", "EAtom", ".", "intern", "(", "\"stream\"", ")", ";", "public", "static", "EAtom", "am_line", "=", "EAtom", ".", "intern", "(", "\"line\"", ")", ";", "public", "static", "EAtom", "am_hide", "=", "EAtom", ".", "intern", "(", "\"hide\"", ")", ";", "public", "static", "EAtom", "am_cd", "=", "EAtom", ".", "intern", "(", "\"cd\"", ")", ";", "public", "static", "EAtom", "am_env", "=", "EAtom", ".", "intern", "(", "\"env\"", ")", ";", "public", "static", "EAtom", "am_args", "=", "EAtom", ".", "intern", "(", "\"args\"", ")", ";", "public", "static", "EAtom", "am_arg0", "=", "EAtom", ".", "intern", "(", "\"arg0\"", ")", ";", "public", "static", "EAtom", "am_exit_status", "=", "EAtom", ".", "intern", "(", "\"exit_status\"", ")", ";", "public", "static", "EAtom", "am_use_stdio", "=", "EAtom", ".", "intern", "(", "\"use_stdio\"", ")", ";", "public", "static", "EAtom", "am_nouse_stdio", "=", "EAtom", ".", "intern", "(", "\"nouse_stdio\"", ")", ";", "public", "static", "EAtom", "am_stderr_to_stdout", "=", "EAtom", ".", "intern", "(", "\"\"", ")", ";", "public", "static", "EAtom", "am_in", "=", "EAtom", ".", "intern", "(", "\"in\"", ")", ";", "public", "static", "EAtom", "am_out", "=", "EAtom", ".", "intern", "(", "\"out\"", ")", ";", "public", "static", "EAtom", "am_binary", "=", "EAtom", ".", "intern", "(", "\"binary\"", ")", ";", "public", "static", "EAtom", "am_eof", "=", "EAtom", ".", "intern", "(", "\"eof\"", ")", ";", "public", "static", "EAtom", "am_close", "=", "EAtom", ".", "intern", "(", "\"close\"", ")", ";", "public", "static", "EAtom", "am_command", "=", "EAtom", ".", "intern", "(", "\"command\"", ")", ";", "public", "static", "EAtom", "am_connect", "=", "EAtom", ".", "intern", "(", "\"connect\"", ")", ";", "public", "static", "EAtom", "am_connected", "=", "EAtom", ".", "intern", "(", "\"connected\"", ")", ";", "public", "abstract", "boolean", "isOpen", "(", ")", ";", "public", "static", "EPort", "read", "(", "EInputStream", "ei", ")", "{", "throw", "new", "NotImplemented", "(", ")", ";", "}", "public", "static", "EPort", "make", "(", "EAtom", "node", ",", "int", "id", ",", "int", "creation", ")", "{", "throw", "new", "NotImplemented", "(", ")", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "\"#Port<\"", "+", "id", "+", "\".\"", "+", "creation", "+", "\">\"", ";", "}", "@", "Override", "public", "void", "encode", "(", "EOutputStream", "eos", ")", "{", "eos", ".", "write_port", "(", "node", ".", "node", "(", ")", ".", "getName", "(", ")", ",", "id", ",", "creation", ")", ";", "}", "public", "abstract", "EObject", "port_info", "(", "EAtom", "spec", ")", ";", "public", "abstract", "void", "set_data", "(", "EObject", "data", ")", ";", "public", "abstract", "EObject", "get_data", "(", ")", ";", "public", "abstract", "void", "close", "(", ")", "throws", "Pausable", ";", "}", "</s>" ]
7,935
[ "<s>", "package", "erjang", ";", "import", "java", ".", "io", ".", "ByteArrayOutputStream", ";", "import", "java", ".", "nio", ".", "ByteBuffer", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "erjang", ".", "m", ".", "ets", ".", "EMatchContext", ";", "import", "erjang", ".", "m", ".", "ets", ".", "EPattern", ";", "import", "erjang", ".", "m", ".", "ets", ".", "ETermPattern", ";", "public", "abstract", "class", "ECons", "extends", "EObject", "implements", "Iterable", "<", "EObject", ">", "{", "@", "Override", "int", "cmp_order", "(", ")", "{", "return", "CMP_ORDER_LIST", ";", "}", "public", "boolean", "match", "(", "ETermPattern", "matcher", ",", "EMatchContext", "r", ")", "{", "return", "matcher", ".", "match", "(", "this", ",", "r", ")", ";", "}", "@", "Override", "public", "ETermPattern", "compileMatch", "(", "Set", "<", "Integer", ">", "out", ")", "{", "return", "EPattern", ".", "compilePattern", "(", "this", ",", "out", ")", ";", "}", "@", "Override", "int", "compare_same", "(", "EObject", "rhs", ")", "{", "ECons", "ths", "=", "this", ";", "ECons", "other", "=", "rhs", ".", "testCons", "(", ")", ";", "do", "{", "if", "(", "other", ".", "isNil", "(", ")", ")", "return", "ths", ".", "isNil", "(", ")", "?", "0", ":", "1", ";", "if", "(", "ths", ".", "isNil", "(", ")", ")", "return", "-", "1", ";", "int", "cmp1", "=", "ths", ".", "head", "(", ")", ".", "erlangCompareTo", "(", "other", ".", "head", "(", ")", ")", ";", "if", "(", "cmp1", "!=", "0", ")", "return", "cmp1", ";", "EObject", "thisTail", "=", "ths", ".", "tail", "(", ")", ";", "EObject", "otherTail", "=", "other", ".", "tail", "(", ")", ";", "if", "(", "!", "(", "thisTail", "instanceof", "ECons", "&&", "otherTail", "instanceof", "ECons", ")", ")", "return", "thisTail", ".", "erlangCompareTo", "(", "otherTail", ")", ";", "else", "{", "ths", "=", "thisTail", ".", "testCons", "(", ")", ";", "other", "=", "otherTail", ".", "testCons", "(", ")", ";", "}", "}", "while", "(", "true", ")", ";", "}", "@", "Override", "public", "boolean", "equalsExactly", "(", "EObject", "rhs", ")", "{", "if", "(", "this", "==", "rhs", ")", "return", "true", ";", "ECons", "ths", "=", "this", ";", "ECons", "other", "=", "rhs", ".", "testCons", "(", ")", ";", "if", "(", "other", "==", "null", ")", "return", "false", ";", "do", "{", "boolean", "other_is_nil", "=", "other", ".", "isNil", "(", ")", ";", "boolean", "this_is_nil", "=", "ths", ".", "isNil", "(", ")", ";", "if", "(", "other_is_nil", ")", "return", "this_is_nil", ";", "if", "(", "this_is_nil", ")", "return", "false", ";", "if", "(", "!", "ths", ".", "head", "(", ")", ".", "equalsExactly", "(", "other", ".", "head", "(", ")", ")", ")", "{", "return", "false", ";", "}", "EObject", "thisTail", "=", "ths", ".", "tail", "(", ")", ";", "EObject", "otherTail", "=", "other", ".", "tail", "(", ")", ";", "ths", "=", "thisTail", ".", "testCons", "(", ")", ";", "other", "=", "otherTail", ".", "testCons", "(", ")", ";", "if", "(", "ths", "==", "null", "||", "other", "==", "null", ")", "return", "thisTail", ".", "equalsExactly", "(", "otherTail", ")", ";", "}", "while", "(", "true", ")", ";", "}", "public", "abstract", "EObject", "head", "(", ")", ";", "public", "abstract", "EObject", "tail", "(", ")", ";", "public", "ECons", "testCons", "(", ")", "{", "return", "this", ";", "}", "public", "int", "count", "(", ")", "{", "EObject", "cell", "=", "tail", "(", ")", ";", "int", "count", "=", "1", ";", "while", "(", "cell", "!=", "ERT", ".", "NIL", "&&", "(", "cell", "instanceof", "ECons", ")", ")", "{", "cell", "=", "(", "(", "ECons", ")", "cell", ")", ".", "tail", "(", ")", ";", "count", "+=", "1", ";", "}", "return", "count", ";", "}", "public", "ECons", "prepend", "(", "ESeq", "list", ")", "{", "ESeq", "rlist", "=", "ERT", ".", "NIL", ";", "while", "(", "!", "list", ".", "isNil", "(", ")", ")", "{", "rlist", "=", "rlist", ".", "cons", "(", "list", ".", "head", "(", ")", ")", ";", "list", "=", "list", ".", "tail", "(", ")", ";", "}", "ECons", "r", "=", "this", ";", "while", "(", "!", "rlist", ".", "isNil", "(", ")", ")", "{", "r", "=", "r", ".", "cons", "(", "rlist", ".", "head", "(", ")", ")", ";", "rlist", "=", "rlist", ".", "tail", "(", ")", ";", "}", "return", "r", ";", "}", "public", "boolean", "collectIOList", "(", "List", "<", "ByteBuffer", ">", "out", ")", "{", "ECons", "list", ";", "EObject", "tail", ";", "list_loop", ":", "for", "(", "tail", "=", "this", ";", "(", "list", "=", "tail", ".", "testNonEmptyList", "(", ")", ")", "!=", "null", ";", "tail", "=", "list", ".", "tail", "(", ")", ")", "{", "EObject", "head", "=", "list", ".", "head", "(", ")", ";", "ESmall", "intval", ";", "EBinary", "binary", ";", "ECons", "sublist", ";", "if", "(", "(", "intval", "=", "head", ".", "testSmall", "(", ")", ")", "!=", "null", ")", "{", "ByteArrayOutputStream", "barr", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "byte_loop", ":", "do", "{", "int", "byteValue", "=", "intval", ".", "value", "&", "0xff", ";", "if", "(", "intval", ".", "value", "!=", "byteValue", ")", "{", "return", "false", ";", "}", "barr", ".", "write", "(", "byteValue", ")", ";", "tail", "=", "list", ".", "tail", "(", ")", ";", "if", "(", "(", "list", "=", "tail", ".", "testNonEmptyList", "(", ")", ")", "!=", "null", ")", "{", "head", "=", "list", ".", "head", "(", ")", ";", "}", "else", "{", "out", ".", "add", "(", "ByteBuffer", ".", "wrap", "(", "barr", ".", "toByteArray", "(", ")", ")", ")", ";", "break", "list_loop", ";", "}", "}", "while", "(", "(", "intval", "=", "head", ".", "testSmall", "(", ")", ")", "!=", "null", ")", ";", "out", ".", "add", "(", "ByteBuffer", ".", "wrap", "(", "barr", ".", "toByteArray", "(", ")", ")", ")", ";", "}", "if", "(", "(", "binary", "=", "head", ".", "testBinary", "(", ")", ")", "!=", "null", ")", "{", "binary", ".", "collectIOList", "(", "out", ")", ";", "}", "else", "if", "(", "(", "sublist", "=", "head", ".", "testNonEmptyList", "(", ")", ")", "!=", "null", ")", "{", "if", "(", "!", "sublist", ".", "collectIOList", "(", "out", ")", ")", "return", "false", ";", "}", "else", "if", "(", "head", ".", "isNil", "(", ")", ")", "{", "}", "else", "{", "ERT", ".", "debug", "(", "\"head", "is", "\"", "+", "head", "+", "\"::\"", "+", "head", ".", "getClass", "(", ")", ")", ";", "return", "false", ";", "}", "}", "if", "(", "!", "tail", ".", "collectIOList", "(", "out", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}", "public", "void", "collectCharList", "(", "CharCollector", "out", ")", "throws", "CharCollector", ".", "CollectingException", ",", "CharCollector", ".", "InvalidElementException", ",", "IOException", "{", "ECons", "list", ";", "EObject", "tail", ";", "for", "(", "tail", "=", "this", ";", "(", "list", "=", "tail", ".", "testNonEmptyList", "(", ")", ")", "!=", "null", ";", "tail", "=", "list", ".", "tail", "(", ")", ")", "{", "EObject", "head", "=", "list", ".", "head", "(", ")", ";", "ESmall", "intval", ";", "if", "(", "(", "intval", "=", "head", ".", "testSmall", "(", ")", ")", "!=", "null", ")", "{", "try", "{", "out", ".", "addInteger", "(", "intval", ".", "value", ")", ";", "}", "catch", "(", "CharCollector", ".", "DecodingException", "e", ")", "{", "throw", "new", "CharCollector", ".", "CollectingException", "(", "list", ")", ";", "}", "}", "else", "{", "try", "{", "head", ".", "collectCharList", "(", "out", ")", ";", "}", "catch", "(", "CharCollector", ".", "CollectingException", "e", ")", "{", "throw", "new", "CharCollector", ".", "CollectingException", "(", "list", ".", "tail", "(", ")", ".", "cons", "(", "e", ".", "restOfInput", ")", ")", ";", "}", "}", "}", "if", "(", "tail", ".", "testNumber", "(", ")", "!=", "null", ")", "{", "throw", "new", "CharCollector", ".", "InvalidElementException", "(", ")", ";", "}", "else", "tail", ".", "collectCharList", "(", "out", ")", ";", "}", "@", "Override", "public", "Iterator", "<", "EObject", ">", "iterator", "(", ")", "{", "return", "new", "EObjectIterator", "(", "this", ")", ";", "}", "}", "</s>" ]
7,936
[ "<s>", "package", "erjang", ";", "import", "java", ".", "math", ".", "BigInteger", ";", "public", "class", "EBitStringBuilder", "{", "public", "static", "final", "int", "PB_IS_WRITABLE", "=", "1", ";", "public", "static", "final", "int", "PB_ACTIVE_WRITER", "=", "2", ";", "EBitString", "bs", ";", "int", "byte_pos", ";", "int", "extra_bits", ";", "byte", "[", "]", "data", ";", "byte", "flags", ";", "public", "EBitStringBuilder", "(", "int", "byte_size", ",", "int", "flags", ")", "{", "this", ".", "flags", "=", "(", "byte", ")", "flags", ";", "data", "=", "new", "byte", "[", "byte_size", "]", ";", "bs", "=", "EBitString", ".", "make", "(", "data", ",", "0", ",", "byte_size", ",", "0", ")", ";", "}", "public", "static", "EBitStringBuilder", "bs_init_writable", "(", "EObject", "size", ")", "{", "int", "bin_size", "=", "1024", ";", "ESmall", "sz", "=", "size", ".", "testSmall", "(", ")", ";", "if", "(", "sz", "!=", "null", "&&", "sz", ".", "value", ">=", "0", ")", "{", "bin_size", "=", "sz", ".", "value", ";", "}", "EBitStringBuilder", "res", "=", "new", "EBitStringBuilder", "(", "bin_size", ",", "PB_IS_WRITABLE", "|", "PB_ACTIVE_WRITER", ")", ";", "return", "res", ";", "}", "public", "EBitStringBuilder", "(", "int", "byte_size", ",", "int", "extra_bits", ",", "int", "flags", ")", "{", "if", "(", "flags", "!=", "0", ")", "throw", "new", "NotImplemented", "(", "\"flags=\"", "+", "flags", ")", ";", "data", "=", "new", "byte", "[", "byte_size", "+", "(", "extra_bits", ">", "0", "?", "1", ":", "0", ")", "]", ";", "bs", "=", "EBitString", ".", "make", "(", "data", ",", "0", ",", "byte_size", ",", "extra_bits", ")", ";", "}", "public", "EBitString", "bitstring", "(", ")", "{", "return", "bs", ";", "}", "public", "void", "put_float", "(", "EObject", "value", ",", "int", "bit_size", ",", "int", "flags", ")", "{", "if", "(", "extra_bits", "!=", "0", ")", "throw", "new", "NotImplemented", "(", ")", ";", "switch", "(", "bit_size", ")", "{", "case", "32", ":", "{", "ENumber", "en", "=", "value", ".", "testNumber", "(", ")", ";", "if", "(", "en", "==", "null", ")", "{", "throw", "ERT", ".", "badarg", "(", "value", ")", ";", "}", "float", "val", "=", "(", "float", ")", "en", ".", "doubleValue", "(", ")", ";", "put_int32", "(", "Float", ".", "floatToIntBits", "(", "val", ")", ",", "flags", ")", ";", "return", ";", "}", "case", "64", ":", "{", "ENumber", "en", "=", "value", ".", "testNumber", "(", ")", ";", "if", "(", "en", "==", "null", ")", "{", "throw", "ERT", ".", "badarg", "(", "value", ")", ";", "}", "double", "val", "=", "en", ".", "doubleValue", "(", ")", ";", "put_int64", "(", "Double", ".", "doubleToLongBits", "(", "val", ")", ",", "flags", ")", ";", "return", ";", "}", "}", "throw", "new", "NotImplemented", "(", "\"val=\"", "+", "value", "+", "\";size=\"", "+", "bit_size", "+", "\";flags=\"", "+", "flags", ")", ";", "}", "public", "void", "put_integer", "(", "EObject", "value", ",", "int", "flags", ")", "{", "throw", "new", "NotImplemented", "(", "\"val=\"", "+", "value", "+", "\";flags=\"", "+", "flags", ")", ";", "}", "public", "void", "put_integer", "(", "EObject", "value", ",", "int", "bit_size", ",", "int", "flags", ")", "{", "boolean", "litteEndian", "=", "(", "flags", "&", "EBinMatchState", ".", "BSF_LITTLE", ")", ">", "0", ";", "EInteger", "ei", "=", "value", ".", "testInteger", "(", ")", ";", "if", "(", "ei", "==", "null", ")", "throw", "ERT", ".", "badarg", "(", "value", ")", ";", "if", "(", "bit_size", "==", "8", "&&", "extra_bits", "==", "0", ")", "{", "data", "[", "byte_pos", "++", "]", "=", "(", "byte", ")", "ei", ".", "intValue", "(", ")", ";", "return", ";", "}", "ESmall", "sm", "=", "value", ".", "testSmall", "(", ")", ";", "if", "(", "extra_bits", "==", "0", "&&", "(", "bit_size", "%", "8", ")", "==", "0", ")", "{", "int", "nBytes", "=", "bit_size", "/", "8", ";", "int", "pos", ",", "delta", ";", "if", "(", "litteEndian", ")", "{", "pos", "=", "byte_pos", ";", "delta", "=", "1", ";", "}", "else", "{", "pos", "=", "byte_pos", "+", "nBytes", "-", "1", ";", "delta", "=", "-", "1", ";", "}", "byte_pos", "+=", "nBytes", ";", "if", "(", "sm", "!=", "null", ")", "{", "int", "val", "=", "sm", ".", "intValue", "(", ")", ";", "while", "(", "nBytes", "--", ">", "0", ")", "{", "data", "[", "pos", "]", "=", "(", "byte", ")", "val", ";", "pos", "+=", "delta", ";", "val", ">>=", "8", ";", "}", "}", "else", "{", "BigInteger", "big_int", "=", "ei", ".", "bigintValue", "(", ")", ";", "byte", "[", "]", "bytes", "=", "big_int", ".", "toByteArray", "(", ")", ";", "int", "src_pos", "=", "bytes", ".", "length", ";", "while", "(", "--", "src_pos", ">=", "0", "&&", "nBytes", "--", ">", "0", ")", "{", "data", "[", "pos", "]", "=", "bytes", "[", "src_pos", "]", ";", "pos", "+=", "delta", ";", "}", "if", "(", "nBytes", ">", "0", ")", "{", "byte", "sign_byte", "=", "(", "byte", ")", "(", "big_int", ".", "signum", "(", ")", "<", "0", "?", "-", "1", ":", "0", ")", ";", "while", "(", "nBytes", "--", ">", "0", ")", "{", "data", "[", "pos", "]", "=", "sign_byte", ";", "pos", "+=", "delta", ";", "}", "}", "}", "return", ";", "}", "if", "(", "bit_size", "<=", "32", "&&", "(", "bit_size", "%", "8", ")", "!=", "0", ")", "{", "int", "val", "=", "sm", ".", "value", ";", "if", "(", "litteEndian", ")", "throw", "new", "NotImplemented", "(", ")", ";", "int", "bits_left_in_current_byte", "=", "8", "-", "extra_bits", ";", "int", "msb_bits", "=", "Math", ".", "min", "(", "bits_left_in_current_byte", ",", "bit_size", ")", ";", "int", "lsb_bits", "=", "bit_size", "-", "msb_bits", ";", "while", "(", "lsb_bits", "+", "msb_bits", ">", "0", ")", "{", "int", "mask", "=", "(", "(", "1", "<<", "msb_bits", ")", "-", "1", ")", ";", "int", "putval", "=", "(", "(", "val", ">>>", "lsb_bits", ")", "&", "mask", ")", "<<", "(", "8", "-", "msb_bits", ")", ";", "int", "getval", "=", "data", "[", "byte_pos", "]", ";", "assert", "(", "(", "putval", "&", "getval", ")", "==", "0", ")", ";", "data", "[", "byte_pos", "]", "=", "(", "byte", ")", "(", "putval", "|", "getval", ")", ";", "extra_bits", "=", "(", "extra_bits", "+", "msb_bits", ")", "%", "8", ";", "if", "(", "extra_bits", "==", "0", ")", "{", "byte_pos", "+=", "1", ";", "}", "lsb_bits", "-=", "msb_bits", ";", "msb_bits", "=", "Math", ".", "min", "(", "8", ",", "lsb_bits", ")", ";", "}", "return", ";", "}", "EBig", "bi", "=", "value", ".", "testBig", "(", ")", ";", "if", "(", "bit_size", "<=", "64", "&&", "(", "bit_size", "%", "8", ")", "!=", "0", ")", "{", "long", "val", "=", "bi", "==", "null", "?", "sm", ".", "longValue", "(", ")", ":", "bi", ".", "longValue", "(", ")", ";", "if", "(", "litteEndian", ")", "throw", "new", "NotImplemented", "(", ")", ";", "int", "bits_left_in_current_byte", "=", "(", "extra_bits", "==", "0", "?", "8", ":", "8", "-", "extra_bits", ")", ";", "int", "msb_bits", "=", "Math", ".", "min", "(", "bits_left_in_current_byte", ",", "bit_size", ")", ";", "int", "lsb_bits", "=", "bit_size", "-", "msb_bits", ";", "while", "(", "lsb_bits", "+", "msb_bits", ">", "0", ")", "{", "int", "mask", "=", "(", "(", "1", "<<", "msb_bits", ")", "-", "1", ")", ";", "int", "putval", "=", "(", "int", ")", "(", "(", "val", ">>>", "lsb_bits", ")", "&", "mask", ")", ";", "int", "getval", "=", "data", "[", "byte_pos", "]", "&", "~", "mask", ";", "assert", "(", "(", "putval", "&", "getval", ")", "==", "0", ")", ";", "data", "[", "byte_pos", "]", "=", "(", "byte", ")", "(", "putval", "|", "getval", ")", ";", "extra_bits", "=", "(", "extra_bits", "+", "msb_bits", ")", "%", "8", ";", "if", "(", "extra_bits", "==", "0", ")", "{", "byte_pos", "+=", "1", ";", "}", "lsb_bits", "-=", "msb_bits", ";", "msb_bits", "=", "Math", ".", "min", "(", "8", ",", "lsb_bits", ")", ";", "}", ";", "return", ";", "}", "throw", "new", "NotImplemented", "(", "\"\"", "+", "value", "+", "\";", "bit_size=\"", "+", "bit_size", "+", "\";", "flags=\"", "+", "flags", ")", ";", "}", "protected", "void", "put_int64", "(", "long", "val", ",", "int", "flags", ")", "{", "if", "(", "(", "flags", "&", "EBinMatchState", ".", "BSF_LITTLE", ")", ">", "0", ")", "{", "put_int32_little", "(", "(", "int", ")", "val", ")", ";", "put_int32_little", "(", "(", "int", ")", "(", "val", ">>", "32", ")", ")", ";", "}", "else", "{", "put_int32_big", "(", "(", "int", ")", "(", "val", ">>", "32", ")", ")", ";", "put_int32_big", "(", "(", "int", ")", "val", ")", ";", "}", "}", "protected", "void", "put_int32", "(", "int", "val", ",", "int", "flags", ")", "{", "if", "(", "(", "flags", "&", "EBinMatchState", ".", "BSF_LITTLE", ")", ">", "0", ")", "{", "put_int32_little", "(", "val", ")", ";", "}", "else", "{", "put_int32_big", "(", "val", ")", ";", "}", "}", "protected", "void", "put_int32_little", "(", "int", "val", ")", "{", "byte", "b1", ",", "b2", ",", "b3", ",", "b4", ";", "b1", "=", "(", "byte", ")", "val", ";", "val", ">>=", "8", ";", "b2", "=", "(", "byte", ")", "val", ";", "val", ">>=", "8", ";", "b3", "=", "(", "byte", ")", "val", ";", "val", ">>=", "8", ";", "b4", "=", "(", "byte", ")", "val", ";", "put_byte", "(", "b1", ")", ";", "put_byte", "(", "b2", ")", ";", "put_byte", "(", "b3", ")", ";", "put_byte", "(", "b4", ")", ";", "}", "protected", "void", "put_int32_big", "(", "int", "val", ")", "{", "byte", "b1", ",", "b2", ",", "b3", ",", "b4", ";", "b4", "=", "(", "byte", ")", "val", ";", "val", ">>=", "8", ";", "b3", "=", "(", "byte", ")", "val", ";", "val", ">>=", "8", ";", "b2", "=", "(", "byte", ")", "val", ";", "val", ">>=", "8", ";", "b1", "=", "(", "byte", ")", "val", ";", "put_byte", "(", "b1", ")", ";", "put_byte", "(", "b2", ")", ";", "put_byte", "(", "b3", ")", ";", "put_byte", "(", "b4", ")", ";", "}", "private", "void", "put_byte", "(", "byte", "val", ")", "{", "if", "(", "extra_bits", "==", "0", ")", "{", "data", "[", "byte_pos", "++", "]", "=", "val", ";", "return", ";", "}", "else", "{", "int", "bits1", "=", "extra_bits", ";", "int", "bits2", "=", "8", "-", "bits1", ";", "data", "[", "byte_pos", "]", "|=", "(", "byte", ")", "(", "(", "0xff", "&", "val", ")", ">>", "bits1", ")", ";", "data", "[", "byte_pos", "+", "1", "]", "=", "(", "byte", ")", "(", "(", "val", "&", "(", "(", "1", "<<", "bits1", ")", "-", "1", ")", ")", "<<", "bits2", ")", ";", "byte_pos", "+=", "1", ";", "}", "}", "public", "void", "put_string", "(", "EString", "str", ")", "{", "if", "(", "extra_bits", "!=", "0", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "str", ".", "length", "(", ")", ";", "i", "++", ")", "{", "put_byte", "(", "str", ".", "data", "[", "str", ".", "off", "+", "i", "]", ")", ";", "}", "return", ";", "}", "System", ".", "arraycopy", "(", "str", ".", "data", ",", "str", ".", "off", ",", "data", ",", "byte_pos", ",", "str", ".", "length", "(", ")", ")", ";", "byte_pos", "+=", "str", ".", "length", "(", ")", ";", "}", "public", "static", "EBitStringBuilder", "bs_private_append", "(", "EObject", "str_or_builder", ",", "int", "extra_size", ",", "int", "unit", ",", "int", "flags", ")", "{", "EBitString", "ebs", "=", "str_or_builder", ".", "testBitString", "(", ")", ";", "if", "(", "ebs", "==", "null", ")", "throw", "new", "NotImplemented", "(", ")", ";", "long", "bitSize", "=", "ebs", ".", "bitSize", "(", ")", "+", "extra_size", ";", "int", "size", "=", "(", "int", ")", "(", "bitSize", "/", "8", ")", ";", "int", "extra", "=", "(", "int", ")", "(", "bitSize", "%", "8", ")", ";", "EBitStringBuilder", "result", "=", "new", "EBitStringBuilder", "(", "size", ",", "extra", ",", "flags", ")", ";", "System", ".", "arraycopy", "(", "ebs", ".", "data", ",", "ebs", ".", "byteOffset", "(", ")", ",", "result", ".", "data", ",", "0", ",", "ebs", ".", "dataByteSize", "(", ")", ")", ";", "result", ".", "byte_pos", "=", "ebs", ".", "byteSize", "(", ")", ";", "result", ".", "extra_bits", "=", "ebs", ".", "extra_bits", ";", "return", "result", ";", "}", "public", "static", "EBitStringBuilder", "bs_append", "(", "EObject", "str_or_builder", ",", "int", "extra_size", ",", "int", "unit", ",", "int", "flags", ")", "{", "EBitString", "ebs", "=", "str_or_builder", ".", "testBitString", "(", ")", ";", "if", "(", "ebs", "==", "null", ")", "throw", "new", "NotImplemented", "(", ")", ";", "long", "bitSize", "=", "ebs", ".", "bitSize", "(", ")", "+", "extra_size", ";", "int", "size", "=", "(", "int", ")", "(", "bitSize", "/", "8", ")", ";", "int", "extra", "=", "(", "int", ")", "(", "bitSize", "%", "8", ")", ";", "EBitStringBuilder", "result", "=", "new", "EBitStringBuilder", "(", "size", ",", "extra", ",", "flags", ")", ";", "System", ".", "arraycopy", "(", "ebs", ".", "data", ",", "ebs", ".", "byteOffset", "(", ")", ",", "result", ".", "data", ",", "0", ",", "ebs", ".", "dataByteSize", "(", ")", ")", ";", "result", ".", "byte_pos", "=", "ebs", ".", "byteSize", "(", ")", ";", "result", ".", "extra_bits", "=", "ebs", ".", "extra_bits", ";", "return", "result", ";", "}", "public", "void", "put_bitstring", "(", "EObject", "str", ",", "int", "size", ",", "int", "flags", ")", "{", "EBitString", "ebs", "=", "str", ".", "testBitString", "(", ")", ";", "if", "(", "ebs", "==", "null", ")", "throw", "new", "InternalError", "(", "\"\"", "+", "str", ".", "getClass", "(", ")", ")", ";", "if", "(", "extra_bits", "!=", "0", ")", "throw", "new", "NotImplemented", "(", ")", ";", "if", "(", "size", "!=", "-", "1", "&&", "size", "!=", "ebs", ".", "bitSize", "(", ")", ")", "{", "throw", "new", "NotImplemented", "(", ")", ";", "}", "System", ".", "arraycopy", "(", "ebs", ".", "data", ",", "ebs", ".", "byteOffset", "(", ")", ",", "data", ",", "byte_pos", ",", "ebs", ".", "totalByteSize", "(", ")", ")", ";", "byte_pos", "+=", "ebs", ".", "byteSize", "(", ")", ";", "extra_bits", "+=", "ebs", ".", "extra_bits", ";", "}", "public", "void", "put_utf8", "(", "EObject", "value", ",", "int", "flags", ")", "{", "throw", "new", "NotImplemented", "(", "\"val=\"", "+", "value", "+", "\";flags=\"", "+", "flags", ")", ";", "}", "public", "void", "put_utf16", "(", "EObject", "value", ",", "int", "flags", ")", "{", "throw", "new", "NotImplemented", "(", "\"val=\"", "+", "value", "+", "\";flags=\"", "+", "flags", ")", ";", "}", "public", "void", "put_utf32", "(", "EObject", "value", ",", "int", "flags", ")", "{", "throw", "new", "NotImplemented", "(", "\"val=\"", "+", "value", "+", "\";flags=\"", "+", "flags", ")", ";", "}", "static", "public", "ESmall", "bs_utf8_size", "(", "EObject", "value", ")", "{", "throw", "new", "NotImplemented", "(", "\"val=\"", "+", "value", ")", ";", "}", "static", "public", "ESmall", "bs_utf16_size", "(", "EObject", "value", ")", "{", "throw", "new", "NotImplemented", "(", "\"val=\"", "+", "value", ")", ";", "}", "}", "</s>" ]
7,937
[ "<s>", "package", "erjang", ";", "import", "java", ".", "math", ".", "BigInteger", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "erjang", ".", "m", ".", "ets", ".", "EMatchContext", ";", "import", "erjang", ".", "m", ".", "ets", ".", "EPattern", ";", "import", "erjang", ".", "m", ".", "ets", ".", "ETermPattern", ";", "public", "abstract", "class", "ENumber", "extends", "EObject", "{", "@", "Override", "int", "cmp_order", "(", ")", "{", "return", "CMP_ORDER_NUMBER", ";", "}", "public", "boolean", "match", "(", "ETermPattern", "matcher", ",", "EMatchContext", "r", ")", "{", "return", "matcher", ".", "match", "(", "this", ",", "r", ")", ";", "}", "@", "Override", "public", "ETermPattern", "compileMatch", "(", "Set", "<", "Integer", ">", "out", ")", "{", "return", "EPattern", ".", "compilePattern", "(", "this", ",", "out", ")", ";", "}", "public", "abstract", "double", "doubleValue", "(", ")", ";", "public", "abstract", "int", "intValue", "(", ")", ";", "public", "static", "ENumber", "parseInt", "(", "String", "str", ")", "{", "try", "{", "int", "val", "=", "java", ".", "lang", ".", "Integer", ".", "parseInt", "(", "str", ")", ";", "return", "new", "ESmall", "(", "val", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "BigInteger", "val", "=", "new", "java", ".", "math", ".", "BigInteger", "(", "str", ")", ";", "return", "new", "EBig", "(", "val", ")", ";", "}", "}", "public", "ENumber", "testNumber", "(", ")", "{", "return", "this", ";", "}", "public", "abstract", "ENumber", "abs", "(", ")", ";", "public", "abstract", "EInteger", "asInteger", "(", ")", ";", "public", "EDouble", "divide", "(", "double", "rhs", ")", "{", "return", "ERT", ".", "box", "(", "doubleValue", "(", ")", "/", "rhs", ")", ";", "}", "}", "</s>" ]
7,938
[ "<s>", "package", "erjang", ";", "import", "erjang", ".", "m", ".", "erlang", ".", "DistEntry", ";", "import", "kilim", ".", "Mailbox", ";", "import", "kilim", ".", "Pausable", ";", "import", "kilim", ".", "Task", ";", "public", "class", "EInternalPID", "extends", "EPID", "implements", "ELocalHandle", "{", "private", "EProc", "task", ";", "private", "int", "id", ";", "private", "DistEntry", "distEntry", ";", "public", "EInternalPID", "testInternalPID", "(", ")", "{", "return", "this", ";", "}", "@", "Override", "protected", "int", "id", "(", ")", "{", "return", "id", "&", "0x7fff", ";", "}", "@", "Override", "protected", "int", "serial", "(", ")", "{", "return", "id", ">>>", "15", ";", "}", "@", "Override", "public", "EAtom", "node", "(", ")", "{", "return", "ERT", ".", "getLocalNode", "(", ")", ".", "node", ";", "}", "@", "Override", "protected", "int", "creation", "(", ")", "{", "return", "ERT", ".", "getLocalNode", "(", ")", ".", "creation", ";", "}", "public", "EInternalPID", "(", "EProc", "self", ")", "{", "super", "(", "ERT", ".", "getLocalNode", "(", ")", ")", ";", "this", ".", "task", "=", "self", ";", "this", ".", "id", "=", "task", ".", "id", ";", "}", "@", "Override", "public", "boolean", "is_alive", "(", ")", "{", "return", "task", "!=", "null", "&&", "task", ".", "is_alive", "(", ")", ";", "}", "public", "ELocalHandle", "testLocalHandle", "(", ")", "{", "return", "this", ";", "}", "@", "Override", "public", "EProc", "task", "(", ")", "{", "return", "task", ";", "}", "@", "Override", "public", "boolean", "link_oneway", "(", "EHandle", "other", ")", "throws", "Pausable", "{", "EProc", "task", "=", "this", ".", "task", ";", "if", "(", "task", "!=", "null", ")", "return", "task", ".", "link_oneway", "(", "other", ")", ";", "return", "false", ";", "}", "@", "Override", "public", "void", "unlink_oneway", "(", "EHandle", "other", ")", "throws", "Pausable", "{", "EProc", "task", "=", "this", ".", "task", ";", "if", "(", "task", "!=", "null", ")", "task", ".", "unlink_oneway", "(", "other", ")", ";", "}", "public", "synchronized", "boolean", "add_monitor", "(", "EHandle", "observer", ",", "ERef", "ref", ")", "throws", "Pausable", "{", "EProc", "task", "=", "this", ".", "task", ";", "if", "(", "task", "!=", "null", ")", "return", "task", ".", "add_monitor", "(", "observer", ",", "ref", ")", ";", "else", "return", "false", ";", "}", "@", "Override", "public", "void", "send_monitor_exit", "(", "EHandle", "from", ",", "ERef", "ref", ",", "EObject", "reason", ")", "throws", "Pausable", "{", "EProc", "task", "=", "this", ".", "task", ";", "if", "(", "task", "!=", "null", ")", "{", "task", ".", "send_monitor_exit", "(", "from", ",", "ref", ",", "reason", ")", ";", "}", "}", "@", "Override", "public", "void", "remove_monitor", "(", "EHandle", "sender", ",", "ERef", "r", ",", "boolean", "flush", ")", "throws", "Pausable", "{", "EProc", "task", "=", "this", ".", "task", ";", "if", "(", "task", "!=", "null", ")", "task", ".", "remove_monitor", "(", "r", ",", "flush", ")", ";", "}", "@", "Override", "public", "void", "set_group_leader", "(", "EPID", "group_leader", ")", "{", "EProc", "task", "=", "this", ".", "task", ";", "if", "(", "task", "!=", "null", ")", "task", ".", "set_group_leader", "(", "group_leader", ")", ";", "}", "public", "int", "internal_pid_number", "(", ")", "{", "return", "id", ";", "}", "@", "Override", "public", "EObject", "process_info", "(", ")", "{", "EProc", "task", "=", "this", ".", "task", ";", "if", "(", "task", "==", "null", ")", "return", "ERT", ".", "am_undefined", ";", "return", "task", ".", "process_info", "(", ")", ";", "}", "@", "Override", "public", "EObject", "process_info", "(", "EObject", "spec", ")", "{", "EProc", "task", "=", "this", ".", "task", ";", "if", "(", "task", "==", "null", ")", "return", "ERT", ".", "am_undefined", ";", "return", "task", ".", "process_info", "(", "spec", ")", ";", "}", "@", "Override", "public", "boolean", "equalsExactly", "(", "EObject", "rhs", ")", "{", "return", "rhs", "==", "this", ";", "}", "@", "Override", "public", "int", "hashCode", "(", ")", "{", "return", "System", ".", "identityHashCode", "(", "this", ")", ";", "}", "public", "void", "add_exit_hook", "(", "ExitHook", "hook", ")", "{", "EProc", "task", "=", "this", ".", "task", ";", "if", "(", "task", "!=", "null", "&&", "is_alive", "(", ")", ")", "task", ".", "add_exit_hook", "(", "hook", ")", ";", "}", "public", "void", "remove_exit_hook", "(", "ExitHook", "hook", ")", "{", "EProc", "task", "=", "this", ".", "task", ";", "if", "(", "task", "!=", "null", ")", "task", ".", "remove_exit_hook", "(", "hook", ")", ";", "}", "public", "void", "done", "(", ")", "{", "this", ".", "task", "=", "null", ";", "}", "public", "void", "set_dist_entry", "(", "DistEntry", "distEntry", ")", "{", "this", ".", "distEntry", "=", "distEntry", ";", "}", "}", "</s>" ]
7,939
[ "<s>", "package", "erjang", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "java", ".", "util", ".", "logging", ".", "Logger", ";", "import", "erjang", ".", "m", ".", "ets", ".", "EMatchContext", ";", "import", "erjang", ".", "m", ".", "ets", ".", "EPattern", ";", "import", "erjang", ".", "m", ".", "ets", ".", "ETermPattern", ";", "public", "abstract", "class", "EPID", "extends", "EHandle", "{", "static", "Logger", "log", "=", "Logger", ".", "getLogger", "(", "\"erjang.proc\"", ")", ";", "public", "EPID", "(", "EAbstractNode", "node", ")", "{", "super", "(", "node", ")", ";", "}", "@", "Override", "int", "cmp_order", "(", ")", "{", "return", "CMP_ORDER_PID", ";", "}", "public", "EPID", "testPID", "(", ")", "{", "return", "this", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "if", "(", "node", "(", ")", "==", "ERT", ".", "getLocalNode", "(", ")", ".", "node", ")", "{", "return", "\"<\"", "+", "creation", "(", ")", "+", "\".\"", "+", "serial", "(", ")", "+", "\".\"", "+", "id", "(", ")", "+", "\">\"", ";", "}", "else", "{", "return", "\"<\"", "+", "node", "(", ")", "+", "\".\"", "+", "creation", "(", ")", "+", "\".\"", "+", "serial", "(", ")", "+", "\".\"", "+", "id", "(", ")", "+", "\">\"", ";", "}", "}", "public", "boolean", "match", "(", "ETermPattern", "matcher", ",", "EMatchContext", "r", ")", "{", "return", "matcher", ".", "match", "(", "this", ",", "r", ")", ";", "}", "@", "Override", "public", "ETermPattern", "compileMatch", "(", "Set", "<", "Integer", ">", "out", ")", "{", "return", "EPattern", ".", "compilePattern", "(", "this", ",", "out", ")", ";", "}", "public", "EString", "getName", "(", ")", "{", "return", "EString", ".", "fromString", "(", "toString", "(", ")", ")", ";", "}", "@", "Override", "int", "compare_same", "(", "EObject", "rhs", ")", "{", "if", "(", "rhs", "==", "this", ")", "return", "0", ";", "EPID", "op", "=", "(", "EPID", ")", "rhs", ";", "if", "(", "id", "(", ")", "!=", "op", ".", "id", "(", ")", ")", "{", "if", "(", "id", "(", ")", "<", "op", ".", "id", "(", ")", ")", "return", "-", "1", ";", "return", "1", ";", "}", "if", "(", "serial", "(", ")", "!=", "op", ".", "serial", "(", ")", ")", "{", "if", "(", "serial", "(", ")", "<", "op", ".", "serial", "(", ")", ")", "return", "-", "1", ";", "return", "1", ";", "}", "if", "(", "creation", "(", ")", "!=", "op", ".", "creation", "(", ")", ")", "{", "if", "(", "creation", "(", ")", "<", "op", ".", "creation", "(", ")", ")", "return", "-", "1", ";", "return", "1", ";", "}", "return", "node", "(", ")", ".", "compareTo", "(", "op", ".", "node", "(", ")", ")", ";", "}", "@", "Override", "public", "int", "hashCode", "(", ")", "{", "return", "(", "100000007", "*", "id", "(", ")", "+", "200000033", "*", "serial", "(", ")", "+", "300000007", "*", "creation", "(", ")", "+", "400000009", "*", "node", "(", ")", ".", "hashCode", "(", ")", ")", ";", "}", "public", "abstract", "void", "set_group_leader", "(", "EPID", "gl", ")", ";", "public", "abstract", "EObject", "process_info", "(", ")", ";", "public", "abstract", "EObject", "process_info", "(", "EObject", "spec", ")", ";", "public", "static", "EPID", "read", "(", "EInputStream", "ei", ")", "throws", "IOException", "{", "return", "ei", ".", "read_pid", "(", ")", ";", "}", "public", "static", "EPID", "make", "(", "EAtom", "node", ",", "int", "id", ",", "int", "serial", ",", "int", "creation", ")", "{", "if", "(", "node", "==", "ERT", ".", "getLocalNode", "(", ")", ".", "node", ")", "{", "EPID", "res", "=", "EProc", ".", "find", "(", "id", ",", "serial", ")", ";", "if", "(", "res", "!=", "null", ")", "return", "res", ";", "log", ".", "warning", "(", "\"deadpid", "<\"", "+", "id", "+", "\".\"", "+", "serial", "+", "\".\"", "+", "creation", "+", "\">\"", ")", ";", "}", "EAbstractNode", "peer", "=", "EPeer", ".", "get", "(", "node", ")", ";", "if", "(", "peer", "instanceof", "EPeer", ")", "{", "return", "new", "EExternalPID", "(", "(", "EPeer", ")", "peer", ",", "id", ",", "serial", ",", "creation", ")", ";", "}", "else", "{", "log", ".", "fine", "(", "\"localnode=\"", "+", "ERT", ".", "getLocalNode", "(", ")", ".", "node", "+", "\";", "asking=\"", "+", "node", ")", ";", "return", "new", "EExternalPID", "(", "EPeer", ".", "get_or_create", "(", "node", ",", "creation", ",", "0", ",", "0", ")", ",", "id", ",", "serial", ",", "creation", ")", ";", "}", "}", "public", "abstract", "boolean", "is_alive", "(", ")", ";", "public", "void", "encode", "(", "EOutputStream", "eos", ")", "{", "eos", ".", "write_pid", "(", "node", ".", "node", ",", "id", "(", ")", ",", "serial", "(", ")", ",", "creation", "(", ")", ")", ";", "}", "protected", "int", "serial", "(", ")", "{", "throw", "new", "erjang", ".", "NotImplemented", "(", ")", ";", "}", "protected", "int", "id", "(", ")", "{", "throw", "new", "erjang", ".", "NotImplemented", "(", ")", ";", "}", "protected", "int", "creation", "(", ")", "{", "throw", "new", "erjang", ".", "NotImplemented", "(", ")", ";", "}", "}", "</s>" ]
7,940
[ "<s>", "package", "erjang", ";", "public", "interface", "EFunMaker", "{", "EFun", "make", "(", "EPID", "pid", ",", "EObject", "[", "]", "freevars", ")", ";", "}", "</s>" ]
7,941
[ "<s>", "package", "erjang", ";", "import", "kilim", ".", "Pausable", ";", "import", "java", ".", "util", ".", "concurrent", ".", "atomic", ".", "AtomicLong", ";", "import", "java", ".", "util", ".", "concurrent", ".", "atomic", ".", "AtomicInteger", ";", "public", "class", "ELocalNode", "extends", "EAbstractNode", "{", "private", "int", "serial", "=", "0", ";", "private", "int", "pidCount", "=", "1", ";", "private", "int", "portCount", "=", "1", ";", "private", "int", "refId", "[", "]", ";", "protected", "ELocalNode", "(", ")", "{", "super", "(", ")", ";", "init", "(", ")", ";", "}", "protected", "ELocalNode", "(", "final", "EAtom", "node", ")", "{", "super", "(", "node", ")", ";", "init", "(", ")", ";", "}", "protected", "ELocalNode", "(", "final", "EAtom", "node", ",", "final", "EAtom", "cookie", ")", "{", "super", "(", "node", ",", "cookie", ")", ";", "init", "(", ")", ";", "}", "private", "void", "init", "(", ")", "{", "serial", "=", "0", ";", "pidCount", "=", "1", ";", "portCount", "=", "1", ";", "refId", "=", "new", "int", "[", "3", "]", ";", "refId", "[", "0", "]", "=", "1", ";", "refId", "[", "1", "]", "=", "0", ";", "refId", "[", "2", "]", "=", "0", ";", "}", "final", "static", "AtomicLong", "ref_serial_low", "=", "new", "AtomicLong", "(", ")", ";", "final", "static", "AtomicInteger", "ref_serial_high", "=", "new", "AtomicInteger", "(", ")", ";", "public", "ERef", "createRef", "(", ")", "{", "long", "low", "=", "ref_serial_low", ".", "incrementAndGet", "(", ")", ";", "int", "high", "=", "ref_serial_high", ".", "get", "(", ")", ";", "if", "(", "(", "low", ">>>", "63", ")", "!=", "(", "high", "&", "1", ")", ")", "{", "ref_serial_high", ".", "compareAndSet", "(", "high", ",", "++", "high", ")", ";", "}", "int", "id1", "=", "(", "int", ")", "(", "low", "&", "(", "(", "1", "<<", "18", ")", "-", "1", ")", ")", ";", "int", "id2", "=", "(", "int", ")", "(", "low", ">>", "18", ")", ";", "int", "id3", "=", "(", "int", ")", "(", "(", "low", ">>", "(", "18", "+", "32", ")", ")", "|", "(", "high", "<<", "(", "63", "-", "(", "18", "+", "32", ")", ")", ")", ")", ";", "return", "new", "ERef", "(", "node", ",", "id1", ",", "id2", ",", "id3", ",", "creation", ")", ";", "}", "public", "synchronized", "int", "createPortID", "(", ")", "{", "portCount", "++", ";", "if", "(", "portCount", ">", "0xfffffff", ")", "{", "portCount", "=", "0", ";", "}", "return", "portCount", ";", "}", "public", "EObject", "dsig_reg_send", "(", "EInternalPID", "caller", ",", "EAtom", "name", ",", "EObject", "msg", ")", "throws", "Pausable", "{", "return", "ERT", ".", "send", "(", "caller", ".", "task", "(", ")", ",", "name", ",", "msg", ")", ";", "}", "public", "void", "dsig_demonitor", "(", "EHandle", "sender", ",", "ERef", "ref", ",", "EObject", "to_pid_or_name", ")", "throws", "Pausable", "{", "EInternalPID", "pid", ";", "EAtom", "name", ";", "if", "(", "(", "pid", "=", "to_pid_or_name", ".", "testInternalPID", "(", ")", ")", "!=", "null", ")", "{", "EProc", "task", "=", "pid", ".", "task", "(", ")", ";", "if", "(", "task", "!=", "null", ")", "task", ".", "demonitor", "(", "ref", ")", ";", "}", "else", "if", "(", "(", "name", "=", "to_pid_or_name", ".", "testAtom", "(", ")", ")", "!=", "null", ")", "{", "EObject", "local", "=", "ERT", ".", "whereis", "(", "name", ")", ";", "if", "(", "(", "pid", "=", "local", ".", "testInternalPID", "(", ")", ")", "!=", "null", ")", "{", "EProc", "task", "=", "pid", ".", "task", "(", ")", ";", "if", "(", "task", "!=", "null", ")", "task", ".", "demonitor", "(", "ref", ")", ";", "}", "}", "}", "}", "</s>" ]
7,942
[ "<s>", "package", "erjang", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "nio", ".", "charset", ".", "Charset", ";", "import", "java", ".", "nio", ".", "charset", ".", "CharsetDecoder", ";", "import", "java", ".", "nio", ".", "charset", ".", "CoderResult", ";", "import", "java", ".", "nio", ".", "CharBuffer", ";", "import", "java", ".", "nio", ".", "ByteBuffer", ";", "public", "class", "CharCollector", "{", "public", "static", "ByteBuffer", "EMPTY", "=", "ByteBuffer", ".", "wrap", "(", "new", "byte", "[", "0", "]", ")", ";", "public", "static", "int", "BUF_SIZE", "=", "20486", ";", "CharsetDecoder", "decoder", ";", "CharBuffer", "buffer", ";", "Appendable", "output", ";", "boolean", "dirtyDecoder", "=", "false", ";", "public", "CharCollector", "(", "Charset", "charset", ",", "Appendable", "output", ")", "{", "buffer", "=", "CharBuffer", ".", "allocate", "(", "BUF_SIZE", ")", ";", "this", ".", "output", "=", "output", ";", "this", ".", "decoder", "=", "charset", ".", "newDecoder", "(", ")", ";", "this", ".", "decoder", ".", "reset", "(", ")", ";", "}", "public", "void", "addInteger", "(", "int", "value", ")", "throws", "IOException", ",", "DecodingException", "{", "if", "(", "dirtyDecoder", ")", "try", "{", "flushDecoder", "(", ")", ";", "}", "catch", "(", "PartialDecodingException", "e", ")", "{", "throw", "new", "DecodingException", "(", ")", ";", "}", "char", "c", "=", "(", "char", ")", "value", ";", "if", "(", "c", "!=", "value", ")", "fail", "(", "new", "DecodingException", "(", ")", ")", ";", "if", "(", "!", "buffer", ".", "hasRemaining", "(", ")", ")", "flushBuffer", "(", ")", ";", "buffer", ".", "put", "(", "c", ")", ";", "}", "public", "void", "addIntegers", "(", "byte", "[", "]", "data", ",", "int", "offset", ",", "int", "length", ")", "throws", "IOException", ",", "PartialDecodingException", "{", "if", "(", "length", "==", "0", ")", "return", ";", "if", "(", "dirtyDecoder", ")", "flushDecoder", "(", ")", ";", "while", "(", "length", ">", "0", ")", "{", "int", "free", "=", "buffer", ".", "remaining", "(", ")", ";", "while", "(", "length", ">", "0", "&&", "free", ">", "0", ")", "{", "char", "c", "=", "(", "char", ")", "(", "data", "[", "offset", "]", "&", "0xFF", ")", ";", "buffer", ".", "put", "(", "c", ")", ";", "offset", "++", ";", "length", "--", ";", "free", "--", ";", "}", "if", "(", "free", "==", "0", ")", "flushBuffer", "(", ")", ";", "}", "}", "public", "void", "addBinary", "(", "byte", "[", "]", "data", ",", "int", "offset", ",", "int", "length", ")", "throws", "IOException", ",", "PartialDecodingException", "{", "addBinary", "(", "ByteBuffer", ".", "wrap", "(", "data", ",", "offset", ",", "length", ")", ",", "false", ")", ";", "}", "public", "void", "addBinary", "(", "ByteBuffer", "data", ",", "boolean", "endOfInput", ")", "throws", "IOException", ",", "PartialDecodingException", "{", "CoderResult", "res", ";", "do", "{", "res", "=", "decoder", ".", "decode", "(", "data", ",", "buffer", ",", "endOfInput", ")", ";", "if", "(", "!", "handle", "(", "res", ")", ")", "fail", "(", "new", "PartialDecodingException", "(", "data", ".", "position", "(", ")", ")", ")", ";", "}", "while", "(", "res", "==", "CoderResult", ".", "OVERFLOW", ")", ";", "if", "(", "data", ".", "hasRemaining", "(", ")", ")", "throw", "new", "NotImplemented", "(", "\"\"", ")", ";", "dirtyDecoder", "=", "true", ";", "}", "protected", "boolean", "handle", "(", "CoderResult", "res", ")", "throws", "IOException", "{", "if", "(", "res", "==", "CoderResult", ".", "UNDERFLOW", ")", "{", "return", "true", ";", "}", "else", "if", "(", "res", "==", "CoderResult", ".", "OVERFLOW", ")", "{", "flushBuffer", "(", ")", ";", "return", "true", ";", "}", "else", "return", "false", ";", "}", "public", "void", "end", "(", ")", "throws", "IOException", ",", "PartialDecodingException", "{", "flushDecoder", "(", ")", ";", "flushBuffer", "(", ")", ";", "}", "protected", "void", "fail", "(", "DecodingException", "e", ")", "throws", "DecodingException", ",", "IOException", "{", "flushBuffer", "(", ")", ";", "throw", "e", ";", "}", "protected", "void", "fail", "(", "PartialDecodingException", "e", ")", "throws", "PartialDecodingException", ",", "IOException", "{", "flushBuffer", "(", ")", ";", "throw", "e", ";", "}", "protected", "void", "flushDecoder", "(", ")", "throws", "IOException", ",", "PartialDecodingException", "{", "addBinary", "(", "EMPTY", ",", "true", ")", ";", "decoder", ".", "flush", "(", "buffer", ")", ";", "decoder", ".", "reset", "(", ")", ";", "dirtyDecoder", "=", "false", ";", "}", "protected", "void", "flushBuffer", "(", ")", "throws", "IOException", "{", "buffer", ".", "flip", "(", ")", ";", "output", ".", "append", "(", "buffer", ")", ";", "}", "public", "static", "class", "DecodingException", "extends", "Exception", "{", "}", "public", "static", "class", "PartialDecodingException", "extends", "Exception", "{", "public", "final", "int", "inputPos", ";", "public", "PartialDecodingException", "(", "int", "inputPos", ")", "{", "this", ".", "inputPos", "=", "inputPos", ";", "}", "}", "public", "static", "class", "InvalidElementException", "extends", "Exception", "{", "}", "public", "static", "class", "CollectingException", "extends", "Exception", "{", "public", "final", "EObject", "restOfInput", ";", "public", "CollectingException", "(", "EObject", "restOfInput", ")", "{", "this", ".", "restOfInput", "=", "restOfInput", ";", "}", "}", "public", "void", "addIntegers", "(", "char", "[", "]", "data", ",", "int", "offset", ",", "int", "length", ")", "throws", "IOException", ",", "PartialDecodingException", "{", "if", "(", "length", "==", "0", ")", "return", ";", "if", "(", "dirtyDecoder", ")", "flushDecoder", "(", ")", ";", "while", "(", "length", ">", "0", ")", "{", "int", "free", "=", "buffer", ".", "remaining", "(", ")", ";", "while", "(", "length", ">", "0", "&&", "free", ">", "0", ")", "{", "char", "c", "=", "(", "char", ")", "(", "data", "[", "offset", "]", "&", "0xFFFF", ")", ";", "buffer", ".", "put", "(", "c", ")", ";", "offset", "++", ";", "length", "--", ";", "free", "--", ";", "}", "if", "(", "free", "==", "0", ")", "flushBuffer", "(", ")", ";", "}", "}", "}", "</s>" ]
7,943
[ "<s>", "package", "erjang", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Constructor", ";", "import", "java", ".", "lang", ".", "reflect", ".", "InvocationTargetException", ";", "public", "class", "EClassEFunMaker", "implements", "EFunMaker", "{", "private", "Constructor", "<", "?", "extends", "EFun", ">", "cons", ";", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "EClassEFunMaker", "(", "Class", "<", "?", "extends", "EFun", ">", "c", ")", "{", "Constructor", "<", "?", ">", "[", "]", "cons", "=", "c", ".", "getConstructors", "(", ")", ";", "this", ".", "cons", "=", "(", "Constructor", "<", "?", "extends", "EFun", ">", ")", "cons", "[", "0", "]", ";", "}", "@", "Override", "public", "EFun", "make", "(", "EPID", "pid", ",", "EObject", "[", "]", "freevars", ")", "{", "Object", "[", "]", "initargs", "=", "new", "Object", "[", "freevars", ".", "length", "+", "1", "]", ";", "initargs", "[", "0", "]", "=", "pid", ";", "System", ".", "arraycopy", "(", "freevars", ",", "0", ",", "initargs", ",", "1", ",", "freevars", ".", "length", ")", ";", "try", "{", "return", "cons", ".", "newInstance", "(", "initargs", ")", ";", "}", "catch", "(", "InstantiationException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "throw", "new", "InternalError", "(", ")", ";", "}", "catch", "(", "IllegalAccessException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "throw", "new", "InternalError", "(", ")", ";", "}", "catch", "(", "InvocationTargetException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "throw", "new", "InternalError", "(", ")", ";", "}", "}", "}", "</s>" ]
7,944
[ "<s>", "package", "erjang", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "OutputStream", ";", "import", "java", ".", "nio", ".", "ByteBuffer", ";", "import", "java", ".", "util", ".", "zip", ".", "CRC32", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "MethodVisitor", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "Opcodes", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "Type", ";", "public", "class", "EBinary", "extends", "EBitString", "{", "public", "static", "final", "EBinary", "EMPTY", "=", "new", "EBinary", "(", "new", "byte", "[", "0", "]", ")", ";", "public", "EBinary", "(", "byte", "[", "]", "data", ",", "int", "byteOff", ",", "int", "byteLength", ")", "{", "super", "(", "data", ",", "byteOff", ",", "byteLength", ",", "0", ")", ";", "}", "public", "EBinary", "(", "byte", "[", "]", "bytes", ")", "{", "this", "(", "bytes", ",", "0", ",", "bytes", ".", "length", ")", ";", "}", "private", "static", "final", "Type", "EBINARY_TYPE", "=", "Type", ".", "getType", "(", "EBinary", ".", "class", ")", ";", "private", "static", "final", "String", "EBINARY_NAME", "=", "EBINARY_TYPE", ".", "getInternalName", "(", ")", ";", "@", "Override", "public", "Type", "emit_const", "(", "MethodVisitor", "fa", ")", "{", "char", "[", "]", "chs", "=", "new", "char", "[", "byteSize", "(", ")", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "byteSize", "(", ")", ";", "i", "++", ")", "{", "chs", "[", "i", "]", "=", "(", "char", ")", "(", "0xff", "&", "octetAt", "(", "i", ")", ")", ";", "}", "String", "str", "=", "new", "String", "(", "chs", ")", ";", "fa", ".", "visitLdcInsn", "(", "str", ")", ";", "fa", ".", "visitMethodInsn", "(", "Opcodes", ".", "INVOKESTATIC", ",", "EBINARY_NAME", ",", "\"fromString\"", ",", "\"\"", "+", "EBINARY_NAME", "+", "\";\"", ")", ";", "return", "EBINARY_TYPE", ";", "}", "public", "static", "EBinary", "fromString", "(", "String", "str", ")", "{", "int", "size", "=", "str", ".", "length", "(", ")", ";", "byte", "[", "]", "data", "=", "new", "byte", "[", "size", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "str", ".", "length", "(", ")", ";", "i", "++", ")", "{", "data", "[", "i", "]", "=", "(", "byte", ")", "str", ".", "charAt", "(", "i", ")", ";", "}", "return", "new", "EBinary", "(", "data", ",", "0", ",", "size", ")", ";", "}", "public", "EBinary", "testBinary", "(", ")", "{", "return", "this", ";", "}", "public", "byte", "[", "]", "getByteArray", "(", ")", "{", "int", "octets", "=", "byteSize", "(", ")", ";", "byte", "[", "]", "res", "=", "new", "byte", "[", "octets", "]", ";", "System", ".", "arraycopy", "(", "data", ",", "byteOffset", "(", ")", ",", "res", ",", "0", ",", "octets", ")", ";", "return", "res", ";", "}", "public", "long", "crc", "(", ")", "{", "CRC32", "crc", "=", "new", "CRC32", "(", ")", ";", "int", "octets", "=", "byteSize", "(", ")", ";", "crc", ".", "update", "(", "data", ",", "byteOffset", "(", ")", ",", "octets", ")", ";", "return", "crc", ".", "getValue", "(", ")", ";", "}", "public", "void", "appendTo", "(", "OutputStream", "barr", ")", "{", "try", "{", "barr", ".", "write", "(", "data", ",", "byteOffset", "(", ")", ",", "byteSize", "(", ")", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "Error", "(", "e", ")", ";", "}", "}", "public", "void", "writeTo", "(", "OutputStream", "o", ")", "throws", "IOException", "{", "o", ".", "write", "(", "data", ",", "byteOffset", "(", ")", ",", "byteSize", "(", ")", ")", ";", "}", "public", "static", "EBinary", "make", "(", "ByteBuffer", "data", ")", "{", "if", "(", "data", "==", "null", "||", "data", ".", "remaining", "(", ")", "==", "0", ")", "return", "EMPTY", ";", "return", "new", "EBinary", "(", "data", ".", "array", "(", ")", ",", "data", ".", "arrayOffset", "(", ")", "+", "data", ".", "position", "(", ")", ",", "data", ".", "remaining", "(", ")", ")", ";", "}", "public", "ByteBuffer", "toByteBuffer", "(", ")", "{", "return", "ByteBuffer", ".", "wrap", "(", "this", ".", "data", ",", "byteOffset", "(", ")", ",", "byteSize", "(", ")", ")", ";", "}", "public", "static", "EBinary", "read", "(", "EInputStream", "eInputStream", ")", "throws", "IOException", "{", "byte", "[", "]", "data", "=", "eInputStream", ".", "read_binary", "(", ")", ";", "return", "new", "EBinary", "(", "data", ")", ";", "}", "public", "EInputStream", "getInputStream", "(", ")", "{", "int", "octets", "=", "byteSize", "(", ")", ";", "return", "new", "EInputStream", "(", "data", ",", "byteOffset", "(", ")", ",", "octets", ",", "EInputStream", ".", "DECODE_INT_LISTS_AS_STRINGS", ")", ";", "}", "public", "boolean", "is_7bit", "(", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "byteSize", "(", ")", ";", "i", "++", ")", "{", "byte", "b", "=", "data", "[", "byteOffset", "(", ")", "+", "i", "]", ";", "if", "(", "(", "b", "&", "0x80", ")", "!=", "0", ")", "return", "false", ";", "}", "return", "true", ";", "}", "@", "Override", "public", "void", "encode", "(", "EOutputStream", "eos", ")", "{", "eos", ".", "write_binary", "(", "getByteArray", "(", ")", ")", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "\"<<\\\"\"", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "byteSize", "(", ")", ";", "i", "++", ")", "{", "char", "b", "=", "(", "char", ")", "(", "0xff", "&", "byteAt", "(", "i", "*", "8", ")", ")", ";", "if", "(", "b", ">=", "32", "&&", "b", "<", "127", ")", "EString", ".", "appendChar", "(", "sb", ",", "b", ")", ";", "else", "return", "super", ".", "toString", "(", ")", ";", "}", "sb", ".", "append", "(", "\"\\\">>\"", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}", "public", "static", "EBinary", "make", "(", "byte", "[", "]", "res", ")", "{", "return", "new", "EBinary", "(", "res", ")", ";", "}", "public", "EBinary", "sub_binary", "(", "int", "off", ",", "int", "len", ")", "{", "return", "new", "EBinary", "(", "data", ",", "this", ".", "byteOffset", "(", ")", "+", "off", ",", "len", ")", ";", "}", "}", "</s>" ]
7,945
[ "<s>", "package", "erjang", ";", "import", "java", ".", "io", ".", "FileNotFoundException", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "logging", ".", "FileHandler", ";", "import", "java", ".", "util", ".", "logging", ".", "Handler", ";", "import", "java", ".", "util", ".", "logging", ".", "Logger", ";", "import", "erjang", ".", "driver", ".", "EDriver", ";", "import", "erjang", ".", "driver", ".", "efile", ".", "ClassPathResource", ";", "import", "erjang", ".", "driver", ".", "efile", ".", "EFile", ";", "public", "class", "OTPMain", "{", "public", "static", "String", "[", "]", "MODULES", "=", "new", "String", "[", "]", "{", "\"\"", ",", "\"erlang\"", ",", "\"init\"", ",", "\"otp_ring0\"", ",", "\"prim_file\"", ",", "\"prim_inet\"", ",", "\"prim_zip\"", ",", "\"zlib\"", "}", ";", "public", "static", "EDriver", "[", "]", "DRIVERS", "=", "new", "EDriver", "[", "]", "{", "new", "erjang", ".", "driver", ".", "efile", ".", "Driver", "(", ")", ",", "new", "erjang", ".", "driver", ".", "ram_file", ".", "Driver", "(", ")", ",", "new", "erjang", ".", "driver", ".", "tcp_inet", ".", "Driver", "(", ")", ",", "new", "erjang", ".", "driver", ".", "inet_gethost", ".", "Driver", "(", ")", ",", "new", "erjang", ".", "driver", ".", "zlib", ".", "Driver", "(", ")", ",", "new", "erjang", ".", "driver", ".", "js", ".", "EJSDriver", "(", ")", "}", ";", "public", "static", "void", "load_modules_and_drivers", "(", "List", "<", "String", ">", "modules", ",", "List", "<", "EDriver", ">", "drivers", ")", "throws", "ClassNotFoundException", ",", "InstantiationException", ",", "IllegalAccessException", ",", "IOException", "{", "if", "(", "modules", "!=", "null", ")", "{", "String", "erl_bootstrap_ebindir", "=", "ERT", ".", "runtime_info", ".", "erl_bootstrap_ebindir", ";", "if", "(", "ClassPathResource", ".", "isResource", "(", "erl_bootstrap_ebindir", ")", ")", "{", "for", "(", "String", "m", ":", "modules", ")", "{", "String", "beam_path", "=", "erl_bootstrap_ebindir", "+", "\"/\"", "+", "m", "+", "\".beam\"", ";", "EBinary", "bin", "=", "ClassPathResource", ".", "read_file", "(", "beam_path", ")", ";", "if", "(", "bin", "==", "null", ")", "{", "throw", "new", "FileNotFoundException", "(", "beam_path", ")", ";", "}", "EModuleLoader", ".", "load_module", "(", "m", ",", "bin", ")", ";", "}", "}", "else", "{", "for", "(", "String", "m", ":", "modules", ")", "{", "ERT", ".", "load_module", "(", "EAtom", ".", "intern", "(", "m", ")", ")", ";", "}", "}", "}", "if", "(", "drivers", "!=", "null", ")", "{", "for", "(", "EDriver", "d", ":", "drivers", ")", "{", "erjang", ".", "driver", ".", "Drivers", ".", "register", "(", "d", ")", ";", "}", "}", "}", "public", "static", "void", "start_otp_ring0", "(", "ESeq", "argv", ")", "{", "EAtom", "am_otp_ring0", "=", "EAtom", ".", "intern", "(", "\"otp_ring0\"", ")", ";", "EAtom", "am_start", "=", "EAtom", ".", "intern", "(", "\"start\"", ")", ";", "ESeq", "env", "=", "ERT", ".", "NIL", ";", "EProc", "proc", "=", "new", "EProc", "(", "null", ",", "am_otp_ring0", ",", "am_start", ",", "ERT", ".", "NIL", ".", "cons", "(", "argv", ")", ".", "cons", "(", "env", ")", ")", ";", "ERT", ".", "run", "(", "proc", ")", ";", "proc", ".", "joinb", "(", ")", ";", "ERT", ".", "shutdownSchedulers", "(", ")", ";", "ETimerTask", ".", "shutdown", "(", ")", ";", "}", "protected", "static", "ESeq", "process_args", "(", "String", "[", "]", "args", ")", "{", "ESeq", "argv", "=", "ERT", ".", "NIL", ";", "for", "(", "int", "i", "=", "args", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "argv", "=", "argv", ".", "cons", "(", "EBinary", ".", "fromString", "(", "args", "[", "i", "]", ")", ")", ";", "if", "(", "args", "[", "i", "]", ".", "equals", "(", "\"-noinput\"", ")", "||", "args", "[", "i", "]", ".", "equals", "(", "\"-noshell\"", ")", ")", "{", "System", ".", "setProperty", "(", "\"\"", ",", "\"true\"", ")", ";", "}", "}", "return", "argv", ";", "}", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "throws", "ClassNotFoundException", ",", "InstantiationException", ",", "IllegalAccessException", ",", "IOException", "{", "ESeq", "argv", "=", "process_args", "(", "args", ")", ";", "Handler", "fh", "=", "new", "FileHandler", "(", "\"erjang.log\"", ")", ";", "Logger", ".", "getLogger", "(", "\"\"", ")", ".", "addHandler", "(", "fh", ")", ";", "load_modules_and_drivers", "(", "Arrays", ".", "asList", "(", "MODULES", ")", ",", "Arrays", ".", "asList", "(", "DRIVERS", ")", ")", ";", "load_modules_and_drivers", "(", "null", ",", "extra_drivers", ")", ";", "start_otp_ring0", "(", "argv", ")", ";", "ERT", ".", "getOutputStream", "(", ")", ".", "println", "(", "\"done.\"", ")", ";", "}", "static", "List", "<", "EDriver", ">", "extra_drivers", "=", "new", "ArrayList", "<", "EDriver", ">", "(", ")", ";", "public", "static", "void", "add_driver", "(", "EDriver", "driver", ")", "{", "extra_drivers", ".", "add", "(", "driver", ")", ";", "}", "}", "</s>" ]
7,946
[ "<s>", "package", "erjang", ";", "import", "java", ".", "io", ".", "ByteArrayOutputStream", ";", "import", "java", ".", "math", ".", "BigInteger", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "ListIterator", ";", "public", "abstract", "class", "ESeq", "extends", "ECons", "{", "public", "ESeq", "testSeq", "(", ")", "{", "return", "this", ";", "}", "public", "String", "stringValue", "(", ")", "{", "throw", "ERT", ".", "badarg", "(", "this", ")", ";", "}", "@", "Override", "public", "abstract", "ESeq", "tail", "(", ")", ";", "public", "abstract", "ESeq", "cons", "(", "EObject", "h", ")", ";", "public", "EObject", "[", "]", "toArray", "(", ")", "{", "List", "<", "EObject", ">", "out", "=", "new", "ArrayList", "<", "EObject", ">", "(", ")", ";", "ESeq", "curr", "=", "this", ";", "while", "(", "!", "curr", ".", "isNil", "(", ")", ")", "{", "out", ".", "add", "(", "curr", ".", "head", "(", ")", ")", ";", "curr", "=", "curr", ".", "tail", "(", ")", ";", "}", "return", "out", ".", "toArray", "(", "new", "EObject", "[", "out", ".", "size", "(", ")", "]", ")", ";", "}", "public", "int", "length", "(", ")", "{", "int", "count", "=", "0", ";", "ESeq", "curr", "=", "this", ";", "while", "(", "!", "curr", ".", "isNil", "(", ")", ")", "{", "count", "+=", "1", ";", "curr", "=", "curr", ".", "tail", "(", ")", ";", "}", "return", "count", ";", "}", "public", "static", "ESeq", "fromArray", "(", "EObject", "[", "]", "args", ")", "{", "ESeq", "res", "=", "ERT", ".", "NIL", ";", "for", "(", "int", "i", "=", "args", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "res", "=", "res", ".", "cons", "(", "args", "[", "i", "]", ")", ";", "}", "return", "res", ";", "}", "public", "static", "ESeq", "fromArraySkippingNulls", "(", "EObject", "[", "]", "args", ",", "int", "start", ",", "int", "end", ")", "{", "ESeq", "res", "=", "ERT", ".", "NIL", ";", "for", "(", "int", "i", "=", "end", "-", "1", ";", "i", ">=", "start", ";", "i", "--", ")", "{", "if", "(", "args", "[", "i", "]", "!=", "null", ")", "res", "=", "res", ".", "cons", "(", "args", "[", "i", "]", ")", ";", "}", "return", "res", ";", "}", "public", "static", "ESeq", "fromList", "(", "List", "<", "?", "extends", "EObject", ">", "args", ")", "{", "ESeq", "res", "=", "ERT", ".", "NIL", ";", "ListIterator", "<", "?", "extends", "EObject", ">", "iter", "=", "args", ".", "listIterator", "(", "args", ".", "size", "(", ")", ")", ";", "while", "(", "iter", ".", "hasPrevious", "(", ")", ")", "{", "res", "=", "res", ".", "cons", "(", "iter", ".", "previous", "(", ")", ")", ";", "}", "return", "res", ";", "}", "public", "ESeq", "cons", "(", "int", "o1", ")", "{", "if", "(", "(", "o1", "&", "0xff", ")", "==", "o1", ")", "{", "return", "new", "EBinList", "(", "(", "byte", ")", "o1", ",", "this", ")", ".", "testSeq", "(", ")", ";", "}", "else", "{", "return", "cons", "(", "ERT", ".", "box", "(", "o1", ")", ")", ";", "}", "}", "public", "ESeq", "cons", "(", "double", "o1", ")", "{", "return", "cons", "(", "ERT", ".", "box", "(", "o1", ")", ")", ";", "}", "public", "ESeq", "cons", "(", "BigInteger", "o1", ")", "{", "return", "cons", "(", "ERT", ".", "box", "(", "o1", ")", ")", ";", "}", "public", "EString", "testString", "(", ")", "{", "ByteArrayOutputStream", "barr", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "ESeq", "list", "=", "this", ";", "while", "(", "!", "list", ".", "isNil", "(", ")", ")", "{", "EObject", "head", "=", "list", ".", "head", "(", ")", ";", "if", "(", "head", "==", "null", ")", "{", "ERT", ".", "log", ".", "warning", "(", "\"\"", "+", "list", ".", "getClass", "(", ")", ")", ";", "}", "ESmall", "intval", ";", "if", "(", "(", "intval", "=", "head", ".", "testSmall", "(", ")", ")", "==", "null", ")", "{", "return", "null", ";", "}", "int", "byteValue", "=", "intval", ".", "value", "&", "0xff", ";", "if", "(", "intval", ".", "value", "!=", "byteValue", ")", "{", "return", "null", ";", "}", "barr", ".", "write", "(", "byteValue", ")", ";", "list", "=", "list", ".", "tail", "(", ")", ";", "}", "return", "new", "EString", "(", "barr", ".", "toByteArray", "(", ")", ",", "0", ")", ";", "}", "public", "ESeq", "reverse", "(", ")", "{", "ESeq", "result", "=", "ERT", ".", "NIL", ";", "if", "(", "this", ".", "isNil", "(", ")", ")", "return", "result", ";", "EObject", "[", "]", "val", "=", "this", ".", "toArray", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "val", ".", "length", ";", "i", "++", ")", "{", "result", "=", "result", ".", "cons", "(", "val", "[", "i", "]", ")", ";", "}", "return", "result", ";", "}", "public", "ESeq", "prepend", "(", "ESeq", "list", ")", "{", "ESeq", "rlist", "=", "ERT", ".", "NIL", ";", "while", "(", "!", "list", ".", "isNil", "(", ")", ")", "{", "rlist", "=", "rlist", ".", "cons", "(", "list", ".", "head", "(", ")", ")", ";", "list", "=", "list", ".", "tail", "(", ")", ";", "}", "ESeq", "r", "=", "this", ";", "while", "(", "!", "rlist", ".", "isNil", "(", ")", ")", "{", "r", "=", "r", ".", "cons", "(", "rlist", ".", "head", "(", ")", ")", ";", "rlist", "=", "rlist", ".", "tail", "(", ")", ";", "}", "return", "r", ";", "}", "@", "Override", "public", "int", "hashCode", "(", ")", "{", "int", "h", "=", "0", ";", "ESeq", "curr", "=", "this", ";", "do", "{", "h", "=", "31", "*", "h", "+", "curr", ".", "head", "(", ")", ".", "hashCode", "(", ")", ";", "curr", "=", "curr", ".", "tail", "(", ")", ";", "}", "while", "(", "curr", "!=", "ERT", ".", "NIL", ")", ";", "return", "h", ";", "}", "}", "</s>" ]
7,947
[ "<s>", "package", "erjang", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Constructor", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Field", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Method", ";", "import", "java", ".", "net", ".", "URL", ";", "import", "java", ".", "util", ".", "Collection", ";", "import", "java", ".", "util", ".", "Comparator", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "concurrent", ".", "ConcurrentHashMap", ";", "import", "java", ".", "util", ".", "logging", ".", "Level", ";", "import", "java", ".", "util", ".", "logging", ".", "Logger", ";", "import", "erjang", ".", "beam", ".", "Compiler", ";", "import", "erjang", ".", "m", ".", "java", ".", "JavaObject", ";", "import", "kilim", ".", "Pausable", ";", "public", "class", "EModuleManager", "{", "static", "Logger", "log", "=", "Logger", ".", "getLogger", "(", "EModuleManager", ".", "class", ".", "getName", "(", ")", ")", ";", "static", "private", "Map", "<", "EAtom", ",", "ModuleInfo", ">", "infos", "=", "new", "ConcurrentHashMap", "<", "EAtom", ",", "ModuleInfo", ">", "(", ")", ";", "static", "FunctionInfo", "undefined_function", "=", "null", ";", "static", "{", "FunID", "uf", "=", "new", "FunID", "(", "\"\"", ",", "\"\"", ",", "3", ")", ";", "undefined_function", "=", "get_module_info", "(", "uf", ".", "module", ")", ".", "get_function_info", "(", "uf", ")", ";", "}", "static", "class", "FunctionInfo", "{", "private", "final", "FunID", "fun", ";", "public", "FunctionInfo", "(", "FunID", "fun", ")", "{", "this", ".", "fun", "=", "fun", ";", "}", "EModule", "defining_module", ";", "EFun", "resolved_value", ";", "Collection", "<", "FunctionBinder", ">", "resolve_points", "=", "new", "HashSet", "<", "FunctionBinder", ">", "(", ")", ";", "private", "EFun", "error_handler", ";", "private", "ClassLoader", "getModuleClassLoader", "(", ")", "{", "if", "(", "defining_module", "!=", "null", ")", "{", "return", "defining_module", ".", "getModuleClassLoader", "(", ")", ";", "}", "else", "{", "return", "new", "EModuleClassLoader", "(", "null", ")", ";", "}", "}", "synchronized", "void", "add_import", "(", "final", "FunctionBinder", "ref", ")", "throws", "Exception", "{", "resolve_points", ".", "add", "(", "ref", ")", ";", "if", "(", "resolved_value", "!=", "null", ")", "{", "ref", ".", "bind", "(", "resolved_value", ")", ";", "}", "else", "{", "EFun", "h", "=", "getFunErrorHandler", "(", ")", ";", "ref", ".", "bind", "(", "h", ")", ";", "}", "}", "synchronized", "void", "unbind", "(", ")", "throws", "Exception", "{", "for", "(", "FunctionBinder", "f", ":", "resolve_points", ")", "{", "f", ".", "bind", "(", "getFunErrorHandler", "(", ")", ")", ";", "}", "}", "private", "EFun", "getFunction", "(", ")", "{", "if", "(", "resolved_value", "!=", "null", ")", "{", "return", "resolved_value", ";", "}", "else", "{", "return", "getFunErrorHandler", "(", ")", ";", "}", "}", "private", "EFun", "getFunErrorHandler", "(", ")", "{", "if", "(", "error_handler", "!=", "null", ")", "{", "return", "error_handler", ";", "}", "error_handler", "=", "makeErrorHandler", "(", ")", ";", "return", "error_handler", ";", "}", "private", "EFun", "makeErrorHandler", "(", ")", "{", "return", "EFun", ".", "get_fun_with_handler", "(", "fun", ".", "module", ".", "toString", "(", ")", ",", "fun", ".", "function", ".", "toString", "(", ")", ",", "fun", ".", "arity", ",", "new", "EFunHandler", "(", ")", "{", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "\"\"", "+", "fun", ".", "toString", "(", ")", "+", "\">\"", ";", "}", "public", "EObject", "invoke", "(", "EProc", "proc", ",", "EObject", "[", "]", "args", ")", "throws", "Pausable", "{", "EFun", "uf", "=", "undefined_function", ".", "resolved_value", ";", "if", "(", "get_module_info", "(", "fun", ".", "module", ")", ".", "is_loaded", "(", ")", ")", "{", "log", ".", "log", "(", "Level", ".", "INFO", ",", "\"MISSING", "\"", "+", "fun", ")", ";", "}", "else", "{", "log", ".", "log", "(", "Level", ".", "FINER", ",", "\"resolving\"", "+", "fun", ")", ";", "}", "Class", "c", "=", "null", ";", "try", "{", "c", "=", "Class", ".", "forName", "(", "fun", ".", "module", ".", "getName", "(", ")", ")", ";", "}", "catch", "(", "ClassNotFoundException", "e", ")", "{", "}", "if", "(", "c", "!=", "null", ")", "{", "if", "(", "fun", ".", "function", "==", "ERT", ".", "am_new", ")", "{", "Constructor", "[", "]", "cons", "=", "c", ".", "getConstructors", "(", ")", ";", "return", "JavaObject", ".", "choose_and_invoke_constructor", "(", "proc", ",", "args", ",", "cons", ")", ";", "}", "else", "{", "Method", "[", "]", "methods", "=", "c", ".", "getMethods", "(", ")", ";", "return", "JavaObject", ".", "choose_and_invoke_method", "(", "proc", ",", "null", ",", "fun", ".", "function", ",", "args", ",", "methods", ",", "true", ")", ";", "}", "}", "if", "(", "uf", "==", "null", ")", "{", "if", "(", "!", "module_loaded", "(", "fun", ".", "module", ")", ")", "{", "try", "{", "EModuleLoader", ".", "find_and_load_module", "(", "fun", ".", "module", ".", "getName", "(", ")", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "}", "}", "if", "(", "resolved_value", "!=", "null", ")", "{", "return", "resolved_value", ".", "invoke", "(", "proc", ",", "args", ")", ";", "}", "log", ".", "log", "(", "Level", ".", "INFO", ",", "\"\"", "+", "fun", "+", "\"\"", ")", ";", "throw", "new", "ErlangUndefined", "(", "fun", ".", "module", ",", "fun", ".", "function", ",", "fun", ".", "arity", ")", ";", "}", "else", "{", "ESeq", "arg_list", "=", "ESeq", ".", "fromArray", "(", "args", ")", ";", "ESeq", "ufa", "=", "ESeq", ".", "fromArray", "(", "new", "EObject", "[", "]", "{", "fun", ".", "module", ",", "fun", ".", "function", ",", "arg_list", "}", ")", ";", "return", "uf", ".", "apply", "(", "proc", ",", "ufa", ")", ";", "}", "}", "}", ",", "getModuleClassLoader", "(", ")", ")", ";", "}", "synchronized", "void", "add_export", "(", "EModule", "definer", ",", "FunID", "fun2", ",", "EFun", "value", ")", "throws", "Exception", "{", "this", ".", "resolved_value", "=", "value", ";", "this", ".", "defining_module", "=", "definer", ";", "for", "(", "FunctionBinder", "f", ":", "resolve_points", ")", "{", "f", ".", "bind", "(", "value", ")", ";", "}", "}", "public", "EFun", "resolve", "(", ")", "{", "return", "getFunction", "(", ")", ";", "}", "public", "boolean", "exported", "(", ")", "{", "return", "resolved_value", "!=", "null", ";", "}", "}", "static", "class", "ModuleInfo", "{", "protected", "static", "final", "EAtom", "am_badfun", "=", "EAtom", ".", "intern", "(", "\"badfun\"", ")", ";", "private", "EModule", "resident", ";", "private", "EAtom", "module", ";", "private", "EBinary", "module_md5", "=", "empty_md5", ";", "Map", "<", "FunID", ",", "FunctionInfo", ">", "binding_points", "=", "new", "ConcurrentHashMap", "<", "FunID", ",", "FunctionInfo", ">", "(", ")", ";", "public", "ModuleInfo", "(", "EAtom", "module", ")", "{", "this", ".", "module", "=", "module", ";", "}", "public", "void", "add_import", "(", "FunID", "fun", ",", "FunctionBinder", "ref", ")", "throws", "Exception", "{", "FunctionInfo", "info", "=", "get_function_info", "(", "fun", ")", ";", "info", ".", "add_import", "(", "ref", ")", ";", "}", "private", "synchronized", "FunctionInfo", "get_function_info", "(", "FunID", "fun", ")", "{", "FunctionInfo", "info", "=", "binding_points", ".", "get", "(", "fun", ")", ";", "if", "(", "info", "==", "null", ")", "{", "binding_points", ".", "put", "(", "fun", ",", "info", "=", "new", "FunctionInfo", "(", "fun", ")", ")", ";", "}", "return", "info", ";", "}", "public", "void", "add_export", "(", "EModule", "definer", ",", "FunID", "fun", ",", "EFun", "value", ")", "throws", "Exception", "{", "get_function_info", "(", "fun", ")", ".", "add_export", "(", "definer", ",", "fun", ",", "value", ")", ";", "}", "public", "void", "setModule", "(", "EModule", "eModule", ")", "{", "this", ".", "resident", "=", "eModule", ";", "}", "public", "EFun", "resolve", "(", "FunID", "fun", ")", "{", "return", "get_function_info", "(", "fun", ")", ".", "resolve", "(", ")", ";", "}", "public", "boolean", "exports", "(", "FunID", "fun", ")", "{", "return", "get_function_info", "(", "fun", ")", ".", "exported", "(", ")", ";", "}", "public", "boolean", "is_loaded", "(", ")", "{", "return", "resident", "!=", "null", ";", "}", "public", "void", "unload", "(", ")", "throws", "Exception", "{", "resident", "=", "null", ";", "for", "(", "FunctionInfo", "fi", ":", "this", ".", "binding_points", ".", "values", "(", ")", ")", "{", "fi", ".", "unbind", "(", ")", ";", "}", "binding_points", ".", "clear", "(", ")", ";", "this", ".", "resident", "=", "null", ";", "this", ".", "module_md5", "=", "empty_md5", ";", "}", "public", "synchronized", "ESeq", "get_attributes", "(", ")", "{", "ESeq", "res", ";", "if", "(", "resident", "==", "null", ")", "res", "=", "ERT", ".", "NIL", ";", "else", "res", "=", "resident", ".", "attributes", "(", ")", ";", "return", "res", ";", "}", "public", "void", "warn_about_unresolved", "(", ")", "{", "if", "(", "resident", "!=", "null", ")", "{", "for", "(", "FunctionInfo", "fi", ":", "binding_points", ".", "values", "(", ")", ")", "{", "if", "(", "fi", ".", "resolved_value", "==", "null", ")", "{", "log", ".", "log", "(", "Level", ".", "INFO", ",", "\"\"", "+", "fi", ".", "fun", ")", ";", "}", "}", "}", "}", "public", "ESeq", "get_exports", "(", ")", "{", "ESeq", "rep", "=", "ERT", ".", "NIL", ";", "for", "(", "FunctionInfo", "fi", ":", "binding_points", ".", "values", "(", ")", ")", "{", "if", "(", "fi", ".", "exported", "(", ")", ")", "{", "rep", "=", "rep", ".", "cons", "(", "new", "ETuple2", "(", "fi", ".", "fun", ".", "function", ",", "ERT", ".", "box", "(", "fi", ".", "fun", ".", "arity", ")", ")", ")", ";", "}", "}", "return", "rep", ";", "}", "Map", "<", "Integer", ",", "EFunMaker", ">", "new_map", "=", "new", "HashMap", "<", "Integer", ",", "EFunMaker", ">", "(", ")", ";", "Map", "<", "Long", ",", "EFunMaker", ">", "old_map", "=", "new", "HashMap", "<", "Long", ",", "EFunMaker", ">", "(", ")", ";", "public", "EFun", "resolve", "(", "EPID", "pid", ",", "EBinary", "md5", ",", "int", "index", ",", "final", "int", "old_uniq", ",", "final", "int", "old_index", ",", "int", "arity", ",", "EObject", "[", "]", "freevars", ")", "{", "if", "(", "resident", "==", "null", ")", "{", "throw", "new", "NotImplemented", "(", "\"\"", "+", "this", ".", "module", "+", "\"", "is", "loaded\"", ")", ";", "}", "EFunMaker", "maker", "=", "new_map", ".", "get", "(", "index", ")", ";", "if", "(", "maker", "==", "null", "||", "!", "md5", ".", "equals", "(", "module_md5", ")", ")", "{", "LocalFunID", "fid", "=", "new", "LocalFunID", "(", "module", ",", "ERT", ".", "am_undefined", ",", "arity", ",", "old_index", ",", "index", ",", "old_uniq", ",", "md5", ")", ";", "return", "EFun", ".", "get_fun_with_handler", "(", "this", ".", "module", ".", "toString", "(", ")", ",", "\"badfun\"", ",", "0", ",", "new", "EFunHandler", "(", ")", "{", "@", "Override", "public", "EObject", "invoke", "(", "EProc", "proc", ",", "EObject", "[", "]", "args", ")", "throws", "Pausable", "{", "throw", "new", "ErlangError", "(", "am_badfun", ",", "args", ")", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "\"#Fun<\"", "+", "module", "+", "\".\"", "+", "old_index", "+", "\".\"", "+", "old_uniq", "+", "\">\"", ";", "}", "}", ",", "this", ".", "getClass", "(", ")", ".", "getClassLoader", "(", ")", ")", ";", "}", "return", "maker", ".", "make", "(", "pid", ",", "freevars", ")", ";", "}", "static", "final", "EBinary", "empty_md5", "=", "new", "EBinary", "(", "new", "byte", "[", "16", "]", ")", ";", "public", "EFun", "resolve", "(", "final", "EPID", "pid", ",", "final", "int", "old_uniq", ",", "final", "int", "old_index", ",", "final", "EObject", "[", "]", "freevars", ")", "{", "EFunMaker", "maker", "=", "old_map", ".", "get", "(", "(", "(", "(", "long", ")", "old_index", ")", "<<", "32", ")", "|", "(", "long", ")", "old_uniq", ")", ";", "if", "(", "maker", "==", "null", ")", "{", "LocalFunID", "fid", "=", "new", "LocalFunID", "(", "module", ",", "ERT", ".", "am_undef", ",", "0", ",", "old_index", ",", "0", ",", "old_uniq", ",", "empty_md5", ")", ";", "return", "EFun", ".", "get_fun_with_handler", "(", "module", ".", "toString", "(", ")", ",", "\"badfun\"", ",", "0", ",", "new", "EFunHandler", "(", ")", "{", "@", "Override", "public", "EObject", "invoke", "(", "EProc", "proc", ",", "EObject", "[", "]", "args", ")", "throws", "Pausable", "{", "throw", "new", "ErlangError", "(", "am_badfun", ",", "args", ")", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "\"#Fun<\"", "+", "module", "+", "\".\"", "+", "old_index", "+", "\".\"", "+", "old_uniq", "+", "\">\"", ";", "}", "}", ",", "this", ".", "getClass", "(", ")", ".", "getClassLoader", "(", ")", ")", ";", "}", "return", "maker", ".", "make", "(", "pid", ",", "freevars", ")", ";", "}", "public", "void", "register", "(", "LocalFunID", "fun_id", ",", "EFunMaker", "maker", ")", "{", "module_md5", "=", "fun_id", ".", "new_uniq", ";", "new_map", ".", "put", "(", "fun_id", ".", "new_index", ",", "maker", ")", ";", "old_map", ".", "put", "(", "(", "(", "(", "long", ")", "fun_id", ".", "index", ")", "<<", "32", ")", "|", "(", "long", ")", "fun_id", ".", "uniq", ",", "maker", ")", ";", "}", "}", "public", "static", "void", "add_import", "(", "FunID", "fun", ",", "FunctionBinder", "ref", ")", "throws", "Exception", "{", "get_module_info", "(", "fun", ".", "module", ")", ".", "add_import", "(", "fun", ",", "ref", ")", ";", "}", "private", "static", "ModuleInfo", "get_module_info", "(", "EAtom", "module", ")", "{", "ModuleInfo", "mi", ";", "synchronized", "(", "infos", ")", "{", "mi", "=", "infos", ".", "get", "(", "module", ")", ";", "if", "(", "mi", "==", "null", ")", "{", "infos", ".", "put", "(", "module", ",", "mi", "=", "new", "ModuleInfo", "(", "module", ")", ")", ";", "}", "}", "return", "mi", ";", "}", "public", "static", "void", "add_export", "(", "EModule", "mod", ",", "FunID", "fun", ",", "EFun", "value", ")", "throws", "Exception", "{", "get_module_info", "(", "fun", ".", "module", ")", ".", "add_export", "(", "mod", ",", "fun", ",", "value", ")", ";", "}", "static", "void", "setup_module", "(", "EModule", "mod_inst", ")", "throws", "Error", "{", "ModuleInfo", "module_info", "=", "get_module_info", "(", "EAtom", ".", "intern", "(", "mod_inst", ".", "module_name", "(", ")", ")", ")", ";", "module_info", ".", "setModule", "(", "mod_inst", ")", ";", "try", "{", "mod_inst", ".", "registerImportsAndExports", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "Error", "(", "e", ")", ";", "}", "module_info", ".", "warn_about_unresolved", "(", ")", ";", "}", "public", "static", "void", "register_lambda", "(", "LocalFunID", "lambda_id", ",", "Class", "<", "?", "extends", "EFun", ">", "fun", ")", "{", "get_module_info", "(", "lambda_id", ".", "module", ")", ".", "register", "(", "lambda_id", ",", "new", "EClassEFunMaker", "(", "fun", ")", ")", ";", "}", "public", "static", "EFun", "resolve", "(", "FunID", "start", ")", "{", "return", "get_module_info", "(", "start", ".", "module", ")", ".", "resolve", "(", "start", ")", ";", "}", "public", "static", "EFun", "resolve", "(", "EPID", "pid", ",", "EAtom", "module", ",", "EBinary", "md5", ",", "int", "index", ",", "int", "old_uniq", ",", "int", "old_index", ",", "int", "arity", ",", "EObject", "[", "]", "freevars", ")", "{", "return", "get_module_info", "(", "module", ")", ".", "resolve", "(", "pid", ",", "md5", ",", "index", ",", "old_uniq", ",", "old_index", ",", "arity", ",", "freevars", ")", ";", "}", "public", "static", "EFun", "resolve", "(", "EPID", "pid", ",", "EAtom", "module", ",", "int", "old_uniq", ",", "int", "old_index", ",", "EObject", "[", "]", "freevars", ")", "{", "return", "get_module_info", "(", "module", ")", ".", "resolve", "(", "pid", ",", "old_uniq", ",", "old_index", ",", "freevars", ")", ";", "}", "public", "static", "boolean", "function_exported", "(", "EAtom", "m", ",", "EAtom", "f", ",", "int", "a", ")", "{", "FunID", "fun", "=", "new", "FunID", "(", "m", ",", "f", ",", "a", ")", ";", "return", "get_module_info", "(", "m", ")", ".", "exports", "(", "fun", ")", ";", "}", "public", "static", "boolean", "module_loaded", "(", "EAtom", "m", ")", "{", "ModuleInfo", "mi", "=", "get_module_info", "(", "m", ")", ";", "return", "mi", ".", "is_loaded", "(", ")", ";", "}", "public", "static", "ESeq", "get_attributes", "(", "EAtom", "mod", ")", "{", "ModuleInfo", "mi", "=", "get_module_info", "(", "mod", ")", ";", "return", "mi", ".", "get_attributes", "(", ")", ";", "}", "public", "static", "ESeq", "get_exports", "(", "EAtom", "mod", ")", "{", "ModuleInfo", "mi", "=", "get_module_info", "(", "mod", ")", ";", "return", "mi", ".", "get_exports", "(", ")", ";", "}", "public", "static", "abstract", "class", "FunctionBinder", "{", "public", "abstract", "void", "bind", "(", "EFun", "value", ")", "throws", "Exception", ";", "public", "abstract", "FunID", "getFunID", "(", ")", ";", "}", "public", "static", "ESeq", "loaded_modules", "(", ")", "{", "EAtom", "[", "]", "mods", ";", "synchronized", "(", "infos", ")", "{", "mods", "=", "infos", ".", "keySet", "(", ")", ".", "toArray", "(", "new", "EAtom", "[", "0", "]", ")", ";", "}", "ESeq", "out", "=", "ERT", ".", "NIL", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "mods", ".", "length", ";", "i", "++", ")", "{", "out", "=", "out", ".", "cons", "(", "mods", "[", "i", "]", ")", ";", "}", "return", "out", ";", "}", "public", "static", "EAtom", "delete_module", "(", "EAtom", "module", ")", "{", "ModuleInfo", "mi", "=", "get_module_info", "(", "module", ")", ";", "try", "{", "mi", ".", "unload", "(", ")", ";", "}", "catch", "(", "ErlangException", "e", ")", "{", "throw", "e", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "ErlangError", "(", "e", ")", ";", "}", "return", "ERT", ".", "am_ok", ";", "}", "}", "</s>" ]
7,948
[ "<s>", "package", "erjang", ";", "public", "class", "ETuple1", "extends", "ETuple", "{", "public", "EObject", "elem1", ";", "public", "ETuple1", "(", ")", "{", "}", "public", "ETuple1", "(", "EObject", "elem1", ")", "{", "this", ".", "elem1", "=", "elem1", ";", "}", "static", "public", "ETuple1", "cast", "(", "ETuple", "value", ")", "{", "if", "(", "value", ".", "arity", "(", ")", "==", "1", ")", "return", "(", "ETuple1", ")", "value", ";", "return", "null", ";", "}", "static", "public", "ETuple1", "cast", "(", "EObject", "value", ")", "{", "if", "(", "value", "instanceof", "ETuple1", ")", "return", "(", "ETuple1", ")", "value", ";", "return", "null", ";", "}", "@", "Override", "public", "ETuple1", "blank", "(", ")", "{", "ETuple1", "res", "=", "new", "ETuple1", "(", ")", ";", "return", "res", ";", "}", "@", "Override", "public", "int", "arity", "(", ")", "{", "return", "1", ";", "}", "@", "Override", "public", "void", "set", "(", "int", "index", ",", "EObject", "term", ")", "{", "if", "(", "index", "==", "1", ")", "{", "elem1", "=", "term", ";", "return", ";", "}", "bad_nth", "(", "index", ")", ";", "}", "@", "Override", "public", "EObject", "elm", "(", "int", "i", ")", "{", "if", "(", "i", "==", "1", ")", "return", "elem1", ";", "return", "bad_nth", "(", "i", ")", ";", "}", "}", "</s>" ]
7,949
[ "<s>", "package", "erjang", ";", "import", "java", ".", "math", ".", "BigDecimal", ";", "import", "java", ".", "math", ".", "BigInteger", ";", "import", "java", ".", "util", ".", "Formatter", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "MethodVisitor", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "Opcodes", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "Type", ";", "public", "class", "EDouble", "extends", "ENumber", "{", "private", "static", "final", "Type", "EDOUBLE_TYPE", "=", "Type", ".", "getType", "(", "EDouble", ".", "class", ")", ";", "public", "final", "double", "value", ";", "public", "EDouble", "(", "double", "value", ")", "{", "this", ".", "value", "=", "value", ";", "}", "@", "Override", "public", "int", "hashCode", "(", ")", "{", "long", "bits", "=", "Double", ".", "doubleToLongBits", "(", "value", ")", ";", "return", "(", "int", ")", "(", "bits", "^", "(", "bits", ">>>", "32", ")", ")", ";", "}", "@", "Override", "int", "compare_same", "(", "EObject", "rhs", ")", "{", "return", "rhs", ".", "r_compare_same", "(", "this", ")", ";", "}", "int", "r_compare_same", "(", "ESmall", "lhs", ")", "{", "return", "lhs", ".", "value", "<", "value", "?", "-", "1", ":", "lhs", ".", "value", "==", "value", "?", "0", ":", "1", ";", "}", "int", "r_compare_same", "(", "EBig", "lhs", ")", "{", "double", "doubleValue", "=", "lhs", ".", "doubleValue", "(", ")", ";", "return", "doubleValue", "<", "value", "?", "-", "1", ":", "doubleValue", "==", "value", "?", "0", ":", "1", ";", "}", "int", "r_compare_same", "(", "EDouble", "lhs", ")", "{", "return", "lhs", ".", "value", "<", "value", "?", "-", "1", ":", "lhs", ".", "value", "==", "value", "?", "0", ":", "1", ";", "}", "public", "boolean", "equals", "(", "Object", "other", ")", "{", "if", "(", "other", "instanceof", "EDouble", ")", "{", "EDouble", "o", "=", "(", "EDouble", ")", "other", ";", "return", "o", ".", "value", "==", "value", ";", "}", "return", "false", ";", "}", "@", "Override", "public", "boolean", "equalsExactly", "(", "EObject", "rhs", ")", "{", "return", "rhs", ".", "r_equals_exactly", "(", "this", ")", ";", "}", "boolean", "r_equals_exactly", "(", "EDouble", "lhs", ")", "{", "return", "lhs", ".", "value", "==", "value", ";", "}", "public", "EDouble", "testFloat", "(", ")", "{", "return", "this", ";", "}", "@", "Override", "public", "int", "intValue", "(", ")", "{", "return", "(", "int", ")", "value", ";", "}", "public", "static", "EObject", "parseDouble", "(", "String", "string", ")", "{", "return", "new", "EDouble", "(", "Double", ".", "parseDouble", "(", "string", ")", ")", ";", "}", "@", "Override", "public", "EDouble", "abs", "(", ")", "{", "return", "new", "EDouble", "(", "Math", ".", "abs", "(", "value", ")", ")", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "String", ".", "valueOf", "(", "value", ")", ";", "}", "public", "EInteger", "asInteger", "(", ")", "{", "if", "(", "value", ">=", "Integer", ".", "MIN_VALUE", "&&", "value", "<=", "Integer", ".", "MAX_VALUE", ")", "{", "return", "new", "ESmall", "(", "(", "int", ")", "value", ")", ";", "}", "else", "{", "return", "new", "EBig", "(", "BigDecimal", ".", "valueOf", "(", "value", ")", ".", "toBigInteger", "(", ")", ")", ";", "}", "}", "@", "Override", "public", "org", ".", "objectweb", ".", "asm", ".", "Type", "emit_const", "(", "MethodVisitor", "fa", ")", "{", "Type", "type", "=", "EDOUBLE_TYPE", ";", "fa", ".", "visitTypeInsn", "(", "Opcodes", ".", "NEW", ",", "type", ".", "getInternalName", "(", ")", ")", ";", "fa", ".", "visitInsn", "(", "Opcodes", ".", "DUP", ")", ";", "fa", ".", "visitLdcInsn", "(", "new", "Double", "(", "value", ")", ")", ";", "fa", ".", "visitMethodInsn", "(", "Opcodes", ".", "INVOKESPECIAL", ",", "type", ".", "getInternalName", "(", ")", ",", "\"<init>\"", ",", "\"(D)V\"", ")", ";", "return", "type", ";", "}", "public", "EString", "to_list", "(", ")", "{", "Formatter", "form", "=", "new", "Formatter", "(", ")", ";", "form", "=", "form", ".", "format", "(", "\"%.20e\"", ",", "value", ")", ";", "String", "value", "=", "form", ".", "toString", "(", ")", ";", "return", "new", "EString", "(", "value", ")", ";", "}", "public", "ENumber", "add", "(", "EObject", "other", ",", "boolean", "guard", ")", "{", "return", "other", ".", "add", "(", "value", ",", "guard", ")", ";", "}", "public", "ENumber", "r_add", "(", "int", "lhs", ")", "{", "return", "ERT", ".", "box", "(", "(", "long", ")", "lhs", "+", "value", ")", ";", "}", "public", "ENumber", "add", "(", "double", "lhs", ",", "boolean", "guard", ")", "{", "return", "ERT", ".", "box", "(", "lhs", "+", "value", ")", ";", "}", "public", "ENumber", "add", "(", "BigInteger", "lhs", ",", "boolean", "guard", ")", "{", "return", "ERT", ".", "box", "(", "lhs", ".", "doubleValue", "(", ")", "+", "value", ")", ";", "}", "@", "Override", "public", "ENumber", "negate", "(", ")", "{", "return", "new", "EDouble", "(", "-", "value", ")", ";", "}", "public", "EDouble", "subtract", "(", "int", "rhs", ")", "{", "return", "ERT", ".", "box", "(", "value", "-", "rhs", ")", ";", "}", "public", "ENumber", "subtract", "(", "EObject", "other", ",", "boolean", "guard", ")", "{", "return", "other", ".", "r_subtract", "(", "value", ",", "guard", ")", ";", "}", "public", "ENumber", "r_subtract", "(", "int", "lhs", ",", "boolean", "guard", ")", "{", "return", "ERT", ".", "box", "(", "(", "long", ")", "lhs", "-", "value", ")", ";", "}", "public", "ENumber", "r_subtract", "(", "double", "lhs", ",", "boolean", "guard", ")", "{", "return", "ERT", ".", "box", "(", "lhs", "-", "value", ")", ";", "}", "public", "ENumber", "r_subtract", "(", "BigInteger", "lhs", ",", "boolean", "guard", ")", "{", "return", "ERT", ".", "box", "(", "lhs", ".", "doubleValue", "(", ")", "-", "value", ")", ";", "}", "public", "EDouble", "multiply", "(", "EObject", "other", ")", "{", "return", "other", ".", "r_multiply", "(", "value", ")", ";", "}", "public", "ENumber", "r_multiply", "(", "int", "lhs", ")", "{", "return", "ERT", ".", "box", "(", "lhs", "*", "value", ")", ";", "}", "public", "EDouble", "r_multiply", "(", "double", "lhs", ")", "{", "return", "ERT", ".", "box", "(", "lhs", "*", "value", ")", ";", "}", "public", "ENumber", "r_multiply", "(", "BigInteger", "lhs", ")", "{", "return", "ERT", ".", "box", "(", "lhs", ".", "doubleValue", "(", ")", "*", "value", ")", ";", "}", "public", "EDouble", "divide", "(", "EObject", "other", ")", "{", "return", "other", ".", "r_divide", "(", "value", ")", ";", "}", "public", "EDouble", "r_divide", "(", "int", "lhs", ")", "{", "return", "ERT", ".", "box", "(", "lhs", "/", "value", ")", ";", "}", "public", "EDouble", "r_divide", "(", "double", "lhs", ")", "{", "return", "ERT", ".", "box", "(", "lhs", "/", "value", ")", ";", "}", "public", "EDouble", "r_divide", "(", "BigInteger", "lhs", ")", "{", "return", "ERT", ".", "box", "(", "lhs", ".", "doubleValue", "(", ")", "/", "value", ")", ";", "}", "@", "Override", "public", "double", "doubleValue", "(", ")", "{", "return", "value", ";", "}", "@", "Override", "public", "ENumber", "add", "(", "int", "rhs", ",", "boolean", "guard", ")", "{", "return", "ERT", ".", "box", "(", "value", "+", "rhs", ")", ";", "}", "public", "static", "EDouble", "read", "(", "EInputStream", "ei", ")", "throws", "java", ".", "io", ".", "IOException", "{", "return", "new", "EDouble", "(", "ei", ".", "read_double", "(", ")", ")", ";", "}", "@", "Override", "public", "void", "encode", "(", "EOutputStream", "eos", ")", "{", "eos", ".", "write_double", "(", "value", ")", ";", "}", "}", "</s>" ]
7,950
[ "<s>", "package", "erjang", ";", "public", "class", "Erj", "{", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "throws", "Exception", "{", "String", "m", "=", "args", "[", "0", "]", ";", "String", "f", ";", "int", "idx", ";", "if", "(", "(", "idx", "=", "m", ".", "indexOf", "(", "':'", ")", ")", "==", "-", "1", ")", "{", "f", "=", "\"main\"", ";", "}", "else", "{", "f", "=", "m", ".", "substring", "(", "idx", "+", "1", ")", ";", "m", "=", "m", ".", "substring", "(", "0", ",", "idx", ")", ";", "}", "EAtom", "module", "=", "EAtom", ".", "intern", "(", "m", ")", ";", "EAtom", "fun", "=", "EAtom", ".", "intern", "(", "f", ")", ";", "load", "(", "\"erlang\"", ")", ";", "load", "(", "m", ")", ";", "ESeq", "env", "=", "ERT", ".", "NIL", ";", "ESeq", "argv", "=", "ERT", ".", "NIL", ";", "for", "(", "int", "i", "=", "args", ".", "length", "-", "1", ";", "i", ">", "0", ";", "i", "--", ")", "{", "argv", "=", "argv", ".", "cons", "(", "EBinary", ".", "fromString", "(", "args", "[", "i", "]", ")", ")", ";", "}", "EProc", "p", ";", "ERT", ".", "run", "(", "p", "=", "new", "EProc", "(", "null", ",", "module", ",", "fun", ",", "argv", ")", ")", ";", "p", ".", "joinb", "(", ")", ";", "System", ".", "out", ".", "println", "(", "\"done.\"", ")", ";", "}", "private", "static", "void", "load", "(", "String", "module", ")", "throws", "Exception", "{", "EModuleLoader", ".", "find_and_load_module", "(", "module", ")", ";", "}", "}", "</s>" ]
7,951
[ "<s>", "package", "erjang", ";", "import", "java", ".", "io", ".", "BufferedReader", ";", "import", "java", ".", "io", ".", "Closeable", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileReader", ";", "import", "java", ".", "io", ".", "FilenameFilter", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "io", ".", "InputStreamReader", ";", "import", "java", ".", "io", ".", "Reader", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "regex", ".", "Matcher", ";", "import", "java", ".", "util", ".", "regex", ".", "Pattern", ";", "import", "erjang", ".", "driver", ".", "efile", ".", "ClassPathResource", ";", "import", "erjang", ".", "driver", ".", "efile", ".", "EFile", ";", "public", "class", "RuntimeInfo", "{", "public", "final", "String", "erts_version", ";", "public", "final", "String", "otp_version", ";", "public", "final", "String", "erl_rootdir", ";", "public", "final", "String", "erl_bootstrap_ebindir", ";", "public", "final", "boolean", "unicodeDriverInterface", ";", "public", "RuntimeInfo", "(", "String", "erts_version", ",", "String", "otp_version", ",", "String", "erl_rootdir", ",", "String", "erl_bootstrap_ebindir", ")", "{", "this", ".", "erts_version", "=", "erts_version", ";", "this", ".", "otp_version", "=", "otp_version", ";", "this", ".", "erl_rootdir", "=", "erl_rootdir", ";", "this", ".", "erl_bootstrap_ebindir", "=", "erl_bootstrap_ebindir", ";", "if", "(", "otp_version", "!=", "null", ")", "{", "unicodeDriverInterface", "=", "(", "\"R14B\"", ".", "compareTo", "(", "otp_version", ")", "<", "0", ")", ";", "}", "else", "{", "unicodeDriverInterface", "=", "false", ";", "}", "}", "public", "void", "verify", "(", ")", "throws", "RuntimeException", "{", "if", "(", "isNullOrEmpty", "(", "erl_rootdir", ")", ")", "{", "throw", "new", "RuntimeException", "(", "\"\"", ")", ";", "}", "if", "(", "isNullOrEmpty", "(", "erts_version", ")", ")", "{", "throw", "new", "RuntimeException", "(", "\"\"", ")", ";", "}", "if", "(", "isNullOrEmpty", "(", "otp_version", ")", ")", "{", "throw", "new", "RuntimeException", "(", "\"\"", ")", ";", "}", "}", "public", "boolean", "isClassPathInstallation", "(", ")", "{", "return", "isClassPathInstallation", "(", "erl_rootdir", ")", ";", "}", "public", "static", "boolean", "isClassPathInstallation", "(", "String", "erl_rootdir", ")", "{", "return", "ClassPathResource", ".", "isResource", "(", "erl_rootdir", ")", ";", "}", "protected", "static", "final", "String", "ERLANG_RELEASESTARTFILE", "=", "\"\"", ";", "protected", "static", "final", "String", "ERLANG_RELEASEFILE", "=", "\"\"", ";", "protected", "static", "final", "String", "ERLANG_STARTSCRIPT", "=", "\"\"", ";", "protected", "static", "final", "String", "ERLANG_BOOTFILE", "=", "\"\"", ";", "protected", "static", "final", "String", "ERLANG_STARTSCRIPT_REGEX", "=", "\"\"", ";", "protected", "static", "final", "String", "ERLANG_RELEASEFILE_REGEX", "=", "\"\"", ";", "protected", "static", "final", "String", "ERLANG_RELEASESTARTFILE_REGEX", "=", "\"\"", ";", "public", "static", "RuntimeInfo", "setup", "(", "String", "erts_version", ",", "String", "otp_version", ",", "String", "erl_rootdir", ")", "{", "if", "(", "isNullOrEmpty", "(", "erl_rootdir", ")", ")", "{", "erl_rootdir", "=", "guess_erl_root", "(", ")", ";", "}", "if", "(", "!", "isNullOrEmpty", "(", "erl_rootdir", ")", ")", "{", "if", "(", "erl_rootdir", ".", "endsWith", "(", "\"/\"", ")", "||", "erl_rootdir", ".", "endsWith", "(", "\"\\\\\"", ")", ")", "{", "erl_rootdir", "=", "erl_rootdir", ".", "substring", "(", "0", ",", "erl_rootdir", ".", "length", "(", ")", "-", "1", ")", ";", "}", "}", "if", "(", "isNullOrEmpty", "(", "erts_version", ")", ")", "{", "erts_version", "=", "guess_erts_version", "(", "erl_rootdir", ")", ";", "}", "if", "(", "isNullOrEmpty", "(", "otp_version", ")", ")", "{", "otp_version", "=", "guess_otp_version", "(", "erl_rootdir", ")", ";", "}", "String", "erl_bootstrap_ebindir", "=", "System", ".", "getenv", "(", "\"\"", ")", ";", "if", "(", "isNullOrEmpty", "(", "erl_bootstrap_ebindir", ")", ")", "{", "erl_bootstrap_ebindir", "=", "erl_rootdir", ";", "if", "(", "!", "erl_bootstrap_ebindir", ".", "endsWith", "(", "\"/\"", ")", "&&", "!", "erl_bootstrap_ebindir", ".", "endsWith", "(", "\"\\\\\"", ")", ")", "{", "erl_bootstrap_ebindir", "+=", "File", ".", "separator", ";", "}", "erl_bootstrap_ebindir", "+=", "\"lib\"", "+", "File", ".", "separator", "+", "\"erts-\"", "+", "erts_version", "+", "File", ".", "separator", "+", "\"ebin\"", ";", "}", "return", "new", "RuntimeInfo", "(", "erts_version", ",", "otp_version", ",", "erl_rootdir", ",", "erl_bootstrap_ebindir", ")", ";", "}", "public", "static", "String", "guess_otp_version", "(", "String", "erl_rootdir", ")", "{", "String", "otp_version", "=", "guess_version", "(", "ERLANG_RELEASESTARTFILE_REGEX", ",", "2", ",", "erl_rootdir", ",", "ERLANG_RELEASESTARTFILE", ")", ";", "if", "(", "isNullOrEmpty", "(", "otp_version", ")", ")", "{", "otp_version", "=", "guess_version", "(", "ERLANG_RELEASEFILE_REGEX", ",", "1", ",", "erl_rootdir", ",", "ERLANG_RELEASEFILE", ")", ";", "}", "if", "(", "isNullOrEmpty", "(", "otp_version", ")", ")", "{", "otp_version", "=", "guess_version", "(", "ERLANG_STARTSCRIPT_REGEX", ",", "1", ",", "erl_rootdir", ",", "ERLANG_STARTSCRIPT", ")", ";", "}", "return", "otp_version", ";", "}", "public", "static", "String", "guess_erts_version", "(", "String", "erl_rootdir", ")", "{", "String", "erts_version", "=", "guess_version", "(", "ERLANG_RELEASESTARTFILE_REGEX", ",", "1", ",", "erl_rootdir", ",", "ERLANG_RELEASESTARTFILE", ")", ";", "if", "(", "isNullOrEmpty", "(", "erts_version", ")", ")", "{", "erts_version", "=", "guess_version", "(", "ERLANG_RELEASEFILE_REGEX", ",", "2", ",", "erl_rootdir", ",", "ERLANG_RELEASEFILE", ")", ";", "}", "if", "(", "isNullOrEmpty", "(", "erts_version", ")", ")", "{", "File", "erlangRoot", "=", "new", "File", "(", "erl_rootdir", ")", ";", "if", "(", "erlangRoot", ".", "isDirectory", "(", ")", ")", "{", "File", "libDir", "=", "new", "File", "(", "erlangRoot", ",", "\"lib\"", ")", ";", "String", "[", "]", "ertsDirs", "=", "libDir", ".", "list", "(", "new", "FilenameFilter", "(", ")", "{", "@", "Override", "public", "boolean", "accept", "(", "File", "dir", ",", "String", "name", ")", "{", "return", "name", ".", "startsWith", "(", "\"erts-\"", ")", ";", "}", "}", ")", ";", "if", "(", "ertsDirs", "!=", "null", ")", "{", "for", "(", "int", "d", "=", "0", ";", "d", "<", "ertsDirs", ".", "length", ";", "d", "++", ")", "{", "String", "dir", "=", "ertsDirs", "[", "d", "]", ";", "erts_version", "=", "dir", ";", "}", "}", "}", "}", "return", "erts_version", ";", "}", "protected", "static", "String", "guess_version", "(", "String", "regex", ",", "int", "group", ",", "String", "erl_rootdir", ",", "String", "fileName", ")", "{", "if", "(", "isNullOrEmpty", "(", "erl_rootdir", ")", "||", "RuntimeInfo", ".", "isClassPathInstallation", "(", "erl_rootdir", ")", ")", "{", "return", "guess_version_from_resource", "(", "regex", ",", "group", ",", "fileName", ")", ";", "}", "File", "erlangRoot", "=", "new", "File", "(", "erl_rootdir", ")", ";", "if", "(", "erlangRoot", ".", "isDirectory", "(", ")", ")", "{", "return", "guess_version_from_file", "(", "regex", ",", "group", ",", "new", "File", "(", "erlangRoot", ",", "fileName", ")", ")", ";", "}", "else", "{", "return", "guess_version_from_resource", "(", "regex", ",", "group", ",", "fileName", ")", ";", "}", "}", "protected", "static", "String", "guess_version_from_resource", "(", "String", "regex", ",", "int", "group", ",", "String", "fileName", ")", "{", "InputStream", "input", "=", "null", ";", "try", "{", "input", "=", "Thread", ".", "currentThread", "(", ")", ".", "getContextClassLoader", "(", ")", ".", "getResourceAsStream", "(", "fileName", ")", ";", "return", "guess_version_from_reader", "(", "regex", ",", "group", ",", "new", "InputStreamReader", "(", "input", ")", ")", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "}", "finally", "{", "closeQuietly", "(", "input", ")", ";", "}", "return", "null", ";", "}", "protected", "static", "String", "guess_version_from_file", "(", "String", "regex", ",", "int", "group", ",", "File", "file", ")", "{", "if", "(", "(", "file", "==", "null", ")", "||", "!", "file", ".", "exists", "(", ")", "||", "!", "file", ".", "canRead", "(", ")", ")", "{", "return", "null", ";", "}", "FileReader", "reader", "=", "null", ";", "try", "{", "reader", "=", "new", "FileReader", "(", "file", ")", ";", "return", "guess_version_from_reader", "(", "regex", ",", "group", ",", "reader", ")", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "}", "finally", "{", "closeQuietly", "(", "reader", ")", ";", "}", "return", "null", ";", "}", "protected", "static", "String", "guess_version_from_reader", "(", "String", "regex", ",", "int", "group", ",", "Reader", "input", ")", "{", "BufferedReader", "reader", "=", "null", ";", "try", "{", "Pattern", "pattern", "=", "Pattern", ".", "compile", "(", "regex", ")", ";", "reader", "=", "new", "BufferedReader", "(", "input", ")", ";", "String", "line", ";", "while", "(", "(", "line", "=", "reader", ".", "readLine", "(", ")", ")", "!=", "null", ")", "{", "Matcher", "match", "=", "pattern", ".", "matcher", "(", "line", ")", ";", "if", "(", "!", "match", ".", "matches", "(", ")", ")", "{", "continue", ";", "}", "String", "versionString", "=", "match", ".", "group", "(", "group", ")", ";", "if", "(", "(", "versionString", "!=", "null", ")", "&&", "(", "versionString", ".", "length", "(", ")", ">", "0", ")", ")", "{", "return", "versionString", ".", "trim", "(", ")", ";", "}", "}", "}", "catch", "(", "Throwable", "t", ")", "{", "}", "finally", "{", "closeQuietly", "(", "reader", ")", ";", "}", "return", "null", ";", "}", "protected", "static", "boolean", "isNullOrEmpty", "(", "String", "text", ")", "{", "if", "(", "text", "==", "null", "||", "text", ".", "trim", "(", ")", ".", "length", "(", ")", "==", "0", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}", "public", "static", "String", "guess_erl_root", "(", ")", "{", "String", "erl_rootdir", "=", "System", ".", "getenv", "(", "\"OTPROOT\"", ")", ";", "if", "(", "isNullOrEmpty", "(", "erl_rootdir", ")", ")", "{", "if", "(", "Thread", ".", "currentThread", "(", ")", ".", "getContextClassLoader", "(", ")", ".", "getResource", "(", "ERLANG_BOOTFILE", ")", "!=", "null", ")", "{", "erl_rootdir", "=", "EFile", ".", "RESOURCE_PREFIX", ";", "}", "}", "if", "(", "isNullOrEmpty", "(", "erl_rootdir", ")", ")", "{", "String", "path", "=", "System", ".", "getenv", "(", "\"PATH\"", ")", ";", "List", "<", "String", ">", "paths", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "paths", ".", "addAll", "(", "Arrays", ".", "asList", "(", "path", ".", "split", "(", "File", ".", "pathSeparator", ")", ")", ")", ";", "paths", ".", "add", "(", "\"\"", ")", ";", "paths", ".", "add", "(", "\"\"", ")", ";", "for", "(", "String", "elem", ":", "paths", ")", "{", "File", "dir", "=", "new", "File", "(", "elem", ")", ";", "File", "erl", "=", "new", "File", "(", "dir", ",", "\"erl\"", ")", ";", "if", "(", "erl", ".", "exists", "(", ")", ")", "{", "File", "baseDir", "=", "dir", ".", "getParentFile", "(", ")", ";", "if", "(", "baseDir", "==", "null", ")", "continue", ";", "File", "releases", "=", "new", "File", "(", "baseDir", ",", "\"releases\"", ")", ";", "if", "(", "releases", ".", "isDirectory", "(", ")", ")", "{", "erl_rootdir", "=", "baseDir", ".", "getAbsolutePath", "(", ")", ";", "break", ";", "}", "File", "lib", "=", "new", "File", "(", "baseDir", ",", "\"lib\"", ")", ";", "File", "root", "=", "new", "File", "(", "lib", ",", "\"erlang\"", ")", ";", "if", "(", "root", ".", "exists", "(", ")", ")", "{", "erl_rootdir", "=", "root", ".", "getAbsolutePath", "(", ")", ";", "break", ";", "}", "}", "}", "}", "return", "erl_rootdir", ";", "}", "protected", "static", "void", "closeQuietly", "(", "Closeable", "stream", ")", "{", "if", "(", "stream", "!=", "null", ")", "{", "try", "{", "stream", ".", "close", "(", ")", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "}", "}", "}", "}", "</s>" ]
7,952
[ "<s>", "package", "erjang", ";", "import", "kilim", ".", "Pausable", ";", "public", "interface", "ExitHook", "{", "void", "on_exit", "(", "EInternalPID", "pid", ")", "throws", "Pausable", ";", "}", "</s>" ]
7,953
[ "<s>", "package", "erjang", ".", "sample", ";", "import", "erjang", ".", "EAtom", ";", "import", "erjang", ".", "EList", ";", "import", "erjang", ".", "EObject", ";", "import", "erjang", ".", "ERT", ";", "import", "erjang", ".", "ESeq", ";", "import", "erjang", ".", "EString", ";", "import", "erjang", ".", "RPC", ";", "public", "class", "RPCSample", "{", "static", "EAtom", "am_erlang", "=", "EAtom", ".", "intern", "(", "\"erlang\"", ")", ";", "static", "EAtom", "am_display", "=", "EAtom", ".", "intern", "(", "\"display\"", ")", ";", "static", "EAtom", "am_started", "=", "EAtom", ".", "intern", "(", "\"started\"", ")", ";", "static", "EAtom", "am_init", "=", "EAtom", ".", "intern", "(", "\"init\"", ")", ";", "static", "EAtom", "am_stop", "=", "EAtom", ".", "intern", "(", "\"stop\"", ")", ";", "static", "EAtom", "am_io", "=", "EAtom", ".", "intern", "(", "\"io\"", ")", ";", "static", "EAtom", "am_format", "=", "EAtom", ".", "intern", "(", "\"format\"", ")", ";", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "throws", "Exception", "{", "new", "Thread", "(", ")", "{", "{", "setDaemon", "(", "true", ")", ";", "start", "(", ")", ";", "}", "public", "void", "run", "(", ")", "{", "String", "[", "]", "ARGS", "=", "{", "\"-progname\"", ",", "\"ej\"", ",", "\"-home\"", ",", "System", ".", "getProperty", "(", "\"user.home\"", ")", ",", "\"-root\"", ",", "\"\"", ",", "\"+A\"", ",", "\"2\"", ",", "\"+S\"", ",", "\"1\"", ",", "\"+e\"", ",", "\"5.7.5\"", ",", "\"-s\"", ",", "\"rpc\"", ",", "\"\"", "}", ";", "try", "{", "erjang", ".", "Main", ".", "main", "(", "ARGS", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", ";", "}", ";", "System", ".", "err", ".", "println", "(", "\"\"", ")", ";", "RPC", ".", "wait_for_erjang_started", "(", "60", "*", "1000L", ")", ";", "EString", "hello_str", "=", "EString", ".", "fromString", "(", "\"\"", ")", ";", "ESeq", "format_args", "=", "EList", ".", "make", "(", "hello_str", ",", "ERT", ".", "NIL", ")", ";", "RPC", ".", "call", "(", "am_erlang", ",", "am_display", ",", "(", "EObject", ")", "format_args", ")", ";", "RPC", ".", "call", "(", "am_io", ",", "am_format", ",", "hello_str", ",", "ERT", ".", "NIL", ")", ";", "System", ".", "err", ".", "println", "(", "\"\"", ")", ";", "RPC", ".", "call", "(", "am_init", ",", "am_stop", ",", "ERT", ".", "box", "(", "1", ")", ")", ";", "System", ".", "err", ".", "println", "(", "\"\"", ")", ";", "Thread", ".", "sleep", "(", "5", "*", "1000", ")", ";", "}", "}", "</s>" ]
7,954
[ "<s>", "package", "erjang", ".", "net", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "net", ".", "InetSocketAddress", ";", "import", "java", ".", "net", ".", "SocketAddress", ";", "import", "java", ".", "nio", ".", "channels", ".", "SelectableChannel", ";", "import", "java", ".", "nio", ".", "channels", ".", "ServerSocketChannel", ";", "import", "java", ".", "nio", ".", "channels", ".", "SocketChannel", ";", "import", "erjang", ".", "driver", ".", "efile", ".", "Posix", ";", "public", "class", "InetServerSocket", "extends", "InetSocket", "{", "ServerSocketChannel", "ch", ";", "private", "Integer", "backlog", ";", "public", "InetServerSocket", "(", "LazyInetSocket", "sock", ",", "Integer", "backlog", ")", "throws", "IOException", "{", "ch", "=", "ServerSocketChannel", ".", "open", "(", ")", ";", "this", ".", "backlog", "=", "backlog", ";", "sock", ".", "init", "(", "this", ")", ";", "}", "@", "Override", "public", "SelectableChannel", "channel", "(", ")", "{", "return", "ch", ";", "}", "@", "Override", "public", "boolean", "isBound", "(", ")", "{", "return", "ch", ".", "socket", "(", ")", ".", "isBound", "(", ")", ";", "}", "@", "Override", "public", "InetSocket", "accept", "(", ")", "throws", "IOException", "{", "SocketChannel", "sock", "=", "ch", ".", "accept", "(", ")", ";", "if", "(", "sock", "==", "null", ")", "{", "return", "null", ";", "}", "return", "new", "InetClientSocket", "(", "sock", ")", ";", "}", "@", "Override", "public", "void", "setReuseAddress", "(", "boolean", "reuse", ")", "throws", "IOException", "{", "ch", ".", "socket", "(", ")", ".", "setReuseAddress", "(", "reuse", ")", ";", "}", "@", "Override", "public", "void", "setOOBInline", "(", "boolean", "on", ")", "throws", "IOException", "{", "}", "@", "Override", "public", "void", "setTcpNoDelay", "(", "boolean", "on", ")", "throws", "IOException", "{", "}", "@", "Override", "public", "void", "setLinger", "(", "boolean", "on", ",", "int", "timeout", ")", "throws", "IOException", "{", "}", "@", "Override", "public", "void", "setReceiveBufferSize", "(", "int", "size", ")", "throws", "IOException", "{", "ch", ".", "socket", "(", ")", ".", "setReceiveBufferSize", "(", "size", ")", ";", "}", "@", "Override", "public", "int", "getReceiveBufferSize", "(", ")", "throws", "IOException", "{", "return", "ch", ".", "socket", "(", ")", ".", "getReceiveBufferSize", "(", ")", ";", "}", "@", "Override", "public", "void", "setTimeout", "(", "int", "timeout", ")", "throws", "IOException", "{", "ch", ".", "socket", "(", ")", ".", "setSoTimeout", "(", "timeout", ")", ";", "}", "@", "Override", "public", "void", "setSendBufferSize", "(", "int", "size", ")", "throws", "IOException", "{", "}", "public", "boolean", "getReuseAddress", "(", ")", "throws", "IOException", "{", "return", "ch", ".", "socket", "(", ")", ".", "getReuseAddress", "(", ")", ";", "}", "@", "Override", "public", "int", "getLocalPort", "(", ")", "{", "return", "ch", ".", "socket", "(", ")", ".", "getLocalPort", "(", ")", ";", "}", "@", "Override", "public", "void", "bind", "(", "InetSocketAddress", "addr", ")", "throws", "IOException", "{", "if", "(", "backlog", "==", "null", ")", "{", "ch", ".", "socket", "(", ")", ".", "bind", "(", "addr", ")", ";", "}", "else", "{", "ch", ".", "socket", "(", ")", ".", "bind", "(", "addr", ",", "backlog", ")", ";", "}", "}", "@", "Override", "public", "boolean", "connect", "(", "InetSocketAddress", "remote", ")", "throws", "IOException", "{", "throw", "new", "erjang", ".", "NotImplemented", "(", ")", ";", "}", "@", "Override", "public", "InetSocketAddress", "getLocalSocketAddress", "(", ")", "{", "return", "(", "InetSocketAddress", ")", "ch", ".", "socket", "(", ")", ".", "getLocalSocketAddress", "(", ")", ";", "}", "@", "Override", "public", "void", "listen", "(", "int", "backlog", ")", "throws", "IOException", "{", "this", ".", "backlog", "=", "new", "Integer", "(", "backlog", ")", ";", "}", "@", "Override", "public", "void", "setKeepAlive", "(", "boolean", "on", ")", "throws", "IOException", "{", "}", "public", "void", "setNonBlocking", "(", ")", "throws", "IOException", "{", "ch", ".", "configureBlocking", "(", "false", ")", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "\"\"", "+", "ch", ".", "toString", "(", ")", "+", "\"", "open=\"", "+", "ch", ".", "isOpen", "(", ")", "+", "\"", "blocking=\"", "+", "ch", ".", "isBlocking", "(", ")", "+", "\"", "addr=\"", "+", "ch", ".", "socket", "(", ")", ".", "getLocalSocketAddress", "(", ")", "+", "\"]\"", ";", "}", "}", "</s>" ]
7,955
[ "<s>", "package", "erjang", ".", "net", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "net", ".", "InetSocketAddress", ";", "import", "java", ".", "net", ".", "SocketAddress", ";", "import", "java", ".", "nio", ".", "ByteBuffer", ";", "import", "java", ".", "nio", ".", "channels", ".", "SelectableChannel", ";", "import", "java", ".", "nio", ".", "channels", ".", "ServerSocketChannel", ";", "import", "java", ".", "nio", ".", "channels", ".", "SocketChannel", ";", "import", "java", ".", "util", ".", "concurrent", ".", "atomic", ".", "AtomicLong", ";", "import", "erjang", ".", "NotImplemented", ";", "import", "erjang", ".", "driver", ".", "efile", ".", "Posix", ";", "public", "class", "LazyInetSocket", "extends", "InetSocket", "{", "static", "final", "int", "OPEN_FLAG", "=", "0x01", ";", "int", "status", "=", "OPEN_FLAG", ";", "static", "AtomicLong", "next_id", "=", "new", "AtomicLong", "(", ")", ";", "private", "final", "long", "id", ";", "private", "final", "ProtocolFamily", "domain", ";", "private", "final", "ProtocolType", "type", ";", "private", "final", "Protocol", "protocol", ";", "private", "InetSocket", "delegate", ";", "InetSocketAddress", "bindingAddress", ";", "public", "Integer", "so_rcv_buf", ";", "public", "Integer", "so_snd_buf", ";", "public", "Integer", "so_timeout", ";", "public", "Boolean", "so_reuse_addr", ";", "public", "Boolean", "so_keep_alive", ";", "public", "Boolean", "so_oob_inline", ";", "public", "Boolean", "so_nodelay", ";", "public", "Integer", "so_traffic_class", ";", "public", "Integer", "so_linger", ";", "private", "Boolean", "so_broadcast", ";", "private", "Boolean", "blocking", ";", "void", "init", "(", "InetSocket", "s", ")", "throws", "IOException", "{", "if", "(", "blocking", "!=", "null", ")", "{", "s", ".", "configureBlocking", "(", "blocking", ")", ";", "}", "if", "(", "so_rcv_buf", "!=", "null", ")", "{", "s", ".", "setReceiveBufferSize", "(", "so_rcv_buf", ")", ";", "}", "if", "(", "so_snd_buf", "!=", "null", ")", "{", "s", ".", "setSendBufferSize", "(", "so_snd_buf", ")", ";", "}", "if", "(", "so_timeout", "!=", "null", ")", "{", "setTimeout", "(", "so_timeout", ")", ";", "}", "if", "(", "so_reuse_addr", "!=", "null", ")", "{", "s", ".", "setReuseAddress", "(", "so_reuse_addr", ")", ";", "}", "if", "(", "so_keep_alive", "!=", "null", ")", "{", "s", ".", "setKeepAlive", "(", "so_keep_alive", ")", ";", "}", "if", "(", "so_oob_inline", "!=", "null", ")", "{", "s", ".", "setOOBInline", "(", "so_oob_inline", ")", ";", "}", "if", "(", "so_nodelay", "!=", "null", ")", "{", "s", ".", "setTcpNoDelay", "(", "so_nodelay", ")", ";", "}", "if", "(", "so_broadcast", "!=", "null", ")", "{", "s", ".", "setBroadcast", "(", "so_broadcast", ")", ";", "}", "if", "(", "so_traffic_class", "!=", "null", ")", "{", "s", ".", "setTrafficClass", "(", "so_traffic_class", ")", ";", "}", "if", "(", "so_linger", "!=", "null", ")", "{", "if", "(", "so_linger", ">", "0", ")", "{", "s", ".", "setLinger", "(", "true", ",", "so_linger", ")", ";", "}", "else", "{", "s", ".", "setLinger", "(", "false", ",", "0", ")", ";", "}", "}", "if", "(", "bindingAddress", "!=", "null", ")", "{", "s", ".", "bind", "(", "bindingAddress", ")", ";", "}", "}", "LazyInetSocket", "(", "ProtocolFamily", "domain", ",", "ProtocolType", "type", ",", "Protocol", "protocol", ")", "{", "this", ".", "domain", "=", "domain", ";", "this", ".", "type", "=", "type", ";", "this", ".", "protocol", "=", "protocol", ";", "this", ".", "id", "=", "next_id", ".", "incrementAndGet", "(", ")", ";", "}", "public", "void", "bind", "(", "InetSocketAddress", "localAddress", ")", "throws", "IOException", "{", "if", "(", "delegate", "!=", "null", ")", "{", "delegate", ".", "bind", "(", "localAddress", ")", ";", "return", ";", "}", "else", "{", "this", ".", "bindingAddress", "=", "localAddress", ";", "}", "}", "public", "boolean", "connect", "(", "InetSocketAddress", "remote", ")", "throws", "IOException", "{", "if", "(", "delegate", "==", "null", ")", "{", "if", "(", "protocol", "==", "Protocol", ".", "TCP", ")", "{", "delegate", "=", "new", "InetClientSocket", "(", "this", ")", ";", "}", "else", "if", "(", "protocol", "==", "Protocol", ".", "UDP", ")", "{", "delegate", "=", "new", "InetDatagramSocket", "(", "this", ")", ";", "}", "else", "{", "throw", "new", "NotImplemented", "(", ")", ";", "}", "}", "if", "(", "delegate", ".", "connect", "(", "remote", ")", ")", "{", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}", "@", "Override", "public", "boolean", "finishConnect", "(", ")", "throws", "IOException", "{", "if", "(", "delegate", "==", "null", ")", "{", "if", "(", "protocol", "==", "Protocol", ".", "TCP", ")", "{", "delegate", "=", "new", "InetClientSocket", "(", "this", ")", ";", "}", "else", "if", "(", "protocol", "==", "Protocol", ".", "UDP", ")", "{", "delegate", "=", "new", "InetDatagramSocket", "(", "this", ")", ";", "}", "else", "{", "throw", "new", "NotImplemented", "(", ")", ";", "}", "}", "return", "delegate", ".", "finishConnect", "(", ")", ";", "}", "public", "void", "listen", "(", "int", "backlog", ")", "throws", "IOException", "{", "if", "(", "delegate", "==", "null", ")", "{", "switch", "(", "protocol", ")", "{", "case", "TCP", ":", "delegate", "=", "new", "InetServerSocket", "(", "this", ",", "new", "Integer", "(", "backlog", ")", ")", ";", "break", ";", "default", ":", "throw", "new", "PosixIOException", "(", "Posix", ".", "EOPNOTSUPP", ",", "\"\"", ")", ";", "}", "}", "delegate", ".", "listen", "(", "backlog", ")", ";", "}", "@", "Override", "public", "InetSocket", "accept", "(", ")", "throws", "IOException", "{", "if", "(", "delegate", "==", "null", ")", "{", "switch", "(", "protocol", ")", "{", "case", "TCP", ":", "delegate", "=", "new", "InetServerSocket", "(", "this", ",", "null", ")", ";", "break", ";", "default", ":", "throw", "new", "PosixIOException", "(", "Posix", ".", "EOPNOTSUPP", ",", "\"\"", ")", ";", "}", "}", "return", "delegate", ".", "accept", "(", ")", ";", "}", "@", "Override", "public", "int", "send", "(", "ByteBuffer", "packet", ",", "SocketAddress", "target", ")", "throws", "IOException", "{", "if", "(", "delegate", "==", "null", ")", "{", "delegate", "=", "new", "InetDatagramSocket", "(", "this", ")", ";", "}", "return", "delegate", ".", "send", "(", "packet", ",", "target", ")", ";", "}", "@", "Override", "public", "InetSocketAddress", "getLocalSocketAddress", "(", ")", "{", "if", "(", "delegate", "==", "null", ")", "return", "bindingAddress", ";", "return", "delegate", ".", "getLocalSocketAddress", "(", ")", ";", "}", "@", "Override", "public", "SelectableChannel", "channel", "(", ")", "{", "if", "(", "delegate", "==", "null", ")", "{", "return", "null", ";", "}", "return", "delegate", ".", "channel", "(", ")", ";", "}", "@", "Override", "public", "void", "configureBlocking", "(", "boolean", "block", ")", "throws", "IOException", "{", "if", "(", "delegate", "==", "null", ")", "{", "this", ".", "blocking", "=", "Boolean", ".", "valueOf", "(", "block", ")", ";", "return", ";", "}", "delegate", ".", "channel", "(", ")", ".", "configureBlocking", "(", "block", ")", ";", "}", "@", "Override", "public", "void", "setKeepAlive", "(", "boolean", "val", ")", "throws", "IOException", "{", "if", "(", "delegate", "==", "null", ")", "{", "so_keep_alive", "=", "Boolean", ".", "valueOf", "(", "val", ")", ";", "}", "else", "{", "delegate", ".", "setKeepAlive", "(", "val", ")", ";", "}", "}", "@", "Override", "public", "boolean", "getKeepAlive", "(", ")", "throws", "IOException", "{", "if", "(", "delegate", "==", "null", ")", "{", "return", "delegate", ".", "getKeepAlive", "(", ")", ";", "}", "else", "{", "return", "so_keep_alive", "==", "null", "?", "false", ":", "so_keep_alive", ".", "booleanValue", "(", ")", ";", "}", "}", "@", "Override", "public", "void", "setOOBInline", "(", "boolean", "val", ")", "throws", "IOException", "{", "if", "(", "delegate", "==", "null", ")", "{", "so_oob_inline", "=", "Boolean", ".", "valueOf", "(", "val", ")", ";", "}", "else", "{", "delegate", ".", "setOOBInline", "(", "val", ")", ";", "}", "}", "@", "Override", "public", "void", "setReuseAddress", "(", "boolean", "val", ")", "throws", "IOException", "{", "if", "(", "delegate", "==", "null", ")", "{", "so_reuse_addr", "=", "Boolean", ".", "valueOf", "(", "val", ")", ";", "}", "else", "{", "delegate", ".", "setReuseAddress", "(", "val", ")", ";", "}", "}", "@", "Override", "public", "boolean", "getReuseAddress", "(", ")", "throws", "IOException", "{", "if", "(", "delegate", "==", "null", ")", "{", "return", "delegate", ".", "getReuseAddress", "(", ")", ";", "}", "else", "{", "return", "so_reuse_addr", "==", "null", "?", "false", ":", "so_reuse_addr", ".", "booleanValue", "(", ")", ";", "}", "}", "@", "Override", "public", "void", "setTcpNoDelay", "(", "boolean", "val", ")", "throws", "IOException", "{", "if", "(", "delegate", "==", "null", ")", "{", "so_nodelay", "=", "Boolean", ".", "valueOf", "(", "val", ")", ";", "}", "else", "{", "delegate", ".", "setTcpNoDelay", "(", "val", ")", ";", "}", "}", "@", "Override", "public", "boolean", "getNoDelay", "(", ")", "throws", "IOException", "{", "if", "(", "delegate", "==", "null", ")", "{", "return", "delegate", ".", "getNoDelay", "(", ")", ";", "}", "else", "{", "return", "so_nodelay", "==", "null", "?", "false", ":", "so_nodelay", ".", "booleanValue", "(", ")", ";", "}", "}", "@", "Override", "public", "void", "setBroadcast", "(", "boolean", "val", ")", "throws", "IOException", "{", "if", "(", "delegate", "==", "null", ")", "{", "so_broadcast", "=", "Boolean", ".", "valueOf", "(", "val", ")", ";", "}", "else", "{", "delegate", ".", "setBroadcast", "(", "val", ")", ";", "}", "}", "@", "Override", "public", "void", "setTrafficClass", "(", "int", "ival", ")", "throws", "IOException", "{", "if", "(", "delegate", "==", "null", ")", "{", "so_traffic_class", "=", "new", "Integer", "(", "ival", ")", ";", "}", "else", "{", "delegate", ".", "setTrafficClass", "(", "ival", ")", ";", "}", "}", "@", "Override", "public", "void", "setReceiveBufferSize", "(", "int", "size", ")", "throws", "IOException", "{", "if", "(", "delegate", "==", "null", ")", "{", "so_rcv_buf", "=", "new", "Integer", "(", "size", ")", ";", "}", "else", "{", "delegate", ".", "setReceiveBufferSize", "(", "size", ")", ";", "}", "}", "@", "Override", "public", "int", "getReceiveBufferSize", "(", ")", "throws", "IOException", "{", "if", "(", "delegate", "==", "null", ")", "{", "return", "delegate", ".", "getReceiveBufferSize", "(", ")", ";", "}", "else", "{", "return", "so_rcv_buf", "==", "null", "?", "0", ":", "so_rcv_buf", ".", "intValue", "(", ")", ";", "}", "}", "@", "Override", "public", "void", "setSendBufferSize", "(", "int", "size", ")", "throws", "IOException", "{", "if", "(", "delegate", "==", "null", ")", "{", "so_snd_buf", "=", "new", "Integer", "(", "size", ")", ";", "}", "else", "{", "delegate", ".", "setSendBufferSize", "(", "size", ")", ";", "}", "}", "@", "Override", "public", "int", "getSendBufferSize", "(", ")", "throws", "IOException", "{", "if", "(", "delegate", "==", "null", ")", "{", "return", "delegate", ".", "getSendBufferSize", "(", ")", ";", "}", "else", "{", "return", "so_snd_buf", "==", "null", "?", "0", ":", "so_snd_buf", ".", "intValue", "(", ")", ";", "}", "}", "@", "Override", "public", "void", "setTimeout", "(", "int", "timeout", ")", "throws", "IOException", "{", "if", "(", "delegate", "==", "null", ")", "{", "so_timeout", "=", "new", "Integer", "(", "timeout", ")", ";", "}", "else", "{", "delegate", ".", "setTimeout", "(", "timeout", ")", ";", "}", "}", "@", "Override", "public", "void", "setLinger", "(", "boolean", "on", ",", "int", "timeout", ")", "throws", "IOException", "{", "if", "(", "delegate", "==", "null", ")", "{", "if", "(", "on", "==", "false", ")", "{", "so_linger", "=", "new", "Integer", "(", "-", "1", ")", ";", "}", "else", "{", "so_linger", "=", "new", "Integer", "(", "timeout", ")", ";", "}", "}", "else", "{", "delegate", ".", "setLinger", "(", "on", ",", "timeout", ")", ";", "}", "}", "@", "Override", "public", "void", "close", "(", ")", "throws", "IOException", "{", "if", "(", "delegate", "!=", "null", ")", "{", "delegate", ".", "close", "(", ")", ";", "}", "else", "{", "status", "&=", "~", "OPEN_FLAG", ";", "}", "}", "public", "boolean", "isBound", "(", ")", "{", "if", "(", "delegate", "!=", "null", ")", "{", "return", "delegate", ".", "isBound", "(", ")", ";", "}", "return", "this", ".", "bindingAddress", "!=", "null", ";", "}", "@", "Override", "public", "boolean", "isOpen", "(", ")", "{", "if", "(", "delegate", "!=", "null", ")", "{", "return", "delegate", ".", "isOpen", "(", ")", ";", "}", "return", "(", "this", ".", "status", "&", "OPEN_FLAG", ")", "==", "OPEN_FLAG", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "if", "(", "delegate", "==", "null", ")", "{", "return", "\"LazySocket[\"", "+", "\"bound=\"", "+", "this", ".", "bindingAddress", "+", "\";", "linger=\"", "+", "this", ".", "so_linger", "+", "\";", "rcvbuf=\"", "+", "this", ".", "so_rcv_buf", "+", "\";", "sndbuf=\"", "+", "this", ".", "so_snd_buf", "+", "\";", "timeout=\"", "+", "this", ".", "so_timeout", "+", "\";", "reuse=\"", "+", "this", ".", "so_reuse_addr", "+", "\";", "keepalive=\"", "+", "this", ".", "so_keep_alive", "+", "\"]\"", ";", "}", "else", "{", "return", "delegate", ".", "toString", "(", ")", ";", "}", "}", "}", "</s>" ]
7,956
[ "<s>", "package", "erjang", ".", "net", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "net", ".", "InetSocketAddress", ";", "import", "java", ".", "net", ".", "SocketAddress", ";", "import", "java", ".", "net", ".", "SocketException", ";", "import", "java", ".", "nio", ".", "channels", ".", "SelectableChannel", ";", "import", "java", ".", "nio", ".", "channels", ".", "SocketChannel", ";", "public", "class", "InetClientSocket", "extends", "InetSocket", "{", "private", "SocketChannel", "ch", ";", "public", "InetClientSocket", "(", "LazyInetSocket", "sock", ")", "throws", "IOException", "{", "ch", "=", "SocketChannel", ".", "open", "(", ")", ";", "sock", ".", "init", "(", "this", ")", ";", "}", "public", "InetClientSocket", "(", "SocketChannel", "sock", ")", "{", "this", ".", "ch", "=", "sock", ";", "}", "@", "Override", "public", "SelectableChannel", "channel", "(", ")", "{", "return", "ch", ";", "}", "@", "Override", "public", "boolean", "isBound", "(", ")", "{", "return", "ch", ".", "socket", "(", ")", ".", "isBound", "(", ")", ";", "}", "@", "Override", "public", "void", "bind", "(", "InetSocketAddress", "addr", ")", "throws", "IOException", "{", "ch", ".", "socket", "(", ")", ".", "bind", "(", "addr", ")", ";", "}", "@", "Override", "public", "void", "setKeepAlive", "(", "boolean", "on", ")", "throws", "SocketException", "{", "ch", ".", "socket", "(", ")", ".", "setKeepAlive", "(", "on", ")", ";", "}", "@", "Override", "public", "boolean", "getKeepAlive", "(", ")", "throws", "IOException", "{", "return", "ch", ".", "socket", "(", ")", ".", "getKeepAlive", "(", ")", ";", "}", "@", "Override", "public", "void", "setReuseAddress", "(", "boolean", "reuse", ")", "throws", "IOException", "{", "ch", ".", "socket", "(", ")", ".", "setReuseAddress", "(", "reuse", ")", ";", "}", "@", "Override", "public", "boolean", "getReuseAddress", "(", ")", "throws", "IOException", "{", "return", "ch", ".", "socket", "(", ")", ".", "getReuseAddress", "(", ")", ";", "}", "@", "Override", "public", "void", "setOOBInline", "(", "boolean", "on", ")", "throws", "IOException", "{", "ch", ".", "socket", "(", ")", ".", "setOOBInline", "(", "on", ")", ";", "}", "@", "Override", "public", "void", "setTcpNoDelay", "(", "boolean", "on", ")", "throws", "IOException", "{", "ch", ".", "socket", "(", ")", ".", "setTcpNoDelay", "(", "on", ")", ";", "}", "@", "Override", "public", "void", "setReceiveBufferSize", "(", "int", "size", ")", "throws", "IOException", "{", "ch", ".", "socket", "(", ")", ".", "setReceiveBufferSize", "(", "size", ")", ";", "}", "@", "Override", "public", "int", "getReceiveBufferSize", "(", ")", "throws", "IOException", "{", "return", "ch", ".", "socket", "(", ")", ".", "getReceiveBufferSize", "(", ")", ";", "}", "@", "Override", "public", "void", "setTimeout", "(", "int", "timeout", ")", "throws", "IOException", "{", "ch", ".", "socket", "(", ")", ".", "setSoTimeout", "(", "timeout", ")", ";", "}", "@", "Override", "public", "void", "setSendBufferSize", "(", "int", "size", ")", "throws", "IOException", "{", "ch", ".", "socket", "(", ")", ".", "setSendBufferSize", "(", "size", ")", ";", "}", "@", "Override", "public", "int", "getSendBufferSize", "(", ")", "throws", "IOException", "{", "return", "ch", ".", "socket", "(", ")", ".", "getSendBufferSize", "(", ")", ";", "}", "@", "Override", "public", "void", "setLinger", "(", "boolean", "on", ",", "int", "timeout", ")", "throws", "IOException", "{", "ch", ".", "socket", "(", ")", ".", "setSoLinger", "(", "on", ",", "timeout", ")", ";", "}", "@", "Override", "public", "InetSocket", "accept", "(", ")", "throws", "IOException", "{", "throw", "new", "erjang", ".", "NotImplemented", "(", ")", ";", "}", "@", "Override", "public", "boolean", "connect", "(", "InetSocketAddress", "remote", ")", "throws", "IOException", "{", "return", "ch", ".", "connect", "(", "remote", ")", ";", "}", "@", "Override", "public", "boolean", "finishConnect", "(", ")", "throws", "IOException", "{", "return", "ch", ".", "finishConnect", "(", ")", ";", "}", "@", "Override", "public", "InetSocketAddress", "getLocalSocketAddress", "(", ")", "{", "return", "(", "InetSocketAddress", ")", "ch", ".", "socket", "(", ")", ".", "getLocalSocketAddress", "(", ")", ";", "}", "@", "Override", "public", "void", "listen", "(", "int", "backlog", ")", "throws", "IOException", "{", "throw", "new", "erjang", ".", "NotImplemented", "(", ")", ";", "}", "@", "Override", "public", "void", "close", "(", ")", "throws", "IOException", "{", "ch", ".", "close", "(", ")", ";", "}", "public", "void", "setTrafficClass", "(", "int", "ival", ")", "throws", "IOException", "{", "ch", ".", "socket", "(", ")", ".", "setTrafficClass", "(", "ival", ")", ";", "}", "public", "void", "setNonBlocking", "(", ")", "throws", "IOException", "{", "ch", ".", "configureBlocking", "(", "false", ")", ";", "}", "@", "Override", "public", "InetSocketAddress", "getRemoteAddress", "(", ")", "{", "return", "(", "InetSocketAddress", ")", "ch", ".", "socket", "(", ")", ".", "getRemoteSocketAddress", "(", ")", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "return", "\"\"", "+", "ch", ".", "toString", "(", ")", "+", "\"", "open=\"", "+", "ch", ".", "isOpen", "(", ")", "+", "\"", "addr=\"", "+", "ch", ".", "socket", "(", ")", ".", "getLocalSocketAddress", "(", ")", "+", "\"", "remote=\"", "+", "ch", ".", "socket", "(", ")", ".", "getRemoteSocketAddress", "(", ")", "+", "\"]\"", ";", "}", "}", "</s>" ]
7,957
[ "<s>", "package", "erjang", ".", "net", ";", "public", "enum", "ProtocolType", "{", "STREAM", ",", "DGRAM", ",", "RAW", ",", "SEQPACKET", ",", "RDM", "}", "</s>" ]
7,958
[ "<s>", "package", "erjang", ".", "net", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "net", ".", "InetAddress", ";", "import", "java", ".", "net", ".", "InetSocketAddress", ";", "import", "java", ".", "net", ".", "NetworkInterface", ";", "import", "java", ".", "net", ".", "SocketAddress", ";", "import", "java", ".", "nio", ".", "ByteBuffer", ";", "import", "java", ".", "nio", ".", "channels", ".", "SelectableChannel", ";", "import", "erjang", ".", "driver", ".", "efile", ".", "Posix", ";", "public", "abstract", "class", "InetSocket", "{", "public", "static", "InetSocket", "open", "(", "ProtocolFamily", "domain", ",", "ProtocolType", "type", ",", "Protocol", "protocol", ")", "{", "return", "new", "LazyInetSocket", "(", "domain", ",", "type", ",", "protocol", ")", ";", "}", "public", "abstract", "SelectableChannel", "channel", "(", ")", ";", "public", "abstract", "boolean", "connect", "(", "InetSocketAddress", "remote", ")", "throws", "IOException", ";", "public", "abstract", "void", "bind", "(", "InetSocketAddress", "localAddress", ")", "throws", "IOException", ";", "public", "abstract", "boolean", "isBound", "(", ")", ";", "public", "abstract", "void", "listen", "(", "int", "backlog", ")", "throws", "IOException", ";", "public", "abstract", "InetSocket", "accept", "(", ")", "throws", "IOException", ";", "public", "abstract", "InetSocketAddress", "getLocalSocketAddress", "(", ")", ";", "public", "abstract", "void", "setReuseAddress", "(", "boolean", "reuse", ")", "throws", "IOException", ";", "public", "abstract", "void", "setReceiveBufferSize", "(", "int", "size", ")", "throws", "IOException", ";", "public", "abstract", "void", "setTimeout", "(", "int", "timeout", ")", "throws", "IOException", ";", "public", "abstract", "void", "setSendBufferSize", "(", "int", "size", ")", "throws", "IOException", ";", "public", "void", "setKeepAlive", "(", "boolean", "on", ")", "throws", "IOException", "{", "throw", "new", "PosixIOException", "(", "Posix", ".", "EINVAL", ",", "\"\"", "+", "this", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ";", "}", "public", "void", "setOOBInline", "(", "boolean", "on", ")", "throws", "IOException", "{", "throw", "new", "PosixIOException", "(", "Posix", ".", "EINVAL", ",", "\"\"", "+", "this", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ";", "}", "public", "void", "setTcpNoDelay", "(", "boolean", "on", ")", "throws", "IOException", "{", "throw", "new", "PosixIOException", "(", "Posix", ".", "EINVAL", ",", "\"\"", "+", "this", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ";", "}", "public", "void", "setLinger", "(", "boolean", "on", ",", "int", "timeout", ")", "throws", "IOException", "{", "throw", "new", "PosixIOException", "(", "Posix", ".", "EINVAL", ",", "\"\"", "+", "this", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ";", "}", "public", "void", "setBroadcast", "(", "boolean", "on", ")", "throws", "IOException", "{", "throw", "new", "PosixIOException", "(", "Posix", ".", "EINVAL", ",", "\"\"", "+", "this", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ";", "}", "public", "int", "send", "(", "ByteBuffer", "packet", ",", "SocketAddress", "target", ")", "throws", "IOException", "{", "throw", "new", "PosixIOException", "(", "Posix", ".", "EINVAL", ",", "\"\"", "+", "this", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ";", "}", "public", "void", "close", "(", ")", "throws", "IOException", "{", "channel", "(", ")", ".", "close", "(", ")", ";", "}", "public", "void", "configureBlocking", "(", "boolean", "block", ")", "throws", "IOException", "{", "channel", "(", ")", ".", "configureBlocking", "(", "block", ")", ";", "}", "public", "boolean", "isOpen", "(", ")", "{", "return", "channel", "(", ")", ".", "isOpen", "(", ")", ";", "}", "public", "boolean", "finishConnect", "(", ")", "throws", "IOException", "{", "throw", "new", "PosixIOException", "(", "Posix", ".", "EINVAL", ",", "\"\"", "+", "this", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ";", "}", "public", "int", "getLocalPort", "(", ")", "{", "InetSocketAddress", "addr", "=", "(", "InetSocketAddress", ")", "getLocalSocketAddress", "(", ")", ";", "if", "(", "addr", "==", "null", ")", "{", "return", "0", ";", "}", "return", "addr", ".", "getPort", "(", ")", ";", "}", "public", "void", "setTrafficClass", "(", "int", "ival", ")", "throws", "IOException", "{", "throw", "new", "PosixIOException", "(", "Posix", ".", "EINVAL", ",", "\"\"", "+", "this", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ";", "}", "public", "void", "setTimeToLive", "(", "int", "ival", ")", "throws", "IOException", "{", "throw", "new", "PosixIOException", "(", "Posix", ".", "EINVAL", ",", "\"\"", "+", "this", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ";", "}", "public", "void", "setLoopbackMode", "(", "boolean", "on", ")", "throws", "IOException", "{", "throw", "new", "PosixIOException", "(", "Posix", ".", "EINVAL", ",", "\"\"", "+", "this", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ";", "}", "public", "void", "setInterface", "(", "InetAddress", "addr", ")", "throws", "IOException", "{", "throw", "new", "PosixIOException", "(", "Posix", ".", "EINVAL", ",", "\"\"", "+", "this", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ";", "}", "public", "void", "joinGroup", "(", "SocketAddress", "mcastaddr", ",", "NetworkInterface", "netIf", ")", "throws", "IOException", "{", "throw", "new", "PosixIOException", "(", "Posix", ".", "EINVAL", ",", "\"\"", "+", "this", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ";", "}", "public", "void", "leaveGroup", "(", "SocketAddress", "mcastaddr", ",", "NetworkInterface", "netIf", ")", "throws", "IOException", "{", "throw", "new", "PosixIOException", "(", "Posix", ".", "EINVAL", ",", "\"\"", "+", "this", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ";", "}", "public", "void", "setNonBlocking", "(", ")", "throws", "IOException", "{", "throw", "new", "PosixIOException", "(", "Posix", ".", "EINVAL", ",", "\"\"", "+", "this", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ";", "}", "public", "boolean", "getNoDelay", "(", ")", "throws", "IOException", "{", "throw", "new", "PosixIOException", "(", "Posix", ".", "EINVAL", ",", "\"\"", "+", "this", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ";", "}", "public", "boolean", "getKeepAlive", "(", ")", "throws", "IOException", "{", "throw", "new", "PosixIOException", "(", "Posix", ".", "EINVAL", ",", "\"\"", "+", "this", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ";", "}", "public", "boolean", "getReuseAddress", "(", ")", "throws", "IOException", "{", "throw", "new", "PosixIOException", "(", "Posix", ".", "EINVAL", ",", "\"\"", "+", "this", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ";", "}", "public", "int", "getSendBufferSize", "(", ")", "throws", "IOException", "{", "throw", "new", "PosixIOException", "(", "Posix", ".", "EINVAL", ",", "\"\"", "+", "this", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ";", "}", "public", "int", "getReceiveBufferSize", "(", ")", "throws", "IOException", "{", "throw", "new", "PosixIOException", "(", "Posix", ".", "EINVAL", ",", "\"\"", "+", "this", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ";", "}", "public", "InetSocketAddress", "getRemoteAddress", "(", ")", "{", "throw", "new", "erjang", ".", "NotImplemented", "(", ")", ";", "}", "}", "</s>" ]
7,959
[ "<s>", "package", "erjang", ".", "net", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "net", ".", "InetSocketAddress", ";", "import", "java", ".", "net", ".", "SocketAddress", ";", "import", "java", ".", "nio", ".", "ByteBuffer", ";", "import", "java", ".", "nio", ".", "channels", ".", "DatagramChannel", ";", "import", "java", ".", "nio", ".", "channels", ".", "SelectableChannel", ";", "import", "erjang", ".", "driver", ".", "efile", ".", "Posix", ";", "public", "class", "InetDatagramSocket", "extends", "InetSocket", "{", "private", "DatagramChannel", "ch", ";", "public", "InetDatagramSocket", "(", "LazyInetSocket", "sock", ")", "throws", "IOException", "{", "ch", "=", "DatagramChannel", ".", "open", "(", ")", ";", "sock", ".", "init", "(", "this", ")", ";", "}", "@", "Override", "public", "InetSocket", "accept", "(", ")", "throws", "IOException", "{", "throw", "new", "erjang", ".", "NotImplemented", "(", ")", ";", "}", "@", "Override", "public", "void", "bind", "(", "InetSocketAddress", "localAddress", ")", "throws", "IOException", "{", "ch", ".", "socket", "(", ")", ".", "bind", "(", "localAddress", ")", ";", "}", "@", "Override", "public", "SelectableChannel", "channel", "(", ")", "{", "return", "ch", ";", "}", "@", "Override", "public", "boolean", "connect", "(", "InetSocketAddress", "remote", ")", "throws", "IOException", "{", "ch", ".", "socket", "(", ")", ".", "connect", "(", "remote", ")", ";", "return", "true", ";", "}", "@", "Override", "public", "boolean", "finishConnect", "(", ")", "throws", "IOException", "{", "return", "true", ";", "}", "@", "Override", "public", "InetSocketAddress", "getLocalSocketAddress", "(", ")", "{", "return", "(", "InetSocketAddress", ")", "ch", ".", "socket", "(", ")", ".", "getLocalSocketAddress", "(", ")", ";", "}", "@", "Override", "public", "boolean", "isBound", "(", ")", "{", "return", "ch", ".", "socket", "(", ")", ".", "isBound", "(", ")", ";", "}", "@", "Override", "public", "void", "listen", "(", "int", "backlog", ")", "throws", "IOException", "{", "throw", "new", "PosixIOException", "(", "Posix", ".", "EINVAL", ",", "\"\"", ")", ";", "}", "@", "Override", "public", "void", "setReceiveBufferSize", "(", "int", "size", ")", "throws", "IOException", "{", "ch", ".", "socket", "(", ")", ".", "setReceiveBufferSize", "(", "size", ")", ";", "}", "@", "Override", "public", "void", "setReuseAddress", "(", "boolean", "on", ")", "throws", "IOException", "{", "ch", ".", "socket", "(", ")", ".", "setReuseAddress", "(", "on", ")", ";", "}", "@", "Override", "public", "void", "setSendBufferSize", "(", "int", "size", ")", "throws", "IOException", "{", "ch", ".", "socket", "(", ")", ".", "setSendBufferSize", "(", "size", ")", ";", "}", "@", "Override", "public", "void", "setTimeout", "(", "int", "timeout", ")", "throws", "IOException", "{", "ch", ".", "socket", "(", ")", ".", "setSoTimeout", "(", "timeout", ")", ";", "}", "@", "Override", "public", "void", "setBroadcast", "(", "boolean", "on", ")", "throws", "IOException", "{", "ch", ".", "socket", "(", ")", ".", "setBroadcast", "(", "on", ")", ";", "}", "@", "Override", "public", "void", "setTrafficClass", "(", "int", "ival", ")", "throws", "IOException", "{", "ch", ".", "socket", "(", ")", ".", "setTrafficClass", "(", "ival", ")", ";", "}", "@", "Override", "public", "int", "send", "(", "ByteBuffer", "packet", ",", "SocketAddress", "target", ")", "throws", "IOException", "{", "return", "ch", ".", "send", "(", "packet", ",", "target", ")", ";", "}", "}", "</s>" ]
7,960
[ "<s>", "package", "erjang", ".", "net", ";", "import", "erjang", ".", "driver", ".", "tcp_inet", ".", "TCPINet", ";", "public", "enum", "ProtocolFamily", "{", "INET", "(", "TCPINet", ".", "INET_AF_INET", ")", ",", "INET6", "(", "TCPINet", ".", "INET_AF_INET6", ")", ",", "LOOPBACK", "(", "TCPINet", ".", "INET_AF_LOOPBACK", ")", ",", "ANY", "(", "TCPINet", ".", "INET_AF_ANY", ")", ";", "public", "final", "byte", "code", ";", "private", "ProtocolFamily", "(", "byte", "code", ")", "{", "this", ".", "code", "=", "code", ";", "}", "}", "</s>" ]
7,961
[ "<s>", "package", "erjang", ".", "net", ";", "public", "enum", "Protocol", "{", "TCP", ",", "UDP", ",", "SCTP", ";", "}", "</s>" ]
7,962
[ "<s>", "package", "erjang", ".", "net", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "erjang", ".", "driver", ".", "efile", ".", "Posix", ";", "@", "SuppressWarnings", "(", "\"serial\"", ")", "public", "class", "PosixIOException", "extends", "IOException", "{", "public", "final", "int", "errno", ";", "public", "PosixIOException", "(", "int", "errno", ",", "String", "string", ")", "{", "super", "(", "Posix", ".", "errno_id", "(", "errno", ")", ".", "toUpperCase", "(", ")", "+", "\":", "\"", "+", "string", ")", ";", "this", ".", "errno", "=", "errno", ";", "}", "}", "</s>" ]
7,963
[ "<s>", "package", "erjang", ";", "import", "java", ".", "math", ".", "BigInteger", ";", "import", "java", ".", "nio", ".", "ByteBuffer", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "java", ".", "util", ".", "Comparator", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "MethodVisitor", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "Type", ";", "import", "erjang", ".", "driver", ".", "EPortControl", ";", "import", "erjang", ".", "m", ".", "ets", ".", "EMatchContext", ";", "import", "erjang", ".", "m", ".", "ets", ".", "ETermPattern", ";", "import", "erjang", ".", "m", ".", "java", ".", "JavaObject", ";", "public", "abstract", "class", "EObject", "{", "public", "static", "final", "ErlangOrderComparator", "ERLANG_ORDERING", "=", "new", "ErlangOrderComparator", "(", ")", ";", "public", "ECons", "cons", "(", "EObject", "h", ")", "{", "ESmall", "sm", ";", "if", "(", "(", "sm", "=", "h", ".", "testSmall", "(", ")", ")", "!=", "null", "&&", "(", "(", "sm", ".", "value", "&", "0xff", ")", "==", "sm", ".", "value", ")", ")", "{", "return", "new", "EBinList", "(", "(", "byte", ")", "sm", ".", "value", ",", "this", ")", ";", "}", "else", "{", "return", "new", "EPair", "(", "h", ",", "this", ")", ";", "}", "}", "public", "JavaObject", "testJavaObject", "(", ")", "{", "return", "null", ";", "}", "public", "ERef", "testReference", "(", ")", "{", "return", "null", ";", "}", "public", "EString", "testString", "(", ")", "{", "return", "null", ";", "}", "public", "EBigString", "testBigString", "(", ")", "{", "return", "null", ";", "}", "public", "EFun", "testFunction", "(", ")", "{", "return", "null", ";", "}", "public", "EFun", "testFunction2", "(", "int", "nargs", ")", "{", "return", "null", ";", "}", "public", "EAtom", "testAtom", "(", ")", "{", "return", "null", ";", "}", "public", "ECons", "testNonEmptyList", "(", ")", "{", "return", "null", ";", "}", "public", "ETuple", "testTuple", "(", ")", "{", "return", "null", ";", "}", "public", "ESeq", "testSeq", "(", ")", "{", "return", "null", ";", "}", "public", "EPID", "testPID", "(", ")", "{", "return", "null", ";", "}", "public", "int", "asInt", "(", ")", "{", "throw", "new", "RuntimeException", "(", "\"\"", "+", "this", "+", "\"", "to", "int\"", ")", ";", "}", "public", "ENumber", "testNumber", "(", ")", "{", "return", "null", ";", "}", "public", "ECons", "testCons", "(", ")", "{", "return", "null", ";", "}", "public", "EInteger", "testInteger", "(", ")", "{", "return", "null", ";", "}", "public", "ENil", "testNil", "(", ")", "{", "return", "null", ";", "}", "public", "boolean", "isNil", "(", ")", "{", "return", "testNil", "(", ")", "!=", "null", ";", "}", "public", "boolean", "isBoolean", "(", ")", "{", "return", "this", "==", "ERT", ".", "TRUE", "||", "this", "==", "ERT", ".", "FALSE", ";", "}", "public", "EAtom", "testBoolean", "(", ")", "{", "return", "null", ";", "}", "public", "EBinary", "testBinary", "(", ")", "{", "return", "null", ";", "}", "public", "EPort", "testPort", "(", ")", "{", "return", "null", ";", "}", "public", "ESmall", "testSmall", "(", ")", "{", "return", "null", ";", "}", "public", "EBig", "testBig", "(", ")", "{", "return", "null", ";", "}", "public", "EDouble", "testFloat", "(", ")", "{", "return", "null", ";", "}", "public", "boolean", "collectIOList", "(", "List", "<", "ByteBuffer", ">", "out", ")", "{", "return", "false", ";", "}", "public", "void", "collectCharList", "(", "CharCollector", "out", ")", "throws", "CharCollector", ".", "CollectingException", ",", "CharCollector", ".", "InvalidElementException", ",", "IOException", "{", "throw", "new", "CharCollector", ".", "InvalidElementException", "(", ")", ";", "}", "public", "Type", "emit_const", "(", "MethodVisitor", "mv", ")", "{", "throw", "new", "NotImplemented", "(", "\"\"", "+", "this", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ";", "}", "@", "BIF", "(", "name", "=", "\"-\"", ")", "public", "ENumber", "negate", "(", ")", "{", "throw", "ERT", ".", "badarith", "(", "this", ")", ";", "}", "@", "BIF", "(", "name", "=", "\"+\"", ")", "public", "ENumber", "add", "(", "EObject", "rhs", ")", "{", "return", "add", "(", "rhs", ",", "false", ")", ";", "}", "@", "BIF", "(", "name", "=", "\"+\"", ")", "public", "ENumber", "add", "(", "ESmall", "rhs", ")", "{", "return", "add", "(", "rhs", ".", "value", ",", "false", ")", ";", "}", "@", "BIF", "(", "name", "=", "\"+\"", ",", "type", "=", "BIF", ".", "Type", ".", "GUARD", ")", "public", "final", "ENumber", "add$g", "(", "ESmall", "rhs", ")", "{", "return", "add", "(", "rhs", ".", "value", ",", "true", ")", ";", "}", "public", "ENumber", "add", "(", "EObject", "rhs", ",", "boolean", "guard", ")", "{", "if", "(", "guard", ")", "return", "null", ";", "throw", "ERT", ".", "badarith", "(", "this", ",", "rhs", ")", ";", "}", "public", "ENumber", "add", "(", "int", "lhs", ",", "boolean", "guard", ")", "{", "if", "(", "guard", ")", "return", "null", ";", "throw", "ERT", ".", "badarith", "(", "lhs", ",", "this", ")", ";", "}", "public", "ENumber", "add", "(", "double", "lhs", ",", "boolean", "guard", ")", "{", "if", "(", "guard", ")", "return", "null", ";", "throw", "ERT", ".", "badarith", "(", "lhs", ",", "this", ")", ";", "}", "public", "ENumber", "add", "(", "BigInteger", "lhs", ",", "boolean", "guard", ")", "{", "if", "(", "guard", ")", "return", "null", ";", "throw", "ERT", ".", "badarith", "(", "lhs", ",", "this", ")", ";", "}", "@", "BIF", "(", "name", "=", "\"-\"", ")", "public", "ENumber", "subtract", "(", "EObject", "rhs", ")", "{", "return", "subtract", "(", "rhs", ",", "false", ")", ";", "}", "public", "ENumber", "subtract", "(", "ESmall", "rhs", ")", "{", "return", "subtract", "(", "rhs", ",", "false", ")", ";", "}", "public", "ENumber", "subtract", "(", "EObject", "rhs", ",", "boolean", "guard", ")", "{", "if", "(", "guard", ")", "return", "null", ";", "throw", "ERT", ".", "badarith", "(", "this", ",", "rhs", ")", ";", "}", "public", "ENumber", "subtract", "(", "int", "rhs", ")", "{", "throw", "ERT", ".", "badarith", "(", "this", ",", "rhs", ")", ";", "}", "ENumber", "r_subtract", "(", "int", "lhs", ",", "boolean", "guard", ")", "{", "if", "(", "guard", ")", "return", "null", ";", "throw", "ERT", ".", "badarith", "(", "lhs", ",", "this", ")", ";", "}", "ENumber", "r_subtract", "(", "double", "lhs", ",", "boolean", "guard", ")", "{", "if", "(", "guard", ")", "return", "null", ";", "throw", "ERT", ".", "badarith", "(", "lhs", ",", "this", ")", ";", "}", "ENumber", "r_subtract", "(", "BigInteger", "lhs", ",", "boolean", "guard", ")", "{", "if", "(", "guard", ")", "return", "null", ";", "throw", "ERT", ".", "badarith", "(", "lhs", ",", "this", ")", ";", "}", "@", "BIF", "(", "name", "=", "\"div\"", ")", "public", "EInteger", "idiv", "(", "EObject", "rhs", ")", "{", "throw", "ERT", ".", "badarith", "(", "this", ",", "rhs", ")", ";", "}", "public", "EInteger", "idiv", "(", "int", "rhs", ")", "{", "throw", "ERT", ".", "badarith", "(", "this", ",", "rhs", ")", ";", "}", "EInteger", "r_idiv", "(", "int", "lhs", ")", "{", "throw", "ERT", ".", "badarith", "(", "lhs", ",", "this", ")", ";", "}", "EInteger", "r_idiv", "(", "BigInteger", "lhs", ")", "{", "throw", "ERT", ".", "badarith", "(", "lhs", ",", "this", ")", ";", "}", "@", "BIF", "(", "name", "=", "\"rem\"", ")", "public", "EInteger", "irem", "(", "EObject", "rhs", ")", "{", "throw", "ERT", ".", "badarith", "(", "this", ",", "rhs", ")", ";", "}", "EInteger", "r_irem", "(", "int", "lhs", ")", "{", "throw", "ERT", ".", "badarith", "(", "lhs", ",", "this", ")", ";", "}", "EInteger", "r_irem", "(", "BigInteger", "lhs", ")", "{", "throw", "ERT", ".", "badarith", "(", "lhs", ",", "this", ")", ";", "}", "@", "BIF", "(", "name", "=", "\"/\"", ")", "public", "EDouble", "divide", "(", "EObject", "rhs", ")", "{", "throw", "ERT", ".", "badarith", "(", "this", ",", "rhs", ")", ";", "}", "EDouble", "r_divide", "(", "int", "lhs", ")", "{", "throw", "ERT", ".", "badarith", "(", "lhs", ",", "this", ")", ";", "}", "EDouble", "r_divide", "(", "double", "lhs", ")", "{", "throw", "ERT", ".", "badarith", "(", "lhs", ",", "this", ")", ";", "}", "EDouble", "r_divide", "(", "BigInteger", "lhs", ")", "{", "throw", "ERT", ".", "badarith", "(", "lhs", ",", "this", ")", ";", "}", "@", "BIF", "(", "name", "=", "\"*\"", ")", "public", "ENumber", "multiply", "(", "EObject", "rhs", ")", "{", "throw", "ERT", ".", "badarith", "(", "this", ",", "rhs", ")", ";", "}", "public", "ENumber", "r_multiply", "(", "int", "lhs", ")", "{", "throw", "ERT", ".", "badarith", "(", "new", "ESmall", "(", "lhs", ")", ",", "this", ")", ";", "}", "public", "EDouble", "r_multiply", "(", "double", "lhs", ")", "{", "throw", "ERT", ".", "badarith", "(", "new", "EDouble", "(", "lhs", ")", ",", "this", ")", ";", "}", "public", "ENumber", "r_multiply", "(", "BigInteger", "lhs", ")", "{", "throw", "ERT", ".", "badarith", "(", "new", "EBig", "(", "lhs", ")", ",", "this", ")", ";", "}", "@", "BIF", "(", "name", "=", "\"bsr\"", ")", "public", "EInteger", "bsr", "(", "EObject", "rhs", ")", "{", "throw", "ERT", ".", "badarith", "(", "this", ",", "rhs", ")", ";", "}", "EInteger", "r_bsr", "(", "int", "lhs", ")", "{", "throw", "ERT", ".", "badarith", "(", "lhs", ",", "this", ")", ";", "}", "EInteger", "r_bsr", "(", "BigInteger", "lhs", ")", "{", "throw", "ERT", ".", "badarith", "(", "lhs", ",", "this", ")", ";", "}", "@", "BIF", "(", "name", "=", "\"bsl\"", ")", "public", "EInteger", "bsl", "(", "EObject", "rhs", ")", "{", "throw", "ERT", ".", "badarith", "(", "this", ",", "rhs", ")", ";", "}", "EInteger", "r_bsl", "(", "int", "lhs", ")", "{", "throw", "ERT", ".", "badarith", "(", "lhs", ",", "this", ")", ";", "}", "EInteger", "r_bsl", "(", "BigInteger", "lhs", ")", "{", "throw", "ERT", ".", "badarith", "(", "lhs", ",", "this", ")", ";", "}", "@", "BIF", "(", "name", "=", "\"band\"", ")", "public", "EInteger", "band", "(", "EObject", "rhs", ")", "{", "throw", "ERT", ".", "badarith", "(", "this", ",", "rhs", ")", ";", "}", "public", "EInteger", "band", "(", "int", "lhs", ")", "{", "throw", "ERT", ".", "badarith", "(", "lhs", ",", "this", ")", ";", "}", "public", "EInteger", "band", "(", "BigInteger", "lhs", ")", "{", "throw", "ERT", ".", "badarith", "(", "lhs", ",", "this", ")", ";", "}", "@", "BIF", "(", "name", "=", "\"bor\"", ")", "public", "EInteger", "bor", "(", "EObject", "rhs", ")", "{", "throw", "ERT", ".", "badarith", "(", "this", ",", "rhs", ")", ";", "}", "public", "EInteger", "bor", "(", "int", "lhs", ")", "{", "throw", "ERT", ".", "badarith", "(", "lhs", ",", "this", ")", ";", "}", "public", "EInteger", "bor", "(", "BigInteger", "lhs", ")", "{", "throw", "ERT", ".", "badarith", "(", "lhs", ",", "this", ")", ";", "}", "@", "BIF", "(", "name", "=", "\"bxor\"", ")", "public", "EInteger", "bxor", "(", "EObject", "rhs", ")", "{", "throw", "ERT", ".", "badarith", "(", "this", ",", "rhs", ")", ";", "}", "@", "BIF", "(", "name", "=", "\"bxor\"", ")", "public", "EInteger", "bxor", "(", "ESmall", "rhs", ")", "{", "return", "bxor", "(", "rhs", ".", "value", ")", ";", "}", "public", "EInteger", "bxor", "(", "int", "lhs", ")", "{", "throw", "ERT", ".", "badarith", "(", "lhs", ",", "this", ")", ";", "}", "public", "EInteger", "bxor", "(", "BigInteger", "lhs", ")", "{", "throw", "ERT", ".", "badarith", "(", "lhs", ",", "this", ")", ";", "}", "@", "BIF", "(", "name", "=", "\"bnot\"", ")", "public", "EInteger", "bnot", "(", ")", "{", "throw", "ERT", ".", "badarith", "(", "this", ")", ";", "}", "public", "EDouble", "divide", "(", "double", "rhs", ")", "{", "throw", "ERT", ".", "badarith", "(", "this", ",", "rhs", ")", ";", "}", "public", "EInteger", "irem", "(", "int", "rhs", ")", "{", "throw", "ERT", ".", "badarith", "(", "this", ",", "rhs", ")", ";", "}", "@", "Override", "public", "abstract", "int", "hashCode", "(", ")", ";", "@", "Override", "public", "boolean", "equals", "(", "Object", "other", ")", "{", "if", "(", "other", "==", "this", ")", "return", "true", ";", "if", "(", "other", "instanceof", "EObject", ")", "{", "return", "equalsExactly", "(", "(", "EObject", ")", "other", ")", ";", "}", "else", "{", "return", "false", ";", "}", "}", "public", "boolean", "equals", "(", "EObject", "other", ")", "{", "if", "(", "other", "==", "this", ")", "return", "true", ";", "return", "equalsExactly", "(", "other", ")", ";", "}", "public", "final", "int", "erlangCompareTo", "(", "EObject", "rhs", ")", "{", "if", "(", "rhs", "==", "this", ")", "return", "0", ";", "int", "cmp1", "=", "cmp_order", "(", ")", ";", "int", "cmp2", "=", "rhs", ".", "cmp_order", "(", ")", ";", "if", "(", "cmp1", "==", "cmp2", ")", "{", "return", "compare_same", "(", "rhs", ")", ";", "}", "else", "if", "(", "cmp1", "<", "cmp2", ")", "{", "return", "-", "1", ";", "}", "else", "{", "return", "1", ";", "}", "}", "int", "compare_same", "(", "EObject", "rhs", ")", "{", "throw", "new", "Error", "(", "\"\"", ")", ";", "}", "int", "r_compare_same", "(", "ESmall", "lhs", ")", "{", "throw", "new", "NotImplemented", "(", ")", ";", "}", "int", "r_compare_same", "(", "EBig", "lhs", ")", "{", "throw", "new", "NotImplemented", "(", ")", ";", "}", "int", "r_compare_same", "(", "EDouble", "lhs", ")", "{", "throw", "new", "NotImplemented", "(", ")", ";", "}", "int", "r_compare_same", "(", "EInternalPID", "lhs", ")", "{", "throw", "new", "NotImplemented", "(", ")", ";", "}", "public", "boolean", "equalsExactly", "(", "EObject", "rhs", ")", "{", "return", "erlangCompareTo", "(", "rhs", ")", "==", "0", ";", "}", "public", "final", "boolean", "erlangEquals", "(", "EObject", "rhs", ")", "{", "return", "erlangCompareTo", "(", "rhs", ")", "==", "0", ";", "}", "boolean", "r_equals_exactly", "(", "ESmall", "lhs", ")", "{", "return", "false", ";", "}", "boolean", "r_equals_exactly", "(", "EBig", "lhs", ")", "{", "return", "false", ";", "}", "boolean", "r_equals_exactly", "(", "EDouble", "lhs", ")", "{", "return", "false", ";", "}", "public", "static", "final", "int", "CMP_ORDER_ERJANG_INTERNAL", "=", "-", "1", ";", "public", "static", "final", "int", "CMP_ORDER_NUMBER", "=", "0", ";", "public", "static", "final", "int", "CMP_ORDER_ATOM", "=", "1", ";", "public", "static", "final", "int", "CMP_ORDER_REFERENCE", "=", "2", ";", "public", "static", "final", "int", "CMP_ORDER_FUN", "=", "3", ";", "public", "static", "final", "int", "CMP_ORDER_PORT", "=", "4", ";", "public", "static", "final", "int", "CMP_ORDER_PID", "=", "5", ";", "public", "static", "final", "int", "CMP_ORDER_TUPLE", "=", "6", ";", "public", "static", "final", "int", "CMP_ORDER_LIST", "=", "7", ";", "public", "static", "final", "int", "CMP_ORDER_BITSTRING", "=", "8", ";", "int", "cmp_order", "(", ")", "{", "throw", "new", "Error", "(", "\"\"", ")", ";", "}", "@", "BIF", "public", "EAtom", "is_function", "(", "EObject", "arity", ")", "{", "return", "ERT", ".", "FALSE", ";", "}", "public", "EAtom", "ge", "(", "EObject", "o2", ")", "{", "return", "ERT", ".", "box", "(", "this", ".", "erlangCompareTo", "(", "o2", ")", ">=", "0", ")", ";", "}", "public", "EBitString", "testBitString", "(", ")", "{", "return", "null", ";", "}", "public", "EInternalPort", "testInternalPort", "(", ")", "{", "return", "null", ";", "}", "public", "EPortControl", "testPortControl", "(", ")", "{", "return", "null", ";", "}", "public", "EHandle", "testHandle", "(", ")", "{", "return", "null", ";", "}", "public", "EInternalPID", "testInternalPID", "(", ")", "{", "return", "null", ";", "}", "public", "boolean", "match", "(", "ETermPattern", "matcher", ",", "EMatchContext", "r", ")", "{", "return", "false", ";", "}", "public", "ETermPattern", "compileMatch", "(", "Set", "<", "Integer", ">", "out", ")", "{", "throw", "ERT", ".", "badarg", "(", "this", ")", ";", "}", "public", "EBinMatchState", "testBinMatchState", "(", ")", "{", "return", "null", ";", "}", "public", "void", "encode", "(", "EOutputStream", "eos", ")", "{", "throw", "new", "NotImplemented", "(", "\"Encode", "for", "\"", "+", "getClass", "(", ")", ".", "getName", "(", ")", ")", ";", "}", "final", "public", "boolean", "is_eq", "(", "EObject", "other", ")", "{", "return", "erlangEquals", "(", "other", ")", ";", "}", "final", "public", "boolean", "is_eq_exact", "(", "EObject", "other", ")", "{", "return", "equalsExactly", "(", "other", ")", ";", "}", "final", "public", "boolean", "is_ne", "(", "EObject", "other", ")", "{", "return", "!", "erlangEquals", "(", "other", ")", ";", "}", "final", "public", "boolean", "is_ne_exact", "(", "EObject", "other", ")", "{", "return", "!", "equalsExactly", "(", "other", ")", ";", "}", "final", "public", "boolean", "is_lt", "(", "EObject", "other", ")", "{", "return", "this", ".", "erlangCompareTo", "(", "other", ")", "<", "0", ";", "}", "final", "public", "boolean", "is_ge", "(", "EObject", "other", ")", "{", "return", "this", ".", "erlangCompareTo", "(", "other", ")", ">=", "0", ";", "}", "public", "EObject", "prepend", "(", "ESeq", "list", ")", "{", "ESeq", "rlist", "=", "ERT", ".", "NIL", ";", "while", "(", "!", "list", ".", "isNil", "(", ")", ")", "{", "rlist", "=", "rlist", ".", "cons", "(", "list", ".", "head", "(", ")", ")", ";", "list", "=", "list", ".", "tail", "(", ")", ";", "}", "EObject", "r", "=", "this", ";", "while", "(", "!", "rlist", ".", "isNil", "(", ")", ")", "{", "r", "=", "r", ".", "cons", "(", "rlist", ".", "head", "(", ")", ")", ";", "rlist", "=", "rlist", ".", "tail", "(", ")", ";", "}", "return", "r", ";", "}", "public", "ENumber", "inc", "(", ")", "{", "return", "ESmall", ".", "ONE", ".", "add", "(", "this", ")", ";", "}", "public", "ENumber", "dec", "(", ")", "{", "return", "ESmall", ".", "MINUS_ONE", ".", "add", "(", "this", ")", ";", "}", "public", "boolean", "is_zero", "(", ")", "{", "return", "false", ";", "}", "public", "static", "abstract", "class", "ValueComparator", "implements", "Comparator", "<", "EObject", ">", "{", "public", "abstract", "int", "compare", "(", "EObject", "a", ",", "EObject", "b", ")", ";", "}", "private", "static", "class", "ErlangOrderComparator", "extends", "ValueComparator", "{", "public", "int", "compare", "(", "EObject", "a", ",", "EObject", "b", ")", "{", "return", "a", ".", "erlangCompareTo", "(", "b", ")", ";", "}", "}", "}", "</s>" ]
7,964
[ "<s>", "package", "erjang", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "MethodVisitor", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "Opcodes", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "Type", ";", "public", "final", "class", "EList", "extends", "ESeq", "{", "private", "final", "EObject", "head", ";", "private", "final", "ESeq", "tail", ";", "public", "EList", "(", "EObject", "h", ",", "ESeq", "tail", ")", "{", "if", "(", "tail", "==", "null", ")", "tail", "=", "ERT", ".", "NIL", ";", "if", "(", "h", "==", "null", ")", "throw", "new", "NullPointerException", "(", ")", ";", "this", ".", "head", "=", "h", ";", "this", ".", "tail", "=", "tail", ";", "}", "public", "ECons", "testNonEmptyList", "(", ")", "{", "return", "this", ";", "}", "protected", "EList", "(", ")", "{", "head", "=", "tail", "=", "null", ";", "}", "@", "Override", "public", "EList", "cons", "(", "EObject", "h", ")", "{", "return", "new", "EList", "(", "h", ",", "this", ")", ";", "}", "@", "Override", "public", "EObject", "head", "(", ")", "{", "return", "head", ";", "}", "@", "Override", "public", "ESeq", "tail", "(", ")", "{", "return", "tail", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "try", "{", "ESeq", "str", "=", "EString", ".", "make", "(", "this", ")", ";", "return", "str", ".", "toString", "(", ")", ";", "}", "catch", "(", "ErlangException", "e", ")", "{", "}", "StringBuffer", "sb", "=", "new", "StringBuffer", "(", "\"[\"", ")", ";", "assert", "(", "this", "instanceof", "EList", ")", ";", "ESeq", "val", "=", "this", ";", "while", "(", "(", "val", ".", "testNil", "(", ")", ")", "==", "null", ")", "{", "if", "(", "val", "!=", "this", ")", "{", "sb", ".", "append", "(", "\",\"", ")", ";", "}", "sb", ".", "append", "(", "val", ".", "head", "(", ")", ")", ";", "val", "=", "val", ".", "tail", "(", ")", ";", "}", "sb", ".", "append", "(", "\"]\"", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}", "static", "Type", "ELIST_TYPE", "=", "Type", ".", "getType", "(", "EList", ".", "class", ")", ";", "static", "Type", "ESEQ_TYPE", "=", "Type", ".", "getType", "(", "ESeq", ".", "class", ")", ";", "static", "Type", "ETERM_TYPE", "=", "Type", ".", "getType", "(", "EObject", ".", "class", ")", ";", "static", "String", "CONSTRUCTOR_DESC", "=", "\"(\"", "+", "ETERM_TYPE", ".", "getDescriptor", "(", ")", "+", "ESEQ_TYPE", ".", "getDescriptor", "(", ")", "+", "\")V\"", ";", "@", "Override", "public", "Type", "emit_const", "(", "MethodVisitor", "fa", ")", "{", "Type", "type", "=", "ELIST_TYPE", ";", "fa", ".", "visitTypeInsn", "(", "Opcodes", ".", "NEW", ",", "type", ".", "getInternalName", "(", ")", ")", ";", "fa", ".", "visitInsn", "(", "Opcodes", ".", "DUP", ")", ";", "(", "(", "EObject", ")", "head", ")", ".", "emit_const", "(", "fa", ")", ";", "(", "(", "EObject", ")", "tail", ")", ".", "emit_const", "(", "fa", ")", ";", "fa", ".", "visitMethodInsn", "(", "Opcodes", ".", "INVOKESPECIAL", ",", "type", ".", "getInternalName", "(", ")", ",", "\"<init>\"", ",", "CONSTRUCTOR_DESC", ")", ";", "return", "type", ";", "}", "public", "static", "ESeq", "make", "(", "Object", "...", "messages", ")", "{", "ESeq", "result", "=", "ERT", ".", "NIL", ";", "for", "(", "int", "i", "=", "messages", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "result", "=", "result", ".", "cons", "(", "(", "EObject", ")", "messages", "[", "i", "]", ")", ";", "}", "return", "result", ";", "}", "public", "static", "ESeq", "make", "(", "int", "...", "messages", ")", "{", "ESeq", "result", "=", "ERT", ".", "NIL", ";", "for", "(", "int", "i", "=", "messages", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "result", "=", "result", ".", "cons", "(", "ERT", ".", "box", "(", "messages", "[", "i", "]", ")", ")", ";", "}", "return", "result", ";", "}", "public", "static", "EObject", "read", "(", "EInputStream", "buf", ")", "throws", "IOException", "{", "final", "int", "arity", "=", "buf", ".", "read_list_head", "(", ")", ";", "EObject", "[", "]", "elems", ";", "EObject", "tail", ";", "if", "(", "arity", ">", "0", ")", "{", "elems", "=", "new", "EObject", "[", "arity", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "arity", ";", "i", "++", ")", "{", "elems", "[", "i", "]", "=", "buf", ".", "read_any", "(", ")", ";", "}", "if", "(", "buf", ".", "peek1", "(", ")", "==", "EExternal", ".", "nilTag", ")", "{", "buf", ".", "read_nil", "(", ")", ";", "tail", "=", "ERT", ".", "NIL", ";", "}", "else", "{", "tail", "=", "buf", ".", "read_any", "(", ")", ";", "}", "EObject", "res", "=", "tail", ";", "for", "(", "int", "i", "=", "arity", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "res", "=", "res", ".", "cons", "(", "elems", "[", "i", "]", ")", ";", "}", "return", "res", ";", "}", "else", "{", "return", "ERT", ".", "NIL", ";", "}", "}", "@", "Override", "public", "void", "encode", "(", "EOutputStream", "eos", ")", "{", "int", "len", "=", "this", ".", "length", "(", ")", ";", "eos", ".", "write_list_head", "(", "len", ")", ";", "ESeq", "curr", "=", "this", ";", "while", "(", "!", "curr", ".", "isNil", "(", ")", ")", "{", "eos", ".", "write_any", "(", "curr", ".", "head", "(", ")", ")", ";", "curr", "=", "curr", ".", "tail", "(", ")", ";", "}", "eos", ".", "write_nil", "(", ")", ";", "}", "}", "</s>" ]
7,965
[ "<s>", "package", "erjang", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Field", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Method", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Modifier", ";", "public", "abstract", "class", "EModule", "{", "public", "EModule", "(", ")", "{", "this", "(", "false", ")", ";", "}", "public", "EModule", "(", "boolean", "delay_setup", ")", "{", "if", "(", "!", "delay_setup", ")", "setup", "(", ")", ";", "}", "protected", "void", "setup", "(", ")", "{", "EModuleManager", ".", "setup_module", "(", "this", ")", ";", "}", "public", "abstract", "String", "module_name", "(", ")", ";", "public", "ESeq", "attributes", "(", ")", "{", "return", "ERT", ".", "NIL", ";", "}", "public", "abstract", "void", "registerImportsAndExports", "(", ")", "throws", "Exception", ";", "public", "abstract", "ClassLoader", "getModuleClassLoader", "(", ")", ";", "protected", "void", "load_native_bifs", "(", ")", "throws", "Exception", "{", "Class", "<", "?", "extends", "ENative", ">", "natives", ";", "String", "nname", "=", "\"erjang.m.\"", "+", "module_name", "(", ")", "+", "\".Native\"", ";", "try", "{", "natives", "=", "(", "Class", "<", "?", "extends", "ENative", ">", ")", "Class", ".", "forName", "(", "nname", ",", "true", ",", "getModuleClassLoader", "(", ")", ")", ";", "}", "catch", "(", "ClassNotFoundException", "e", ")", "{", "return", ";", "}", "ENative", "en", ";", "try", "{", "en", "=", "natives", ".", "newInstance", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "Error", "(", "\"\"", "+", "module_name", "(", ")", ",", "e", ")", ";", "}", "for", "(", "Class", "nat", ":", "en", ".", "getNativeClasses", "(", ")", ")", "{", "process_native_annotations", "(", "nat", ")", ";", "}", "}", "protected", "void", "process_native_annotations", "(", "Class", "nat", ")", "throws", "Exception", "{", "for", "(", "Field", "field", ":", "nat", ".", "getDeclaredFields", "(", ")", ")", "{", "if", "(", "!", "Modifier", ".", "isStatic", "(", "field", ".", "getModifiers", "(", ")", ")", ")", "continue", ";", "Import", "imp", "=", "field", ".", "getAnnotation", "(", "Import", ".", "class", ")", ";", "if", "(", "imp", "!=", "null", ")", "{", "field", ".", "setAccessible", "(", "true", ")", ";", "FunID", "f", "=", "new", "FunID", "(", "imp", ")", ";", "EModuleManager", ".", "add_import", "(", "f", ",", "new", "FieldBinder", "(", "field", ",", "f", ",", "module_name", "(", ")", ")", ")", ";", "continue", ";", "}", "}", "Method", "[", "]", "methods", "=", "nat", ".", "getDeclaredMethods", "(", ")", ";", "next_method", ":", "for", "(", "Method", "method", ":", "methods", ")", "{", "BIF", "efun", "=", "method", ".", "getAnnotation", "(", "BIF", ".", "class", ")", ";", "if", "(", "efun", "!=", "null", "&&", "efun", ".", "type", "(", ")", ".", "export", "(", ")", ")", "{", "String", "mod", "=", "module_name", "(", ")", ";", "String", "name", "=", "efun", ".", "name", "(", ")", ";", "if", "(", "name", ".", "equals", "(", "\"__SELFNAME__\"", ")", ")", "name", "=", "method", ".", "getName", "(", ")", ";", "Class", "<", "?", ">", "[", "]", "parameterTypes", "=", "method", ".", "getParameterTypes", "(", ")", ";", "int", "arity", "=", "parameterTypes", ".", "length", ";", "if", "(", "arity", ">", "0", "&&", "parameterTypes", "[", "0", "]", ".", "equals", "(", "EProc", ".", "class", ")", ")", "{", "arity", "-=", "1", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "parameterTypes", ".", "length", ";", "i", "++", ")", "{", "if", "(", "i", "==", "0", "&&", "parameterTypes", "[", "i", "]", ".", "equals", "(", "EProc", ".", "class", ")", ")", "continue", ";", "if", "(", "parameterTypes", "[", "i", "]", ".", "equals", "(", "EObject", ".", "class", ")", ")", "continue", ";", "continue", "next_method", ";", "}", "FunID", "f", "=", "new", "FunID", "(", "mod", ",", "name", ",", "arity", ")", ";", "EModuleManager", ".", "add_export", "(", "this", ",", "f", ",", "EFun", ".", "make", "(", "method", ",", "mod", ")", ")", ";", "}", "}", "}", "public", "static", "class", "FieldBinder", "extends", "EModuleManager", ".", "FunctionBinder", "{", "final", "Field", "field", ";", "final", "FunID", "funID", ";", "final", "String", "mod", ";", "public", "FieldBinder", "(", "Field", "field", ",", "FunID", "funID", ",", "String", "mod", ")", "{", "this", ".", "field", "=", "field", ";", "field", ".", "setAccessible", "(", "true", ")", ";", "this", ".", "funID", "=", "funID", ";", "this", ".", "mod", "=", "mod", ";", "}", "@", "Override", "public", "FunID", "getFunID", "(", ")", "{", "return", "funID", ";", "}", "public", "void", "bind", "(", "EFun", "value", ")", "throws", "Exception", "{", "field", ".", "set", "(", "null", ",", "value", ")", ";", "}", "public", "String", "toString", "(", ")", "{", "return", "\"\"", "+", "funID", "+", "\"", "in", "\"", "+", "mod", "+", "\":", "\"", "+", "field", "+", "\">\"", ";", "}", "}", "}", "</s>" ]
7,966
[ "<s>", "package", "erjang", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "erjang", ".", "m", ".", "ets", ".", "EMatchContext", ";", "import", "erjang", ".", "m", ".", "ets", ".", "ETermPattern", ";", "public", "final", "class", "ERef", "extends", "EObject", "{", "private", "EAtom", "node", ";", "private", "int", "creation", ";", "private", "int", "[", "]", "ids", ";", "@", "Override", "public", "ERef", "testReference", "(", ")", "{", "return", "this", ";", "}", "public", "ERef", "(", "EAtom", "node", ",", "int", "[", "]", "ids", ",", "int", "creation", ")", "{", "this", ".", "node", "=", "node", ";", "this", ".", "creation", "=", "creation", "&", "0x03", ";", "int", "len", "=", "ids", ".", "length", ";", "this", ".", "ids", "=", "new", "int", "[", "3", "]", ";", "this", ".", "ids", "[", "0", "]", "=", "0", ";", "this", ".", "ids", "[", "1", "]", "=", "0", ";", "this", ".", "ids", "[", "2", "]", "=", "0", ";", "if", "(", "len", ">", "3", ")", "{", "len", "=", "3", ";", "}", "System", ".", "arraycopy", "(", "ids", ",", "0", ",", "this", ".", "ids", ",", "0", ",", "len", ")", ";", "this", ".", "ids", "[", "0", "]", "&=", "0x3ffff", ";", "}", "public", "ERef", "(", "EAtom", "node", ",", "int", "id1", ",", "int", "id2", ",", "int", "id3", ",", "int", "creation", ")", "{", "this", ".", "node", "=", "node", ";", "this", ".", "creation", "=", "creation", "&", "0x03", ";", "this", ".", "ids", "=", "new", "int", "[", "3", "]", ";", "this", ".", "ids", "[", "0", "]", "=", "id1", "&", "0x3ffff", ";", "this", ".", "ids", "[", "1", "]", "=", "id2", ";", "this", ".", "ids", "[", "2", "]", "=", "id3", ";", "}", "public", "ERef", "(", "EAtom", "node", ",", "int", "id", ",", "int", "creation", ")", "{", "this", ".", "node", "=", "node", ";", "ids", "=", "new", "int", "[", "1", "]", ";", "ids", "[", "0", "]", "=", "id", "&", "0x3ffff", ";", "this", ".", "creation", "=", "creation", "&", "0x03", ";", "}", "@", "Override", "public", "boolean", "match", "(", "ETermPattern", "matcher", ",", "EMatchContext", "r", ")", "{", "return", "matcher", ".", "match", "(", "this", ",", "r", ")", ";", "}", "@", "Override", "int", "compare_same", "(", "EObject", "rhs", ")", "{", "int", "val", "=", "compare_same2", "(", "rhs", ")", ";", "return", "val", ";", "}", "int", "compare_same2", "(", "EObject", "rhs", ")", "{", "ERef", "oref", "=", "(", "ERef", ")", "rhs", ";", "int", "cmp", "=", "node", ".", "compareTo", "(", "oref", ".", "node", ")", ";", "if", "(", "cmp", "!=", "0", ")", "return", "cmp", ";", "cmp", "=", "cmp", "(", "creation", ",", "oref", ".", "creation", ")", ";", "if", "(", "cmp", "!=", "0", ")", "return", "cmp", ";", "cmp", "=", "cmp", "(", "ids", ".", "length", ",", "oref", ".", "ids", ".", "length", ")", ";", "if", "(", "cmp", "!=", "0", ")", "return", "cmp", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "ids", ".", "length", ";", "i", "++", ")", "{", "cmp", "=", "cmp", "(", "ids", "[", "i", "]", ",", "oref", ".", "ids", "[", "i", "]", ")", ";", "if", "(", "cmp", "!=", "0", ")", "return", "cmp", ";", "}", "return", "0", ";", "}", "private", "static", "int", "cmp", "(", "int", "i1", ",", "int", "i2", ")", "{", "if", "(", "i1", "==", "i2", ")", "return", "0", ";", "if", "(", "i1", "<", "i2", ")", "return", "-", "1", ";", "return", "1", ";", "}", "@", "Override", "public", "boolean", "equals", "(", "Object", "rhs", ")", "{", "boolean", "val", "=", "equals2", "(", "rhs", ")", ";", "return", "val", ";", "}", "public", "boolean", "equals2", "(", "final", "Object", "o", ")", "{", "if", "(", "!", "(", "o", "instanceof", "ERef", ")", ")", "{", "return", "false", ";", "}", "final", "ERef", "ref", "=", "(", "ERef", ")", "o", ";", "if", "(", "(", "node", "!=", "ref", ".", "node", "(", ")", ")", "||", "creation", "!=", "ref", ".", "creation", "(", ")", ")", "{", "return", "false", ";", "}", "if", "(", "isNewRef", "(", ")", "&&", "ref", ".", "isNewRef", "(", ")", ")", "{", "return", "ids", "[", "0", "]", "==", "ref", ".", "ids", "[", "0", "]", "&&", "ids", "[", "1", "]", "==", "ref", ".", "ids", "[", "1", "]", "&&", "ids", "[", "2", "]", "==", "ref", ".", "ids", "[", "2", "]", ";", "}", "return", "ids", "[", "0", "]", "==", "ref", ".", "ids", "[", "0", "]", ";", "}", "@", "Override", "public", "int", "hashCode", "(", ")", "{", "int", "res", "=", "500000003", "*", "node", ".", "hashCode", "(", ")", "+", "1000000007", "*", "creation", "+", "1500000001", "*", "ids", "[", "0", "]", ";", "if", "(", "isNewRef", "(", ")", ")", "{", "res", "+=", "ids", "[", "1", "]", "*", "250000013", "+", "ids", "[", "2", "]", "*", "750000007", ";", "}", "return", "res", ";", "}", "@", "Override", "int", "cmp_order", "(", ")", "{", "return", "CMP_ORDER_REFERENCE", ";", "}", "public", "int", "id", "(", ")", "{", "return", "ids", "[", "0", "]", ";", "}", "public", "int", "[", "]", "ids", "(", ")", "{", "return", "ids", ";", "}", "public", "boolean", "isNewRef", "(", ")", "{", "return", "ids", ".", "length", ">", "1", ";", "}", "public", "int", "creation", "(", ")", "{", "return", "creation", ";", "}", "public", "EAtom", "node", "(", ")", "{", "return", "node", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "String", "s", "=", "\"#Ref<\"", "+", "node", "+", "\".\"", "+", "creation", "(", ")", ";", "for", "(", "int", "i", "=", "ids", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "s", "+=", "\".\"", "+", "ids", "[", "i", "]", ";", "}", "s", "+=", "\">\"", ";", "return", "s", ";", "}", "public", "int", "[", "]", "internal_ref_numbers", "(", ")", "{", "throw", "new", "NotImplemented", "(", ")", ";", "}", "public", "static", "ERef", "read", "(", "EInputStream", "ei", ")", "throws", "IOException", "{", "return", "ei", ".", "read_ref", "(", ")", ";", "}", "@", "Override", "public", "void", "encode", "(", "EOutputStream", "eos", ")", "{", "eos", ".", "write_ref", "(", "node", ".", "getName", "(", ")", ",", "ids", ",", "creation", ")", ";", "}", "}", "</s>" ]
7,967
[ "<s>", "package", "erjang", ";", "import", "java", ".", "nio", ".", "ByteBuffer", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "MethodVisitor", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "Opcodes", ";", "import", "org", ".", "objectweb", ".", "asm", ".", "Type", ";", "public", "class", "EBinList", "extends", "ECons", "{", "private", "static", "final", "int", "INITIAL_BUFFER_SIZE", "=", "10", ";", "final", "byte", "[", "]", "data", ";", "final", "int", "off", ";", "final", "int", "len", ";", "final", "EObject", "tail", ";", "private", "boolean", "shared", ";", "private", "EBinList", "(", "byte", "[", "]", "data", ",", "int", "off", ",", "int", "len", ",", "EObject", "tail", ",", "boolean", "shared", ")", "{", "assert", "len", "!=", "0", ";", "this", ".", "data", "=", "data", ";", "this", ".", "off", "=", "off", ";", "this", ".", "len", "=", "len", ";", "this", ".", "tail", "=", "tail", ";", "this", ".", "shared", "=", "shared", ";", "assert", "(", "tail", "!=", "null", ")", ";", "if", "(", "len", "<", "1", "||", "off", "+", "len", ">", "data", ".", "length", ")", "throw", "ERT", ".", "badarg", "(", ")", ";", "}", "@", "Override", "public", "int", "hashCode", "(", ")", "{", "ESeq", "seq", ";", "if", "(", "(", "seq", "=", "testSeq", "(", ")", ")", "!=", "null", ")", "return", "seq", ".", "hashCode", "(", ")", ";", "int", "h", "=", "0", ";", "for", "(", "int", "i", "=", "off", ";", "i", "<", "off", "+", "len", ";", "i", "++", ")", "{", "h", "=", "31", "*", "h", "+", "data", "[", "i", "]", ";", "}", "return", "h", "+", "tail", ".", "hashCode", "(", ")", ";", "}", "public", "EBinList", "(", "byte", "value", ",", "EObject", "tail", ")", "{", "this", ".", "data", "=", "new", "byte", "[", "INITIAL_BUFFER_SIZE", "]", ";", "this", ".", "off", "=", "INITIAL_BUFFER_SIZE", "-", "1", ";", "this", ".", "len", "=", "1", ";", "this", ".", "tail", "=", "tail", ";", "this", ".", "shared", "=", "false", ";", "data", "[", "off", "]", "=", "value", ";", "}", "public", "ECons", "testNonEmptyList", "(", ")", "{", "if", "(", "len", "==", "0", ")", "return", "tail", ".", "testNonEmptyList", "(", ")", ";", "return", "this", ";", "}", "public", "ESeq", "testSeq", "(", ")", "{", "if", "(", "tail", ".", "testSeq", "(", ")", "!=", "null", ")", "{", "return", "this", ".", "seq", "(", ")", ";", "}", "else", "{", "return", "null", ";", "}", "}", "public", "EBinList", "(", "byte", "[", "]", "header", ",", "EObject", "tail", ")", "{", "this", "(", "header", ",", "0", ",", "header", ".", "length", ",", "tail", ",", "true", ")", ";", "}", "public", "EBinList", "(", "ByteBuffer", "buf", ",", "EObject", "tail", ")", "{", "this", "(", "buf", ".", "array", "(", ")", ",", "buf", ".", "arrayOffset", "(", ")", "+", "buf", ".", "position", "(", ")", ",", "buf", ".", "remaining", "(", ")", ",", "tail", ",", "true", ")", ";", "}", "@", "Override", "public", "ECons", "cons", "(", "EObject", "h", ")", "{", "ESmall", "sm", ";", "if", "(", "(", "sm", "=", "h", ".", "testSmall", "(", ")", ")", "!=", "null", "&&", "sm", ".", "value", ">=", "0", "&&", "sm", ".", "value", "<", "256", ")", "{", "byte", "[", "]", "res_data", "=", "data", ";", "int", "res_off", "=", "off", ";", "int", "res_len", "=", "len", "+", "1", ";", "synchronized", "(", "this", ")", "{", "if", "(", "shared", "||", "off", "==", "0", ")", "{", "res_data", "=", "new", "byte", "[", "len", "*", "2", "+", "1", "]", ";", "System", ".", "arraycopy", "(", "data", ",", "off", ",", "res_data", ",", "len", "+", "1", ",", "len", ")", ";", "res_off", "=", "len", "+", "1", ";", "}", "else", "{", "shared", "=", "true", ";", "}", "}", "res_data", "[", "--", "res_off", "]", "=", "(", "byte", ")", "sm", ".", "value", ";", "return", "new", "EBinList", "(", "res_data", ",", "res_off", ",", "res_len", ",", "tail", ",", "res_data", "==", "data", ")", ";", "}", "else", "{", "return", "new", "EPair", "(", "h", ",", "this", ")", ";", "}", "}", "public", "EObject", "drop", "(", "int", "n", ")", "{", "if", "(", "n", ">", "len", ")", "throw", "new", "IllegalArgumentException", "(", ")", ";", "if", "(", "n", "==", "len", ")", "return", "tail", ";", "synchronized", "(", "this", ")", "{", "shared", "=", "true", ";", "}", "return", "new", "EBinList", "(", "data", ",", "off", "+", "n", ",", "len", "-", "n", ",", "tail", ",", "true", ")", ";", "}", "@", "Override", "public", "ESmall", "head", "(", ")", "{", "return", "ESmall", ".", "little", "[", "(", "data", "[", "off", "]", "&", "0xff", ")", "]", ";", "}", "@", "Override", "public", "EObject", "tail", "(", ")", "{", "if", "(", "len", "==", "1", ")", "return", "tail", ";", "return", "new", "EBinList", "(", "data", ",", "off", "+", "1", ",", "len", "-", "1", ",", "tail", ",", "true", ")", ";", "}", "@", "Override", "public", "boolean", "isNil", "(", ")", "{", "assert", "len", "!=", "0", ";", "return", "false", ";", "}", "@", "Override", "public", "ENil", "testNil", "(", ")", "{", "if", "(", "isNil", "(", ")", ")", "return", "ERT", ".", "NIL", ";", "return", "null", ";", "}", "public", "EString", "testString", "(", ")", "{", "EString", "st", "=", "tail", ".", "testString", "(", ")", ";", "if", "(", "st", "==", "null", ")", "{", "return", "null", ";", "}", "byte", "[", "]", "out_bin", "=", "new", "byte", "[", "len", "+", "st", ".", "length", "(", ")", "]", ";", "System", ".", "arraycopy", "(", "this", ".", "data", ",", "this", ".", "off", ",", "out_bin", ",", "0", ",", "this", ".", "len", ")", ";", "System", ".", "arraycopy", "(", "st", ".", "data", ",", "st", ".", "off", ",", "out_bin", ",", "len", ",", "st", ".", "length", "(", ")", ")", ";", "return", "new", "EString", "(", "out_bin", ",", "0", ")", ";", "}", "private", "ESeq", "seq", "(", ")", "{", "return", "new", "Seq", "(", ")", ";", "}", "private", "class", "Seq", "extends", "ESeq", "{", "@", "Override", "public", "ECons", "testNonEmptyList", "(", ")", "{", "return", "EBinList", ".", "this", ".", "testNonEmptyList", "(", ")", ";", "}", "@", "Override", "public", "ESeq", "cons", "(", "EObject", "h", ")", "{", "return", "EBinList", ".", "this", ".", "cons", "(", "h", ")", ".", "testSeq", "(", ")", ";", "}", "@", "Override", "public", "ESeq", "tail", "(", ")", "{", "return", "EBinList", ".", "this", ".", "tail", "(", ")", ".", "testSeq", "(", ")", ";", "}", "@", "Override", "public", "EObject", "head", "(", ")", "{", "return", "EBinList", ".", "this", ".", "head", "(", ")", ";", "}", "@", "Override", "public", "void", "encode", "(", "EOutputStream", "eos", ")", "{", "EBinList", ".", "this", ".", "encode", "(", "eos", ")", ";", "}", "}", "private", "boolean", "all_printable", "(", ")", "{", "byte", "val", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "len", ";", "i", "++", ")", "{", "val", "=", "data", "[", "off", "+", "i", "]", ";", "if", "(", "val", "<", "'", "'", "||", "val", ">=", "127", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "if", "(", "tail", ".", "isNil", "(", ")", "&&", "all_printable", "(", ")", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "\"\\\"\"", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "len", ";", "i", "++", ")", "{", "byte", "val", "=", "data", "[", "off", "+", "i", "]", ";", "sb", ".", "append", "(", "(", "char", ")", "val", ")", ";", "}", "sb", ".", "append", "(", "'\"'", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "\"[\"", ")", ";", "int", "max", "=", "Math", ".", "min", "(", "len", ",", "40", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "max", ";", "i", "++", ")", "{", "if", "(", "i", "!=", "0", ")", "{", "sb", ".", "append", "(", "\",\"", ")", ";", "}", "byte", "val", "=", "data", "[", "off", "+", "i", "]", ";", "if", "(", "val", ">", "'", "'", "&&", "val", "<", "127", ")", "{", "sb", ".", "append", "(", "'$'", ")", ";", "sb", ".", "append", "(", "(", "char", ")", "val", ")", ";", "}", "else", "{", "sb", ".", "append", "(", "val", "&", "0xFF", ")", ";", "}", "}", "if", "(", "max", "!=", "len", ")", "{", "sb", ".", "append", "(", "\"...\"", ")", ";", "}", "if", "(", "!", "tail", ".", "isNil", "(", ")", ")", "{", "sb", ".", "append", "(", "'|'", ")", ";", "sb", ".", "append", "(", "tail", ")", ";", "}", "sb", ".", "append", "(", "\"]\"", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}", "@", "Override", "public", "boolean", "collectIOList", "(", "List", "<", "ByteBuffer", ">", "out", ")", "{", "out", ".", "add", "(", "ByteBuffer", ".", "wrap", "(", "data", ",", "off", ",", "len", ")", ")", ";", "return", "tail", ".", "collectIOList", "(", "out", ")", ";", "}", "@", "Override", "public", "void", "collectCharList", "(", "CharCollector", "out", ")", "throws", "CharCollector", ".", "CollectingException", ",", "CharCollector", ".", "InvalidElementException", ",", "IOException", "{", "try", "{", "out", ".", "addBinary", "(", "data", ",", "off", ",", "len", ")", ";", "}", "catch", "(", "CharCollector", ".", "PartialDecodingException", "e", ")", "{", "throw", "new", "CharCollector", ".", "CollectingException", "(", "drop", "(", "e", ".", "inputPos", "-", "off", ")", ")", ";", "}", "if", "(", "tail", ".", "testNumber", "(", ")", "!=", "null", ")", "{", "throw", "new", "CharCollector", ".", "InvalidElementException", "(", ")", ";", "}", "else", "tail", ".", "collectCharList", "(", "out", ")", ";", "}", "@", "Override", "public", "void", "encode", "(", "EOutputStream", "eos", ")", "{", "eos", ".", "write_list_head", "(", "len", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "len", ";", "i", "++", ")", "{", "eos", ".", "write_int", "(", "data", "[", "off", "+", "i", "]", ")", ";", "}", "eos", ".", "write_any", "(", "tail", ")", ";", "}", "public", "static", "EBinList", "fromString", "(", "String", "c", ",", "EObject", "tail", ")", "{", "byte", "[", "]", "data", "=", "new", "byte", "[", "c", ".", "length", "(", ")", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "data", ".", "length", ";", "i", "++", ")", "{", "data", "[", "i", "]", "=", "(", "byte", ")", "c", ".", "charAt", "(", "i", ")", ";", "}", "return", "new", "EBinList", "(", "data", ",", "tail", ")", ";", "}", "private", "static", "final", "Type", "EBINLIST_TYPE", "=", "Type", ".", "getType", "(", "EBinList", ".", "class", ")", ";", "private", "static", "final", "Type", "STRING_TYPE", "=", "Type", ".", "getType", "(", "String", ".", "class", ")", ";", "private", "static", "final", "String", "EOBJECT_DESC", "=", "Type", ".", "getDescriptor", "(", "EObject", ".", "class", ")", ";", "@", "Override", "public", "Type", "emit_const", "(", "MethodVisitor", "fa", ")", "{", "Type", "type", "=", "EBINLIST_TYPE", ";", "char", "[", "]", "ch", "=", "new", "char", "[", "len", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "len", ";", "i", "++", ")", "{", "ch", "[", "i", "]", "=", "(", "char", ")", "(", "0xff", "&", "(", "int", ")", "data", "[", "off", "+", "i", "]", ")", ";", "}", "fa", ".", "visitLdcInsn", "(", "new", "String", "(", "ch", ")", ")", ";", "tail", ".", "emit_const", "(", "fa", ")", ";", "fa", ".", "visitMethodInsn", "(", "Opcodes", ".", "INVOKESTATIC", ",", "type", ".", "getInternalName", "(", ")", ",", "\"fromString\"", ",", "\"(\"", "+", "STRING_TYPE", ".", "getDescriptor", "(", ")", "+", "EOBJECT_DESC", "+", "\")\"", "+", "type", ".", "getDescriptor", "(", ")", ")", ";", "return", "type", ";", "}", "}", "</s>" ]
7,968
[ "<s>", "package", "erjang", ";", "@", "SuppressWarnings", "(", "\"serial\"", ")", "public", "class", "ErlangError", "extends", "ErlangException", "{", "private", "ESeq", "args", ";", "public", "EAtom", "getExClass", "(", ")", "{", "return", "am_error", ";", "}", "public", "ErlangError", "(", "Throwable", "cause", ")", "{", "super", "(", "cause", ")", ";", "}", "public", "ErlangError", "(", "EObject", "reason", ")", "{", "super", "(", "reason", ")", ";", "}", "public", "ErlangError", "(", "EObject", "reason", ",", "ESeq", "args", ")", "{", "super", "(", "reason", ")", ";", "this", ".", "args", "=", "args", ";", "}", "public", "ErlangError", "(", "EObject", "reason", ",", "EObject", "...", "args", ")", "{", "super", "(", "reason", ")", ";", "this", ".", "args", "=", "ESeq", ".", "fromArray", "(", "args", ")", ";", "}", "public", "ErlangError", "(", "EObject", "reason", ",", "Throwable", "cause", ",", "EObject", "...", "args", ")", "{", "super", "(", "reason", ",", "cause", ")", ";", "this", ".", "args", "=", "ESeq", ".", "fromArray", "(", "args", ")", ";", "}", "@", "Override", "public", "EObject", "reason", "(", ")", "{", "ETuple2", "val", "=", "new", "ETuple2", "(", "super", ".", "reason", "(", ")", ",", "getTrace", "(", ")", ")", ";", "return", "val", ";", "}", "public", "ESeq", "getTrace", "(", ")", "{", "ESeq", "trace", "=", "super", ".", "getTrace", "(", ")", ";", "if", "(", "args", "!=", "null", "&&", "!", "trace", ".", "isNil", "(", ")", ")", "{", "ETuple3", "first", "=", "ETuple3", ".", "cast", "(", "trace", ".", "head", "(", ")", ".", "testTuple", "(", ")", ")", ";", "ESeq", "res", "=", "trace", ".", "tail", "(", ")", ".", "testSeq", "(", ")", ";", "ETuple3", "fa", "=", "new", "ETuple3", "(", ")", ";", "fa", ".", "elem1", "=", "first", ".", "elem1", ";", "fa", ".", "elem2", "=", "first", ".", "elem2", ";", "fa", ".", "elem3", "=", "args", ";", "trace", "=", "res", ".", "cons", "(", "fa", ")", ";", "}", "return", "trace", ";", "}", "}", "</s>" ]
7,969
[ "<s>", "package", "org", ".", "agmip", ".", "translators", ".", "aquacrop", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "nio", ".", "charset", ".", "Charset", ";", "import", "java", ".", "nio", ".", "file", ".", "Files", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "junit", ".", "framework", ".", "Test", ";", "import", "junit", ".", "framework", ".", "TestCase", ";", "import", "junit", ".", "framework", ".", "TestSuite", ";", "import", "org", ".", "agmip", ".", "util", ".", "JSONAdapter", ";", "public", "class", "TranslationTest", "extends", "TestCase", "{", "private", "Map", "inputMap", ";", "public", "TranslationTest", "(", "String", "testName", ")", "{", "super", "(", "testName", ")", ";", "try", "{", "File", "f", "=", "new", "File", "(", "\"\"", ")", ";", "List", "<", "String", ">", "lines", "=", "Files", ".", "readAllLines", "(", "f", ".", "toPath", "(", ")", ",", "Charset", ".", "forName", "(", "\"UTF-8\"", ")", ")", ";", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "String", "line", ":", "lines", ")", "{", "sb", ".", "append", "(", "line", ")", ";", "}", "inputMap", "=", "JSONAdapter", ".", "fromJSON", "(", "sb", ".", "toString", "(", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "fail", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "}", "public", "static", "Test", "suite", "(", ")", "{", "return", "new", "TestSuite", "(", "TranslationTest", ".", "class", ")", ";", "}", "public", "void", "testWeatherTranslation", "(", ")", "{", "ClimateTranslatorOutput", "t", "=", "new", "ClimateTranslatorOutput", "(", ")", ";", "try", "{", "File", "tempFile", "=", "File", ".", "createTempFile", "(", "\"\"", ",", "\".cli\"", ")", ";", "t", ".", "writeFile", "(", "tempFile", ".", "getAbsolutePath", "(", ")", ",", "inputMap", ")", ";", "assertTrue", "(", "true", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "fail", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "}", "public", "void", "testSoilTranslation", "(", ")", "{", "SoilTranslatorOutput", "t", "=", "new", "SoilTranslatorOutput", "(", ")", ";", "try", "{", "File", "tempFile", "=", "File", ".", "createTempFile", "(", "\"\"", ",", "\".sol\"", ")", ";", "t", ".", "writeFile", "(", "tempFile", ".", "getAbsolutePath", "(", ")", ",", "inputMap", ")", ";", "assertTrue", "(", "true", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "fail", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "}", "public", "void", "testIrrigationTranslation", "(", ")", "{", "IrrigationTranslatorOutput", "t", "=", "new", "IrrigationTranslatorOutput", "(", ")", ";", "try", "{", "File", "tempFile", "=", "File", ".", "createTempFile", "(", "\"\"", ",", "\".irr\"", ")", ";", "t", ".", "writeFile", "(", "tempFile", ".", "getAbsolutePath", "(", ")", ",", "inputMap", ")", ";", "assertTrue", "(", "true", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "fail", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "}", "}", "</s>" ]
7,970
[ "<s>", "package", "org", ".", "agmip", ".", "translators", ".", "aquacrop", ".", "tools", ";", "import", "junit", ".", "framework", ".", "Assert", ";", "import", "org", ".", "junit", ".", "Before", ";", "import", "org", ".", "junit", ".", "Test", ";", "public", "class", "EToCalculatorTest", "{", "@", "Before", "public", "void", "setUp", "(", ")", "throws", "Exception", "{", "}", "@", "Test", "public", "void", "testCaseA", "(", ")", "{", "Assert", ".", "assertEquals", "(", "1.4", ",", "WeatherDataCalculator", ".", "calculateETReference", "(", "16", ",", "22.37", ",", "222", ",", "5.0", ",", "-", "5.0", ")", ",", "0.1", ")", ";", "Assert", ".", "assertEquals", "(", "1.5", ",", "WeatherDataCalculator", ".", "calculateETReference", "(", "47", ",", "22.37", ",", "222", ",", "7.0", ",", "0.0", ")", ",", "0.1", ")", ";", "Assert", ".", "assertEquals", "(", "2.3", ",", "WeatherDataCalculator", ".", "calculateETReference", "(", "75", ",", "22.37", ",", "222", ",", "12.0", ",", "2.0", ")", ",", "0.1", ")", ";", "Assert", ".", "assertEquals", "(", "2.8", ",", "WeatherDataCalculator", ".", "calculateETReference", "(", "106", ",", "22.37", ",", "222", ",", "15.0", ",", "5.0", ")", ",", "0.1", ")", ";", "Assert", ".", "assertEquals", "(", "3.5", ",", "WeatherDataCalculator", ".", "calculateETReference", "(", "136", ",", "22.37", ",", "222", ",", "19.0", ",", "8.0", ")", ",", "0.1", ")", ";", "Assert", ".", "assertEquals", "(", "4.8", ",", "WeatherDataCalculator", ".", "calculateETReference", "(", "167", ",", "22.37", ",", "222", ",", "25.0", ",", "10.0", ")", ",", "0.1", ")", ";", "Assert", ".", "assertEquals", "(", "5.4", ",", "WeatherDataCalculator", ".", "calculateETReference", "(", "197", ",", "22.37", ",", "222", ",", "30.0", ",", "15.0", ")", ",", "0.1", ")", ";", "Assert", ".", "assertEquals", "(", "6.2", ",", "WeatherDataCalculator", ".", "calculateETReference", "(", "228", ",", "22.37", ",", "222", ",", "35.0", ",", "18.0", ")", ",", "0.1", ")", ";", "Assert", ".", "assertEquals", "(", "4.6", ",", "WeatherDataCalculator", ".", "calculateETReference", "(", "259", ",", "22.37", ",", "222", ",", "28.0", ",", "13.0", ")", ",", "0.1", ")", ";", "Assert", ".", "assertEquals", "(", "1.3", ",", "WeatherDataCalculator", ".", "calculateETReference", "(", "289", ",", "22.37", ",", "222", ",", "13.0", ",", "10.0", ")", ",", "0.1", ")", ";", "Assert", ".", "assertEquals", "(", "0.8", ",", "WeatherDataCalculator", ".", "calculateETReference", "(", "320", ",", "22.37", ",", "222", ",", "7.0", ",", "5.0", ")", ",", "0.1", ")", ";", "Assert", ".", "assertEquals", "(", "0.7", ",", "WeatherDataCalculator", ".", "calculateETReference", "(", "350", ",", "22.37", ",", "222", ",", "3.0", ",", "0.0", ")", ",", "0.1", ")", ";", "}", "@", "Test", "public", "void", "testCaseB", "(", ")", "{", "Assert", ".", "assertEquals", "(", "8.0", ",", "WeatherDataCalculator", ".", "calculateETReference", "(", "15", ",", "-", "52.56", ",", "3500", ",", "40.0", ",", "20.0", ")", ",", "0.1", ")", ";", "Assert", ".", "assertEquals", "(", "6.5", ",", "WeatherDataCalculator", ".", "calculateETReference", "(", "46", ",", "-", "52.56", ",", "3500", ",", "38.0", ",", "18.0", ")", ",", "0.1", ")", ";", "Assert", ".", "assertEquals", "(", "4.5", ",", "WeatherDataCalculator", ".", "calculateETReference", "(", "74", ",", "-", "52.56", ",", "3500", ",", "35.0", ",", "16.0", ")", ",", "0.1", ")", ";", "Assert", ".", "assertEquals", "(", "2.4", ",", "WeatherDataCalculator", ".", "calculateETReference", "(", "105", ",", "-", "52.56", ",", "3500", ",", "30.0", ",", "14.0", ")", ",", "0.1", ")", ";", "Assert", ".", "assertEquals", "(", "0.8", ",", "WeatherDataCalculator", ".", "calculateETReference", "(", "135", ",", "-", "52.56", ",", "3500", ",", "20.0", ",", "12.0", ")", ",", "0.1", ")", ";", "Assert", ".", "assertEquals", "(", "0.4", ",", "WeatherDataCalculator", ".", "calculateETReference", "(", "166", ",", "-", "52.56", ",", "3500", ",", "15.0", ",", "10.0", ")", ",", "0.1", ")", ";", "Assert", ".", "assertEquals", "(", "0.4", ",", "WeatherDataCalculator", ".", "calculateETReference", "(", "196", ",", "-", "52.56", ",", "3500", ",", "12.0", ",", "8.0", ")", ",", "0.1", ")", ";", "Assert", ".", "assertEquals", "(", "1.0", ",", "WeatherDataCalculator", ".", "calculateETReference", "(", "227", ",", "-", "52.56", ",", "3500", ",", "17.0", ",", "10.0", ")", ",", "0.1", ")", ";", "Assert", ".", "assertEquals", "(", "1.9", ",", "WeatherDataCalculator", ".", "calculateETReference", "(", "258", ",", "-", "52.56", ",", "3500", ",", "20.0", ",", "12.0", ")", ",", "0.1", ")", ";", "Assert", ".", "assertEquals", "(", "3.6", ",", "WeatherDataCalculator", ".", "calculateETReference", "(", "288", ",", "-", "52.56", ",", "3500", ",", "25.0", ",", "14.0", ")", ",", "0.1", ")", ";", "Assert", ".", "assertEquals", "(", "5.6", ",", "WeatherDataCalculator", ".", "calculateETReference", "(", "319", ",", "-", "52.56", ",", "3500", ",", "30.0", ",", "16.0", ")", ",", "0.1", ")", ";", "Assert", ".", "assertEquals", "(", "7.2", ",", "WeatherDataCalculator", ".", "calculateETReference", "(", "349", ",", "-", "52.56", ",", "3500", ",", "35.0", ",", "18.0", ")", ",", "0.1", ")", ";", "}", "}", "</s>" ]
7,971
[ "<s>", "package", "org", ".", "agmip", ".", "translators", ".", "aquacrop", ".", "tools", ";", "import", "junit", ".", "framework", ".", "Assert", ";", "import", "org", ".", "junit", ".", "Before", ";", "import", "org", ".", "junit", ".", "Test", ";", "public", "class", "DayNumbersTest", "{", "@", "Before", "public", "void", "setUp", "(", ")", "throws", "Exception", "{", "}", "@", "Test", "public", "void", "testDayNumberCalculations", "(", ")", "{", "Assert", ".", "assertEquals", "(", "1", ",", "DayNumbers", ".", "calculateDayNumber", "(", "1", ",", "1", ",", "1901", ",", "true", ")", ")", ";", "Assert", ".", "assertEquals", "(", "31", ",", "DayNumbers", ".", "calculateDayNumber", "(", "31", ",", "1", ",", "1901", ",", "true", ")", ")", ";", "Assert", ".", "assertEquals", "(", "365", ",", "DayNumbers", ".", "calculateDayNumber", "(", "31", ",", "12", ",", "1901", ",", "true", ")", ")", ";", "Assert", ".", "assertEquals", "(", "366", ",", "DayNumbers", ".", "calculateDayNumber", "(", "1", ",", "1", ",", "1902", ",", "true", ")", ")", ";", "}", "@", "Test", "(", "expected", "=", "IllegalArgumentException", ".", "class", ")", "public", "void", "testYearOutOfRange", "(", ")", "{", "DayNumbers", ".", "calculateDayNumber", "(", "1", ",", "1", ",", "1900", ",", "true", ")", ";", "}", "@", "Test", "(", "expected", "=", "IllegalArgumentException", ".", "class", ")", "public", "void", "testDayOutOfRange", "(", ")", "{", "DayNumbers", ".", "calculateDayNumber", "(", "0", ",", "1", ",", "1901", ",", "true", ")", ";", "}", "@", "Test", "(", "expected", "=", "IllegalArgumentException", ".", "class", ")", "public", "void", "testInvalidDayInMonth", "(", ")", "{", "DayNumbers", ".", "calculateDayNumber", "(", "29", ",", "2", ",", "1901", ",", "true", ")", ";", "}", "@", "Test", "(", "expected", "=", "IllegalArgumentException", ".", "class", ")", "public", "void", "testMonthOutOfRange", "(", ")", "{", "DayNumbers", ".", "calculateDayNumber", "(", "1", ",", "0", ",", "1901", ",", "true", ")", ";", "}", "}", "</s>" ]
7,972
[ "<s>", "package", "org", ".", "agmip", ".", "translators", ".", "aquacrop", ".", "tools", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "agmip", ".", "util", ".", "MapUtil", ";", "@", "SuppressWarnings", "(", "{", "\"rawtypes\"", ",", "\"unchecked\"", "}", ")", "public", "class", "MapHelper", "{", "public", "static", "boolean", "hasValueFor", "(", "Map", "data", ",", "String", "...", "keys", ")", "{", "for", "(", "String", "key", ":", "keys", ")", "{", "if", "(", "!", "\"\"", ".", "equals", "(", "MapUtil", ".", "getValueOr", "(", "data", ",", "key", ",", "\"\"", ")", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}", "public", "static", "String", "getValueOrNullFor", "(", "Map", "data", ",", "String", "...", "keys", ")", "{", "return", "getValueFor", "(", "data", ",", "null", ",", "keys", ")", ";", "}", "public", "static", "String", "getValueFor", "(", "Map", "data", ",", "String", "orValue", ",", "String", "...", "keys", ")", "{", "String", "val", ";", "for", "(", "String", "key", ":", "keys", ")", "{", "val", "=", "MapUtil", ".", "getValueOr", "(", "data", ",", "key", ",", "\"\"", ")", ";", "if", "(", "!", "\"\"", ".", "equals", "(", "val", ")", ")", "{", "return", "val", ";", "}", "}", "return", "orValue", ";", "}", "}", "</s>" ]
7,973
[ "<s>", "package", "org", ".", "agmip", ".", "translators", ".", "aquacrop", ".", "tools", ";", "public", "class", "AgMIP", "{", "public", "final", "static", "String", "WEATHER_BUCKET_NAME", "=", "\"weather\"", ";", "public", "final", "static", "String", "SOIL_BUCKET_NAME", "=", "\"soil\"", ";", "public", "final", "static", "String", "MANAGEMENT_BUCKET_NAME", "=", "\"management\"", ";", "public", "final", "static", "String", "MANAGEMENT_EVENT_PLANT", "=", "\"planting\"", ";", "public", "final", "static", "String", "MANAGEMENT_EVENT_IRRIGATE", "=", "\"irrigation\"", ";", "public", "final", "static", "String", "MANAGEMENT_EVENT_FERTILIZE", "=", "\"fertilizer\"", ";", "public", "final", "static", "String", "MANAGEMENT_EVENT_ORGANIC", "=", "\"\"", ";", "public", "final", "static", "String", "MANAGEMENT_EVENT_CHEMICAL", "=", "\"chemical\"", ";", "public", "final", "static", "String", "MANAGEMENT_EVENT_HARVEST", "=", "\"harvest\"", ";", "public", "final", "static", "String", "MANAGEMENT_EVENT_TILLAGE", "=", "\"tillage\"", ";", "}", "</s>" ]
7,974
[ "<s>", "package", "org", ".", "agmip", ".", "translators", ".", "aquacrop", ".", "tools", ";", "import", "java", ".", "util", ".", "Calendar", ";", "import", "java", ".", "util", ".", "GregorianCalendar", ";", "public", "class", "DayNumbers", "{", "private", "static", "final", "double", "ELAPSED_DAYS", "[", "]", "=", "{", "0.0", ",", "31.0", ",", "59.25", ",", "90.25", ",", "120.25", ",", "151.25", ",", "181.25", ",", "212.25", ",", "243.25", ",", "273.25", ",", "304.25", ",", "334.25", "}", ";", "private", "static", "final", "Calendar", "_calendar", "=", "new", "GregorianCalendar", "(", ")", ";", "public", "static", "int", "[", "]", "decodeDateString", "(", "String", "dateString", ")", "{", "int", "dayMonthYear", "[", "]", "=", "new", "int", "[", "]", "{", "1", ",", "1", ",", "1901", "}", ";", "dayMonthYear", "[", "2", "]", "=", "Integer", ".", "valueOf", "(", "dateString", ".", "substring", "(", "0", ",", "4", ")", ")", ";", "dayMonthYear", "[", "1", "]", "=", "Integer", ".", "valueOf", "(", "dateString", ".", "substring", "(", "4", ",", "6", ")", ")", ";", "dayMonthYear", "[", "0", "]", "=", "Integer", ".", "valueOf", "(", "dateString", ".", "substring", "(", "6", ",", "8", ")", ")", ";", "return", "dayMonthYear", ";", "}", "public", "static", "int", "calculateDayInYear", "(", "String", "dateString", ",", "boolean", "checked", ")", "{", "int", "[", "]", "dmy", "=", "decodeDateString", "(", "dateString", ")", ";", "return", "calculateDayInYear", "(", "dmy", "[", "0", "]", ",", "dmy", "[", "1", "]", ",", "dmy", "[", "2", "]", ",", "checked", ")", ";", "}", "public", "static", "int", "calculateDayInYear", "(", "int", "day", ",", "int", "month", ",", "int", "year", ",", "boolean", "checked", ")", "{", "if", "(", "checked", ")", "{", "checkDayNumberInput", "(", "day", ",", "month", ",", "year", ")", ";", "}", "_calendar", ".", "set", "(", "Calendar", ".", "YEAR", ",", "year", ")", ";", "_calendar", ".", "set", "(", "Calendar", ".", "MONTH", ",", "month", "-", "1", ")", ";", "_calendar", ".", "set", "(", "Calendar", ".", "DAY_OF_MONTH", ",", "day", ")", ";", "return", "_calendar", ".", "get", "(", "Calendar", ".", "DAY_OF_YEAR", ")", ";", "}", "public", "static", "long", "calculateDayNumber", "(", "String", "dateString", ",", "boolean", "checked", ")", "{", "int", "[", "]", "dmy", "=", "decodeDateString", "(", "dateString", ")", ";", "return", "calculateDayNumber", "(", "dmy", "[", "0", "]", ",", "dmy", "[", "1", "]", ",", "dmy", "[", "2", "]", ",", "checked", ")", ";", "}", "public", "static", "long", "calculateDayNumber", "(", "int", "day", ",", "int", "month", ",", "int", "year", ",", "boolean", "checked", ")", "{", "if", "(", "checked", ")", "{", "checkDayNumberInput", "(", "day", ",", "month", ",", "year", ")", ";", "}", "return", "(", "long", ")", "(", "(", "year", "-", "1901", ")", "*", "365.25", "+", "ELAPSED_DAYS", "[", "month", "-", "1", "]", "+", "day", "+", "0.05", ")", ";", "}", "public", "static", "void", "checkDayNumberInput", "(", "int", "day", ",", "int", "month", ",", "int", "year", ")", "{", "if", "(", "(", "year", "<", "1901", ")", "||", "(", "year", ">", "2099", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"\"", ")", ";", "}", "if", "(", "(", "month", "<", "1", ")", "||", "(", "month", ">", "12", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"\"", ")", ";", "}", "_calendar", ".", "set", "(", "Calendar", ".", "YEAR", ",", "year", ")", ";", "_calendar", ".", "set", "(", "Calendar", ".", "MONTH", ",", "month", "-", "1", ")", ";", "int", "days", "=", "_calendar", ".", "getActualMaximum", "(", "Calendar", ".", "DAY_OF_MONTH", ")", ";", "if", "(", "(", "day", "<", "1", ")", "||", "(", "day", ">", "days", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"\"", ")", ";", "}", "}", "}", "</s>" ]
7,975
[ "<s>", "package", "org", ".", "agmip", ".", "translators", ".", "aquacrop", ".", "tools", ";", "public", "class", "IrrigationDataCalculator", "{", "}", "</s>" ]
7,976
[ "<s>", "package", "org", ".", "agmip", ".", "translators", ".", "aquacrop", ".", "tools", ";", "import", "java", ".", "util", ".", "LinkedHashMap", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "agmip", ".", "translators", ".", "aquacrop", ".", "domain", ".", "SoilHorizon", ";", "public", "class", "SoilDataCalculator", "{", "private", "final", "static", "double", "SURFACE_LAYER_Z", "=", "0.04", ";", "private", "Map", "<", "String", ",", "SoilLookupEntry", ">", "lookup", "=", "new", "LinkedHashMap", "<", "String", ",", "SoilLookupEntry", ">", "(", ")", ";", "protected", "class", "SoilLookupEntry", "{", "String", "name", ";", "double", "satVolPro", ";", "double", "fcVolPro", ";", "double", "pwpVolPro", ";", "double", "kSatMM", ";", "public", "SoilLookupEntry", "(", "String", "name", ",", "double", "sat", ",", "double", "fc", ",", "double", "pwp", ",", "double", "ksat", ")", "{", "this", ".", "name", "=", "name", ";", "satVolPro", "=", "sat", ";", "fcVolPro", "=", "fc", ";", "pwpVolPro", "=", "pwp", ";", "kSatMM", "=", "ksat", ";", "}", "}", "public", "SoilDataCalculator", "(", ")", "{", "lookup", ".", "put", "(", "\"\"", ",", "new", "SoilLookupEntry", "(", "\"Sand\"", ",", "36.0", ",", "13.0", ",", "6.0", ",", "1500.0", ")", ")", ";", "lookup", ".", "put", "(", "\"\"", ",", "new", "SoilLookupEntry", "(", "\"Loamy", "sand\"", ",", "38.0", ",", "16.0", ",", "8.0", ",", "800.0", ")", ")", ";", "lookup", ".", "put", "(", "\"\"", ",", "new", "SoilLookupEntry", "(", "\"Sandy", "loam\"", ",", "41.0", ",", "22.0", ",", "10.0", ",", "500.0", ")", ")", ";", "lookup", ".", "put", "(", "\"FLO,LO\"", ",", "new", "SoilLookupEntry", "(", "\"Loam\"", ",", "46.0", ",", "31.0", ",", "15.0", ",", "250.0", ")", ")", ";", "lookup", ".", "put", "(", "\"SILO\"", ",", "new", "SoilLookupEntry", "(", "\"Silt", "loam\"", ",", "46.0", ",", "33.0", ",", "13.0", ",", "150.0", ")", ")", ";", "lookup", ".", "put", "(", "\"CSI,SI\"", ",", "new", "SoilLookupEntry", "(", "\"Silt\"", ",", "43.0", ",", "33.0", ",", "9.0", ",", "50.0", ")", ")", ";", "lookup", ".", "put", "(", "\"SACLL\"", ",", "new", "SoilLookupEntry", "(", "\"\"", ",", "47.0", ",", "32.0", ",", "20.0", ",", "125.0", ")", ")", ";", "lookup", ".", "put", "(", "\"CLLO\"", ",", "new", "SoilLookupEntry", "(", "\"Clay", "loam\"", ",", "50.0", ",", "39.0", ",", "23.0", ",", "100.0", ")", ")", ";", "lookup", ".", "put", "(", "\"SICLL\"", ",", "new", "SoilLookupEntry", "(", "\"\"", ",", "52.0", ",", "44.0", ",", "23.0", ",", "120.0", ")", ")", ";", "lookup", ".", "put", "(", "\"SACL\"", ",", "new", "SoilLookupEntry", "(", "\"Sandy", "clay\"", ",", "50.0", ",", "39.0", ",", "27.0", ",", "75.0", ")", ")", ";", "lookup", ".", "put", "(", "\"SICL\"", ",", "new", "SoilLookupEntry", "(", "\"Silty", "clay\"", ",", "54.0", ",", "50.0", ",", "32.0", ",", "15.0", ")", ")", ";", "lookup", ".", "put", "(", "\"CL\"", ",", "new", "SoilLookupEntry", "(", "\"Clay\"", ",", "55.0", ",", "54.0", ",", "39.0", ",", "2.0", ")", ")", ";", "}", "public", "void", "initSWCFromAgMIPCode", "(", "SoilHorizon", "horizon", ",", "String", "sltxCode", ")", "{", "if", "(", "(", "horizon", "==", "null", ")", "||", "(", "sltxCode", "==", "null", ")", ")", "{", "return", ";", "}", "for", "(", "String", "key", ":", "lookup", ".", "keySet", "(", ")", ")", "{", "for", "(", "String", "code", ":", "key", ".", "split", "(", "\",\"", ")", ")", "{", "if", "(", "code", ".", "equalsIgnoreCase", "(", "sltxCode", ")", ")", "{", "SoilLookupEntry", "entry", "=", "lookup", ".", "get", "(", "key", ")", ";", "horizon", ".", "setDescription", "(", "entry", ".", "name", ")", ";", "horizon", ".", "setSoilWaterContentAtFieldCapacity", "(", "entry", ".", "fcVolPro", ")", ";", "horizon", ".", "setSoilWaterContentAtPermanentWiltingPoint", "(", "entry", ".", "pwpVolPro", ")", ";", "horizon", ".", "setSoilWaterContentAtSaturation", "(", "entry", ".", "satVolPro", ")", ";", "return", ";", "}", "}", "}", "}", "public", "void", "initKSatFromAgMIPCode", "(", "SoilHorizon", "horizon", ",", "String", "sltxCode", ")", "{", "if", "(", "(", "horizon", "==", "null", ")", "||", "(", "sltxCode", "==", "null", ")", ")", "{", "return", ";", "}", "for", "(", "String", "key", ":", "lookup", ".", "keySet", "(", ")", ")", "{", "for", "(", "String", "code", ":", "key", ".", "split", "(", "\",\"", ")", ")", "{", "if", "(", "code", ".", "equalsIgnoreCase", "(", "sltxCode", ")", ")", "{", "SoilLookupEntry", "entry", "=", "lookup", ".", "get", "(", "key", ")", ";", "horizon", ".", "setDescription", "(", "entry", ".", "name", ")", ";", "horizon", ".", "setSaturatedHydrolicConductivity", "(", "entry", ".", "kSatMM", ")", ";", "return", ";", "}", "}", "}", "}", "public", "static", "int", "calculateSoilClass", "(", "double", "satVolPro", ",", "double", "pwpVolPro", ",", "double", "fcVolPro", ",", "double", "kSatMM", ")", "{", "if", "(", "satVolPro", "<=", "55.0", ")", "{", "if", "(", "pwpVolPro", ">=", "20.0", ")", "{", "if", "(", "(", "satVolPro", ">=", "49.0", ")", "&&", "(", "fcVolPro", ">=", "40.0", ")", ")", "{", "return", "4", ";", "}", "else", "{", "return", "3", ";", "}", "}", "else", "{", "if", "(", "fcVolPro", "<", "23.0", ")", "{", "return", "1", ";", "}", "else", "{", "if", "(", "(", "pwpVolPro", ">", "16.0", ")", "&&", "(", "kSatMM", "<", "100", ")", ")", "{", "return", "3", ";", "}", "else", "{", "if", "(", "(", "pwpVolPro", "<", "6.0", ")", "&&", "(", "fcVolPro", "<", "28.0", ")", "&&", "(", "kSatMM", ">", "750", ")", ")", "{", "return", "1", ";", "}", "else", "{", "return", "2", ";", "}", "}", "}", "}", "}", "return", "4", ";", "}", "public", "static", "String", "soilClassDescription", "(", "int", "soilClass", ")", "{", "switch", "(", "soilClass", ")", "{", "case", "1", ":", "return", "\"sandy\"", ";", "case", "2", ":", "return", "\"loamy\"", ";", "case", "3", ":", "return", "\"sandy", "clayey\"", ";", "case", "4", ":", "return", "\"silty", "clayey\"", ";", "default", ":", "return", "\"unknown\"", ";", "}", "}", "public", "static", "double", "calculateCapillaryRiseEstimationParameterA", "(", "int", "soilClass", ",", "double", "kSatMM", ")", "{", "switch", "(", "soilClass", ")", "{", "case", "1", ":", "return", "-", "0.3112", "-", "kSatMM", "/", "100000", ";", "case", "2", ":", "return", "-", "0.4986", "-", "9", "*", "kSatMM", "/", "100000", ";", "case", "3", ":", "return", "-", "0.5677", "-", "4", "*", "kSatMM", "/", "100000", ";", "default", ":", "return", "-", "0.6366", "+", "8", "*", "kSatMM", "/", "10000", ";", "}", "}", "public", "static", "double", "calculateCapillaryRiseEstimationParameterB", "(", "int", "soilClass", ",", "double", "kSatMM", ")", "{", "switch", "(", "soilClass", ")", "{", "case", "1", ":", "return", "-", "1.4936", "+", "0.2416", "*", "Math", ".", "log", "(", "kSatMM", ")", ";", "case", "2", ":", "return", "-", "2.1320", "+", "0.4778", "*", "Math", ".", "log", "(", "kSatMM", ")", ";", "case", "3", ":", "return", "-", "3.7189", "+", "0.5922", "*", "Math", ".", "log", "(", "kSatMM", ")", ";", "default", ":", "return", "-", "1.9165", "+", "0.7063", "*", "Math", ".", "log", "(", "kSatMM", ")", ";", "}", "}", "public", "static", "int", "calculateCurveNumber", "(", "double", "kSatMMOfTopSoilHorizon", ")", "{", "if", "(", "kSatMMOfTopSoilHorizon", ">=", "250.0", ")", "{", "return", "65", ";", "}", "else", "if", "(", "kSatMMOfTopSoilHorizon", ">=", "50.0", ")", "{", "return", "75", ";", "}", "else", "if", "(", "kSatMMOfTopSoilHorizon", ">=", "10.0", ")", "{", "return", "80", ";", "}", "else", "{", "return", "85", ";", "}", "}", "public", "static", "double", "calculateReadilyEvaporableWater", "(", "double", "fcVolPro", ",", "double", "pwpVolPro", ")", "{", "double", "rew", "=", "Math", ".", "round", "(", "10", "*", "(", "fcVolPro", "-", "(", "pwpVolPro", "/", "2", ")", ")", "*", "SURFACE_LAYER_Z", ")", ";", "if", "(", "rew", "<", "0.0", ")", "{", "rew", "=", "0.0", ";", "}", "if", "(", "rew", ">", "15.0", ")", "{", "rew", "=", "15.0", ";", "}", "return", "rew", ";", "}", "}", "</s>" ]
7,977
[ "<s>", "package", "org", ".", "agmip", ".", "translators", ".", "aquacrop", ".", "tools", ";", "public", "class", "WeatherDataCalculator", "{", "public", "static", "double", "calculateETReference", "(", "int", "day", ",", "double", "latDeg", ",", "double", "altitudeZ", ",", "double", "tMax", ",", "double", "tMin", ")", "{", "double", "pAtm", "=", "Math", ".", "exp", "(", "Math", ".", "log", "(", "101.3", ")", "+", "5.26", "*", "Math", ".", "log", "(", "(", "293", "-", "0.0065", "*", "altitudeZ", ")", "/", "293", ")", ")", ";", "double", "psyConst", "=", "pAtm", "*", "0.664742", "/", "1000", ";", "double", "tMean", "=", "(", "tMax", "+", "tMin", ")", "/", "2", ";", "double", "delta", "=", "4098", "*", "(", "0.6108", "*", "Math", ".", "exp", "(", "(", "17.27", "*", "tMean", ")", "/", "(", "tMean", "+", "237.3", ")", ")", ")", "/", "(", "(", "tMean", "+", "237.3", ")", "*", "(", "tMean", "+", "237.3", ")", ")", ";", "double", "esTx", "=", "0.6108", "*", "Math", ".", "exp", "(", "(", "17.27", "*", "tMax", ")", "/", "(", "tMax", "+", "237.3", ")", ")", ";", "double", "esTn", "=", "0.6108", "*", "Math", ".", "exp", "(", "(", "17.27", "*", "tMin", ")", "/", "(", "tMin", "+", "237.3", ")", ")", ";", "double", "es", "=", "(", "esTx", "+", "esTn", ")", "/", "2", ";", "double", "ea", "=", "esTn", ";", "double", "u2", "=", "2.0", ";", "double", "ra", "=", "calculateExtraTerrestrialRadiation", "(", "day", ",", "latDeg", ")", ";", "double", "rSo", "=", "(", "0.75", "+", "altitudeZ", "*", "2.0", "/", "100000.0", ")", "*", "ra", ";", "double", "rs", "=", "0.16", "*", "Math", ".", "sqrt", "(", "tMax", "-", "tMin", ")", "*", "ra", ";", "double", "sbVal", "=", "(", "4.903", "/", "1000000000", ")", "*", "(", "Math", ".", "exp", "(", "4", "*", "Math", ".", "log", "(", "tMax", "+", "273.16", ")", ")", "+", "Math", ".", "exp", "(", "4", "*", "Math", ".", "log", "(", "tMin", "+", "273.16", ")", ")", ")", "/", "2", ";", "double", "rNl", "=", "sbVal", "*", "(", "0.34", "-", "0.14", "*", "Math", ".", "sqrt", "(", "ea", ")", ")", "*", "(", "1.35", "*", "(", "rs", "/", "rSo", ")", "-", "0.35", ")", ";", "double", "rN", "=", "(", "1", "-", "0.23", ")", "*", "rs", "-", "rNl", ";", "double", "etRef", "=", "(", "0.408", "*", "delta", "*", "rN", "+", "psyConst", "*", "(", "900", "/", "(", "tMean", "+", "273", ")", ")", "*", "u2", "*", "(", "es", "-", "ea", ")", ")", "/", "(", "delta", "+", "psyConst", "*", "(", "1", "+", "0.34", "*", "u2", ")", ")", ";", "return", "etRef", ";", "}", "public", "static", "double", "calculateExtraTerrestrialRadiation", "(", "int", "day", ",", "double", "latDeg", ")", "{", "double", "latRad", "=", "Math", ".", "PI", "*", "latDeg", "/", "180", ";", "double", "dr", "=", "1", "+", "0.033", "*", "Math", ".", "cos", "(", "day", "*", "2", "*", "Math", ".", "PI", "/", "365", ")", ";", "double", "delta", "=", "0.409", "*", "Math", ".", "sin", "(", "day", "*", "2", "*", "Math", ".", "PI", "/", "365", "-", "1.39", ")", ";", "double", "tanTan", "=", "-", "Math", ".", "tan", "(", "latRad", ")", "*", "Math", ".", "tan", "(", "delta", ")", ";", "double", "omegaS", ";", "if", "(", "tanTan", ">", "1.0", ")", "{", "omegaS", "=", "0.0", ";", "}", "else", "if", "(", "tanTan", "<", "-", "1.0", ")", "{", "omegaS", "=", "Math", ".", "PI", ";", "}", "else", "{", "omegaS", "=", "Math", ".", "acos", "(", "tanTan", ")", ";", "}", "double", "ra", "=", "(", "24", "*", "60", "/", "Math", ".", "PI", ")", "*", "0.0820", "*", "dr", "*", "(", "omegaS", "*", "Math", ".", "sin", "(", "latRad", ")", "*", "Math", ".", "sin", "(", "delta", ")", "+", "Math", ".", "cos", "(", "latRad", ")", "*", "Math", ".", "cos", "(", "delta", ")", "*", "Math", ".", "sin", "(", "omegaS", ")", ")", ";", "return", "ra", ";", "}", "}", "</s>" ]
7,978
[ "<s>", "package", "org", ".", "agmip", ".", "translators", ".", "aquacrop", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "agmip", ".", "core", ".", "types", ".", "TranslatorOutput", ";", "import", "org", ".", "agmip", ".", "translators", ".", "aquacrop", ".", "domain", ".", "Soil", ";", "import", "org", ".", "apache", ".", "velocity", ".", "Template", ";", "import", "org", ".", "apache", ".", "velocity", ".", "VelocityContext", ";", "import", "org", ".", "apache", ".", "velocity", ".", "app", ".", "Velocity", ";", "public", "class", "SoilTranslatorOutput", "extends", "BaseTranslatorOutput", "implements", "TranslatorOutput", "{", "public", "void", "writeFile", "(", "String", "file", ",", "Map", "data", ")", "{", "Velocity", ".", "init", "(", ")", ";", "VelocityContext", "vc", "=", "new", "VelocityContext", "(", ")", ";", "Soil", "soil", "=", "Soil", ".", "create", "(", "data", ")", ";", "assert", "(", "soil", ".", "getHorizons", "(", ")", ".", "size", "(", ")", ">", "0", ")", ";", "vc", ".", "put", "(", "\"format\"", ",", "new", "AquaCropFormatter", "(", ")", ")", ";", "vc", ".", "put", "(", "\"\"", ",", "AQUACROP_VERSION", ")", ";", "vc", ".", "put", "(", "\"soil\"", ",", "soil", ")", ";", "Template", "t", "=", "Velocity", ".", "getTemplate", "(", "\"\"", ",", "\"UTF-8\"", ")", ";", "int", "pos", "=", "file", ".", "lastIndexOf", "(", "\".\"", ")", ";", "String", "outFile", "=", "file", ".", "substring", "(", "0", ",", "pos", ")", "+", "\".sol\"", ";", "writeFile", "(", "vc", ",", "t", ",", "outFile", ")", ";", "}", "}", "</s>" ]
7,979
[ "<s>", "package", "org", ".", "agmip", ".", "translators", ".", "aquacrop", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "agmip", ".", "core", ".", "types", ".", "TranslatorOutput", ";", "import", "org", ".", "agmip", ".", "translators", ".", "aquacrop", ".", "BaseTranslatorOutput", ".", "AquaCropFormatter", ";", "import", "org", ".", "agmip", ".", "translators", ".", "aquacrop", ".", "domain", ".", "IrrigationManagement", ";", "import", "org", ".", "agmip", ".", "translators", ".", "aquacrop", ".", "domain", ".", "Soil", ";", "import", "org", ".", "apache", ".", "velocity", ".", "Template", ";", "import", "org", ".", "apache", ".", "velocity", ".", "VelocityContext", ";", "import", "org", ".", "apache", ".", "velocity", ".", "app", ".", "Velocity", ";", "public", "class", "IrrigationTranslatorOutput", "extends", "BaseTranslatorOutput", "implements", "TranslatorOutput", "{", "public", "void", "writeFile", "(", "String", "file", ",", "Map", "data", ")", "{", "Velocity", ".", "init", "(", ")", ";", "VelocityContext", "vc", "=", "new", "VelocityContext", "(", ")", ";", "IrrigationManagement", "irrigation", "=", "IrrigationManagement", ".", "create", "(", "data", ")", ";", "assert", "(", "irrigation", ".", "getEvents", "(", ")", ".", "size", "(", ")", ">", "0", ")", ";", "vc", ".", "put", "(", "\"format\"", ",", "new", "AquaCropFormatter", "(", ")", ")", ";", "vc", ".", "put", "(", "\"\"", ",", "AQUACROP_VERSION", ")", ";", "vc", ".", "put", "(", "\"irrigation\"", ",", "irrigation", ")", ";", "Template", "t", "=", "Velocity", ".", "getTemplate", "(", "\"\"", ",", "\"UTF-8\"", ")", ";", "int", "pos", "=", "file", ".", "lastIndexOf", "(", "\".\"", ")", ";", "String", "outFile", "=", "file", ".", "substring", "(", "0", ",", "pos", ")", "+", "\".irr\"", ";", "writeFile", "(", "vc", ",", "t", ",", "outFile", ")", ";", "}", "}", "</s>" ]
7,980
[ "<s>", "package", "org", ".", "agmip", ".", "translators", ".", "aquacrop", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "agmip", ".", "core", ".", "types", ".", "TranslatorOutput", ";", "import", "org", ".", "agmip", ".", "translators", ".", "aquacrop", ".", "domain", ".", "Weather", ";", "import", "org", ".", "apache", ".", "velocity", ".", "Template", ";", "import", "org", ".", "apache", ".", "velocity", ".", "VelocityContext", ";", "import", "org", ".", "apache", ".", "velocity", ".", "app", ".", "Velocity", ";", "public", "class", "ClimateTranslatorOutput", "extends", "BaseTranslatorOutput", "implements", "TranslatorOutput", "{", "private", "final", "static", "String", "CO2_FILE_NAME", "=", "\"maunaloa.co2\"", ";", "public", "void", "writeFile", "(", "String", "file", ",", "Map", "data", ")", "{", "Velocity", ".", "init", "(", ")", ";", "VelocityContext", "vc", "=", "new", "VelocityContext", "(", ")", ";", "Weather", "weather", "=", "Weather", ".", "create", "(", "data", ")", ";", "assert", "(", "weather", ".", "getDaily", "(", ")", ".", "size", "(", ")", ">", "0", ")", ";", "vc", ".", "put", "(", "\"format\"", ",", "new", "AquaCropFormatter", "(", ")", ")", ";", "vc", ".", "put", "(", "\"\"", ",", "AQUACROP_VERSION", ")", ";", "vc", ".", "put", "(", "\"weather\"", ",", "weather", ")", ";", "Template", "t", "=", "Velocity", ".", "getTemplate", "(", "\"\"", ",", "\"UTF-8\"", ")", ";", "int", "pos", "=", "file", ".", "lastIndexOf", "(", "\".\"", ")", ";", "String", "temperatureFile", "=", "file", ".", "substring", "(", "0", ",", "pos", ")", "+", "\".tmp\"", ";", "writeFile", "(", "vc", ",", "t", ",", "temperatureFile", ")", ";", "t", "=", "Velocity", ".", "getTemplate", "(", "\"\"", ",", "\"UTF-8\"", ")", ";", "String", "et0File", "=", "file", ".", "substring", "(", "0", ",", "pos", ")", "+", "\".et0\"", ";", "writeFile", "(", "vc", ",", "t", ",", "et0File", ")", ";", "t", "=", "Velocity", ".", "getTemplate", "(", "\"\"", ",", "\"UTF-8\"", ")", ";", "String", "rainFile", "=", "file", ".", "substring", "(", "0", ",", "pos", ")", "+", "\".plu\"", ";", "writeFile", "(", "vc", ",", "t", ",", "rainFile", ")", ";", "vc", ".", "put", "(", "\"temp_file\"", ",", "temperatureFile", ")", ";", "vc", ".", "put", "(", "\"et0_file\"", ",", "et0File", ")", ";", "vc", ".", "put", "(", "\"rain_file\"", ",", "rainFile", ")", ";", "vc", ".", "put", "(", "\"co2_file\"", ",", "CO2_FILE_NAME", ")", ";", "t", "=", "Velocity", ".", "getTemplate", "(", "\"\"", ",", "\"UTF-8\"", ")", ";", "writeFile", "(", "vc", ",", "t", ",", "file", ".", "substring", "(", "0", ",", "pos", ")", "+", "\".cli\"", ")", ";", "}", "}", "</s>" ]
7,981
[ "<s>", "package", "org", ".", "agmip", ".", "translators", ".", "aquacrop", ";", "import", "java", ".", "io", ".", "BufferedWriter", ";", "import", "java", ".", "io", ".", "DataOutputStream", ";", "import", "java", ".", "io", ".", "FileOutputStream", ";", "import", "java", ".", "io", ".", "OutputStreamWriter", ";", "import", "java", ".", "nio", ".", "charset", ".", "Charset", ";", "import", "org", ".", "apache", ".", "velocity", ".", "Template", ";", "import", "org", ".", "apache", ".", "velocity", ".", "VelocityContext", ";", "public", "class", "BaseTranslatorOutput", "{", "public", "final", "static", "String", "AQUACROP_VERSION", "=", "\"4.0\"", ";", "public", "class", "AquaCropFormatter", "{", "public", "String", "headerInt", "(", "int", "val", ")", "{", "return", "String", ".", "format", "(", "\"%7s\"", ",", "String", ".", "valueOf", "(", "val", ")", ")", ";", "}", "public", "String", "dbl", "(", "double", "val", ",", "int", "size", ",", "int", "decimals", ")", "{", "String", "frm", "=", "String", ".", "format", "(", "\"%%%d.%df\"", ",", "size", ",", "decimals", ")", ";", "return", "String", ".", "format", "(", "frm", ",", "val", ")", ";", "}", "}", "protected", "void", "writeFile", "(", "VelocityContext", "context", ",", "Template", "template", ",", "String", "file", ")", "{", "try", "{", "FileOutputStream", "fstream", "=", "new", "FileOutputStream", "(", "file", ")", ";", "DataOutputStream", "out", "=", "new", "DataOutputStream", "(", "fstream", ")", ";", "BufferedWriter", "bw", "=", "new", "BufferedWriter", "(", "new", "OutputStreamWriter", "(", "out", ",", "Charset", ".", "forName", "(", "\"UTF-8\"", ")", ")", ")", ";", "template", ".", "merge", "(", "context", ",", "bw", ")", ";", "bw", ".", "flush", "(", ")", ";", "bw", ".", "close", "(", ")", ";", "System", ".", "out", ".", "println", "(", "\"\"", "+", "file", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "System", ".", "err", ".", "println", "(", "\"\"", "+", "e", ".", "getMessage", "(", ")", ")", ";", "}", "}", "}", "</s>" ]
7,982
[ "<s>", "package", "org", ".", "agmip", ".", "translators", ".", "aquacrop", ".", "domain", ";", "import", "java", ".", "util", ".", "LinkedHashMap", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "agmip", ".", "translators", ".", "aquacrop", ".", "tools", ".", "AgMIP", ";", "import", "org", ".", "agmip", ".", "util", ".", "MapUtil", ";", "import", "org", ".", "agmip", ".", "util", ".", "MapUtil", ".", "BucketEntry", ";", "@", "SuppressWarnings", "(", "{", "\"rawtypes\"", ",", "\"unchecked\"", "}", ")", "public", "class", "IrrigationManagement", "extends", "Management", "{", "private", "String", "name", ";", "private", "String", "method", ";", "private", "double", "percSoilSurfaceWetted", ";", "private", "int", "irrigationMode", ";", "public", "static", "IrrigationManagement", "create", "(", "Map", "data", ")", "{", "IrrigationManagement", "obj", "=", "new", "IrrigationManagement", "(", ")", ";", "obj", ".", "from", "(", "data", ")", ";", "return", "obj", ";", "}", "public", "void", "from", "(", "Map", "data", ")", "{", "BucketEntry", "dataBucket", "=", "MapUtil", ".", "getBucket", "(", "data", ",", "AgMIP", ".", "MANAGEMENT_BUCKET_NAME", ")", ";", "assert", "(", "dataBucket", "!=", "null", ")", ";", "List", "<", "LinkedHashMap", "<", "String", ",", "String", ">", ">", "dataItems", "=", "dataBucket", ".", "getDataList", "(", ")", ";", "assert", "(", "dataItems", ".", "size", "(", ")", ">", "0", ")", ";", "events", ".", "clear", "(", ")", ";", "ManagementEvent", "startEvent", "=", "null", ";", "for", "(", "Map", "<", "String", ",", "String", ">", "dataItem", ":", "dataItems", ")", "{", "ManagementEvent", "event", "=", "createEvent", "(", "dataItem", ")", ";", "if", "(", "event", "instanceof", "PlantingManagementEvent", ")", "{", "startEvent", "=", "event", ";", "}", "if", "(", "(", "startEvent", "!=", "null", ")", "&&", "(", "event", "instanceof", "IrrigationManagementEvent", ")", ")", "{", "events", ".", "add", "(", "event", ")", ";", "}", "if", "(", "(", "startEvent", "!=", "null", ")", "&&", "(", "event", "instanceof", "HarvestingManagementEvent", ")", ")", "{", "break", ";", "}", "}", "}", "public", "String", "getName", "(", ")", "{", "return", "name", ";", "}", "public", "void", "setName", "(", "String", "name", ")", "{", "this", ".", "name", "=", "name", ";", "}", "public", "String", "getMethod", "(", ")", "{", "return", "method", ";", "}", "public", "void", "setMethod", "(", "String", "method", ")", "{", "this", ".", "method", "=", "method", ";", "}", "public", "double", "getPercSoilSurfaceWetted", "(", ")", "{", "return", "percSoilSurfaceWetted", ";", "}", "public", "void", "setPercSoilSurfaceWetted", "(", "double", "percSoilSurfaceWetted", ")", "{", "this", ".", "percSoilSurfaceWetted", "=", "percSoilSurfaceWetted", ";", "}", "public", "int", "getIrrigationMode", "(", ")", "{", "return", "irrigationMode", ";", "}", "public", "void", "setIrrigationMode", "(", "int", "irrigationMode", ")", "{", "this", ".", "irrigationMode", "=", "irrigationMode", ";", "}", "}", "</s>" ]
7,983
[ "<s>", "package", "org", ".", "agmip", ".", "translators", ".", "aquacrop", ".", "domain", ";", "import", "java", ".", "util", ".", "Map", ";", "@", "SuppressWarnings", "(", "\"rawtypes\"", ")", "public", "class", "PlantingManagementEvent", "extends", "ManagementEvent", "{", "public", "static", "PlantingManagementEvent", "create", "(", "Map", "data", ")", "{", "PlantingManagementEvent", "obj", "=", "new", "PlantingManagementEvent", "(", ")", ";", "obj", ".", "from", "(", "data", ")", ";", "return", "obj", ";", "}", "public", "void", "from", "(", "Map", "data", ")", "{", "super", ".", "from", "(", "data", ")", ";", "}", "}", "</s>" ]
7,984
[ "<s>", "package", "org", ".", "agmip", ".", "translators", ".", "aquacrop", ".", "domain", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "LinkedHashMap", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "agmip", ".", "translators", ".", "aquacrop", ".", "tools", ".", "AgMIP", ";", "import", "org", ".", "agmip", ".", "translators", ".", "aquacrop", ".", "tools", ".", "DayNumbers", ";", "import", "org", ".", "agmip", ".", "translators", ".", "aquacrop", ".", "tools", ".", "WeatherDataCalculator", ";", "import", "org", ".", "agmip", ".", "util", ".", "MapUtil", ";", "import", "org", ".", "agmip", ".", "util", ".", "MapUtil", ".", "BucketEntry", ";", "@", "SuppressWarnings", "(", "{", "\"rawtypes\"", ",", "\"unchecked\"", "}", ")", "public", "class", "Weather", "{", "private", "String", "name", ";", "private", "String", "firstDate", ";", "private", "double", "latitude", ";", "private", "double", "longitude", ";", "private", "double", "elevation", ";", "private", "List", "<", "DailyWeather", ">", "daily", "=", "new", "ArrayList", "<", "DailyWeather", ">", "(", ")", ";", "public", "static", "Weather", "create", "(", "Map", "data", ")", "{", "Weather", "w", "=", "new", "Weather", "(", ")", ";", "w", ".", "from", "(", "data", ")", ";", "return", "w", ";", "}", "public", "void", "from", "(", "Map", "data", ")", "{", "BucketEntry", "dataBucket", "=", "MapUtil", ".", "getBucket", "(", "data", ",", "AgMIP", ".", "WEATHER_BUCKET_NAME", ")", ";", "assert", "(", "dataBucket", "!=", "null", ")", ";", "Map", "<", "String", ",", "String", ">", "globalData", "=", "dataBucket", ".", "getValues", "(", ")", ";", "name", "=", "MapUtil", ".", "getValueOr", "(", "globalData", ",", "\"wst_name\"", ",", "\"Unknown\"", ")", ";", "latitude", "=", "Double", ".", "valueOf", "(", "MapUtil", ".", "getValueOr", "(", "globalData", ",", "\"wst_lat\"", ",", "\"0.0\"", ")", ")", ";", "longitude", "=", "Double", ".", "valueOf", "(", "MapUtil", ".", "getValueOr", "(", "globalData", ",", "\"wst_long\"", ",", "\"0.0\"", ")", ")", ";", "elevation", "=", "Double", ".", "valueOf", "(", "MapUtil", ".", "getValueOr", "(", "globalData", ",", "\"elev\"", ",", "\"0.0\"", ")", ")", ";", "List", "<", "LinkedHashMap", "<", "String", ",", "String", ">", ">", "dataItems", "=", "dataBucket", ".", "getDataList", "(", ")", ";", "assert", "(", "dataItems", ".", "size", "(", ")", ">", "0", ")", ";", "firstDate", "=", "(", "String", ")", "MapUtil", ".", "getValueOr", "(", "dataItems", ".", "get", "(", "0", ")", ",", "\"w_date\"", ",", "\"19010101\"", ")", ";", "daily", ".", "clear", "(", ")", ";", "for", "(", "Map", "<", "String", ",", "String", ">", "dataItem", ":", "dataItems", ")", "{", "DailyWeather", "item", "=", "DailyWeather", ".", "create", "(", "dataItem", ")", ";", "int", "day", "=", "DayNumbers", ".", "calculateDayInYear", "(", "item", ".", "getDate", "(", ")", ",", "false", ")", ";", "item", ".", "setET0", "(", "WeatherDataCalculator", ".", "calculateETReference", "(", "day", ",", "latitude", ",", "elevation", ",", "item", ".", "getMaxTemp", "(", ")", ",", "item", ".", "getMinTemp", "(", ")", ")", ")", ";", "daily", ".", "add", "(", "item", ")", ";", "}", "}", "public", "String", "getName", "(", ")", "{", "return", "name", ";", "}", "public", "void", "setName", "(", "String", "name", ")", "{", "this", ".", "name", "=", "name", ";", "}", "public", "String", "getFirstDate", "(", ")", "{", "return", "firstDate", ";", "}", "public", "void", "setFirstDate", "(", "String", "firstDate", ")", "{", "this", ".", "firstDate", "=", "firstDate", ";", "}", "public", "double", "getLatitude", "(", ")", "{", "return", "latitude", ";", "}", "public", "void", "setLatitude", "(", "double", "latitude", ")", "{", "this", ".", "latitude", "=", "latitude", ";", "}", "public", "double", "getLongitude", "(", ")", "{", "return", "longitude", ";", "}", "public", "void", "setLongitude", "(", "double", "longitude", ")", "{", "this", ".", "longitude", "=", "longitude", ";", "}", "public", "double", "getElevation", "(", ")", "{", "return", "elevation", ";", "}", "public", "void", "setElevation", "(", "double", "elevation", ")", "{", "this", ".", "elevation", "=", "elevation", ";", "}", "public", "List", "<", "DailyWeather", ">", "getDaily", "(", ")", "{", "return", "daily", ";", "}", "public", "void", "setDaily", "(", "List", "<", "DailyWeather", ">", "daily", ")", "{", "this", ".", "daily", "=", "daily", ";", "}", "}", "</s>" ]
7,985
[ "<s>", "package", "org", ".", "agmip", ".", "translators", ".", "aquacrop", ".", "domain", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "agmip", ".", "translators", ".", "aquacrop", ".", "tools", ".", "DayNumbers", ";", "import", "org", ".", "agmip", ".", "translators", ".", "aquacrop", ".", "tools", ".", "MapHelper", ";", "@", "SuppressWarnings", "(", "{", "\"rawtypes\"", "}", ")", "public", "class", "ManagementEvent", "{", "private", "String", "event", ";", "private", "String", "date", ";", "private", "int", "[", "]", "dayMonthYear", ";", "public", "void", "from", "(", "Map", "data", ")", "{", "event", "=", "MapHelper", ".", "getValueFor", "(", "data", ",", "\"Unknown\"", ",", "\"event\"", ")", ";", "date", "=", "MapHelper", ".", "getValueFor", "(", "data", ",", "\"190101\"", ",", "\"date\"", ")", ";", "dayMonthYear", "=", "DayNumbers", ".", "decodeDateString", "(", "date", ")", ";", "}", "public", "String", "getEvent", "(", ")", "{", "return", "event", ";", "}", "public", "void", "setEvent", "(", "String", "event", ")", "{", "this", ".", "event", "=", "event", ";", "}", "public", "String", "getDate", "(", ")", "{", "return", "date", ";", "}", "public", "void", "setDate", "(", "String", "date", ")", "{", "this", ".", "date", "=", "date", ";", "}", "public", "int", "[", "]", "getDayMonthYear", "(", ")", "{", "return", "dayMonthYear", ";", "}", "public", "void", "setDayMonthYear", "(", "int", "[", "]", "dayMonthYear", ")", "{", "this", ".", "dayMonthYear", "=", "dayMonthYear", ";", "}", "}", "</s>" ]
7,986
[ "<s>", "package", "org", ".", "agmip", ".", "translators", ".", "aquacrop", ".", "domain", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "agmip", ".", "translators", ".", "aquacrop", ".", "tools", ".", "DayNumbers", ";", "import", "org", ".", "agmip", ".", "util", ".", "MapUtil", ";", "@", "SuppressWarnings", "(", "{", "\"rawtypes\"", ",", "\"unchecked\"", "}", ")", "public", "class", "DailyWeather", "{", "private", "String", "date", ";", "private", "int", "[", "]", "dayMonthYear", ";", "private", "double", "minTemp", ";", "private", "double", "maxTemp", ";", "private", "double", "rain", ";", "private", "double", "ET0", ";", "public", "static", "DailyWeather", "create", "(", "Map", "data", ")", "{", "DailyWeather", "dw", "=", "new", "DailyWeather", "(", ")", ";", "dw", ".", "from", "(", "data", ")", ";", "return", "dw", ";", "}", "public", "void", "from", "(", "Map", "data", ")", "{", "date", "=", "MapUtil", ".", "getValueOr", "(", "data", ",", "\"w_date\"", ",", "\"19010101\"", ")", ";", "dayMonthYear", "=", "DayNumbers", ".", "decodeDateString", "(", "date", ")", ";", "minTemp", "=", "Double", ".", "valueOf", "(", "MapUtil", ".", "getValueOr", "(", "data", ",", "\"tmin\"", ",", "\"12.0\"", ")", ")", ";", "maxTemp", "=", "Double", ".", "valueOf", "(", "MapUtil", ".", "getValueOr", "(", "data", ",", "\"tmax\"", ",", "\"28.0\"", ")", ")", ";", "rain", "=", "Double", ".", "valueOf", "(", "MapUtil", ".", "getValueOr", "(", "data", ",", "\"rain\"", ",", "\"0.0\"", ")", ")", ";", "ET0", "=", "Double", ".", "valueOf", "(", "MapUtil", ".", "getValueOr", "(", "data", ",", "\"evap\"", ",", "\"5.0\"", ")", ")", ";", "}", "public", "String", "getDate", "(", ")", "{", "return", "date", ";", "}", "public", "void", "setDate", "(", "String", "date", ")", "{", "this", ".", "date", "=", "date", ";", "}", "public", "int", "[", "]", "getDayMonthYear", "(", ")", "{", "return", "dayMonthYear", ";", "}", "public", "void", "setDayMonthYear", "(", "int", "[", "]", "dayMonthYear", ")", "{", "this", ".", "dayMonthYear", "=", "dayMonthYear", ";", "}", "public", "double", "getMinTemp", "(", ")", "{", "return", "minTemp", ";", "}", "public", "void", "setMinTemp", "(", "double", "minTemp", ")", "{", "this", ".", "minTemp", "=", "minTemp", ";", "}", "public", "double", "getMaxTemp", "(", ")", "{", "return", "maxTemp", ";", "}", "public", "void", "setMaxTemp", "(", "double", "maxTemp", ")", "{", "this", ".", "maxTemp", "=", "maxTemp", ";", "}", "public", "double", "getRain", "(", ")", "{", "return", "rain", ";", "}", "public", "void", "setRain", "(", "double", "rain", ")", "{", "this", ".", "rain", "=", "rain", ";", "}", "public", "double", "getET0", "(", ")", "{", "return", "ET0", ";", "}", "public", "void", "setET0", "(", "double", "eT0", ")", "{", "ET0", "=", "eT0", ";", "}", "}", "</s>" ]
7,987
[ "<s>", "package", "org", ".", "agmip", ".", "translators", ".", "aquacrop", ".", "domain", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "agmip", ".", "translators", ".", "aquacrop", ".", "tools", ".", "AgMIP", ";", "import", "org", ".", "agmip", ".", "translators", ".", "aquacrop", ".", "tools", ".", "MapHelper", ";", "@", "SuppressWarnings", "(", "{", "\"rawtypes\"", "}", ")", "public", "abstract", "class", "Management", "{", "protected", "List", "<", "ManagementEvent", ">", "events", "=", "new", "ArrayList", "<", "ManagementEvent", ">", "(", ")", ";", "public", "ManagementEvent", "createEvent", "(", "Map", "data", ")", "{", "String", "event", "=", "MapHelper", ".", "getValueFor", "(", "data", ",", "\"Unknown\"", ",", "\"event\"", ")", ";", "if", "(", "AgMIP", ".", "MANAGEMENT_EVENT_PLANT", ".", "equalsIgnoreCase", "(", "event", ")", ")", "{", "return", "PlantingManagementEvent", ".", "create", "(", "data", ")", ";", "}", "if", "(", "AgMIP", ".", "MANAGEMENT_EVENT_IRRIGATE", ".", "equalsIgnoreCase", "(", "event", ")", ")", "{", "return", "IrrigationManagementEvent", ".", "create", "(", "data", ")", ";", "}", "if", "(", "AgMIP", ".", "MANAGEMENT_EVENT_HARVEST", ".", "equalsIgnoreCase", "(", "event", ")", ")", "{", "return", "HarvestingManagementEvent", ".", "create", "(", "data", ")", ";", "}", "return", "null", ";", "}", "public", "abstract", "void", "from", "(", "Map", "data", ")", ";", "public", "List", "<", "ManagementEvent", ">", "getEvents", "(", ")", "{", "return", "events", ";", "}", "public", "void", "setEvents", "(", "List", "<", "ManagementEvent", ">", "events", ")", "{", "this", ".", "events", "=", "events", ";", "}", "}", "</s>" ]
7,988
[ "<s>", "package", "org", ".", "agmip", ".", "translators", ".", "aquacrop", ".", "domain", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "LinkedHashMap", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "agmip", ".", "translators", ".", "aquacrop", ".", "tools", ".", "AgMIP", ";", "import", "org", ".", "agmip", ".", "translators", ".", "aquacrop", ".", "tools", ".", "SoilDataCalculator", ";", "import", "org", ".", "agmip", ".", "util", ".", "MapUtil", ";", "import", "org", ".", "agmip", ".", "util", ".", "MapUtil", ".", "BucketEntry", ";", "@", "SuppressWarnings", "(", "{", "\"rawtypes\"", ",", "\"unchecked\"", "}", ")", "public", "class", "Soil", "{", "private", "String", "id", ";", "private", "String", "name", ";", "private", "double", "latitude", ";", "private", "double", "longitude", ";", "private", "String", "classification", ";", "private", "int", "curveNumber", ";", "private", "int", "readilyEvaporatedWater", ";", "private", "List", "<", "SoilHorizon", ">", "horizons", "=", "new", "ArrayList", "<", "SoilHorizon", ">", "(", ")", ";", "public", "static", "Soil", "create", "(", "Map", "data", ")", "{", "Soil", "s", "=", "new", "Soil", "(", ")", ";", "s", ".", "from", "(", "data", ")", ";", "return", "s", ";", "}", "public", "void", "from", "(", "Map", "data", ")", "{", "BucketEntry", "dataBucket", "=", "MapUtil", ".", "getBucket", "(", "data", ",", "AgMIP", ".", "SOIL_BUCKET_NAME", ")", ";", "assert", "(", "dataBucket", "!=", "null", ")", ";", "Map", "<", "String", ",", "String", ">", "globalData", "=", "dataBucket", ".", "getValues", "(", ")", ";", "id", "=", "MapUtil", ".", "getValueOr", "(", "globalData", ",", "\"soil_id\"", ",", "\"Unknown\"", ")", ";", "name", "=", "MapUtil", ".", "getValueOr", "(", "globalData", ",", "\"soil_name\"", ",", "\"Unknown\"", ")", ";", "latitude", "=", "Double", ".", "valueOf", "(", "MapUtil", ".", "getValueOr", "(", "globalData", ",", "\"soil_lat\"", ",", "\"0.0\"", ")", ")", ";", "longitude", "=", "Double", ".", "valueOf", "(", "MapUtil", ".", "getValueOr", "(", "globalData", ",", "\"soil_long\"", ",", "\"0.0\"", ")", ")", ";", "classification", "=", "MapUtil", ".", "getValueOr", "(", "globalData", ",", "\"\"", ",", "\"Unknown\"", ")", ";", "curveNumber", "=", "Integer", ".", "valueOf", "(", "MapUtil", ".", "getValueOr", "(", "globalData", ",", "\"slro\"", ",", "\"0\"", ")", ")", ";", "List", "<", "LinkedHashMap", "<", "String", ",", "String", ">", ">", "dataItems", "=", "dataBucket", ".", "getDataList", "(", ")", ";", "assert", "(", "dataItems", ".", "size", "(", ")", ">", "0", ")", ";", "horizons", ".", "clear", "(", ")", ";", "double", "previousSoilLayerBaseDepth", "=", "0.0", ";", "for", "(", "Map", "<", "String", ",", "String", ">", "dataItem", ":", "dataItems", ")", "{", "SoilHorizon", "item", "=", "SoilHorizon", ".", "create", "(", "dataItem", ")", ";", "item", ".", "setThickness", "(", "item", ".", "getSoilLayerBaseDepth", "(", ")", "-", "previousSoilLayerBaseDepth", ")", ";", "previousSoilLayerBaseDepth", "=", "item", ".", "getSoilLayerBaseDepth", "(", ")", ";", "int", "soilClass", "=", "SoilDataCalculator", ".", "calculateSoilClass", "(", "item", ".", "getSoilWaterContentAtSaturation", "(", ")", ",", "item", ".", "getSoilWaterContentAtPermanentWiltingPoint", "(", ")", ",", "item", ".", "getSoilWaterContentAtFieldCapacity", "(", ")", ",", "item", ".", "getSaturatedHydrolicConductivity", "(", ")", ")", ";", "item", ".", "setDescription", "(", "SoilDataCalculator", ".", "soilClassDescription", "(", "soilClass", ")", ")", ";", "item", ".", "setCapillaryRiseEstimationParameterA", "(", "SoilDataCalculator", ".", "calculateCapillaryRiseEstimationParameterA", "(", "soilClass", ",", "item", ".", "getSaturatedHydrolicConductivity", "(", ")", ")", ")", ";", "item", ".", "setCapillaryRiseEstimationParameterB", "(", "SoilDataCalculator", ".", "calculateCapillaryRiseEstimationParameterB", "(", "soilClass", ",", "item", ".", "getSaturatedHydrolicConductivity", "(", ")", ")", ")", ";", "horizons", ".", "add", "(", "item", ")", ";", "}", "SoilHorizon", "top", "=", "horizons", ".", "get", "(", "0", ")", ";", "readilyEvaporatedWater", "=", "(", "int", ")", "SoilDataCalculator", ".", "calculateReadilyEvaporableWater", "(", "top", ".", "getSoilWaterContentAtFieldCapacity", "(", ")", ",", "top", ".", "getSoilWaterContentAtPermanentWiltingPoint", "(", ")", ")", ";", "}", "public", "String", "getName", "(", ")", "{", "return", "name", ";", "}", "public", "void", "setName", "(", "String", "name", ")", "{", "this", ".", "name", "=", "name", ";", "}", "public", "int", "getCurveNumber", "(", ")", "{", "return", "curveNumber", ";", "}", "public", "void", "setCurveNumber", "(", "int", "curveNumber", ")", "{", "this", ".", "curveNumber", "=", "curveNumber", ";", "}", "public", "int", "getReadilyEvaporatedWater", "(", ")", "{", "return", "readilyEvaporatedWater", ";", "}", "public", "void", "setReadilyEvaporatedWater", "(", "int", "readilyEvaporatedWater", ")", "{", "this", ".", "readilyEvaporatedWater", "=", "readilyEvaporatedWater", ";", "}", "public", "List", "<", "SoilHorizon", ">", "getHorizons", "(", ")", "{", "return", "horizons", ";", "}", "public", "void", "setHorizons", "(", "List", "<", "SoilHorizon", ">", "horizons", ")", "{", "this", ".", "horizons", "=", "horizons", ";", "}", "public", "String", "getId", "(", ")", "{", "return", "id", ";", "}", "public", "void", "setId", "(", "String", "id", ")", "{", "this", ".", "id", "=", "id", ";", "}", "public", "double", "getLatitude", "(", ")", "{", "return", "latitude", ";", "}", "public", "void", "setLatitude", "(", "double", "latitude", ")", "{", "this", ".", "latitude", "=", "latitude", ";", "}", "public", "double", "getLongitude", "(", ")", "{", "return", "longitude", ";", "}", "public", "void", "setLongitude", "(", "double", "longitude", ")", "{", "this", ".", "longitude", "=", "longitude", ";", "}", "public", "String", "getClassification", "(", ")", "{", "return", "classification", ";", "}", "public", "void", "setClassification", "(", "String", "classification", ")", "{", "this", ".", "classification", "=", "classification", ";", "}", "}", "</s>" ]
7,989
[ "<s>", "package", "org", ".", "agmip", ".", "translators", ".", "aquacrop", ".", "domain", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "agmip", ".", "translators", ".", "aquacrop", ".", "tools", ".", "MapHelper", ";", "import", "org", ".", "agmip", ".", "translators", ".", "aquacrop", ".", "tools", ".", "SoilDataCalculator", ";", "@", "SuppressWarnings", "(", "{", "\"rawtypes\"", "}", ")", "public", "class", "SoilHorizon", "{", "private", "double", "baseDepth", ";", "private", "double", "soilWaterContentAtSaturation", ";", "private", "double", "soilWaterContentAtFieldCapacity", ";", "private", "double", "soilWaterContentAtPermanentWiltingPoint", ";", "private", "double", "saturatedHydrolicConductivity", ";", "private", "double", "thickness", ";", "private", "double", "capillaryRiseEstimationParameterA", ";", "private", "double", "capillaryRiseEstimationParameterB", ";", "private", "String", "description", ";", "public", "static", "SoilHorizon", "create", "(", "Map", "data", ")", "{", "SoilHorizon", "sh", "=", "new", "SoilHorizon", "(", ")", ";", "sh", ".", "from", "(", "data", ")", ";", "return", "sh", ";", "}", "public", "void", "from", "(", "Map", "data", ")", "{", "String", "sllbVal", "=", "MapHelper", ".", "getValueFor", "(", "data", ",", "\"10.0\"", ",", "\"sllb\"", ")", ";", "String", "sltxVal", "=", "MapHelper", ".", "getValueFor", "(", "data", ",", "\"SA\"", ",", "\"sltx\"", ")", ";", "String", "slsatVal", "=", "MapHelper", ".", "getValueFor", "(", "data", ",", "\"0.0\"", ",", "\"slsat\"", ")", ";", "String", "wpVal", "=", "MapHelper", ".", "getValueOrNullFor", "(", "data", ",", "\"slwp\"", ",", "\"slll\"", ")", ";", "String", "fcVal", "=", "MapHelper", ".", "getValueOrNullFor", "(", "data", ",", "\"slfc1\"", ",", "\"sldul\"", ")", ";", "String", "ksatVal", "=", "MapHelper", ".", "getValueOrNullFor", "(", "data", ",", "\"sksat\"", ")", ";", "baseDepth", "=", "Double", ".", "valueOf", "(", "sllbVal", ")", "/", "100", ";", "soilWaterContentAtSaturation", "=", "Double", ".", "valueOf", "(", "slsatVal", ")", "*", "100", ";", "SoilDataCalculator", "sdc", "=", "null", ";", "if", "(", "ksatVal", "!=", "null", ")", "{", "saturatedHydrolicConductivity", "=", "Double", ".", "valueOf", "(", "ksatVal", ")", "*", "240", ";", "}", "else", "{", "sdc", "=", "new", "SoilDataCalculator", "(", ")", ";", "sdc", ".", "initKSatFromAgMIPCode", "(", "this", ",", "sltxVal", ")", ";", "}", "if", "(", "(", "wpVal", "!=", "null", ")", "&&", "(", "fcVal", "!=", "null", ")", ")", "{", "soilWaterContentAtPermanentWiltingPoint", "=", "Double", ".", "valueOf", "(", "wpVal", ")", "*", "100", ";", "soilWaterContentAtFieldCapacity", "=", "Double", ".", "valueOf", "(", "fcVal", ")", "*", "100", ";", "}", "else", "{", "if", "(", "sdc", "==", "null", ")", "{", "sdc", "=", "new", "SoilDataCalculator", "(", ")", ";", "}", "sdc", ".", "initSWCFromAgMIPCode", "(", "this", ",", "sltxVal", ")", ";", "}", "}", "public", "double", "getSoilLayerBaseDepth", "(", ")", "{", "return", "baseDepth", ";", "}", "public", "void", "setSoilLayerBaseDepth", "(", "double", "soilLayerBaseDepth", ")", "{", "this", ".", "baseDepth", "=", "soilLayerBaseDepth", ";", "}", "public", "double", "getThickness", "(", ")", "{", "return", "thickness", ";", "}", "public", "void", "setThickness", "(", "double", "thickness", ")", "{", "this", ".", "thickness", "=", "thickness", ";", "}", "public", "double", "getSoilWaterContentAtSaturation", "(", ")", "{", "return", "soilWaterContentAtSaturation", ";", "}", "public", "void", "setSoilWaterContentAtSaturation", "(", "double", "soilWaterContentAtSaturation", ")", "{", "this", ".", "soilWaterContentAtSaturation", "=", "soilWaterContentAtSaturation", ";", "}", "public", "double", "getSoilWaterContentAtFieldCapacity", "(", ")", "{", "return", "soilWaterContentAtFieldCapacity", ";", "}", "public", "void", "setSoilWaterContentAtFieldCapacity", "(", "double", "soilWaterContentAtFieldCapacity", ")", "{", "this", ".", "soilWaterContentAtFieldCapacity", "=", "soilWaterContentAtFieldCapacity", ";", "}", "public", "double", "getSoilWaterContentAtPermanentWiltingPoint", "(", ")", "{", "return", "soilWaterContentAtPermanentWiltingPoint", ";", "}", "public", "void", "setSoilWaterContentAtPermanentWiltingPoint", "(", "double", "soilWaterContentAtPermanentWiltingPoint", ")", "{", "this", ".", "soilWaterContentAtPermanentWiltingPoint", "=", "soilWaterContentAtPermanentWiltingPoint", ";", "}", "public", "double", "getSaturatedHydrolicConductivity", "(", ")", "{", "return", "saturatedHydrolicConductivity", ";", "}", "public", "void", "setSaturatedHydrolicConductivity", "(", "double", "saturatedHydrolicConductivity", ")", "{", "this", ".", "saturatedHydrolicConductivity", "=", "saturatedHydrolicConductivity", ";", "}", "public", "double", "getCapillaryRiseEstimationParameterA", "(", ")", "{", "return", "capillaryRiseEstimationParameterA", ";", "}", "public", "void", "setCapillaryRiseEstimationParameterA", "(", "double", "capillaryRiseEstimationParameterA", ")", "{", "this", ".", "capillaryRiseEstimationParameterA", "=", "capillaryRiseEstimationParameterA", ";", "}", "public", "double", "getCapillaryRiseEstimationParameterB", "(", ")", "{", "return", "capillaryRiseEstimationParameterB", ";", "}", "public", "void", "setCapillaryRiseEstimationParameterB", "(", "double", "capillaryRiseEstimationParameterB", ")", "{", "this", ".", "capillaryRiseEstimationParameterB", "=", "capillaryRiseEstimationParameterB", ";", "}", "public", "String", "getDescription", "(", ")", "{", "return", "description", ";", "}", "public", "void", "setDescription", "(", "String", "description", ")", "{", "this", ".", "description", "=", "description", ";", "}", "}", "</s>" ]
7,990
[ "<s>", "package", "org", ".", "agmip", ".", "translators", ".", "aquacrop", ".", "domain", ";", "import", "java", ".", "util", ".", "Map", ";", "@", "SuppressWarnings", "(", "{", "\"rawtypes\"", "}", ")", "public", "class", "IrrigationManagementEvent", "extends", "ManagementEvent", "{", "private", "int", "numberOfDaysAfterSowingOrPlanting", ";", "private", "int", "applicationDepth", ";", "private", "double", "electricalConductivityOfIrrigationWater", ";", "public", "static", "IrrigationManagementEvent", "create", "(", "Map", "data", ")", "{", "IrrigationManagementEvent", "obj", "=", "new", "IrrigationManagementEvent", "(", ")", ";", "obj", ".", "from", "(", "data", ")", ";", "return", "obj", ";", "}", "public", "void", "from", "(", "Map", "data", ")", "{", "super", ".", "from", "(", "data", ")", ";", "}", "public", "int", "getNumberOfDaysAfterSowingOrPlanting", "(", ")", "{", "return", "numberOfDaysAfterSowingOrPlanting", ";", "}", "public", "void", "setNumberOfDaysAfterSowingOrPlanting", "(", "int", "numberOfDaysAfterSowingOrPlanting", ")", "{", "this", ".", "numberOfDaysAfterSowingOrPlanting", "=", "numberOfDaysAfterSowingOrPlanting", ";", "}", "public", "int", "getApplicationDepth", "(", ")", "{", "return", "applicationDepth", ";", "}", "public", "void", "setApplicationDepth", "(", "int", "applicationDepth", ")", "{", "this", ".", "applicationDepth", "=", "applicationDepth", ";", "}", "public", "double", "getElectricalConductivityOfIrrigationWater", "(", ")", "{", "return", "electricalConductivityOfIrrigationWater", ";", "}", "public", "void", "setElectricalConductivityOfIrrigationWater", "(", "double", "electricalConductivityOfIrrigationWater", ")", "{", "this", ".", "electricalConductivityOfIrrigationWater", "=", "electricalConductivityOfIrrigationWater", ";", "}", "}", "</s>" ]
7,991
[ "<s>", "package", "org", ".", "agmip", ".", "translators", ".", "aquacrop", ".", "domain", ";", "import", "java", ".", "util", ".", "Map", ";", "@", "SuppressWarnings", "(", "\"rawtypes\"", ")", "public", "class", "HarvestingManagementEvent", "extends", "ManagementEvent", "{", "public", "static", "HarvestingManagementEvent", "create", "(", "Map", "data", ")", "{", "HarvestingManagementEvent", "obj", "=", "new", "HarvestingManagementEvent", "(", ")", ";", "obj", ".", "from", "(", "data", ")", ";", "return", "obj", ";", "}", "public", "void", "from", "(", "Map", "data", ")", "{", "super", ".", "from", "(", "data", ")", ";", "}", "}", "</s>" ]
7,992
[ "<s>", "package", "hudson", ".", "plugins", ".", "labeledgroupedtests", ";", "import", "hudson", ".", "model", ".", "AbstractBuild", ";", "import", "hudson", ".", "model", ".", "Run", ";", "import", "hudson", ".", "tasks", ".", "test", ".", "TestResult", ";", "import", "hudson", ".", "tasks", ".", "test", ".", "AbstractTestResultAction", ";", "import", "hudson", ".", "tasks", ".", "test", ".", "MetaTabulatedResult", ";", "import", "hudson", ".", "tasks", ".", "test", ".", "TestObject", ";", "import", "org", ".", "kohsuke", ".", "stapler", ".", "StaplerRequest", ";", "import", "org", ".", "kohsuke", ".", "stapler", ".", "StaplerResponse", ";", "import", "org", ".", "kohsuke", ".", "stapler", ".", "export", ".", "Exported", ";", "import", "org", ".", "kohsuke", ".", "stapler", ".", "export", ".", "ExportedBean", ";", "import", "java", ".", "util", ".", "*", ";", "import", "java", ".", "util", ".", "logging", ".", "Logger", ";", "@", "ExportedBean", "public", "class", "LabeledTestResultGroup", "extends", "MetaTabulatedResult", "{", "protected", "List", "<", "TestResult", ">", "children", "=", "null", ";", "protected", "transient", "List", "<", "TestResult", ">", "childrenWithFailures", "=", "null", ";", "protected", "transient", "List", "<", "TestResult", ">", "passedChildren", "=", "null", ";", "protected", "String", "label", ";", "protected", "int", "failCount", "=", "0", ";", "protected", "int", "skipCount", "=", "0", ";", "protected", "int", "passCount", "=", "0", ";", "protected", "int", "totalCount", "=", "0", ";", "protected", "float", "duration", "=", "0", ";", "protected", "TestResult", "parent", ";", "protected", "String", "description", "=", "\"\"", ";", "protected", "transient", "boolean", "cacheDirty", "=", "true", ";", "protected", "Map", "<", "String", ",", "TestResult", ">", "childrenByName", ";", "protected", "Map", "<", "TestResult", ",", "String", ">", "nameToChildMap", ";", "protected", "boolean", "namesHaveBeenSet", "=", "false", ";", "private", "static", "final", "Logger", "LOGGER", "=", "Logger", ".", "getLogger", "(", "LabeledTestResultGroup", ".", "class", ".", "getName", "(", ")", ")", ";", "public", "LabeledTestResultGroup", "(", ")", "{", "this", "(", "null", ",", "\"unlabeled\"", ",", "new", "ArrayList", "<", "TestResult", ">", "(", ")", ")", ";", "}", "public", "LabeledTestResultGroup", "(", "TestResult", "parent", ",", "String", "label", ",", "List", "<", "TestResult", ">", "children", ")", "{", "this", ".", "parent", "=", "parent", ";", "this", ".", "label", "=", "label", ";", "this", ".", "children", "=", "children", ";", "childrenWithFailures", "=", "new", "ArrayList", "<", "TestResult", ">", "(", ")", ";", "passedChildren", "=", "new", "ArrayList", "<", "TestResult", ">", "(", ")", ";", "namesHaveBeenSet", "=", "false", ";", "childrenByName", "=", "null", ";", "nameToChildMap", "=", "null", ";", "cacheDirty", "=", "true", ";", "}", "@", "Override", "public", "void", "setParentAction", "(", "AbstractTestResultAction", "action", ")", "{", "for", "(", "TestResult", "result", ":", "children", ")", "{", "result", ".", "setParentAction", "(", "action", ")", ";", "}", "}", "@", "Exported", "(", "visibility", "=", "99", ")", "@", "Override", "public", "int", "getPassCount", "(", ")", "{", "if", "(", "cacheDirty", ")", "updateCache", "(", ")", ";", "return", "passCount", ";", "}", "@", "Exported", "(", "visibility", "=", "99", ")", "@", "Override", "public", "int", "getSkipCount", "(", ")", "{", "if", "(", "cacheDirty", ")", "updateCache", "(", ")", ";", "return", "skipCount", ";", "}", "@", "Exported", "(", "visibility", "=", "99", ")", "@", "Override", "public", "int", "getFailCount", "(", ")", "{", "if", "(", "cacheDirty", ")", "updateCache", "(", ")", ";", "return", "failCount", ";", "}", "@", "Exported", "(", "visibility", "=", "99", ")", "public", "String", "getLabel", "(", ")", "{", "return", "label", ";", "}", "@", "Override", "public", "String", "getName", "(", ")", "{", "return", "label", ";", "}", "public", "String", "getDisplayNameForChild", "(", "TestResult", "c", ")", "{", "if", "(", "!", "namesHaveBeenSet", ")", "lockInNames", "(", ")", ";", "String", "niceName", "=", "nameToChildMap", ".", "get", "(", "c", ")", ";", "if", "(", "niceName", "==", "null", ")", "{", "String", "msg", "=", "\"\"", "+", "c", ".", "toPrettyString", "(", ")", ";", "LOGGER", ".", "severe", "(", "msg", ")", ";", "System", ".", "err", ".", "println", "(", "msg", ")", ";", "return", "\"\"", ";", "}", "return", "niceName", ";", "}", "public", "TestResult", "getChildByIndex", "(", "int", "i", ")", "{", "if", "(", "i", "<", "0", "||", "i", ">=", "children", ".", "size", "(", ")", ")", "{", "String", "msg", "=", "\"\"", "+", "i", "+", "\"", "but", "only", "\"", "+", "children", ".", "size", "(", ")", "+", "\"\"", ";", "LOGGER", ".", "severe", "(", "msg", ")", ";", "throw", "new", "NoSuchElementException", "(", "msg", ")", ";", "}", "return", "children", ".", "get", "(", "i", ")", ";", "}", "@", "Override", "public", "Object", "getDynamic", "(", "String", "token", ",", "StaplerRequest", "req", ",", "StaplerResponse", "rsp", ")", "{", "if", "(", "cacheDirty", ")", "updateCache", "(", ")", ";", "if", "(", "!", "namesHaveBeenSet", ")", "{", "String", "msg", "=", "\"\"", ";", "LOGGER", ".", "severe", "(", "msg", ")", ";", "throw", "new", "RuntimeException", "(", "msg", ")", ";", "}", "TestResult", "thatOne", "=", "childrenByName", ".", "get", "(", "token", ")", ";", "if", "(", "thatOne", "!=", "null", ")", "{", "return", "thatOne", ";", "}", "else", "{", "Object", "result", "=", "super", ".", "getDynamic", "(", "token", ",", "req", ",", "rsp", ")", ";", "if", "(", "result", "!=", "null", ")", "{", "return", "result", ";", "}", "else", "{", "return", "new", "Run", ".", "RedirectUp", "(", ")", ";", "}", "}", "}", "public", "Object", "readResolve", "(", ")", "{", "childrenWithFailures", "=", "new", "ArrayList", "<", "TestResult", ">", "(", ")", ";", "passedChildren", "=", "new", "ArrayList", "<", "TestResult", ">", "(", ")", ";", "updateCache", "(", ")", ";", "return", "this", ";", "}", "@", "Override", "public", "void", "tally", "(", ")", "{", "updateCache", "(", ")", ";", "}", "protected", "void", "updateCache", "(", ")", "{", "failCount", "=", "0", ";", "skipCount", "=", "0", ";", "passCount", "=", "0", ";", "totalCount", "=", "0", ";", "childrenWithFailures", ".", "clear", "(", ")", ";", "passedChildren", ".", "clear", "(", ")", ";", "AbstractTestResultAction", "parentAction", "=", "(", "parent", "==", "null", "?", "null", ":", "parent", ".", "getTestResultAction", "(", ")", ")", ";", "float", "durationAccum", "=", "0.0f", ";", "for", "(", "TestResult", "r", ":", "children", ")", "{", "r", ".", "setParentAction", "(", "parentAction", ")", ";", "r", ".", "setParent", "(", "this", ")", ";", "r", ".", "tally", "(", ")", ";", "durationAccum", "+=", "r", ".", "getDuration", "(", ")", ";", "passCount", "+=", "r", ".", "getPassCount", "(", ")", ";", "failCount", "+=", "r", ".", "getFailCount", "(", ")", ";", "skipCount", "+=", "r", ".", "getSkipCount", "(", ")", ";", "if", "(", "r", ".", "isPassed", "(", ")", ")", "{", "passedChildren", ".", "add", "(", "r", ")", ";", "}", "else", "if", "(", "r", ".", "getFailCount", "(", ")", ">", "0", ")", "{", "childrenWithFailures", ".", "add", "(", "r", ")", ";", "}", "}", "duration", "=", "durationAccum", ";", "totalCount", "=", "passCount", "+", "failCount", "+", "skipCount", ";", "cacheDirty", "=", "false", ";", "}", "@", "Override", "public", "Collection", "<", "?", "extends", "TestResult", ">", "getFailedTests", "(", ")", "{", "if", "(", "cacheDirty", ")", "updateCache", "(", ")", ";", "return", "childrenWithFailures", ";", "}", "@", "Exported", "(", "visibility", "=", "99", ")", "@", "Override", "public", "Collection", "<", "?", "extends", "TestResult", ">", "getChildren", "(", ")", "{", "if", "(", "cacheDirty", ")", "updateCache", "(", ")", ";", "return", "children", ";", "}", "@", "Override", "public", "boolean", "hasChildren", "(", ")", "{", "if", "(", "cacheDirty", ")", "updateCache", "(", ")", ";", "return", "children", ".", "size", "(", ")", ">", "0", ";", "}", "@", "Override", "public", "AbstractBuild", "<", "?", ",", "?", ">", "getOwner", "(", ")", "{", "if", "(", "parent", "==", "null", ")", "return", "null", ";", "return", "parent", ".", "getOwner", "(", ")", ";", "}", "@", "Override", "public", "TestObject", "getParent", "(", ")", "{", "return", "parent", ";", "}", "@", "Override", "public", "float", "getDuration", "(", ")", "{", "if", "(", "cacheDirty", ")", "updateCache", "(", ")", ";", "return", "duration", ";", "}", "@", "Exported", "(", "visibility", "=", "99", ")", "public", "String", "getDisplayName", "(", ")", "{", "return", "label", ";", "}", "public", "void", "addResult", "(", "TestResult", "result", ")", "{", "if", "(", "!", "children", ".", "contains", "(", "result", ")", ")", "{", "children", ".", "add", "(", "result", ")", ";", "cacheDirty", "=", "true", ";", "}", "}", "public", "void", "addAll", "(", "LabeledTestResultGroup", "group", ")", "{", "for", "(", "TestResult", "r", ":", "group", ".", "getChildren", "(", ")", ")", "{", "if", "(", "!", "children", ".", "contains", "(", "r", ")", ")", "{", "children", ".", "add", "(", "r", ")", ";", "cacheDirty", "=", "true", ";", "}", "}", "}", "@", "Override", "public", "TestResult", "getPreviousResult", "(", ")", "{", "if", "(", "parent", "==", "null", ")", "{", "LOGGER", ".", "warning", "(", "\"\"", ")", ";", "return", "null", ";", "}", "AbstractBuild", "<", "?", ",", "?", ">", "b", "=", "parent", ".", "getOwner", "(", ")", ";", "if", "(", "b", "==", "null", ")", "{", "LOGGER", ".", "warning", "(", "\"\"", ")", ";", "return", "null", ";", "}", "while", "(", "true", ")", "{", "AbstractBuild", "<", "?", ",", "?", ">", "n", "=", "b", ";", "b", "=", "b", ".", "getPreviousBuild", "(", ")", ";", "if", "(", "b", "==", "null", ")", "{", "if", "(", "n", ".", "getNumber", "(", ")", "!=", "1", ")", "{", "LOGGER", ".", "warning", "(", "\"\"", "+", "n", ".", "getNumber", "(", ")", "+", "\".\"", ")", ";", "}", "return", "null", ";", "}", "MetaLabeledTestResultGroupAction", "r", "=", "b", ".", "getAction", "(", "MetaLabeledTestResultGroupAction", ".", "class", ")", ";", "if", "(", "r", "!=", "null", ")", "{", "return", "r", ".", "getLabeledTestResultGroup", "(", "label", ")", ";", "}", "}", "}", "@", "Override", "public", "TestResult", "getResultInBuild", "(", "AbstractBuild", "<", "?", ",", "?", ">", "build", ")", "{", "MetaLabeledTestResultGroupAction", "action", "=", "build", ".", "getAction", "(", "MetaLabeledTestResultGroupAction", ".", "class", ")", ";", "if", "(", "action", "==", "null", ")", "{", "if", "(", "label", ".", "equals", "(", "\"unit\"", ")", ")", "{", "AbstractTestResultAction", "tra", "=", "build", ".", "getAction", "(", "AbstractTestResultAction", ".", "class", ")", ";", "if", "(", "tra", "==", "null", ")", "{", "return", "null", ";", "}", "return", "(", "TestResult", ")", "tra", ".", "getResult", "(", ")", ";", "}", "else", "{", "return", "null", ";", "}", "}", "return", "action", ".", "getLabeledTestResultGroup", "(", "label", ")", ";", "}", "@", "Override", "public", "TestResult", "findCorrespondingResult", "(", "String", "id", ")", "{", "String", "childName", ";", "String", "remainingId", "=", "null", ";", "int", "childNameEnd", "=", "id", ".", "indexOf", "(", "'/'", ")", ";", "if", "(", "childNameEnd", "<", "0", ")", "{", "childName", "=", "id", ";", "remainingId", "=", "null", ";", "}", "else", "{", "childName", "=", "id", ".", "substring", "(", "0", ",", "childNameEnd", ")", ";", "if", "(", "childNameEnd", "!=", "id", ".", "length", "(", ")", ")", "{", "remainingId", "=", "id", ".", "substring", "(", "childNameEnd", "+", "1", ")", ";", "}", "}", "TestResult", "child", "=", "childrenByName", ".", "get", "(", "childName", ")", ";", "if", "(", "child", "!=", "null", ")", "{", "if", "(", "remainingId", "!=", "null", ")", "{", "return", "child", ".", "findCorrespondingResult", "(", "remainingId", ")", ";", "}", "else", "{", "return", "child", ";", "}", "}", "return", "null", ";", "}", "@", "Override", "public", "String", "toPrettyString", "(", ")", "{", "if", "(", "cacheDirty", ")", "updateCache", "(", ")", ";", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "TestResult", "r", ":", "children", ")", "{", "sb", ".", "append", "(", "\"t\"", ")", ".", "append", "(", "label", ")", ";", "sb", ".", "append", "(", "\":", "\"", ")", ".", "append", "(", "r", ".", "toPrettyString", "(", ")", ")", ";", "}", "return", "sb", ".", "toString", "(", ")", ";", "}", "public", "int", "getPassDiff", "(", ")", "{", "TestResult", "prev", "=", "getPreviousResult", "(", ")", ";", "if", "(", "prev", "==", "null", ")", "return", "getPassCount", "(", ")", ";", "return", "getPassCount", "(", ")", "-", "prev", ".", "getPassCount", "(", ")", ";", "}", "public", "int", "getSkipDiff", "(", ")", "{", "TestResult", "prev", "=", "getPreviousResult", "(", ")", ";", "if", "(", "prev", "==", "null", ")", "return", "getSkipCount", "(", ")", ";", "return", "getSkipCount", "(", ")", "-", "prev", ".", "getSkipCount", "(", ")", ";", "}", "public", "int", "getFailDiff", "(", ")", "{", "TestResult", "prev", "=", "getPreviousResult", "(", ")", ";", "if", "(", "prev", "==", "null", ")", "return", "getFailCount", "(", ")", ";", "return", "getFailCount", "(", ")", "-", "prev", ".", "getFailCount", "(", ")", ";", "}", "public", "int", "getTotalDiff", "(", ")", "{", "TestResult", "prev", "=", "getPreviousResult", "(", ")", ";", "if", "(", "prev", "==", "null", ")", "return", "getTotalCount", "(", ")", ";", "return", "getTotalCount", "(", ")", "-", "prev", ".", "getTotalCount", "(", ")", ";", "}", "public", "void", "setNameMap", "(", "HashMap", "<", "TestResult", ",", "String", ">", "resultToNameMap", ")", "{", "if", "(", "namesHaveBeenSet", "||", "(", "childrenByName", "!=", "null", ")", "||", "(", "nameToChildMap", "!=", "null", ")", ")", "{", "String", "msg", "=", "\"\"", ";", "LOGGER", ".", "severe", "(", "msg", ")", ";", "System", ".", "out", ".", "println", "(", "msg", ")", ";", "throw", "new", "RuntimeException", "(", "msg", ")", ";", "}", "childrenByName", "=", "new", "HashMap", "<", "String", ",", "TestResult", ">", "(", "totalCount", ")", ";", "nameToChildMap", "=", "new", "HashMap", "<", "TestResult", ",", "String", ">", "(", "totalCount", ")", ";", "for", "(", "TestResult", "r", ":", "children", ")", "{", "String", "name", "=", "resultToNameMap", ".", "get", "(", "r", ")", ";", "if", "(", "name", "==", "null", ")", "{", "String", "msg", "=", "\"\"", ";", "LOGGER", ".", "severe", "(", "msg", ")", ";", "System", ".", "err", ".", "println", "(", "msg", ")", ";", "}", "childrenByName", ".", "put", "(", "name", ",", "r", ")", ";", "nameToChildMap", ".", "put", "(", "r", ",", "name", ")", ";", "}", "namesHaveBeenSet", "=", "true", ";", "}", "protected", "void", "lockInNames", "(", ")", "{", "if", "(", "namesHaveBeenSet", "||", "(", "childrenByName", "!=", "null", ")", "||", "(", "nameToChildMap", "!=", "null", ")", ")", "{", "String", "msg", "=", "\"\"", ";", "LOGGER", ".", "severe", "(", "msg", ")", ";", "System", ".", "out", ".", "println", "(", "msg", ")", ";", "throw", "new", "RuntimeException", "(", "msg", ")", ";", "}", "LOGGER", ".", "warning", "(", "\"\"", ")", ";", "childrenByName", "=", "new", "HashMap", "<", "String", ",", "TestResult", ">", "(", "totalCount", ")", ";", "nameToChildMap", "=", "new", "HashMap", "<", "TestResult", ",", "String", ">", "(", "totalCount", ")", ";", "int", "i", "=", "0", ";", "for", "(", "TestResult", "aResult", ":", "children", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", "(", "\"result-\"", ")", ".", "append", "(", "i", ")", ";", "String", "niceChildName", "=", "sb", ".", "toString", "(", ")", ";", "childrenByName", ".", "put", "(", "niceChildName", ",", "aResult", ")", ";", "nameToChildMap", ".", "put", "(", "aResult", ",", "niceChildName", ")", ";", "}", "namesHaveBeenSet", "=", "true", ";", "}", "}", "</s>" ]
7,993
[ "<s>", "package", "hudson", ".", "plugins", ".", "labeledgroupedtests", ".", "converters", ";", "import", "com", ".", "thoughtworks", ".", "xstream", ".", "io", ".", "HierarchicalStreamWriter", ";", "import", "com", ".", "thoughtworks", ".", "xstream", ".", "io", ".", "HierarchicalStreamReader", ";", "import", "com", ".", "thoughtworks", ".", "xstream", ".", "converters", ".", "MarshallingContext", ";", "import", "com", ".", "thoughtworks", ".", "xstream", ".", "converters", ".", "ConversionException", ";", "import", "com", ".", "thoughtworks", ".", "xstream", ".", "converters", ".", "UnmarshallingContext", ";", "import", "com", ".", "thoughtworks", ".", "xstream", ".", "XStream", ";", "import", "hudson", ".", "tasks", ".", "junit", ".", "JUnitResultArchiver", ";", "import", "hudson", ".", "plugins", ".", "labeledgroupedtests", ".", "LabeledTestGroupConfiguration", ";", "import", "hudson", ".", "plugins", ".", "labeledgroupedtests", ".", "LabeledTestResultGroupPublisher", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "public", "class", "JUnitResultArchiverConverter", "extends", "ConvertToLabeledGroupsConverter", "{", "public", "void", "marshal", "(", "Object", "source", ",", "HierarchicalStreamWriter", "writer", ",", "MarshallingContext", "context", ")", "{", "if", "(", "!", "ENABLE_CONVERSIONS", ")", "{", "LOGGER", ".", "severe", "(", "\"\"", ")", ";", "throw", "new", "IllegalStateException", "(", "\"\"", ")", ";", "}", "if", "(", "!", "(", "source", "instanceof", "JUnitResultArchiver", ")", ")", "{", "throw", "new", "ConversionException", "(", "\"\"", "+", "\"\"", ")", ";", "}", "JUnitResultArchiver", "archiver", "=", "(", "JUnitResultArchiver", ")", "source", ";", "writer", ".", "startNode", "(", "\"testResults\"", ")", ";", "writer", ".", "setValue", "(", "archiver", ".", "getTestResults", "(", ")", ")", ";", "writer", ".", "endNode", "(", ")", ";", "writer", ".", "startNode", "(", "\"\"", ")", ";", "writer", ".", "endNode", "(", ")", ";", "}", "public", "Object", "unmarshal", "(", "HierarchicalStreamReader", "reader", ",", "UnmarshallingContext", "context", ")", "{", "if", "(", "!", "ENABLE_CONVERSIONS", ")", "{", "LOGGER", ".", "info", "(", "\"\"", ")", ";", "throw", "new", "IllegalStateException", "(", "\"\"", ")", ";", "}", "List", "<", "LabeledTestGroupConfiguration", ">", "configs", "=", "new", "ArrayList", "<", "LabeledTestGroupConfiguration", ">", "(", ")", ";", "while", "(", "reader", ".", "hasMoreChildren", "(", ")", ")", "{", "reader", ".", "moveDown", "(", ")", ";", "if", "(", "\"testResults\"", ".", "equals", "(", "reader", ".", "getNodeName", "(", ")", ")", ")", "{", "configs", ".", "add", "(", "new", "LabeledTestGroupConfiguration", "(", "JUNIT_PARSER_TO_USE", ",", "reader", ".", "getValue", "(", ")", ",", "\"unit\"", ")", ")", ";", "}", "else", "if", "(", "\"\"", ".", "equals", "(", "reader", ".", "getNodeName", "(", ")", ")", ")", "{", "if", "(", "reader", ".", "hasMoreChildren", "(", ")", ")", "{", "String", "msg", "=", "\"\"", ";", "msg", "=", "msg", "+", "\"\"", "+", "reader", ".", "getNodeName", "(", ")", "+", "\"'\"", ";", "LOGGER", ".", "severe", "(", "msg", ")", ";", "throw", "new", "ConversionException", "(", "\"\"", ")", ";", "}", "}", "reader", ".", "moveUp", "(", ")", ";", "}", "return", "new", "LabeledTestResultGroupPublisher", "(", "configs", ")", ";", "}", "public", "boolean", "canConvert", "(", "Class", "type", ")", "{", "return", "ENABLE_CONVERSIONS", "&&", "JUnitResultArchiver", ".", "class", "==", "type", ";", "}", "public", "static", "void", "registerWithXStream", "(", "XStream", "xstream", ")", "{", "xstream", ".", "registerConverter", "(", "new", "JUnitResultArchiverConverter", "(", ")", ")", ";", "}", "}", "</s>" ]
7,994
[ "<s>", "package", "hudson", ".", "plugins", ".", "labeledgroupedtests", ".", "converters", ";", "import", "com", ".", "thoughtworks", ".", "xstream", ".", "io", ".", "HierarchicalStreamWriter", ";", "import", "com", ".", "thoughtworks", ".", "xstream", ".", "io", ".", "HierarchicalStreamReader", ";", "import", "com", ".", "thoughtworks", ".", "xstream", ".", "converters", ".", "MarshallingContext", ";", "import", "com", ".", "thoughtworks", ".", "xstream", ".", "converters", ".", "ConversionException", ";", "import", "com", ".", "thoughtworks", ".", "xstream", ".", "converters", ".", "UnmarshallingContext", ";", "import", "com", ".", "thoughtworks", ".", "xstream", ".", "XStream", ";", "import", "hudson", ".", "plugins", ".", "labeledgroupedtests", ".", "LabeledTestGroupConfiguration", ";", "import", "hudson", ".", "plugins", ".", "labeledgroupedtests", ".", "LabeledTestResultGroupPublisher", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "public", "class", "OpenCppunitPublisherConverter", "extends", "ConvertToLabeledGroupsConverter", "{", "public", "void", "marshal", "(", "Object", "source", ",", "HierarchicalStreamWriter", "writer", ",", "MarshallingContext", "context", ")", "{", "if", "(", "!", "ENABLE_CONVERSIONS", ")", "{", "LOGGER", ".", "severe", "(", "\"\"", ")", ";", "throw", "new", "IllegalStateException", "(", "\"\"", ")", ";", "}", "LOGGER", ".", "severe", "(", "\"\"", ")", ";", "throw", "new", "IllegalStateException", "(", "\"\"", ")", ";", "}", "public", "Object", "unmarshal", "(", "HierarchicalStreamReader", "reader", ",", "UnmarshallingContext", "context", ")", "{", "if", "(", "!", "ENABLE_CONVERSIONS", ")", "{", "LOGGER", ".", "info", "(", "\"\"", ")", ";", "throw", "new", "IllegalStateException", "(", "\"\"", ")", ";", "}", "List", "<", "LabeledTestGroupConfiguration", ">", "configs", "=", "new", "ArrayList", "<", "LabeledTestGroupConfiguration", ">", "(", ")", ";", "while", "(", "reader", ".", "hasMoreChildren", "(", ")", ")", "{", "reader", ".", "moveDown", "(", ")", ";", "if", "(", "\"\"", ".", "equals", "(", "reader", ".", "getNodeName", "(", ")", ")", ")", "{", "configs", ".", "add", "(", "new", "LabeledTestGroupConfiguration", "(", "CPPUNIT_PARSER_TO_USE", ",", "reader", ".", "getValue", "(", ")", ",", "\"unit\"", ")", ")", ";", "}", "else", "if", "(", "\"\"", ".", "equals", "(", "reader", ".", "getNodeName", "(", ")", ")", ")", "{", "if", "(", "reader", ".", "hasMoreChildren", "(", ")", ")", "{", "String", "msg", "=", "\"\"", ";", "msg", "=", "msg", "+", "\"\"", "+", "reader", ".", "getNodeName", "(", ")", "+", "\"'\"", ";", "LOGGER", ".", "severe", "(", "msg", ")", ";", "throw", "new", "ConversionException", "(", "\"\"", ")", ";", "}", "}", "else", "if", "(", "\"\"", ".", "equals", "(", "reader", ".", "getNodeName", "(", ")", ")", ")", "{", "String", "useCustom", "=", "reader", ".", "getValue", "(", ")", ";", "if", "(", "Boolean", ".", "parseBoolean", "(", "useCustom", ")", ")", "{", "String", "msg", "=", "\"\"", ";", "msg", "+=", "\"\"", ";", "LOGGER", ".", "warning", "(", "msg", ")", ";", "}", "}", "reader", ".", "moveUp", "(", ")", ";", "}", "return", "new", "LabeledTestResultGroupPublisher", "(", "configs", ")", ";", "}", "public", "boolean", "canConvert", "(", "Class", "type", ")", "{", "String", "className", "=", "type", ".", "getName", "(", ")", ";", "return", "ENABLE_CONVERSIONS", "&&", "OPEN_CPPUNIT_PLUGIN_CLASS_NAME", ".", "equals", "(", "className", ")", ";", "}", "public", "static", "void", "registerWithXStream", "(", "XStream", "xstream", ")", "{", "xstream", ".", "registerConverter", "(", "new", "OpenCppunitPublisherConverter", "(", ")", ")", ";", "}", "}", "</s>" ]
7,995
[ "<s>", "package", "hudson", ".", "plugins", ".", "labeledgroupedtests", ".", "converters", ";", "import", "com", ".", "thoughtworks", ".", "xstream", ".", "converters", ".", "Converter", ";", "import", "com", ".", "thoughtworks", ".", "xstream", ".", "XStream", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "logging", ".", "Logger", ";", "import", "hudson", ".", "tasks", ".", "junit", ".", "JUnitParser", ";", "public", "abstract", "class", "ConvertToLabeledGroupsConverter", "implements", "Converter", "{", "public", "static", "final", "boolean", "ENABLE_CONVERSIONS", "=", "true", ";", "static", "Map", "<", "String", ",", "String", ">", "PARSER_MAP", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", "5", ")", ";", "static", "Map", "<", "String", ",", "String", ">", "HISTORICAL_DATA_MAP", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", "3", ")", ";", "public", "static", "final", "String", "JUNIT_PARSER_TO_USE", "=", "JUnitParser", ".", "class", ".", "getName", "(", ")", ";", "public", "static", "final", "String", "OPEN_CPPUNIT_PLUGIN_CLASS_NAME", "=", "\"\"", ";", "public", "static", "final", "String", "CPPUNIT_PARSER_TO_USE", "=", "\"\"", ";", "protected", "static", "final", "Logger", "LOGGER", "=", "Logger", ".", "getLogger", "(", "ConvertToLabeledGroupsConverter", ".", "class", ".", "getName", "(", ")", ")", ";", "static", "{", "PARSER_MAP", ".", "put", "(", "OPEN_CPPUNIT_PLUGIN_CLASS_NAME", ",", "CPPUNIT_PARSER_TO_USE", ")", ";", "}", "public", "static", "void", "registerWithXStream", "(", "XStream", "xstream", ")", "{", "}", "}", "</s>" ]
7,996
[ "<s>", "package", "hudson", ".", "plugins", ".", "labeledgroupedtests", ";", "import", "hudson", ".", "Util", ";", "import", "hudson", ".", "tasks", ".", "junit", ".", "JUnitParser", ";", "import", "org", ".", "kohsuke", ".", "stapler", ".", "DataBoundConstructor", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "Map", ";", "public", "class", "LabeledTestGroupConfiguration", "{", "private", "String", "parserClassName", ";", "private", "String", "testResultFileMask", ";", "private", "String", "label", ";", "@", "DataBoundConstructor", "public", "LabeledTestGroupConfiguration", "(", "String", "parserClassName", ",", "String", "testResultFileMask", ",", "String", "label", ")", "{", "this", ".", "parserClassName", "=", "parserClassName", ";", "this", ".", "testResultFileMask", "=", "testResultFileMask", ";", "this", ".", "label", "=", "label", ";", "}", "public", "String", "getParserClassName", "(", ")", "{", "return", "parserClassName", ";", "}", "public", "void", "setParserClassName", "(", "String", "parserClassName", ")", "{", "this", ".", "parserClassName", "=", "parserClassName", ";", "}", "public", "String", "getTestResultFileMask", "(", ")", "{", "return", "testResultFileMask", ";", "}", "public", "void", "setTestResultFileMask", "(", "String", "testResultFileMask", ")", "{", "this", ".", "testResultFileMask", "=", "testResultFileMask", ";", "}", "public", "String", "getLabel", "(", ")", "{", "return", "label", ";", "}", "public", "void", "setLabel", "(", "String", "label", ")", "{", "this", ".", "label", "=", "label", ";", "}", "public", "String", "toString", "(", ")", "{", "return", "\"{label:", "\"", "+", "label", "+", "\",", "fileMask:", "\"", "+", "testResultFileMask", "+", "\"\"", "+", "parserClassName", "+", "\"}\"", ";", "}", "public", "String", "toNameString", "(", ")", "{", "String", "niceName", "=", "DISPLAY_NAME_MAP", ".", "get", "(", "parserClassName", ")", ";", "if", "(", "niceName", "==", "null", ")", "niceName", "=", "parserClassName", ";", "return", "Util", ".", "rawEncode", "(", "niceName", ")", ";", "}", "static", "Map", "<", "String", ",", "String", ">", "DISPLAY_NAME_MAP", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", "5", ")", ";", "static", "{", "DISPLAY_NAME_MAP", ".", "put", "(", "JUnitParser", ".", "class", ".", "getName", "(", ")", ",", "\"junit\"", ")", ";", "DISPLAY_NAME_MAP", ".", "put", "(", "\"\"", ",", "\"cppunit\"", ")", ";", "}", "}", "</s>" ]
7,997
[ "<s>", "package", "hudson", ".", "plugins", ".", "labeledgroupedtests", ";", "import", "hudson", ".", "Extension", ";", "import", "hudson", ".", "Launcher", ";", "import", "hudson", ".", "matrix", ".", "MatrixAggregatable", ";", "import", "hudson", ".", "matrix", ".", "MatrixAggregator", ";", "import", "hudson", ".", "matrix", ".", "MatrixBuild", ";", "import", "hudson", ".", "model", ".", "*", ";", "import", "hudson", ".", "tasks", ".", "BuildStepDescriptor", ";", "import", "hudson", ".", "tasks", ".", "BuildStepMonitor", ";", "import", "hudson", ".", "tasks", ".", "Publisher", ";", "import", "hudson", ".", "tasks", ".", "Recorder", ";", "import", "hudson", ".", "tasks", ".", "test", ".", "TestResult", ";", "import", "hudson", ".", "tasks", ".", "test", ".", "TestResultParser", ";", "import", "hudson", ".", "tasks", ".", "test", ".", "TestResultAggregator", ";", "import", "net", ".", "sf", ".", "json", ".", "JSONObject", ";", "import", "org", ".", "kohsuke", ".", "stapler", ".", "DataBoundConstructor", ";", "import", "org", ".", "kohsuke", ".", "stapler", ".", "StaplerRequest", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "Serializable", ";", "import", "java", ".", "util", ".", "*", ";", "import", "java", ".", "util", ".", "logging", ".", "Logger", ";", "public", "class", "LabeledTestResultGroupPublisher", "extends", "Recorder", "implements", "Serializable", ",", "MatrixAggregatable", "{", "private", "static", "final", "Logger", "LOGGER", "=", "Logger", ".", "getLogger", "(", "LabeledTestResultGroupPublisher", ".", "class", ".", "getName", "(", ")", ")", ";", "protected", "List", "<", "LabeledTestGroupConfiguration", ">", "configs", ";", "private", "static", "List", "<", "TestResultParser", ">", "testResultParsers", "=", "null", ";", "@", "DataBoundConstructor", "public", "LabeledTestResultGroupPublisher", "(", "List", "<", "LabeledTestGroupConfiguration", ">", "configs", ")", "{", "if", "(", "configs", "==", "null", "||", "configs", ".", "size", "(", ")", "==", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"\"", ")", ";", "}", "this", ".", "configs", "=", "new", "ArrayList", "<", "LabeledTestGroupConfiguration", ">", "(", "configs", ")", ";", "discoverParsers", "(", ")", ";", "}", "public", "BuildStepMonitor", "getRequiredMonitorService", "(", ")", "{", "return", "BuildStepMonitor", ".", "BUILD", ";", "}", "public", "MatrixAggregator", "createAggregator", "(", "MatrixBuild", "build", ",", "Launcher", "launcher", ",", "BuildListener", "listener", ")", "{", "return", "new", "TestResultAggregator", "(", "build", ",", "launcher", ",", "listener", ")", ";", "}", "public", "static", "void", "discoverParsers", "(", ")", "{", "if", "(", "testResultParsers", "==", "null", ")", "{", "if", "(", "Hudson", ".", "getInstance", "(", ")", "==", "null", ")", "{", "testResultParsers", "=", "new", "ArrayList", "<", "TestResultParser", ">", "(", ")", ";", "return", ";", "}", "testResultParsers", "=", "Hudson", ".", "getInstance", "(", ")", ".", "getExtensionList", "(", "TestResultParser", ".", "class", ")", ";", "}", "}", "public", "static", "List", "<", "TestResultParser", ">", "getTestResultParsers", "(", ")", "{", "discoverParsers", "(", ")", ";", "return", "testResultParsers", ";", "}", "public", "static", "List", "<", "String", ">", "getPhases", "(", ")", "{", "return", "Arrays", ".", "asList", "(", "\"unit\"", ",", "\"smoke\"", ",", "\"regression\"", ",", "\"integration\"", ",", "\"special\"", ",", "\"misc\"", ")", ";", "}", "public", "void", "debugPrint", "(", ")", "{", "for", "(", "LabeledTestGroupConfiguration", "config", ":", "configs", ")", "{", "LOGGER", ".", "info", "(", "\"got", "config:", "\"", "+", "config", ".", "toString", "(", ")", ")", ";", "}", "for", "(", "TestResultParser", "parser", ":", "testResultParsers", ")", "{", "LOGGER", ".", "info", "(", "\"\"", "+", "parser", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ";", "}", "}", "public", "List", "<", "LabeledTestGroupConfiguration", ">", "getConfigs", "(", ")", "{", "return", "configs", ";", "}", "public", "void", "setConfigs", "(", "List", "<", "LabeledTestGroupConfiguration", ">", "configs", ")", "{", "this", ".", "configs", "=", "configs", ";", "}", "@", "Override", "public", "boolean", "perform", "(", "final", "AbstractBuild", "build", ",", "Launcher", "launcher", ",", "final", "BuildListener", "listener", ")", "throws", "InterruptedException", ",", "IOException", "{", "String", "startMsg", "=", "\"\"", ";", "listener", ".", "getLogger", "(", ")", ".", "println", "(", "startMsg", ")", ";", "LOGGER", ".", "fine", "(", "startMsg", ")", ";", "final", "long", "buildTime", "=", "build", ".", "getTimestamp", "(", ")", ".", "getTimeInMillis", "(", ")", ";", "final", "long", "nowMaster", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "HashSet", "<", "String", ">", "labels", "=", "new", "HashSet", "<", "String", ">", "(", "10", ")", ";", "HashMap", "<", "String", ",", "List", "<", "TestResult", ">", ">", "resultGroupsByLabel", "=", "new", "HashMap", "(", "3", ")", ";", "HashMap", "<", "TestResult", ",", "String", ">", "resultsWithName", "=", "new", "HashMap", "<", "TestResult", ",", "String", ">", "(", "configs", ".", "size", "(", ")", ")", ";", "rollupConfigs", "(", ")", ";", "for", "(", "LabeledTestGroupConfiguration", "config", ":", "configs", ")", "{", "try", "{", "String", "parserClassName", "=", "config", ".", "getParserClassName", "(", ")", ";", "String", "label", "=", "config", ".", "getLabel", "(", ")", ";", "labels", ".", "add", "(", "label", ")", ";", "if", "(", "!", "resultGroupsByLabel", ".", "containsKey", "(", "label", ")", ")", "{", "resultGroupsByLabel", ".", "put", "(", "label", ",", "new", "ArrayList", "<", "TestResult", ">", "(", "5", ")", ")", ";", "}", "Collection", "<", "TestResult", ">", "listForThisLabel", "=", "resultGroupsByLabel", ".", "get", "(", "label", ")", ";", "ClassLoader", "uberLoader", "=", "Hudson", ".", "getInstance", "(", ")", ".", "getPluginManager", "(", ")", ".", "uberClassLoader", ";", "Class", "parserClass", "=", "Class", ".", "forName", "(", "parserClassName", ",", "true", ",", "uberLoader", ")", ";", "Object", "parserObject", "=", "parserClass", ".", "newInstance", "(", ")", ";", "String", "nameForThisResult", "=", "config", ".", "toNameString", "(", ")", ";", "TestResult", "someResult", "=", "null", ";", "if", "(", "parserObject", "instanceof", "TestResultParser", ")", "{", "TestResultParser", "parser", "=", "(", "TestResultParser", ")", "parserObject", ";", "someResult", "=", "parser", ".", "parse", "(", "config", ".", "getTestResultFileMask", "(", ")", ",", "build", ",", "launcher", ",", "listener", ")", ";", "}", "else", "{", "LOGGER", ".", "warning", "(", "\"\"", "+", "parserClassName", ")", ";", "listener", ".", "getLogger", "(", ")", ".", "println", "(", "\"\"", "+", "parserClassName", ")", ";", "continue", ";", "}", "if", "(", "someResult", "!=", "null", ")", "{", "listForThisLabel", ".", "add", "(", "someResult", ")", ";", "resultsWithName", ".", "put", "(", "someResult", ",", "nameForThisResult", ")", ";", "String", "msg", "=", "\"\"", "+", "someResult", ".", "toPrettyString", "(", ")", ";", "listener", ".", "getLogger", "(", ")", ".", "println", "(", "msg", ")", ";", "LOGGER", ".", "fine", "(", "msg", ")", ";", "}", "else", "{", "String", "msg", "=", "\"\"", "+", "config", ".", "getTestResultFileMask", "(", ")", "+", "\"\"", ";", "LOGGER", ".", "warning", "(", "msg", ")", ";", "listener", ".", "getLogger", "(", ")", ".", "println", "(", "msg", ")", ";", "}", "}", "catch", "(", "IOException", "e", ")", "{", "LOGGER", ".", "warning", "(", "\"\"", "+", "config", ".", "toString", "(", ")", "+", "\":\"", "+", "e", ".", "getMessage", "(", ")", ")", ";", "e", ".", "printStackTrace", "(", ")", ";", "}", "catch", "(", "ClassNotFoundException", "e", ")", "{", "LOGGER", ".", "warning", "(", "\"\"", "+", "config", ".", "toString", "(", ")", "+", "\":\"", "+", "e", ".", "getMessage", "(", ")", ")", ";", "e", ".", "printStackTrace", "(", ")", ";", "}", "catch", "(", "IllegalAccessException", "e", ")", "{", "LOGGER", ".", "warning", "(", "\"\"", "+", "config", ".", "toString", "(", ")", "+", "\":\"", "+", "e", ".", "getMessage", "(", ")", ")", ";", "e", ".", "printStackTrace", "(", ")", ";", "}", "catch", "(", "InstantiationException", "e", ")", "{", "LOGGER", ".", "warning", "(", "\"\"", "+", "config", ".", "toString", "(", ")", "+", "\":\"", "+", "e", ".", "getMessage", "(", ")", ")", ";", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "MetaLabeledTestResultGroup", "resultGroup", "=", "new", "MetaLabeledTestResultGroup", "(", ")", ";", "for", "(", "String", "label", ":", "labels", ")", "{", "LabeledTestResultGroup", "group", "=", "new", "LabeledTestResultGroup", "(", "resultGroup", ",", "label", ",", "resultGroupsByLabel", ".", "get", "(", "label", ")", ")", ";", "resultGroup", ".", "addTestResultGroup", "(", "label", ",", "group", ")", ";", "group", ".", "setNameMap", "(", "resultsWithName", ")", ";", "}", "MetaLabeledTestResultGroupAction", "action", "=", "new", "MetaLabeledTestResultGroupAction", "(", "build", ",", "resultGroup", ",", "listener", ")", ";", "build", ".", "addAction", "(", "action", ")", ";", "resultGroup", ".", "setParentAction", "(", "action", ")", ";", "resultGroup", ".", "tally", "(", ")", ";", "Result", "healthResult", "=", "determineBuildHealth", "(", "build", ",", "resultGroup", ")", ";", "if", "(", "healthResult", "!=", "null", "&&", "healthResult", ".", "isWorseThan", "(", "build", ".", "getResult", "(", ")", ")", ")", "{", "build", ".", "setResult", "(", "healthResult", ")", ";", "}", "String", "debugString", "=", "resultGroup", ".", "toString", "(", ")", ";", "LOGGER", ".", "info", "(", "\"\"", "+", "debugString", ")", ";", "listener", ".", "getLogger", "(", ")", ".", "println", "(", "\"\"", "+", "debugString", ")", ";", "return", "true", ";", "}", "private", "void", "rollupConfigs", "(", ")", "{", "HashSet", "<", "String", ">", "parserNames", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "HashSet", "<", "String", ">", "labelsInUse", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "for", "(", "LabeledTestGroupConfiguration", "config", ":", "configs", ")", "{", "parserNames", ".", "add", "(", "config", ".", "getParserClassName", "(", ")", ")", ";", "labelsInUse", ".", "add", "(", "config", ".", "getLabel", "(", ")", ")", ";", "}", "List", "<", "LabeledTestGroupConfiguration", ">", "newConfigs", "=", "new", "ArrayList", "<", "LabeledTestGroupConfiguration", ">", "(", ")", ";", "for", "(", "String", "label", ":", "labelsInUse", ")", "{", "for", "(", "String", "parserName", ":", "parserNames", ")", "{", "StringBuilder", "filemaskBuilder", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "LabeledTestGroupConfiguration", "config", ":", "configs", ")", "{", "if", "(", "config", ".", "getParserClassName", "(", ")", ".", "equals", "(", "parserName", ")", "&&", "config", ".", "getLabel", "(", ")", ".", "equals", "(", "label", ")", ")", "{", "if", "(", "filemaskBuilder", ".", "length", "(", ")", ">", "0", ")", "{", "filemaskBuilder", ".", "append", "(", "\",\"", ")", ";", "}", "filemaskBuilder", ".", "append", "(", "config", ".", "getTestResultFileMask", "(", ")", ")", ";", "}", "}", "String", "combinedFilemask", "=", "filemaskBuilder", ".", "toString", "(", ")", ";", "if", "(", "combinedFilemask", ".", "length", "(", ")", ">", "0", ")", "{", "LabeledTestGroupConfiguration", "newConfig", "=", "new", "LabeledTestGroupConfiguration", "(", "parserName", ",", "filemaskBuilder", ".", "toString", "(", ")", ",", "label", ")", ";", "newConfigs", ".", "add", "(", "newConfig", ")", ";", "}", "}", "}", "this", ".", "configs", "=", "newConfigs", ";", "}", "private", "Result", "determineBuildHealth", "(", "AbstractBuild", "build", ",", "MetaLabeledTestResultGroup", "resultGroup", ")", "{", "Result", "worstSoFar", "=", "build", ".", "getResult", "(", ")", ";", "for", "(", "TestResult", "result", ":", "resultGroup", ".", "getChildren", "(", ")", ")", "{", "Result", "thisResult", "=", "result", ".", "getBuildResult", "(", ")", ";", "if", "(", "thisResult", "!=", "null", "&&", "thisResult", ".", "isWorseThan", "(", "worstSoFar", ")", ")", "{", "worstSoFar", "=", "result", ".", "getBuildResult", "(", ")", ";", "}", "}", "return", "worstSoFar", ";", "}", "@", "Override", "public", "Action", "getProjectAction", "(", "AbstractProject", "<", "?", ",", "?", ">", "project", ")", "{", "return", "new", "MetaLabeledTestResultGroupProjectAction", "(", "project", ")", ";", "}", "@", "Extension", "public", "static", "class", "DescriptorImpl", "extends", "BuildStepDescriptor", "<", "Publisher", ">", "{", "public", "String", "getDisplayName", "(", ")", "{", "return", "\"\"", ";", "}", "@", "Override", "public", "Publisher", "newInstance", "(", "StaplerRequest", "req", ",", "JSONObject", "formData", ")", "throws", "hudson", ".", "model", ".", "Descriptor", ".", "FormException", "{", "LOGGER", ".", "info", "(", "formData", ".", "toString", "(", ")", ")", ";", "return", "req", ".", "bindJSON", "(", "LabeledTestResultGroupPublisher", ".", "class", ",", "formData", ")", ";", "}", "public", "boolean", "isApplicable", "(", "Class", "<", "?", "extends", "AbstractProject", ">", "jobType", ")", "{", "return", "!", "\"\"", ".", "equals", "(", "jobType", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", ")", ";", "}", "}", "}", "</s>" ]
7,998
[ "<s>", "package", "hudson", ".", "plugins", ".", "labeledgroupedtests", ";", "import", "hudson", ".", "Plugin", ";", "import", "hudson", ".", "plugins", ".", "labeledgroupedtests", ".", "converters", ".", "*", ";", "import", "hudson", ".", "model", ".", "Items", ";", "import", "hudson", ".", "model", ".", "Run", ";", "import", "com", ".", "thoughtworks", ".", "xstream", ".", "XStream", ";", "public", "class", "LabeledTestGroupsPublisherPlugin", "extends", "Plugin", "{", "public", "static", "void", "registerWithXStream", "(", "XStream", "xs", ")", "{", "JUnitResultArchiverConverter", ".", "registerWithXStream", "(", "xs", ")", ";", "OpenCppunitPublisherConverter", ".", "registerWithXStream", "(", "xs", ")", ";", "xs", ".", "alias", "(", "\"\"", ",", "LabeledTestResultGroupPublisher", ".", "class", ")", ";", "xs", ".", "alias", "(", "\"\"", ",", "MetaLabeledTestResultGroupProjectAction", ".", "class", ")", ";", "xs", ".", "alias", "(", "\"\"", ",", "MetaLabeledTestResultGroupAction", ".", "class", ")", ";", "}", "public", "void", "start", "(", ")", "throws", "Exception", "{", "registerWithXStream", "(", "Run", ".", "XSTREAM", ")", ";", "registerWithXStream", "(", "Items", ".", "XSTREAM", ")", ";", "}", "}", "</s>" ]
7,999
[ "<s>", "package", "hudson", ".", "plugins", ".", "labeledgroupedtests", ";", "import", "com", ".", "thoughtworks", ".", "xstream", ".", "XStream", ";", "import", "hudson", ".", "Functions", ";", "import", "hudson", ".", "XmlFile", ";", "import", "hudson", ".", "model", ".", "AbstractBuild", ";", "import", "hudson", ".", "model", ".", "BuildListener", ";", "import", "hudson", ".", "tasks", ".", "junit", ".", "CaseResult", ";", "import", "hudson", ".", "tasks", ".", "junit", ".", "SuiteResult", ";", "import", "hudson", ".", "tasks", ".", "junit", ".", "TestResult", ";", "import", "hudson", ".", "tasks", ".", "test", ".", "AbstractTestResultAction", ";", "import", "hudson", ".", "tasks", ".", "test", ".", "TestObject", ";", "import", "hudson", ".", "util", ".", "HeapSpaceStringConverter", ";", "import", "hudson", ".", "util", ".", "XStream2", ";", "import", "org", ".", "kohsuke", ".", "stapler", ".", "StaplerProxy", ";", "import", "javax", ".", "rmi", ".", "CORBA", ".", "Util", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "lang", ".", "ref", ".", "WeakReference", ";", "import", "java", ".", "util", ".", "logging", ".", "Level", ";", "import", "java", ".", "util", ".", "logging", ".", "Logger", ";", "public", "class", "MetaLabeledTestResultGroupAction", "extends", "AbstractTestResultAction", "<", "MetaLabeledTestResultGroupAction", ">", "implements", "StaplerProxy", "{", "static", "public", "final", "String", "RESULT_DATA_FILENAME", "=", "\"\"", ";", "private", "int", "failCount", ";", "private", "int", "skipCount", ";", "private", "Integer", "totalCount", ";", "protected", "MetaLabeledTestResultGroup", "resultGroup", ";", "private", "transient", "WeakReference", "<", "MetaLabeledTestResultGroup", ">", "resultGroupReference", ";", "public", "MetaLabeledTestResultGroupAction", "(", "AbstractBuild", "owner", ",", "MetaLabeledTestResultGroup", "r", ",", "BuildListener", "listener", ")", "{", "super", "(", "owner", ")", ";", "setResult", "(", "r", ",", "listener", ")", ";", "}", "public", "synchronized", "void", "setResult", "(", "MetaLabeledTestResultGroup", "r", ",", "BuildListener", "listener", ")", "{", "r", ".", "setParentAction", "(", "this", ")", ";", "totalCount", "=", "r", ".", "getTotalCount", "(", ")", ";", "failCount", "=", "r", ".", "getFailCount", "(", ")", ";", "skipCount", "=", "r", ".", "getSkipCount", "(", ")", ";", "try", "{", "getDataFile", "(", ")", ".", "write", "(", "r", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "e", ".", "printStackTrace", "(", "listener", ".", "fatalError", "(", "\"\"", ")", ")", ";", "}", "this", ".", "resultGroupReference", "=", "new", "WeakReference", "<", "MetaLabeledTestResultGroup", ">", "(", "r", ")", ";", "}", "private", "XmlFile", "getDataFile", "(", ")", "{", "return", "new", "XmlFile", "(", "XSTREAM", ",", "new", "File", "(", "owner", ".", "getRootDir", "(", ")", ",", "RESULT_DATA_FILENAME", ")", ")", ";", "}", "public", "Object", "getTarget", "(", ")", "{", "return", "getResult", "(", ")", ";", "}", "public", "int", "getFailCount", "(", ")", "{", "if", "(", "totalCount", "==", "null", ")", "getResult", "(", ")", ";", "return", "failCount", ";", "}", "public", "int", "getSkipCount", "(", ")", "{", "if", "(", "totalCount", "==", "null", ")", "getResult", "(", ")", ";", "return", "skipCount", ";", "}", "public", "int", "getTotalCount", "(", ")", "{", "if", "(", "totalCount", "==", "null", ")", "getResult", "(", ")", ";", "return", "totalCount", ";", "}", "public", "synchronized", "MetaLabeledTestResultGroup", "getResult", "(", ")", "{", "if", "(", "this", ".", "resultGroup", "!=", "null", ")", "return", "this", ".", "resultGroup", ";", "MetaLabeledTestResultGroup", "r", ";", "if", "(", "resultGroupReference", "==", "null", ")", "{", "r", "=", "load", "(", ")", ";", "resultGroupReference", "=", "new", "WeakReference", "<", "MetaLabeledTestResultGroup", ">", "(", "r", ")", ";", "}", "else", "{", "r", "=", "resultGroupReference", ".", "get", "(", ")", ";", "}", "if", "(", "r", "==", "null", ")", "{", "r", "=", "load", "(", ")", ";", "resultGroupReference", "=", "new", "WeakReference", "<", "MetaLabeledTestResultGroup", ">", "(", "r", ")", ";", "}", "if", "(", "r", "==", "null", ")", "{", "logger", ".", "severe", "(", "\"\"", "+", "this", ")", ";", "return", "null", ";", "}", "if", "(", "totalCount", "==", "null", ")", "{", "totalCount", "=", "r", ".", "getTotalCount", "(", ")", ";", "failCount", "=", "r", ".", "getFailCount", "(", ")", ";", "skipCount", "=", "r", ".", "getSkipCount", "(", ")", ";", "}", "return", "r", ";", "}", "private", "MetaLabeledTestResultGroup", "load", "(", ")", "{", "MetaLabeledTestResultGroup", "r", ";", "try", "{", "r", "=", "(", "MetaLabeledTestResultGroup", ")", "getDataFile", "(", ")", ".", "read", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "logger", ".", "log", "(", "Level", ".", "WARNING", ",", "\"\"", "+", "getDataFile", "(", ")", ",", "e", ")", ";", "r", "=", "new", "MetaLabeledTestResultGroup", "(", ")", ";", "}", "r", ".", "setParentAction", "(", "this", ")", ";", "return", "r", ";", "}", "public", "MetaLabeledTestResultGroup", "getResultAsTestResultGroup", "(", ")", "{", "return", "getResult", "(", ")", ";", "}", "public", "LabeledTestResultGroup", "getLabeledTestResultGroup", "(", "String", "label", ")", "{", "return", "getResult", "(", ")", ".", "getGroupByLabel", "(", "label", ")", ";", "}", "public", "String", "getDescription", "(", "TestObject", "testObject", ")", "{", "return", "getResult", "(", ")", ".", "getDescription", "(", ")", ";", "}", "public", "void", "setDescription", "(", "TestObject", "testObject", ",", "String", "s", ")", "{", "getResult", "(", ")", ".", "setDescription", "(", "s", ")", ";", "}", "public", "String", "getDisplayName", "(", ")", "{", "return", "\"Test", "Results\"", ";", "}", "public", "Object", "readResolve", "(", ")", "{", "if", "(", "this", ".", "resultGroup", "!=", "null", ")", "{", "this", ".", "resultGroup", ".", "setParentAction", "(", "this", ")", ";", "this", ".", "resultGroup", ".", "tally", "(", ")", ";", "totalCount", "=", "this", ".", "resultGroup", ".", "getTotalCount", "(", ")", ";", "failCount", "=", "this", ".", "resultGroup", ".", "getFailCount", "(", ")", ";", "skipCount", "=", "this", ".", "resultGroup", ".", "getSkipCount", "(", ")", ";", "}", "return", "this", ";", "}", "private", "static", "final", "Logger", "logger", "=", "Logger", ".", "getLogger", "(", "MetaLabeledTestResultGroupAction", ".", "class", ".", "getName", "(", ")", ")", ";", "private", "static", "final", "XStream", "XSTREAM", "=", "new", "XStream2", "(", ")", ";", "}", "</s>" ]