name
stringlengths
1
4.98k
code
stringlengths
61
2.07M
asm
stringlengths
57
12.9M
file
stringlengths
18
192
hsql::printExportStatementInfo(hsql::ExportStatement const*, unsigned long)
void printExportStatementInfo(const ExportStatement* stmt, uintmax_t num_indent) { inprint("ExportStatement", num_indent); inprint(stmt->filePath, num_indent + 1); switch (stmt->type) { case ImportType::kImportCSV: inprint("CSV", num_indent + 1); break; case ImportType::kImportTbl: inpri...
subq $0x18, %rsp movq %rdi, 0x10(%rsp) movq %rsi, 0x8(%rsp) movq 0x8(%rsp), %rsi leaq 0x13b73(%rip), %rdi # 0x7e9ed callq 0x39830 movq 0x10(%rsp), %rax movq 0x20(%rax), %rdi movq 0x8(%rsp), %rsi incq %rsi callq 0x39830 movq 0x10(%rsp), %rax movl 0x1c(%rax), %eax movq %rax, (%rsp) subq $0x3, %rax ja 0x6af15 movq (%r...
hyrise[P]sql-parser/src/util/sqlhelper.cpp
hsql::printInsertStatementInfo(hsql::InsertStatement const*, unsigned long)
void printInsertStatementInfo(const InsertStatement* stmt, uintmax_t num_indent) { inprint("InsertStatement", num_indent); inprint(stmt->tableName, num_indent + 1); if (stmt->columns) { inprint("Columns", num_indent + 1); for (char* col_name : *stmt->columns) { inprint(col_name, num_indent + 2); ...
subq $0x58, %rsp movq %rdi, 0x50(%rsp) movq %rsi, 0x48(%rsp) movq 0x48(%rsp), %rsi leaq 0x13a33(%rip), %rdi # 0x7ea0d callq 0x39830 movq 0x50(%rsp), %rax movq 0x28(%rax), %rdi movq 0x48(%rsp), %rsi addq $0x1, %rsi callq 0x39830 movq 0x50(%rsp), %rax cmpq $0x0, 0x30(%rax) je 0x6b08f movq 0x48(%rsp), %rsi addq $0x1, ...
hyrise[P]sql-parser/src/util/sqlhelper.cpp
hsql::printTransactionStatementInfo(hsql::TransactionStatement const*, unsigned long)
void printTransactionStatementInfo(const TransactionStatement* stmt, uintmax_t num_indent) { inprint("TransactionStatement", num_indent); switch (stmt->command) { case kBeginTransaction: inprint("BEGIN", num_indent + 1); break; case kCommitTransaction: inprint("COMMIT", num_indent + 1); ...
subq $0x18, %rsp movq %rdi, 0x10(%rsp) movq %rsi, 0x8(%rsp) movq 0x8(%rsp), %rsi leaq 0x138b2(%rip), %rdi # 0x7ea2c callq 0x39830 movq 0x10(%rsp), %rax movl 0x1c(%rax), %eax movl %eax, 0x4(%rsp) testl %eax, %eax je 0x6b1a7 jmp 0x6b191 movl 0x4(%rsp), %eax subl $0x1, %eax je 0x6b1be jmp 0x6b19c movl 0x4(%rsp), %eax ...
hyrise[P]sql-parser/src/util/sqlhelper.cpp
hsql::printStatementInfo(hsql::SQLStatement const*)
void printStatementInfo(const SQLStatement* stmt) { switch (stmt->type()) { case kStmtSelect: printSelectStatementInfo((const SelectStatement*)stmt, 0); break; case kStmtInsert: printInsertStatementInfo((const InsertStatement*)stmt, 0); break; case kStmtCreate: printCreateSta...
subq $0x18, %rsp movq %rdi, 0x10(%rsp) movq 0x10(%rsp), %rdi callq 0x36140 decl %eax movl %eax, %ecx movq %rcx, 0x8(%rsp) subl $0xd, %eax ja 0x6b286 movq 0x8(%rsp), %rax leaq 0x135cb(%rip), %rcx # 0x7e7e8 movslq (%rcx,%rax,4), %rax addq %rcx, %rax jmpq *%rax movq 0x10(%rsp), %rdi xorl %eax, %eax movl %eax, %esi cal...
hyrise[P]sql-parser/src/util/sqlhelper.cpp
aes_abstract::AddRoundKey()
void aes_abstract::AddRoundKey() { //表示第current_round轮的密钥轮加,从0开始 for (int k = 0; k < 4; k++) { uint32 current_key = round_key[4 * current_round + k]; state[0][k] = state[0][k] ^ (uint8)(current_key >> 24); state[1][k] = state[1][k] ^ (uint8)((current_key & 0x00ff0000) >> 16); sta...
pushq %rbp movq %rsp, %rbp movq %rdi, -0x8(%rbp) movq -0x8(%rbp), %rax movq %rax, -0x18(%rbp) movl $0x0, -0xc(%rbp) cmpl $0x4, -0xc(%rbp) jge 0x2598 movq -0x18(%rbp), %rax movl 0xc0(%rax), %ecx shll $0x2, %ecx addl -0xc(%rbp), %ecx movslq %ecx, %rcx movl 0x10(%rax,%rcx,4), %ecx movl %ecx, -0x10(%rbp) movslq -0xc(%rbp),...
SimpleButNotNaive[P]AES/aes_abstract.cpp
aes_abstract::MixColumns()
void aes_abstract::MixColumns() { uint8 new_state[4][4]; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { uint8 n = 0; for (int k = 0; k < 4; k++) { n ^= FieldMul(mix_column_matrix[i][k], state[k][j]); } new_state[i][j] = n; ...
pushq %rbp movq %rsp, %rbp subq $0x40, %rsp movq %rdi, -0x8(%rbp) movq -0x8(%rbp), %rax movq %rax, -0x40(%rbp) movl $0x0, -0x24(%rbp) cmpl $0x4, -0x24(%rbp) jge 0x2760 movl $0x0, -0x28(%rbp) cmpl $0x4, -0x28(%rbp) jge 0x2750 movb $0x0, -0x29(%rbp) movl $0x0, -0x30(%rbp) cmpl $0x4, -0x30(%rbp) jge 0x2729 movq -0x40(%rbp...
SimpleButNotNaive[P]AES/aes_abstract.cpp
aes_abstract::FieldMul(unsigned char, unsigned char)
uint8 aes_abstract::FieldMul(uint8 a, uint8 b) { // 有限域上两者相乘,计算乘积,a为被乘数,b为乘数 uint8 result = 0; uint8 most_significant_bit = 0; for (int i = 0; i < 8; i++) { if (b & 0x01) { result = result ^ a; } most_significant_bit = 0x80 & a; a = a << 1; if (most_si...
pushq %rbp movq %rsp, %rbp movb %dl, %al movb %sil, %cl movq %rdi, -0x8(%rbp) movb %cl, -0x9(%rbp) movb %al, -0xa(%rbp) movb $0x0, -0xb(%rbp) movb $0x0, -0xc(%rbp) movl $0x0, -0x10(%rbp) cmpl $0x8, -0x10(%rbp) jge 0x284d movzbl -0xa(%rbp), %eax andl $0x1, %eax cmpl $0x0, %eax je 0x2811 movzbl -0xb(%rbp), %eax movzbl -0...
SimpleButNotNaive[P]AES/aes_abstract.cpp
aes_abstract::bytes_to_word(unsigned char*)
uint32 aes_abstract::bytes_to_word(uint8* bytes) { //将一个bytes数组的四个字节合成一个字 uint32 number = 0; number = number | bytes[0]; number = (number << 8) | bytes[1]; number = (number << 8) | bytes[2]; number = (number << 8) | bytes[3]; return number; }
pushq %rbp movq %rsp, %rbp movq %rdi, -0x8(%rbp) movq %rsi, -0x10(%rbp) movl $0x0, -0x14(%rbp) movl -0x14(%rbp), %eax movq -0x10(%rbp), %rcx movzbl (%rcx), %ecx orl %ecx, %eax movl %eax, -0x14(%rbp) movl -0x14(%rbp), %eax shll $0x8, %eax movq -0x10(%rbp), %rcx movzbl 0x1(%rcx), %ecx orl %ecx, %eax movl %eax, -0x14(%rbp...
SimpleButNotNaive[P]AES/aes_abstract.cpp
aes_abstract::KeyExpansion(unsigned int*)
void aes_abstract::KeyExpansion(uint32 initial_key[4]) { // 将初始的密钥分为四个字,密钥拓展为44个字 int i; for (i = 0; i <= 3; i++) { this->round_key[i] = initial_key[i]; } for (; i <= 43; i++) { uint32 temp = round_key[i - 1]; if (i % 4 == 0) { temp = SubWord(RotWord(temp)) ^ r_c...
pushq %rbp movq %rsp, %rbp subq $0x30, %rsp movq %rdi, -0x8(%rbp) movq %rsi, -0x10(%rbp) movq -0x8(%rbp), %rax movq %rax, -0x20(%rbp) movl $0x0, -0x14(%rbp) cmpl $0x3, -0x14(%rbp) jg 0x2907 movq -0x20(%rbp), %rax movq -0x10(%rbp), %rcx movslq -0x14(%rbp), %rdx movl (%rcx,%rdx,4), %edx movslq -0x14(%rbp), %rcx movl %edx...
SimpleButNotNaive[P]AES/aes_abstract.cpp
aes_abstract::SubWord(unsigned int)
uint32 aes_abstract::SubWord(uint32 w) { uint8* byte_array = (uint8*)&w; for (int i = 0; i < 4; i++) { uint8 one_char = byte_array[i]; byte_array[i] = SubByte(byte_array[i]); } return w; }
pushq %rbp movq %rsp, %rbp subq $0x30, %rsp movq %rdi, -0x8(%rbp) movl %esi, -0xc(%rbp) movq -0x8(%rbp), %rax movq %rax, -0x28(%rbp) leaq -0xc(%rbp), %rax movq %rax, -0x18(%rbp) movl $0x0, -0x1c(%rbp) cmpl $0x4, -0x1c(%rbp) jge 0x2a17 movq -0x28(%rbp), %rdi movq -0x18(%rbp), %rax movslq -0x1c(%rbp), %rcx movb (%rax,%rc...
SimpleButNotNaive[P]AES/aes_abstract.cpp
aes_abstract::RotWord(unsigned int)
uint32 aes_abstract::RotWord(uint32 w) { // (B1, B2, B3, B4) --> (B2, B3, B4, B1) uint32 right = (w & 0xff000000) >> 24; // right为字的第一个byte,循环移位到最右边 uint32 left = w << 8; return left | right; }
pushq %rbp movq %rsp, %rbp movq %rdi, -0x8(%rbp) movl %esi, -0xc(%rbp) movl -0xc(%rbp), %eax andl $0xff000000, %eax # imm = 0xFF000000 shrl $0x18, %eax movl %eax, -0x10(%rbp) movl -0xc(%rbp), %eax shll $0x8, %eax movl %eax, -0x14(%rbp) movl -0x14(%rbp), %eax orl -0x10(%rbp), %eax popq %rbp retq nopw (%rax,%rax)
SimpleButNotNaive[P]AES/aes_abstract.cpp
aes_abstract::generate_roundkey(unsigned char*)
void aes_abstract::generate_roundkey(uint8 initial_key_byte[16]) { uint32 initial_key_word[4]; for (int i = 0; i < 4; i++) { initial_key_word[i] = bytes_to_word(&initial_key_byte[4 * i]); } KeyExpansion(initial_key_word); }
pushq %rbp movq %rsp, %rbp subq $0x30, %rsp movq %rdi, -0x8(%rbp) movq %rsi, -0x10(%rbp) movq -0x8(%rbp), %rax movq %rax, -0x30(%rbp) movl $0x0, -0x24(%rbp) cmpl $0x4, -0x24(%rbp) jge 0x2aa2 movq -0x30(%rbp), %rdi movq -0x10(%rbp), %rsi movl -0x24(%rbp), %eax shll $0x2, %eax cltq addq %rax, %rsi callq 0x2860 movl %eax,...
SimpleButNotNaive[P]AES/aes_abstract.cpp
aes_abstract::print_state()
void aes_abstract::print_state(){ printf("The current state:\n"); for(int i = 0;i < 4;i++){ for(int j = 0;j < 4;j++){ printf("%x ", state[i][j]); } printf("\n"); } }
pushq %rbp movq %rsp, %rbp subq $0x20, %rsp movq %rdi, -0x8(%rbp) movq -0x8(%rbp), %rax movq %rax, -0x18(%rbp) leaq 0x53b1(%rip), %rdi # 0x801c movb $0x0, %al callq 0x2040 movl $0x0, -0xc(%rbp) cmpl $0x4, -0xc(%rbp) jge 0x2cd5 movl $0x0, -0x10(%rbp) cmpl $0x4, -0x10(%rbp) jge 0x2cbc movq -0x18(%rbp), %rax movslq -...
SimpleButNotNaive[P]AES/aes_abstract.cpp
aes_decryptor::ShiftRows()
void aes_decryptor::ShiftRows() { int temp = state[1][3]; for (int i = 3; i >= 1; i--) { state[1][i] = state[1][i - 1]; } state[1][0] = temp; temp = state[2][0]; int temp2 = state[2][1]; for (int i = 2; i < 4; i++) { state[2][i - 2] = state[2][i]; } state[2][2] = tem...
pushq %rbp movq %rsp, %rbp movq %rdi, -0x8(%rbp) movq -0x8(%rbp), %rax movq %rax, -0x28(%rbp) movzbl 0x7(%rax), %eax movl %eax, -0xc(%rbp) movl $0x3, -0x10(%rbp) cmpl $0x1, -0x10(%rbp) jl 0x2d28 movq -0x28(%rbp), %rax movl -0x10(%rbp), %ecx subl $0x1, %ecx movslq %ecx, %rcx movb 0x4(%rax,%rcx), %dl movslq -0x10(%rbp), ...
SimpleButNotNaive[P]AES/decryptor.cpp
aes_decryptor::decryption(std::vector<std::vector<unsigned char, std::allocator<unsigned char>>, std::allocator<std::vector<unsigned char, std::allocator<unsigned char>>>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::alloc...
string aes_decryptor::decryption(vector<vector<uint8>> cipher, string key, string init_vector) { uint8 key_array[16]; for (int i = 0; i < key.size(); i++) { key_array[i] = key[i]; } generate_roundkey(key_array); reverse_round_key(); uint8 pre_y[16]; fo...
pushq %rbp movq %rsp, %rbp subq $0x150, %rsp # imm = 0x150 movq %r8, -0x118(%rbp) movq %rcx, -0x110(%rbp) movq %rdx, -0x108(%rbp) movq %rdi, -0x100(%rbp) movq %rdi, %rax movq %rax, -0xf8(%rbp) movq %rdi, -0x8(%rbp) movq %rsi, -0x10(%rbp) movq %rdx, -0x18(%rbp) movq %rcx, -0x20(%rbp) movq %r8, -0x28(%rbp) mov...
SimpleButNotNaive[P]AES/decryptor.cpp
aes_decryptor::reverse_round_key()
void aes_decryptor::reverse_round_key() { int i = 0, j = 10; uint32 temp; while (i < j) { for(int k = 0;k < 4;k++){ swap(round_key[4*i + k], round_key[4*j + k]); } i++; j--; } }
pushq %rbp movq %rsp, %rbp subq $0x20, %rsp movq %rdi, -0x8(%rbp) movq -0x8(%rbp), %rax movq %rax, -0x20(%rbp) movl $0x0, -0xc(%rbp) movl $0xa, -0x10(%rbp) movl -0xc(%rbp), %eax cmpl -0x10(%rbp), %eax jge 0x326e movl $0x0, -0x18(%rbp) cmpl $0x4, -0x18(%rbp) jge 0x325a movq -0x20(%rbp), %rsi movq %rsi, %rdi addq $0x10, ...
SimpleButNotNaive[P]AES/decryptor.cpp
aes_decryptor::decrypt_one_group(unsigned char*)
void aes_decryptor::decrypt_one_group(uint8 cipher[16]) { current_round = 0; for (int i = 0; i < 16; i++) { state[i % 4][i / 4] = cipher[i]; } AddRoundKey(); for (int i = 1; i < NROUND; i++) { ShiftRows(); SubBytes(); AddRoundKey(); MixColumns(); } S...
pushq %rbp movq %rsp, %rbp subq $0x40, %rsp movq %rdi, -0x8(%rbp) movq %rsi, -0x10(%rbp) movq -0x8(%rbp), %rax movq %rax, -0x28(%rbp) movl $0x0, 0xc0(%rax) movl $0x0, -0x14(%rbp) cmpl $0x10, -0x14(%rbp) jge 0x32ff movq -0x10(%rbp), %rax movslq -0x14(%rbp), %rcx movb (%rax,%rcx), %al movb %al, -0x31(%rbp) movl -0x14(%rb...
SimpleButNotNaive[P]AES/decryptor.cpp
aes_decryptor::splice(unsigned char*, unsigned char*)
void aes_decryptor::splice(uint8* p_text_array, uint8 group[16]){ static int cursor = 0; for(int i = 0;i < 16;i++){ p_text_array[cursor] = group[i]; cursor++; } }
pushq %rbp movq %rsp, %rbp movq %rdi, -0x8(%rbp) movq %rsi, -0x10(%rbp) movq %rdx, -0x18(%rbp) movl $0x0, -0x1c(%rbp) cmpl $0x10, -0x1c(%rbp) jge 0x3410 movq -0x18(%rbp), %rax movslq -0x1c(%rbp), %rcx movb (%rax,%rcx), %dl movq -0x10(%rbp), %rax movslq 0x8f91(%rip), %rcx # 0xc384 movb %dl, (%rax,%rcx) movl 0x8f88(...
SimpleButNotNaive[P]AES/decryptor.cpp
aes_decryptor::MixColumns()
void aes_decryptor::MixColumns() { uint8 new_state[4][4]; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { uint8 n = 0; for (int k = 0; k < 4; k++) { n ^= FieldMul(mix_column_matrix_inv[i][k], state[k][j]); } new_state[i][j] = n;...
pushq %rbp movq %rsp, %rbp subq $0x40, %rsp movq %rdi, -0x8(%rbp) movq -0x8(%rbp), %rax movq %rax, -0x40(%rbp) movl $0x0, -0x24(%rbp) cmpl $0x4, -0x24(%rbp) jge 0x35f0 movl $0x0, -0x28(%rbp) cmpl $0x4, -0x28(%rbp) jge 0x35e0 movb $0x0, -0x29(%rbp) movl $0x0, -0x30(%rbp) cmpl $0x4, -0x30(%rbp) jge 0x35b9 movq -0x40(%rbp...
SimpleButNotNaive[P]AES/decryptor.cpp
aes_encryptor::encryption(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
vector<vector<uint8>> aes_encryptor::encryption(string p_text, string key, string init_vector) { string total_plain_text = padding(p_text); vector<vector<uint8>> text_vector = split(total_plain_text); vector<vector<uint8>> cipher; uint8 key_array[16]; for(int i = 0;i < key.size();i++){ key...
pushq %rbp movq %rsp, %rbp subq $0x1c0, %rsp # imm = 0x1C0 movq %r8, -0x1a0(%rbp) movq %rcx, -0x198(%rbp) movq %rdx, -0x190(%rbp) movq %rsi, %rax movq -0x190(%rbp), %rsi movq %rdi, -0x188(%rbp) movq %rdi, %rdx movq %rdx, -0x180(%rbp) movq %rdi, -0x8(%rbp) movq %rax, -0x10(%rbp) movq %rsi, -0x18(%rbp) movq %r...
SimpleButNotNaive[P]AES/encryptor.cpp
aes_encryptor::padding(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
string aes_encryptor::padding(string s) { char padding[17]; int pad_size; if (s.size() % 16 == 0) { pad_size = 16; } else{ pad_size = 16 - (s.size() - (s.size() / 16) * 16); } for(int i = 0;i < pad_size;i++){ padding[i] = pad_size; } padding[pad_size] = '\0';...
pushq %rbp movq %rsp, %rbp subq $0x60, %rsp movq %rdx, -0x50(%rbp) movq %rdi, %rax movq -0x50(%rbp), %rdi movq %rax, -0x48(%rbp) movq %rax, %rcx movq %rcx, -0x40(%rbp) movq %rax, -0x8(%rbp) movq %rsi, -0x10(%rbp) movq %rdi, -0x18(%rbp) callq 0x20d0 andq $0xf, %rax cmpq $0x0, %rax jne 0x4a42 movl $0x10, -0x34(%rbp) jmp ...
SimpleButNotNaive[P]AES/encryptor.cpp
aes_encryptor::split(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
vector<vector<uint8>> aes_encryptor::split(string s){ int group_number = s.size() / 16; vector<vector<uint8>> ret; for(int i = 0;i < group_number;i++){ vector<uint8> one_group; for(int j = 0;j < 16;j++){ one_group.push_back(s[i * 16 + j]); } ret.push_back(one_grou...
pushq %rbp movq %rsp, %rbp subq $0x80, %rsp movq %rdx, -0x70(%rbp) movq %rdi, %rax movq -0x70(%rbp), %rdi movq %rax, -0x60(%rbp) movq %rax, %rcx movq %rcx, -0x68(%rbp) movq %rax, -0x8(%rbp) movq %rsi, -0x10(%rbp) movq %rdi, -0x18(%rbp) callq 0x20d0 movq -0x60(%rbp), %rdi shrq $0x4, %rax movl %eax, -0x1c(%rbp) movb $0x0...
SimpleButNotNaive[P]AES/encryptor.cpp
aes_encryptor::encrypt_one_group(unsigned char*)
void aes_encryptor::encrypt_one_group(uint8 p_text[16]) { current_round = 0; for (int i = 0; i < 16; i++) { state[i % 4][i / 4] = p_text[i]; } AddRoundKey(); for (int round = 1; round < NROUND; round++) { SubBytes(); ShiftRows(); MixColumns(); AddRoundKey(); ...
pushq %rbp movq %rsp, %rbp subq $0x40, %rsp movq %rdi, -0x8(%rbp) movq %rsi, -0x10(%rbp) movq -0x8(%rbp), %rax movq %rax, -0x28(%rbp) movl $0x0, 0xc0(%rax) movl $0x0, -0x14(%rbp) cmpl $0x10, -0x14(%rbp) jge 0x4c6f movq -0x10(%rbp), %rax movslq -0x14(%rbp), %rcx movb (%rax,%rcx), %al movb %al, -0x31(%rbp) movl -0x14(%rb...
SimpleButNotNaive[P]AES/encryptor.cpp
main
int main() { aes_encryptor encrypter; aes_decryptor decryptor; vector<vector<uint8>> cipher; cipher = encrypter.encryption(plain_text, key, IV); printf("密文:\n"); for (auto group : cipher) { for (int i = 0; i < group.size(); i++) { if (group[i] <= 0x0f) prin...
pushq %rbp movq %rsp, %rbp subq $0x2f0, %rsp # imm = 0x2F0 movl $0x0, -0x4(%rbp) leaq -0xc8(%rbp), %rdi callq 0x68b0 leaq -0x18c(%rbp), %rdi callq 0x68d0 leaq -0x1a8(%rbp), %rdi callq 0x4d30 leaq 0x5f0b(%rip), %rsi # 0xc388 leaq -0x1e0(%rbp), %rdi callq 0x20a0 jmp 0x648b leaq 0x5f16(%rip), %rsi # 0...
SimpleButNotNaive[P]AES/main.cpp
main
int main(int argc, char *argv[]) { if (argc != 2) { // 判断参数, 给出用法提示 cout << "Usage:" << endl; cout << "./main <file_name>" << endl; return 0; } read.open(string(argv[1]), ios::in); readin(); scanning = true; bool printParse = true; TreeNode* root = parse(printParse);...
pushq %rbp movq %rsp, %rbp subq $0x60, %rsp movl $0x0, -0x4(%rbp) movl %edi, -0x8(%rbp) movq %rsi, -0x10(%rbp) cmpl $0x2, -0x8(%rbp) je 0x4dac movq 0x29265(%rip), %rdi # 0x2dfc8 leaq 0x1c29a(%rip), %rsi # 0x21004 callq 0x3270 movq %rax, %rdi movq 0x29237(%rip), %rsi # 0x2dfb0 callq 0x32b0 movq 0x29243(%rip)...
JameyWoo[P]csmile/main.cpp
readin()
void readin() { // 读取源文件按行写入到words数组中 int cnt = 0; string str_tmp; while (getline(read, str_tmp)) // 一行一行读入 words.push_back(str_tmp); words.push_back("EOF"); }
pushq %rbp movq %rsp, %rbp subq $0x80, %rsp movl $0x0, -0x4(%rbp) leaq -0x28(%rbp), %rdi callq 0x33b0 leaq 0x29086(%rip), %rdi # 0x2e2e8 leaq -0x28(%rbp), %rsi callq 0x30a0 movq %rax, -0x68(%rbp) jmp 0x5271 movq -0x68(%rbp), %rdi movq (%rdi), %rax movq -0x18(%rax), %rax addq %rax, %rdi callq 0x3370 movb %al, -0x69(...
JameyWoo[P]csmile/scan.cpp
getNextChar(int&)
char getNextChar(int &line) { // 获取下一个字符 if (position >= cur_str.size()) { cur_str = words[++word_cnt]; if (cur_str == "EOF") { scanning = false; return EOF; } cur_str += ' '; // 默认加一个空格. 因为如果独立两行都没有空格的话, 会被合并 position = 0; } position += 1; ...
pushq %rbp movq %rsp, %rbp subq $0x20, %rsp movq %rdi, -0x10(%rbp) movq 0x29215(%rip), %rax # 0x2e578 movq %rax, -0x18(%rbp) leaq 0x291d2(%rip), %rdi # 0x2e540 callq 0x31d0 movq %rax, %rcx movq -0x18(%rbp), %rax cmpq %rcx, %rax jb 0x53ee movl 0x28f07(%rip), %eax # 0x2e28c addl $0x1, %eax movl %eax, 0x28efe(...
JameyWoo[P]csmile/scan.cpp
getToken()
Token getToken() { // 获取token, 主函数里循环调用 string currentToken; // 当前token string token_value; int line; StateType state = START; bool save; // save 表示是否保存该字符 while (state != DONE) { char c = getNextChar(line); save = true; //...
pushq %rbp movq %rsp, %rbp subq $0x150, %rsp # imm = 0x150 movq %rdi, -0x118(%rbp) movq %rdi, %rax movq %rax, -0x110(%rbp) movq %rdi, -0x8(%rbp) leaq -0x28(%rbp), %rdi callq 0x33b0 leaq -0x48(%rbp), %rdi callq 0x33b0 movl $0x0, -0x50(%rbp) cmpl $0x4, -0x50(%rbp) je 0x5a15 leaq -0x4c(%rbp), %rdi callq 0x5350 ...
JameyWoo[P]csmile/scan.cpp
match(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
Token match(string expected) { Token tmp = ptoken; // cout << "ptoken.type = " << ptoken.type << " ptoken.val = " << ptoken.value << endl; // cout << "expected: " << expected << endl; // 匹配一个类型 if (ptoken.type == expected) { // cout << "match: " << ptoken.value << endl; if (ptoken.ty...
pushq %rbp movq %rsp, %rbp subq $0x90, %rsp movq %rsi, -0x78(%rbp) movq %rdi, -0x88(%rbp) movq %rdi, %rax movq %rax, -0x80(%rbp) movq %rdi, -0x8(%rbp) movq %rsi, -0x10(%rbp) movb $0x0, -0x11(%rbp) leaq 0x264a8(%rip), %rsi # 0x2e588 callq 0x7a00 movq -0x78(%rbp), %rsi leaq 0x26498(%rip), %rdi # 0x2e588 callq 0x7...
JameyWoo[P]csmile/parse.cpp
param(TreeNode*)
TreeNode* param(TreeNode* k) { TreeNode* t = new TreeNode("Param"); TreeNode* p = NULL; TreeNode* q = NULL; if (k == NULL && ptoken.type == "void") { p = new TreeNode("void"); match("void"); } else if (k == NULL && ptoken.type == "int") { p = new TreeNode("int"); matc...
pushq %rbp movq %rsp, %rbp subq $0x280, %rsp # imm = 0x280 movq %rdi, -0x8(%rbp) movl $0xe0, %edi callq 0x3280 movq %rax, -0x230(%rbp) movb $0x1, -0x45(%rbp) leaq -0x31(%rbp), %rdi movq %rdi, -0x228(%rbp) callq 0x3480 movq -0x228(%rbp), %rdx leaq 0x18fbf(%rip), %rsi # 0x211a1 leaq -0x30(%rbp), %rdi callq...
JameyWoo[P]csmile/parse.cpp
param_list(TreeNode*)
TreeNode* param_list(TreeNode* k) { // TODO: 到这里暂停, 明天再写. 完善函数的操作 TreeNode* t = param(k); // 先读一个参数 TreeNode* p = t; k = NULL; while (ptoken.type == "Comma") { // 如果读到逗号, 说明还有下一个参数 match("Comma"); TreeNode* q = param(k); if (q != NULL) { if (t == NULL)...
pushq %rbp movq %rsp, %rbp subq $0xb0, %rsp movq %rdi, -0x8(%rbp) movq -0x8(%rbp), %rdi callq 0x81a0 movq %rax, -0x10(%rbp) movq -0x10(%rbp), %rax movq %rax, -0x18(%rbp) movq $0x0, -0x8(%rbp) leaq 0x25d95(%rip), %rdi # 0x2e588 leaq 0x188f8(%rip), %rsi # 0x210f2 callq 0x5e70 testb $0x1, %al jne 0x8808 jmp 0x88f1...
JameyWoo[P]csmile/parse.cpp
params()
TreeNode* params() { TreeNode* t = new TreeNode("Params"); // 根节点, 参数s TreeNode* p = NULL; if (ptoken.type == "void") { p = new TreeNode("void"); match("void"); if (ptoken.type == "RightBracket") { if (t != NULL) { t->child[0] = p; t->chi...
pushq %rbp movq %rsp, %rbp subq $0x110, %rsp # imm = 0x110 movl $0xe0, %edi callq 0x3280 movq %rax, -0xf0(%rbp) movb $0x1, -0x3d(%rbp) leaq -0x29(%rbp), %rdi movq %rdi, -0xe8(%rbp) callq 0x3480 movq -0xe8(%rbp), %rdx leaq 0x18861(%rip), %rsi # 0x211af leaq -0x28(%rbp), %rdi callq 0x4ef0 jmp 0x8959 movq -...
JameyWoo[P]csmile/parse.cpp
local_declaration()
TreeNode* local_declaration() { /** * 一系列的局部声明 */ TreeNode* t = NULL; TreeNode* p = NULL; TreeNode* q = NULL; while (ptoken.type == "int") { p = new TreeNode("LocVarDecl"); // 局部变量声明, 只有int类型 TreeNode* q1 = new TreeNode("int"); p->child[0] = q1; ...
pushq %rbp movq %rsp, %rbp subq $0x430, %rsp # imm = 0x430 movq $0x0, -0x8(%rbp) movq $0x0, -0x10(%rbp) movq $0x0, -0x18(%rbp) leaq 0x2596e(%rip), %rdi # 0x2e588 leaq 0x184d7(%rip), %rsi # 0x210f8 callq 0x5e70 testb $0x1, %al jne 0x8c2f jmp 0x9422 movl $0xe0, %edi callq 0x3280 movq %rax, -0x3d0(%rbp)...
JameyWoo[P]csmile/parse.cpp
selection_stmt()
TreeNode* selection_stmt() { TreeNode* t = new TreeNode("Selection"); match("if"); match("LeftBracket"); if (t != NULL) { t->child[0] = expression(); } match("RightBracket"); bool has_bracket = false; if (ptoken.type == "LeftBigBkt") { has_bracket = true; match("L...
pushq %rbp movq %rsp, %rbp subq $0x410, %rsp # imm = 0x410 movl $0xe0, %edi callq 0x3280 movq %rax, -0x3d0(%rbp) movb $0x1, -0x3d(%rbp) leaq -0x29(%rbp), %rdi movq %rdi, -0x3c8(%rbp) callq 0x3480 movq -0x3c8(%rbp), %rdx leaq 0x17d43(%rip), %rsi # 0x211c1 leaq -0x28(%rbp), %rdi callq 0x4ef0 jmp 0x9489 mov...
JameyWoo[P]csmile/parse.cpp
expression()
TreeNode* expression() { // cout << "expression token: " << ptoken.type << endl; if (ptoken.type == "input") { // 如果是输入 TreeNode* input = new TreeNode("Input"); match("input"); match("LeftBracket"); match("RightBracket"); return input; } else if (ptoken.type == "outp...
pushq %rbp movq %rsp, %rbp subq $0x430, %rsp # imm = 0x430 leaq 0x24a76(%rip), %rdi # 0x2e588 leaq 0x175fd(%rip), %rsi # 0x21116 callq 0x5e70 testb $0x1, %al jne 0x9b27 jmp 0x9dcc movl $0xe0, %edi callq 0x3280 movq %rax, -0x3d0(%rbp) movb $0x1, -0x45(%rbp) leaq -0x31(%rbp), %rdi movq %rdi, -0x3c8(%rb...
JameyWoo[P]csmile/parse.cpp
statement_list()
TreeNode* statement_list() { /** * 一系列的语句 */ TreeNode* t = statement(); TreeNode* p = t; // 判断哪些token可以做为statement的开始 while (ptoken.type == "if" || ptoken.type == "Id" || ptoken.type == "while" || ptoken.type == "return" || ptoken.type == "semicolon" || ptoken.type == "input" ||...
pushq %rbp movq %rsp, %rbp subq $0x20, %rsp callq 0xbda0 movq %rax, -0x8(%rbp) movq -0x8(%rbp), %rax movq %rax, -0x10(%rbp) leaq 0x24258(%rip), %rdi # 0x2e588 leaq 0x16dca(%rip), %rsi # 0x21101 callq 0x5e70 movb %al, %cl movb $0x1, %al testb $0x1, %cl movb %al, -0x19(%rbp) jne 0xa401 leaq 0x24235(%rip), %rdi ...
JameyWoo[P]csmile/parse.cpp
iteration_stmt()
TreeNode* iteration_stmt() { TreeNode* t = new TreeNode("Iteration"); match("while"); match("LeftBracket"); if (t != NULL) { t->child[0] = expression(); } match("RightBracket"); match("LeftBigBkt"); if (t != NULL) { t->child[1] = statement_list(); } match("RightBi...
pushq %rbp movq %rsp, %rbp subq $0x2b0, %rsp # imm = 0x2B0 movl $0xe0, %edi callq 0x3280 movq %rax, -0x280(%rbp) movb $0x1, -0x3d(%rbp) leaq -0x29(%rbp), %rdi movq %rdi, -0x278(%rbp) callq 0x3480 movq -0x278(%rbp), %rdx leaq 0x16d2d(%rip), %rsi # 0x211cb leaq -0x28(%rbp), %rdi callq 0x4ef0 jmp 0xa4a9 mov...
JameyWoo[P]csmile/parse.cpp
var()
TreeNode* var() { TreeNode* t = NULL; TreeNode* p = NULL; if (ptoken.type == "Id") { p = new TreeNode("Id"); p->name = ptoken.value; p->line = ptoken.line; match("Id"); // TODO: 添加数组 t = p; // 非数组时 } return t; }
pushq %rbp movq %rsp, %rbp subq $0xd0, %rsp movq $0x0, -0x8(%rbp) movq $0x0, -0x10(%rbp) leaq 0x23cd6(%rip), %rdi # 0x2e588 leaq 0x168f3(%rip), %rsi # 0x211ac callq 0x5e70 testb $0x1, %al jne 0xa8c7 jmp 0xaa49 movl $0xe0, %edi callq 0x3280 movq %rax, -0xc8(%rbp) movb $0x1, -0x45(%rbp) leaq -0x31(%rbp), %rdi mov...
JameyWoo[P]csmile/parse.cpp
args()
TreeNode* args() { TreeNode* t = new TreeNode("Args"); TreeNode *s = NULL, *p = NULL; if (ptoken.type != "RightBracket") { s = expression(); p = s; while (ptoken.type == "Comma") { TreeNode* q; match("Comma"); q = expression(); if (q !=...
pushq %rbp movq %rsp, %rbp subq $0xe0, %rsp movl $0xe0, %edi callq 0x3280 movq %rax, -0xd8(%rbp) movb $0x1, -0x3d(%rbp) leaq -0x29(%rbp), %rdi movq %rdi, -0xd0(%rbp) callq 0x3480 movq -0xd0(%rbp), %rdx leaq 0x16737(%rip), %rsi # 0x211d5 leaq -0x28(%rbp), %rdi callq 0x4ef0 jmp 0xaaa9 movq -0xd8(%rbp), %rdi leaq -0x2...
JameyWoo[P]csmile/parse.cpp
call(TreeNode*)
TreeNode* call(TreeNode* k) { TreeNode* t = new TreeNode("Call"); if (k != NULL) { t->child[0] = k; } match("LeftBracket"); if (ptoken.type == "RightBracket") { match("RightBracket"); return t; } else if (k != NULL) { t->child[1] = args(); match("RightBrac...
pushq %rbp movq %rsp, %rbp subq $0x1d0, %rsp # imm = 0x1D0 movq %rdi, -0x10(%rbp) movl $0xe0, %edi callq 0x3280 movq %rax, -0x1b0(%rbp) movb $0x1, -0x4d(%rbp) leaq -0x39(%rbp), %rdi movq %rdi, -0x1a8(%rbp) callq 0x3480 movq -0x1a8(%rbp), %rdx leaq 0x16508(%rip), %rsi # 0x211da leaq -0x38(%rbp), %rdi call...
JameyWoo[P]csmile/parse.cpp
factor(TreeNode*)
TreeNode* factor(TreeNode* k) { TreeNode* t = NULL; if (k != NULL) { if (ptoken.type == "LeftBracket" && k->nodekind != "ArrayElem") { // TODO: 数组元素 t = call(k); } else { t = k; } } else { if (ptoken.type == "LeftBracket") { match("LeftBra...
pushq %rbp movq %rsp, %rbp subq $0x210, %rsp # imm = 0x210 movq %rdi, -0x8(%rbp) movq $0x0, -0x10(%rbp) cmpq $0x0, -0x8(%rbp) je 0xb01d leaq 0x235b3(%rip), %rdi # 0x2e588 leaq 0x160d4(%rip), %rsi # 0x210b0 callq 0x5e70 testb $0x1, %al jne 0xafe7 jmp 0xb010 movq -0x8(%rbp), %rdi addq $0x30, %rdi leaq ...
JameyWoo[P]csmile/parse.cpp
term(TreeNode*)
TreeNode* term(TreeNode* k) { TreeNode* t = factor(k); k = NULL; while (ptoken.type == "MDOP") { TreeNode* q = new TreeNode("MDOp"); q->op = ptoken.value; q->child[0] = t; match(ptoken.type); q->child[1] = term(k); t = q; } re...
pushq %rbp movq %rsp, %rbp subq $0xd0, %rsp movq %rdi, -0x8(%rbp) movq -0x8(%rbp), %rdi callq 0xafb0 movq %rax, -0x10(%rbp) movq $0x0, -0x8(%rbp) leaq 0x2311d(%rip), %rdi # 0x2e588 leaq 0x15c39(%rip), %rsi # 0x210ab callq 0x5e70 testb $0x1, %al jne 0xb480 jmp 0xb5dc movl $0xe0, %edi callq 0x3280 movq %rax, -0xc...
JameyWoo[P]csmile/parse.cpp
additive_expression(TreeNode*)
TreeNode* additive_expression(TreeNode* k) { TreeNode* t = term(k); k = NULL; while (ptoken.type == "PMOP") { // 加减 TreeNode* q = new TreeNode("PMOp"); q->op = ptoken.value; q->child[0] = t; match("PMOP"); q->child[1] = term(k); t = ...
pushq %rbp movq %rsp, %rbp subq $0xe0, %rsp movq %rdi, -0x8(%rbp) movq -0x8(%rbp), %rdi callq 0xb440 movq %rax, -0x10(%rbp) movq $0x0, -0x8(%rbp) leaq 0x22f5d(%rip), %rdi # 0x2e588 leaq 0x15a74(%rip), %rsi # 0x210a6 callq 0x5e70 testb $0x1, %al jne 0xb640 jmp 0xb7d7 movl $0xe0, %edi callq 0x3280 movq %rax, -0xd...
JameyWoo[P]csmile/parse.cpp
simple_expression(TreeNode*)
TreeNode* simple_expression(TreeNode* k) { // 这里会处理只有一个整数的情况 TreeNode* t = additive_expression(k); k = NULL; if (ptoken.type == "CompareOp") { // 比较 TreeNode* q = new TreeNode("CompareOp"); q->line = ptoken.line; q->op = ptoken.value; q->child[0] = t;...
pushq %rbp movq %rsp, %rbp subq $0xe0, %rsp movq %rdi, -0x10(%rbp) movq -0x10(%rbp), %rdi callq 0xb600 movq %rax, -0x18(%rbp) movq $0x0, -0x10(%rbp) leaq 0x22d6d(%rip), %rdi # 0x2e588 leaq 0x1586f(%rip), %rsi # 0x21091 callq 0x5e70 testb $0x1, %al jne 0xb830 jmp 0xb9ac movl $0xe0, %edi callq 0x3280 movq %rax, -...
JameyWoo[P]csmile/parse.cpp
return_stmt()
TreeNode* return_stmt() { TreeNode* t = new TreeNode("ReturnStmt"); match("return"); // cout << "exp 之前 -- 0" << endl; if (ptoken.type == "Semicolon") { match("Semicolon"); return t; } else { if (t != NULL) { // cout << "exp 之前" << endl; t->child[0] =...
pushq %rbp movq %rsp, %rbp subq $0x1c0, %rsp # imm = 0x1C0 movl $0xe0, %edi callq 0x3280 movq %rax, -0x1a8(%rbp) movb $0x1, -0x45(%rbp) leaq -0x31(%rbp), %rdi movq %rdi, -0x1a0(%rbp) callq 0x3480 movq -0x1a0(%rbp), %rdx leaq 0x157f8(%rip), %rsi # 0x21206 leaq -0x30(%rbp), %rdi callq 0x4ef0 jmp 0xba19 mov...
JameyWoo[P]csmile/parse.cpp
expression_stmt()
TreeNode* expression_stmt() { TreeNode* t = NULL; t = expression(); match("Semicolon"); return t; }
pushq %rbp movq %rsp, %rbp subq $0x90, %rsp movq $0x0, -0x8(%rbp) callq 0x9b00 movq %rax, -0x8(%rbp) leaq -0x71(%rbp), %rdi movq %rdi, -0x90(%rbp) callq 0x3480 movq -0x90(%rbp), %rdx leaq 0x153af(%rip), %rsi # 0x210c9 leaq -0x70(%rbp), %rdi callq 0x4ef0 jmp 0xbd25 leaq -0x50(%rbp), %rdi leaq -0x70(%rbp), %rsi callq...
JameyWoo[P]csmile/parse.cpp
statement()
TreeNode* statement() { TreeNode* t = NULL; if (ptoken.type == "if") { t = selection_stmt(); } else if (ptoken.type == "while") { t = iteration_stmt(); } else if (ptoken.type == "return") { t = return_stmt(); } else if (ptoken.type == "Id") { t = expression_stmt(); ...
pushq %rbp movq %rsp, %rbp subq $0x10, %rsp movq $0x0, -0x8(%rbp) leaq 0x227d1(%rip), %rdi # 0x2e588 leaq 0x15343(%rip), %rsi # 0x21101 callq 0x5e70 testb $0x1, %al jne 0xbdc9 jmp 0xbdd7 callq 0x9440 movq %rax, -0x8(%rbp) jmp 0xbe87 leaq 0x227aa(%rip), %rdi # 0x2e588 leaq 0x15324(%rip), %rsi # 0x21109 c...
JameyWoo[P]csmile/parse.cpp
compound_stmt()
TreeNode* compound_stmt() { // * 解析函数体 TreeNode* t = new TreeNode("Compound"); // 函数体 match("LeftBigBkt"); t->child[0] = local_declaration(); // 声明都在前面, 以sibling连接 t->child[1] = statement_list(); // 下面是各种语句, 以sibling连接 if (t->child[0] == NULL) { t->child[0] = t->child[...
pushq %rbp movq %rsp, %rbp subq $0x140, %rsp # imm = 0x140 movl $0xe0, %edi callq 0x3280 movq %rax, -0x130(%rbp) movb $0x1, -0x3d(%rbp) leaq -0x29(%rbp), %rdi movq %rdi, -0x128(%rbp) callq 0x3480 movq -0x128(%rbp), %rdx leaq 0x15344(%rip), %rsi # 0x21222 leaq -0x28(%rbp), %rdi callq 0x4ef0 jmp 0xbee9 mov...
JameyWoo[P]csmile/parse.cpp
declaration()
TreeNode* declaration() { /** * 对声明(函数/变量)的递归下降分析 */ TreeNode* t; TreeNode* p; // cout << ptoken.type << ": " << ptoken.value << endl; if (ptoken.type == "int") { p = new TreeNode("int"); match("int"); } else { p = new TreeNode("void"); match("void"); ...
pushq %rbp movq %rsp, %rbp subq $0x5c0, %rsp # imm = 0x5C0 leaq 0x22466(%rip), %rdi # 0x2e588 leaq 0x14fcf(%rip), %rsi # 0x210f8 callq 0x5e70 testb $0x1, %al jne 0xc137 jmp 0xc296 movl $0xe0, %edi callq 0x3280 movq %rax, -0x518(%rbp) movb $0x1, -0x45(%rbp) leaq -0x31(%rbp), %rdi movq %rdi, -0x510(%rb...
JameyWoo[P]csmile/parse.cpp
declaration_list()
TreeNode* declaration_list() { /** * 不断检测声明 * 包括函数声明和变量声明. */ TreeNode* t = declaration(); // 检测一个声明 TreeNode* p = t; // while (ptoken.type != "int" && ptoken.type != "void" && ptoken.type != "EndFile") { // ptoken = getToken(); // if (ptoken.type == "EndFile") break; ...
pushq %rbp movq %rsp, %rbp subq $0xa0, %rsp callq 0xc110 movq %rax, -0x8(%rbp) movq -0x8(%rbp), %rax movq %rax, -0x10(%rbp) leaq 0x217d5(%rip), %rdi # 0x2e588 leaq 0x1433e(%rip), %rsi # 0x210f8 callq 0x5e70 movb %al, %cl movb $0x1, %al testb $0x1, %cl movb %al, -0x95(%rbp) jne 0xcde7 leaq 0x217b3(%rip), %rdi ...
JameyWoo[P]csmile/parse.cpp
preOrder(TreeNode*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void preOrder(TreeNode* t, string indent) { // if (t != NULL) // out << "t->nodekind = " << t->nodekind << endl; if (t == NULL) { out << "NULL!" << endl; return; } if (t->nodekind == "FunDecl") { out << indent << "FunctionDeclaration {\n" << indent << " type:...
pushq %rbp movq %rsp, %rbp subq $0x170, %rsp # imm = 0x170 movq %rsi, -0x108(%rbp) movq %rdi, -0x8(%rbp) movq %rsi, -0x10(%rbp) cmpq $0x0, -0x8(%rbp) jne 0xcf28 leaq 0x216c8(%rip), %rdi # 0x2e5d0 leaq 0x1432e(%rip), %rsi # 0x2123d callq 0x3270 movq %rax, %rdi movq 0x21092(%rip), %rsi # 0x2dfb0 ca...
JameyWoo[P]csmile/parse.cpp
printParse(TreeNode*)
void printParse(TreeNode* t) { out << "Program:{\n" << " type: program,\n" << " body: [\n"; string indent = " "; preOrder(t, indent); out << " ]\n" << "}\n"; out.close(); // ifstream in("parse.txt", ios::in); // 输出到控制台 // string s; // while (getline(in, ...
pushq %rbp movq %rsp, %rbp subq $0x90, %rsp movq %rdi, -0x8(%rbp) leaq 0x20cea(%rip), %rdi # 0x2e5d0 leaq 0x139fe(%rip), %rsi # 0x212eb callq 0x3270 movq %rax, %rdi leaq 0x139fa(%rip), %rsi # 0x212f6 callq 0x3270 movq %rax, %rdi leaq 0x139b6(%rip), %rsi # 0x212c1 callq 0x3270 leaq -0x29(%rbp), %rdi movq...
JameyWoo[P]csmile/parse.cpp
parse(bool)
TreeNode* parse(bool print) { TreeNode* t; ptoken = getToken(); // 获取第一个token, 开始语法分析 t = declaration_list(); // 获取声明列表, c-由一系列整数/函数声明组成 if (print) { printParse(t); cout << "parse print over !" << endl; } return t; }
pushq %rbp movq %rsp, %rbp subq $0x60, %rsp movb %dil, %al andb $0x1, %al movb %al, -0x1(%rbp) leaq -0x58(%rbp), %rdi callq 0x5460 leaq 0x20b18(%rip), %rdi # 0x2e588 leaq -0x58(%rbp), %rsi callq 0xdb00 leaq -0x58(%rbp), %rdi callq 0x4ec0 callq 0xcd90 movq %rax, -0x10(%rbp) testb $0x1, -0x1(%rbp) je 0xdabc movq -0x1...
JameyWoo[P]csmile/parse.cpp
buildSymtab(TreeNode*)
void buildSymtab(TreeNode *syntaxTree) { traverse(syntaxTree, insertNode, nullProc); if (not isError) { cout << "\nprinting symtab ..." << endl; printSymtab(); cout << "print over !\n" << endl; cout << "symtab build over, everything is ok! congratulations!" << e...
pushq %rbp movq %rsp, %rbp subq $0x10, %rsp movq %rdi, -0x8(%rbp) movq -0x8(%rbp), %rdi leaq 0x169(%rip), %rsi # 0xdfd0 leaq 0x7e2(%rip), %rdx # 0xe650 callq 0xdf50 cmpl $0x0, 0x20b66(%rip) # 0x2e9e0 jne 0xdef8 movq 0x20145(%rip), %rdi # 0x2dfc8 leaq 0x134b4(%rip), %rsi # 0x2133e callq 0x3270 mo...
JameyWoo[P]csmile/analyze.cpp
traverse(TreeNode*, void (*)(TreeNode*), void (*)(TreeNode*))
static void traverse(TreeNode *t, void (*preProc)(TreeNode *), void (*postProc)(TreeNode *)) { if (t != NULL) { preProc(t); for (int i = 0; i < MAX_CHILDREN; ++i) { traverse(t->child[i], preProc, postProc); } postProc(t); traverse(t->sibling, preProc, postProc); ...
pushq %rbp movq %rsp, %rbp subq $0x20, %rsp movq %rdi, -0x8(%rbp) movq %rsi, -0x10(%rbp) movq %rdx, -0x18(%rbp) cmpq $0x0, -0x8(%rbp) je 0xdfc5 movq -0x10(%rbp), %rax movq -0x8(%rbp), %rdi callq *%rax movl $0x0, -0x1c(%rbp) cmpl $0x4, -0x1c(%rbp) jge 0xdfa6 movq -0x8(%rbp), %rax movslq -0x1c(%rbp), %rcx movq (%rax,%rcx...
JameyWoo[P]csmile/analyze.cpp
insertNode(TreeNode*)
static void insertNode(TreeNode *t) { if (t->nodekind == "FunDecl") { // 新的函数, 新的作用域 newSymtabs(); fun_names.push_back(t->child[1]->name); if (t->child[0]->nodekind == "int") { t->type = "Integer"; fun_name2ret_type[t->child[1]->na...
pushq %rbp movq %rsp, %rbp subq $0x220, %rsp # imm = 0x220 movq %rdi, -0x8(%rbp) movq -0x8(%rbp), %rdi addq $0x30, %rdi leaq 0x13247(%rip), %rsi # 0x21235 callq 0x5e70 testb $0x1, %al jne 0xdffc jmp 0xe0d8 callq 0x108b0 movq -0x8(%rbp), %rax movq 0x8(%rax), %rsi addq $0xc0, %rsi leaq 0x209d1(%rip), %rdi ...
JameyWoo[P]csmile/analyze.cpp
nullProc(TreeNode*)
static void nullProc(TreeNode *t) { if (t == NULL) return; else return; }
pushq %rbp movq %rsp, %rbp movq %rdi, -0x8(%rbp) cmpq $0x0, -0x8(%rbp) jne 0xe661 jmp 0xe663 jmp 0xe663 popq %rbp retq nopw %cs:(%rax,%rax)
JameyWoo[P]csmile/analyze.cpp
typeCheck(TreeNode*)
void typeCheck(TreeNode *syntaxTree) { traverse(syntaxTree, nullProc, checkNode); if (typeError) { cout << "type check over, your have " << typeError << " errors, please check!" << endl << endl; } else { cout << "type check over, everything is ok! congratulations!" << endl ...
pushq %rbp movq %rsp, %rbp subq $0x10, %rsp movq %rdi, -0x8(%rbp) movq -0x8(%rbp), %rdi leaq -0x37(%rip), %rsi # 0xe650 leaq 0xa2(%rip), %rdx # 0xe730 callq 0xdf50 cmpl $0x0, 0x2034a(%rip) # 0x2e9e4 je 0xe6ec movq 0x1f925(%rip), %rdi # 0x2dfc8 leaq 0x12d18(%rip), %rsi # 0x213c2 callq 0x3270 mov...
JameyWoo[P]csmile/analyze.cpp
checkNode(TreeNode*)
static void checkNode(TreeNode *t) { // symtabOut << t->nodekind << endl; // 添加对函数类型的生成 // 由于是后序遍历, 函数的类型是最后检查的... if (t->nodekind == "FunDecl") { // error("func..."); if (t->child[0]->nodekind == "int") t->type = "Integer"; else if (t->child[0]->nodekind == "void") ...
pushq %rbp movq %rsp, %rbp subq $0x170, %rsp # imm = 0x170 movq %rdi, -0x8(%rbp) movq -0x8(%rbp), %rdi addq $0x30, %rdi leaq 0x12ae7(%rip), %rsi # 0x21235 callq 0x5e70 testb $0x1, %al jne 0xe759 jmp 0xe7c4 movq -0x8(%rbp), %rax movq (%rax), %rdi addq $0x30, %rdi leaq 0x1298d(%rip), %rsi # 0x210f8 cal...
JameyWoo[P]csmile/analyze.cpp
newSymtabs()
void newSymtabs() { // 只有当符号表不为空地时候建立 if (symtabs.size() != 0) { vec_symtabs.push_back(symtabs); } symtabs.clear(); }
pushq %rbp movq %rsp, %rbp leaq 0x1e19d(%rip), %rdi # 0x2ea58 callq 0x11100 cmpq $0x0, %rax je 0x108d9 leaq 0x1e173(%rip), %rdi # 0x2ea40 leaq 0x1e184(%rip), %rsi # 0x2ea58 callq 0x11120 leaq 0x1e178(%rip), %rdi # 0x2ea58 callq 0x11190 popq %rbp retq nopw (%rax,%rax)
JameyWoo[P]csmile/symtab.cpp
st_lookup(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
int st_lookup(string name) { if (symtabs.count(name) == 0) { return -1; } else { return symtabs[name].addr; } }
pushq %rbp movq %rsp, %rbp subq $0x20, %rsp movq %rdi, %rsi movq %rsi, -0x18(%rbp) movq %rsi, -0x10(%rbp) leaq 0x1e14e(%rip), %rdi # 0x2ea58 callq 0x111b0 cmpq $0x0, %rax jne 0x1091e movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF jmp 0x10934 movq -0x18(%rbp), %rsi leaq 0x1e12f(%rip), %rdi # 0x2ea58 callq 0x112...
JameyWoo[P]csmile/symtab.cpp
st_insert(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int, int, int)
void st_insert(string name, int lineno, int loc, int rank) { if (count(fun_names.begin(), fun_names.end(), name) != 0) return; if (rank == 2 || rank == 3) { // symtabOut << "insert: " << name << endl; if (loc == -1) { // 当这个变量存在在符号表中时 symtabs[name].line.push_back(lineno); } ...
pushq %rbp movq %rsp, %rbp subq $0xd0, %rsp movq %rdi, -0xb8(%rbp) movq %rdi, -0x8(%rbp) movl %esi, -0xc(%rbp) movl %edx, -0x10(%rbp) movl %ecx, -0x14(%rbp) leaq 0x1e082(%rip), %rdi # 0x2e9e8 callq 0x5ef0 movq %rax, -0x20(%rbp) leaq 0x1e072(%rip), %rdi # 0x2e9e8 callq 0x5f20 movq -0xb8(%rbp), %rdx movq %rax, -0...
JameyWoo[P]csmile/symtab.cpp
printSymtab()
void printSymtab() { vec_symtabs.push_back(symtabs); symtabOut << "-------------------" << endl; for (auto symtabs: vec_symtabs) { symtabOut << "function: " << fun_names.front() << endl; fun_names.erase(fun_names.begin()); symtabOut << "id -- Param --- lines\n"; for (auto son...
pushq %rbp movq %rsp, %rbp subq $0x170, %rsp # imm = 0x170 leaq 0x1de7e(%rip), %rdi # 0x2ea40 leaq 0x1de8f(%rip), %rsi # 0x2ea58 callq 0x11120 leaq 0x1dc0b(%rip), %rdi # 0x2e7e0 leaq 0x109ed(%rip), %rsi # 0x215c9 callq 0x3270 movq %rax, %rdi movq 0x1d3c5(%rip), %rsi # 0x2dfb0 callq 0x32b0...
JameyWoo[P]csmile/symtab.cpp
cGen[abi:cxx11](TreeNode*)
string cGen(TreeNode* root) { if (root == NULL) return ""; emitComment(root->nodekind); TreeNode* p1, *p2, *p3; if ("FunDecl" == root->nodekind) { p1 = root->child[2]; p2 = root->child[3]; // TODO: 添加函数参数的中间代码 cGen(p2); cGen(root->sibling); } else if ("Compoun...
pushq %rbp movq %rsp, %rbp subq $0xa00, %rsp # imm = 0xA00 movq %rdi, -0x980(%rbp) movq %rdi, %rax movq %rax, -0x978(%rbp) movq %rdi, -0x8(%rbp) movq %rsi, -0x10(%rbp) cmpq $0x0, -0x10(%rbp) jne 0x15cef leaq -0x11(%rbp), %rdi movq %rdi, -0x988(%rbp) callq 0x3480 movq -0x980(%rbp), %rdi movq -0x988(%rbp), %rd...
JameyWoo[P]csmile/cgen.cpp
getParams(TreeNode*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void getParams(TreeNode* params, string func_name) { if (params == NULL) return; // debug("params->child[0]->nodekind : " + params->child[0]->nodekind); if (params->child[0]->nodekind == "void") { // debug("param void"); return; } vector<string> param_stack; map<string, string> ...
pushq %rbp movq %rsp, %rbp subq $0x100, %rsp # imm = 0x100 movq %rsi, -0xd0(%rbp) movq %rdi, -0x8(%rbp) movq %rsi, -0x10(%rbp) cmpq $0x0, -0x8(%rbp) jne 0x177f6 jmp 0x179e3 movq -0x8(%rbp), %rax movq (%rax), %rdi addq $0x30, %rdi leaq 0x98f4(%rip), %rsi # 0x210fc callq 0x5e70 testb $0x1, %al jne 0x17813...
JameyWoo[P]csmile/assembly.cpp
genLocVarDecl(TreeNode*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
int genLocVarDecl(TreeNode* vars, string func_name) { if (vars == NULL) return 0; // debug(vars->child[0]->name); // ! 需要统计有多少个局部变量, 以分配初始的栈空间 stack<string> var_stack; map<string, string> var2stack; int var_cnt = 0; TreeNode* var = vars; while (var != NULL) { var_cnt += 1; ...
pushq %rbp movq %rsp, %rbp subq $0x130, %rsp # imm = 0x130 movq %rsi, -0x100(%rbp) movq %rdi, -0x10(%rbp) movq %rsi, -0x18(%rbp) cmpq $0x0, -0x10(%rbp) jne 0x17a3d movl $0x0, -0x4(%rbp) jmp 0x17c4a leaq -0x68(%rbp), %rdi callq 0x1bf60 leaq -0x98(%rbp), %rdi callq 0xee20 movl $0x0, -0x9c(%rbp) movq -0x10(%rbp...
JameyWoo[P]csmile/assembly.cpp
genOutput(TreeNode*, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::...
void genOutput(TreeNode* output, map<string, string> var2stack) { // debug("in output: " + output->child[0]->nodekind); // debug("in output value: " + to_string(output->child[0]->val)); if (output->child[0]->nodekind == "Const") { assout << "\t" << "movl\t$.LC0, %eax" << endl ...
pushq %rbp movq %rsp, %rbp subq $0x1a0, %rsp # imm = 0x1A0 movq %rsi, -0x98(%rbp) movq %rdi, -0x8(%rbp) movq %rsi, -0x10(%rbp) movq -0x8(%rbp), %rax movq (%rax), %rdi addq $0x30, %rdi leaq 0x954d(%rip), %rsi # 0x211e9 callq 0x5e70 testb $0x1, %al jne 0x17caa jmp 0x17e7b leaq 0x16ff7(%rip), %rdi # 0x...
JameyWoo[P]csmile/assembly.cpp
genCall(TreeNode*, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::ba...
void genCall(TreeNode* call, map<string, string> var2stack) { // ! 结果在 %eax中 if (call == NULL) return; // debug("call: " + call->child[0]->nodekind); // 解析 Call 的参数 // call->child[0] 是这个函数的名字 // call->child[1] 如果不为 NULL 的话, 是 Args 类型的 // 解析args, arg可以是expression, 种类比较多. 考虑是不是要综合一个整体的 Tre...
pushq %rbp movq %rsp, %rbp subq $0x210, %rsp # imm = 0x210 movq %rsi, -0x170(%rbp) movq %rdi, -0x8(%rbp) movq %rsi, -0x10(%rbp) cmpq $0x0, -0x8(%rbp) jne 0x18256 jmp 0x18841 movq -0x8(%rbp), %rax movq 0x8(%rax), %rax movq %rax, -0x18(%rbp) cmpq $0x0, -0x18(%rbp) jne 0x182a6 leaq 0x16a38(%rip), %rdi # 0x2...
JameyWoo[P]csmile/assembly.cpp
genInput(TreeNode*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void genInput(TreeNode* input, string left_loc) { // debug(input->nodekind); assout << "\tmovl\t$.LC1, %eax" << endl << "\tleal\t" << left_loc << ", %edx" << endl << "\tmovl\t" << "%edx, 4(%esp)" << endl << "\tmovl\t%eax, (%esp)" << endl << "\tcall\t__isoc9...
pushq %rbp movq %rsp, %rbp subq $0x20, %rsp movq %rsi, -0x18(%rbp) movq %rdi, -0x8(%rbp) movq %rsi, -0x10(%rbp) leaq 0x1642d(%rip), %rdi # 0x2eca8 leaq 0x8e61(%rip), %rsi # 0x216e3 callq 0x3270 movq %rax, %rdi movq 0x1571f(%rip), %rsi # 0x2dfb0 callq 0x32b0 movq %rax, %rdi leaq 0x8e55(%rip), %rsi # 0x...
JameyWoo[P]csmile/assembly.cpp
genStmt(TreeNode*, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::ba...
void genStmt(TreeNode* stmts, map<string, string> var2stack) { if (stmts == NULL) return; TreeNode* stmt = stmts; while (stmt != NULL) { // debug(stmt->nodekind); if (stmt->nodekind == "Output") { genOutput(stmt, var2stack); } else if (stmt->nodekind == "Assign") { ...
pushq %rbp movq %rsp, %rbp subq $0x1b0, %rsp # imm = 0x1B0 movq %rsi, -0x150(%rbp) movq %rdi, -0x8(%rbp) movq %rsi, -0x10(%rbp) cmpq $0x0, -0x8(%rbp) jne 0x18966 jmp 0x18c93 movq -0x8(%rbp), %rax movq %rax, -0x18(%rbp) cmpq $0x0, -0x18(%rbp) je 0x18c93 movq -0x18(%rbp), %rdi addq $0x30, %rdi leaq 0x8877(%rip...
JameyWoo[P]csmile/assembly.cpp
genAssign(TreeNode*, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::...
void genAssign(TreeNode* assign, map<string, string> var2stack, bool need) { // debug("assign " + assign->child[0]->name); string left_loc = var2stack[assign->child[0]->name]; if (assign->child[1]->nodekind == "Const") { assout << "\tmovl\t$" << to_string(assign->child[1]->val) ...
pushq %rbp movq %rsp, %rbp subq $0x230, %rsp # imm = 0x230 movq %rsi, -0x148(%rbp) movq %rdi, %rcx movq -0x148(%rbp), %rdi movb %dl, %al movq %rcx, -0x8(%rbp) movq %rdi, -0x10(%rbp) andb $0x1, %al movb %al, -0x11(%rbp) movq -0x8(%rbp), %rax movq (%rax), %rsi addq $0xc0, %rsi callq 0xf2e0 movq %rax, %rsi leaq...
JameyWoo[P]csmile/assembly.cpp
genIfElse(TreeNode*, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::...
void genIfElse(TreeNode* ifelse, map<string, string> var2stack) { // debug("ifelse->child[0]: " + ifelse->child[0]->nodekind); // debug("ifelse->child[0]: " + ifelse->child[1]->nodekind); // debug("ifelse->child[0]: " + ifelse->child[2]->nodekind); // ifelse->child[0] 是条件判断 // ifelse->child[1] 是 if ...
pushq %rbp movq %rsp, %rbp subq $0x240, %rsp # imm = 0x240 movq %rsi, -0x1c8(%rbp) movq %rdi, -0x8(%rbp) movq %rsi, -0x10(%rbp) movq -0x8(%rbp), %rax movq (%rax), %rdi addq $0x98, %rdi leaq 0x83a8(%rip), %rsi # 0x21727 callq 0x5e70 testb $0x1, %al jne 0x1938d jmp 0x1986a movq -0x8(%rbp), %rax movq (%rax...
JameyWoo[P]csmile/assembly.cpp
genReturn(TreeNode*, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::...
void genReturn(TreeNode* returnStmt, map<string, string> var2stack) { // debug("return: " + returnStmt->child[0]->nodekind); if (returnStmt->child[0]->nodekind == "Id") { assout << "\tmovl\t" << var2stack[returnStmt->child[0]->name] << ", %eax" << endl; } else if (returnStmt->child[0]->nodekind == "...
pushq %rbp movq %rsp, %rbp subq $0xb0, %rsp movq %rsi, -0x78(%rbp) movq %rdi, -0x8(%rbp) movq %rsi, -0x10(%rbp) movq -0x8(%rbp), %rax movq (%rax), %rdi addq $0x30, %rdi leaq 0x7903(%rip), %rsi # 0x211ac callq 0x5e70 testb $0x1, %al jne 0x198b4 jmp 0x19911 leaq 0x153ed(%rip), %rdi # 0x2eca8 leaq 0x7dd4(%rip), %...
JameyWoo[P]csmile/assembly.cpp
genWhile(TreeNode*, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::b...
void genWhile(TreeNode* iter, map<string, string> var2stack) { // 循环 string L1 = ".L" + to_string(getId()); string L2 = ".L" + to_string(getId()); if (iter->child[0]->op == "==") { // debug(" == "); assout << L1 << ":" << endl; TreeNode* left = iter->child[0]->child[0]; ...
pushq %rbp movq %rsp, %rbp subq $0x4f0, %rsp # imm = 0x4F0 movq %rsi, -0x380(%rbp) movq %rdi, -0x8(%rbp) movq %rsi, -0x10(%rbp) callq 0x177b0 movl %eax, %esi leaq -0x50(%rbp), %rdi movq %rdi, -0x378(%rbp) callq 0xf460 movq -0x378(%rbp), %rdx leaq 0x7c8c(%rip), %rsi # 0x2173b leaq -0x30(%rbp), %rdi callq...
JameyWoo[P]csmile/assembly.cpp
solveCompare(TreeNode*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::less<std::__cxx11::basic_string<char, std:...
void solveCompare(TreeNode* root, string reg, map<string, string> var2stack) { // debug(root->nodekind); // TODO: 最好有一个通用处理的函数, 专门计算 exp等 if (root->nodekind == "Const") { assout << "\tmovl\t$" << to_string(root->val) << ", " << reg << endl; } else if (root->nodekind == "Id") { assout << ...
pushq %rbp movq %rsp, %rbp subq $0x90, %rsp movq %rsi, -0x58(%rbp) movq %rdx, -0x50(%rbp) movq %rdi, -0x8(%rbp) movq %rsi, -0x10(%rbp) movq %rdx, -0x18(%rbp) movq -0x8(%rbp), %rdi addq $0x30, %rdi leaq 0x6a9b(%rip), %rsi # 0x211e9 callq 0x5e70 testb $0x1, %al jne 0x1a75c jmp 0x1a800 leaq 0x14545(%rip), %rdi # ...
JameyWoo[P]csmile/assembly.cpp
genCalc(TreeNode*, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::ba...
void genCalc(TreeNode* calc, map<string, string> var2stack) { // TODO: 出了一个bug, 要注意, 相同优先级是要先左后右来计算的 // TODO: 有 bug, 多重计算的时候, 寄存器会混淆 // * 将计算结果保存到 %edx 中 // * 递归地先将左值计算, 存储到%edx中, 将右值计算, 存储到%ecx中. %eax做暂时的中介. // debug("calc->nodekind: " + calc->nodekind); // debug("calc->op: " + calc->op); ...
pushq %rbp movq %rsp, %rbp subq $0x2c0, %rsp # imm = 0x2C0 movq %rsi, -0x150(%rbp) movq %rdi, -0x8(%rbp) movq %rsi, -0x10(%rbp) leaq -0x30(%rbp), %rdi callq 0x33b0 leaq -0x50(%rbp), %rdi callq 0x33b0 movq -0x8(%rbp), %rax movq (%rax), %rdi addq $0x30, %rdi leaq 0x6911(%rip), %rsi # 0x211ef callq 0x5e70 ...
JameyWoo[P]csmile/assembly.cpp
genFunc(TreeNode*)
void genFunc(TreeNode* func) { // ! 函数需要分析参数的栈情况, 写入符号表. 因此这个符号表非常重要. string func_name = func->child[1]->name; // debug("func name: " + func_name); // debug(func->child[2]->nodekind); // 函数的参数 // debug(func->child[3]->nodekind); // 函数的内容 assout << "\t.global\t" << func->child[1]->name << endl...
pushq %rbp movq %rsp, %rbp subq $0x3d0, %rsp # imm = 0x3D0 movq %rdi, -0x8(%rbp) movq -0x8(%rbp), %rax movq 0x8(%rax), %rsi addq $0xc0, %rsi leaq -0x28(%rbp), %rdi callq 0x3120 leaq 0x13a9a(%rip), %rdi # 0x2eca8 leaq 0x65ec(%rip), %rsi # 0x21801 callq 0x3270 movq %rax, -0x268(%rbp) jmp 0x1b223 movq ...
JameyWoo[P]csmile/assembly.cpp
genAssembly(TreeNode*)
void genAssembly(TreeNode* root) { // 汇编代码的头部 assout << "\t.section\t.rodata" << endl << ".LC0:" << endl << "\t" << ".string \"%d\\n\"" << endl << ".LC1:" << endl << "\t" << ".string \"%d\"" << endl << "\t" << ".text" << end...
pushq %rbp movq %rsp, %rbp subq $0x10, %rsp movq %rdi, -0x8(%rbp) leaq 0x13085(%rip), %rdi # 0x2eca8 leaq 0x5c58(%rip), %rsi # 0x21882 callq 0x3270 movq %rax, %rdi movq 0x12377(%rip), %rsi # 0x2dfb0 callq 0x32b0 movq %rax, %rdi leaq 0x5c4c(%rip), %rsi # 0x21894 callq 0x3270 movq %rax, %rdi movq 0x1235...
JameyWoo[P]csmile/assembly.cpp
assignSignleElement()
void assignSignleElement() { cout<<"-----------[ Build Signle Element ]---------------\n"; { Json n, b, i, r, s, cs, a, d; n.setNull(); cout<<"Json must be null: ["<<n<<"]\n"; b.setBool(true); cout<<"Json must be true: ["<<b<<"]\n"; b.setBool(false); cout<<"Json must be false: ["<<b<<"]\n"; b.se...
subq $0x10f8, %rsp # imm = 0x10F8 movq 0x358da(%rip), %rdi # 0x57fd8 leaq 0x2797b(%rip), %rsi # 0x4a080 callq 0x222a0 leaq 0x10e8(%rsp), %rdi callq 0x30e30 leaq 0x10d8(%rsp), %rdi callq 0x30e30 jmp 0x22726 leaq 0x10b8(%rsp), %rdi callq 0x30e30 jmp 0x22735 leaq 0x10a8(%rsp), %rdi callq 0x30e30 jmp 0x22...
swxlion[P]swxJson/tests/swxJsonFunctionalTest.cpp
fetchSignleElement()
void fetchSignleElement() { Json node; node.addNull("aaa.bbb.null"); node.add("....", "empty_objects"); node.add("aaa.bbb.false", false); node.add("aaa.bbb.true", true); node.add("aaa.bbb.int", -34); node.add("aaa.bbb.real", -3.45e4); node.add("aaa.bbb.string", "cstring"); node["demo.idx.int"] = 99; node["de...
subq $0x2d58, %rsp # imm = 0x2D58 leaq 0x2d48(%rsp), %rdi callq 0x30e30 leaq 0x2d27(%rsp), %rdi movq %rdi, 0xfc8(%rsp) callq 0x224b0 movq 0xfc8(%rsp), %rdx leaq 0x23d3b(%rip), %rsi # 0x4a4a3 leaq 0x2d28(%rsp), %rdi callq 0x30e50 jmp 0x26777 leaq 0x2cef(%rsp), %rdi movq %rdi, 0xfc0(%rsp) callq 0x224b0 movq...
swxlion[P]swxJson/tests/swxJsonFunctionalTest.cpp
swxJson::Json::output(std::ostream&) const
std::ostream& Json::output(std::ostream& os) const { if (_type == JSON_String) { std::string * str = (std::string*)_data; os << '"' << gc_JsonStringEscaper.escape(str) << '"'; } else if (_type == JSON_Integer) { intmax_t * data = (intmax_t*)_data; os << (*data); } else if (_type == JSON_UInteger) { ui...
subq $0x128, %rsp # imm = 0x128 movq %rdi, 0x120(%rsp) movq %rsi, 0x118(%rsp) movq 0x120(%rsp), %rax movq %rax, 0x38(%rsp) cmpl $0x2, (%rax) jne 0x36595 movq 0x38(%rsp), %rax movq 0x8(%rax), %rax movq %rax, 0x110(%rsp) movq 0x118(%rsp), %rdi movl $0x22, %esi callq 0x22380 movq %rax, 0x20(%rsp) movq 0x110(%rs...
swxlion[P]swxJson/src/swxJson.cpp
pathSplit(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<ch...
std::vector<std::string>& pathSplit(const std::string& s, const std::string& delim, std::vector<std::string> &elems) { std::string::size_type start = 0; while (true) { if (start == s.size()) { elems.push_back(""); return elems; } std::string::size_type pos = s.find_first_of(delim, start); if (pos =...
subq $0x108, %rsp # imm = 0x108 movq %rdi, 0xf8(%rsp) movq %rsi, 0xf0(%rsp) movq %rdx, 0xe8(%rsp) movq $0x0, 0xe0(%rsp) movq 0xe0(%rsp), %rax movq %rax, 0x30(%rsp) movq 0xf8(%rsp), %rdi callq 0x221a0 movq %rax, %rcx movq 0x30(%rsp), %rax cmpq %rcx, %rax jne 0x36b9c movq 0xe8(%rsp), %rax movq %rax, 0x20(%rsp)...
swxlion[P]swxJson/src/swxJson.cpp
swxJson::Json::getNodeByKey(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
JsonPtr Json::getNodeByKey(const std::string& key) { if (_type != JSON_Object) return nullptr; std::map<std::string, JsonPtr>* data = (std::map<std::string, JsonPtr>*)_data; auto it = data->find(key); if (it != data->end()) return it->second; else return nullptr; }
subq $0x48, %rsp movq %rdi, (%rsp) movq %rdi, %rax movq %rax, 0x8(%rsp) movq %rdi, 0x40(%rsp) movq %rsi, 0x38(%rsp) movq %rdx, 0x30(%rsp) movq 0x38(%rsp), %rax movq %rax, 0x10(%rsp) cmpl $0x0, (%rax) je 0x36e0d movq (%rsp), %rdi xorl %eax, %eax movl %eax, %esi callq 0x3ec30 jmp 0x36e7c movq 0x10(%rsp), %rax movq 0x8(%r...
swxlion[P]swxJson/src/swxJson.cpp
swxJson::Json::getNodeByIndex(int)
JsonPtr Json::getNodeByIndex(int index) { if (_type != JSON_Array) return nullptr; std::list<JsonPtr>* data = (std::list<JsonPtr>*)_data; auto it = data->begin(); int i = 0; for (; it != data->end(); it++, i++) { if (i == index) return *it; } return nullptr; }
subq $0x58, %rsp movq %rdi, (%rsp) movq %rdi, %rax movq %rax, 0x8(%rsp) movq %rdi, 0x50(%rsp) movq %rsi, 0x48(%rsp) movl %edx, 0x44(%rsp) movq 0x48(%rsp), %rax movq %rax, 0x10(%rsp) cmpl $0x1, (%rax) je 0x36ecf movq (%rsp), %rdi xorl %eax, %eax movl %eax, %esi callq 0x3ec30 jmp 0x36f67 movq 0x10(%rsp), %rax movq 0x8(%r...
swxlion[P]swxJson/src/swxJson.cpp
swxJson::Json::getNode(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
JsonPtr Json::getNode(const std::string& path, const std::string& delim) { std::vector<std::string> sections; pathSplit(path, delim, sections); if (sections.empty()) return getNodeByKey(""); JsonPtr node = getNodeByKey(sections[0]); for (size_t i = 1; i < sections.size() && node != nullptr; i++) node = node-...
subq $0xd8, %rsp movq %rdi, 0x28(%rsp) movq %rdi, %rax movq %rax, 0x30(%rsp) movq %rdi, 0xd0(%rsp) movq %rsi, 0xc8(%rsp) movq %rdx, 0xc0(%rsp) movq %rcx, 0xb8(%rsp) movq 0xc8(%rsp), %rax movq %rax, 0x38(%rsp) leaq 0xa0(%rsp), %rdi movq %rdi, 0x40(%rsp) callq 0x3ecd0 movq 0x40(%rsp), %rdx movq 0xc0(%rsp), %rdi movq 0xb8...
swxlion[P]swxJson/src/swxJson.cpp
swxJson::Json::getParentNode(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, bool&, bool&)
JsonPtr Json::getParentNode(const std::string& path, const std::string& delim, std::string& lastSection, bool& nodeTypeError, bool& nodeNotFound) { nodeTypeError = false; nodeNotFound = false; std::vector<std::string> sections; pathSplit(path, delim, sections); if (sections.empty()) { lastSection = ""; retu...
subq $0xd8, %rsp movq %rdi, 0x30(%rsp) movq %rdi, %rax movq %rax, 0x38(%rsp) movq 0xe0(%rsp), %rax movq %rdi, 0xd0(%rsp) movq %rsi, 0xc8(%rsp) movq %rdx, 0xc0(%rsp) movq %rcx, 0xb8(%rsp) movq %r8, 0xb0(%rsp) movq %r9, 0xa8(%rsp) movq 0xc8(%rsp), %rax movq %rax, 0x40(%rsp) movq 0xa8(%rsp), %rax movb $0x0, (%rax) movq 0x...
swxlion[P]swxJson/src/swxJson.cpp
swxJson::Json::createNode(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, bool)
JsonPtr Json::createNode(const std::string& path, const std::string& delim, bool throwable) { std::vector<std::string> sections; pathSplit(path, delim, sections); if (sections.empty()) sections.push_back(""); JsonPtr node; size_t i = 0; for (; i < sections.size(); i++) { JsonPtr next = (i>0) ? node->getNod...
subq $0x1b8, %rsp # imm = 0x1B8 movq %rdi, 0x90(%rsp) movb %r8b, %al movq %rdi, %r8 movq %r8, 0x98(%rsp) movq %rdi, 0x1b0(%rsp) movq %rsi, 0x1a8(%rsp) movq %rdx, 0x1a0(%rsp) movq %rcx, 0x198(%rsp) andb $0x1, %al movb %al, 0x197(%rsp) movq 0x1a8(%rsp), %rax movq %rax, 0xa0(%rsp) leaq 0x178(%rsp), %rdi movq %r...
swxlion[P]swxJson/src/swxJson.cpp
swxJson::Json::setDict()
void Json::setDict() { if (_type != JSON_Object) { clean(); _type = JSON_Object; _data = new std::map<std::string, JsonPtr>(); } else { std::map<std::string, JsonPtr>* data = (std::map<std::string, JsonPtr>*)_data; data->clear(); } }
subq $0x28, %rsp movq %rdi, 0x20(%rsp) movq 0x20(%rsp), %rax movq %rax, 0x10(%rsp) cmpl $0x0, (%rax) je 0x37e75 movq 0x10(%rsp), %rdi callq 0x380b0 movq 0x10(%rsp), %rax movl $0x0, (%rax) movl $0x30, %edi callq 0x222b0 movq %rax, %rdi movq %rdi, 0x8(%rsp) xorl %esi, %esi movl $0x30, %edx callq 0x22130 movq 0x8(%rsp), %...
swxlion[P]swxJson/src/swxJson.cpp
swxJson::Json::addNode(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::shared_ptr<swxJson::Json>)
bool Json::addNode(const std::string& key, JsonPtr node) { if (_type != JSON_Object) { if (_type == JSON_Uninit) setDict(); else return false; } std::map<std::string, JsonPtr>* data = (std::map<std::string, JsonPtr>*)_data; auto it = data->find(key); if (it != data->end()) return false; (*data)[key...
subq $0x48, %rsp movq %rdx, (%rsp) movq %rdi, 0x38(%rsp) movq %rsi, 0x30(%rsp) movq %rdx, 0x28(%rsp) movq 0x38(%rsp), %rax movq %rax, 0x8(%rsp) cmpl $0x0, (%rax) je 0x38035 movq 0x8(%rsp), %rax cmpl $0x8, (%rax) jne 0x3802c movq 0x8(%rsp), %rdi callq 0x37e10 jmp 0x38033 movb $0x0, 0x47(%rsp) jmp 0x380a2 jmp 0x38035 mov...
swxlion[P]swxJson/src/swxJson.cpp
swxJson::Json::clean()
void Json::clean() { switch (_type) { case JSON_Uninit: return; case JSON_Object: { std::map<std::string, JsonPtr>* data = (std::map<std::string, JsonPtr>*)_data; delete data; break; } case JSON_Array: { std::list<JsonPtr>* data = (std::list<JsonPtr>*)_data; delete data; break; } ...
subq $0x78, %rsp movq %rdi, 0x70(%rsp) movq 0x70(%rsp), %rax movq %rax, 0x30(%rsp) movl (%rax), %eax movq %rax, 0x38(%rsp) subq $0x8, %rax ja 0x3822f movq 0x38(%rsp), %rax leaq 0x1354c(%rip), %rcx # 0x4b62c movslq (%rcx,%rax,4), %rax addq %rcx, %rax jmpq *%rax jmp 0x38242 movq 0x30(%rsp), %rax movq 0x8(%rax), %rax ...
swxlion[P]swxJson/src/swxJson.cpp
swxJson::Json::setNull()
void Json::setNull() { if (_type == JSON_Null) return; clean(); _type = JSON_Null; }
subq $0x18, %rsp movq %rdi, 0x10(%rsp) movq 0x10(%rsp), %rax movq %rax, 0x8(%rsp) cmpl $0x7, (%rax) jne 0x3826a jmp 0x3827f movq 0x8(%rsp), %rdi callq 0x380b0 movq 0x8(%rsp), %rax movl $0x7, (%rax) addq $0x18, %rsp retq nopw %cs:(%rax,%rax)
swxlion[P]swxJson/src/swxJson.cpp
swxJson::Json::setBool(bool)
void Json::setBool(bool value) { if (_type != JSON_Boolean) { clean(); _type = JSON_Boolean; } _data = (value ? (void*)1 : 0); }
subq $0x18, %rsp movb %sil, %al movq %rdi, 0x10(%rsp) andb $0x1, %al movb %al, 0xf(%rsp) movq 0x10(%rsp), %rax movq %rax, (%rsp) cmpl $0x6, (%rax) je 0x382c3 movq (%rsp), %rdi callq 0x380b0 movq (%rsp), %rax movl $0x6, (%rax) movq (%rsp), %rax movb 0xf(%rsp), %sil xorl %ecx, %ecx movl $0x1, %edx testb $0x1, %sil cmovne...
swxlion[P]swxJson/src/swxJson.cpp
swxJson::Json::setInt(long)
void Json::setInt(intmax_t value) { if (_type != JSON_Integer) { clean(); _type = JSON_Integer; _data = new intmax_t(value); } else { intmax_t *data = (intmax_t*)_data; *data = value; } }
subq $0x28, %rsp movq %rdi, 0x20(%rsp) movq %rsi, 0x18(%rsp) movq 0x20(%rsp), %rax movq %rax, 0x8(%rsp) cmpl $0x3, (%rax) je 0x38342 movq 0x8(%rsp), %rdi callq 0x380b0 movq 0x8(%rsp), %rax movl $0x3, (%rax) movl $0x8, %edi callq 0x222b0 movq %rax, %rcx movq 0x8(%rsp), %rax movq 0x18(%rsp), %rdx movq %rdx, (%rcx) movq %...
swxlion[P]swxJson/src/swxJson.cpp
swxJson::Json::setUInt(unsigned long)
void Json::setUInt(uintmax_t value) { if (_type != JSON_UInteger) { clean(); _type = JSON_UInteger; _data = new uintmax_t(value); } else { uintmax_t *data = (uintmax_t*)_data; *data = value; } }
subq $0x28, %rsp movq %rdi, 0x20(%rsp) movq %rsi, 0x18(%rsp) movq 0x20(%rsp), %rax movq %rax, 0x8(%rsp) cmpl $0x4, (%rax) je 0x383c2 movq 0x8(%rsp), %rdi callq 0x380b0 movq 0x8(%rsp), %rax movl $0x4, (%rax) movl $0x8, %edi callq 0x222b0 movq %rax, %rcx movq 0x8(%rsp), %rax movq 0x18(%rsp), %rdx movq %rdx, (%rcx) movq %...
swxlion[P]swxJson/src/swxJson.cpp
swxJson::Json::setReal(double)
void Json::setReal(double value) { if (_type != JSON_Real) { clean(); _type = JSON_Real; _data = new double(value); } else { double * data = (double*)_data; *data = value; } }
subq $0x28, %rsp movq %rdi, 0x20(%rsp) movsd %xmm0, 0x18(%rsp) movq 0x20(%rsp), %rax movq %rax, 0x8(%rsp) cmpl $0x5, (%rax) je 0x38445 movq 0x8(%rsp), %rdi callq 0x380b0 movq 0x8(%rsp), %rax movl $0x5, (%rax) movl $0x8, %edi callq 0x222b0 movq %rax, %rcx movq 0x8(%rsp), %rax movsd 0x18(%rsp), %xmm0 movsd %xmm0, (%rcx) ...
swxlion[P]swxJson/src/swxJson.cpp
swxJson::Json::setString(char const*)
void Json::setString(const char* value) { if (_type != JSON_String) { clean(); _type = JSON_String; if (value) _data = new std::string(value); else _data = new std::string(""); } else { std::string * data = (std::string*)_data; if (value) data->assign(value); else data->assign(""); } }
subq $0x78, %rsp movq %rdi, 0x70(%rsp) movq %rsi, 0x68(%rsp) movq 0x70(%rsp), %rax movq %rax, 0x40(%rsp) cmpl $0x2, (%rax) je 0x385e4 movq 0x40(%rsp), %rdi callq 0x380b0 movq 0x40(%rsp), %rax movl $0x2, (%rax) cmpq $0x0, 0x68(%rsp) je 0x38551 movl $0x20, %edi callq 0x222b0 movq %rax, 0x28(%rsp) movq %rax, 0x20(%rsp) mo...
swxlion[P]swxJson/src/swxJson.cpp
swxJson::Json::setString(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
void Json::setString(const std::string& value) { if (_type != JSON_String) { clean(); _type = JSON_String; _data = new std::string(value); } else { std::string * data = (std::string*)_data; data->assign(value); } }
subq $0x38, %rsp movq %rdi, 0x30(%rsp) movq %rsi, 0x28(%rsp) movq 0x30(%rsp), %rax movq %rax, 0x8(%rsp) cmpl $0x2, (%rax) je 0x386af movq 0x8(%rsp), %rdi callq 0x380b0 movq 0x8(%rsp), %rax movl $0x2, (%rax) movl $0x20, %edi callq 0x222b0 movq %rax, %rdi movq %rdi, %rax movq %rax, (%rsp) movq 0x28(%rsp), %rsi callq 0x22...
swxlion[P]swxJson/src/swxJson.cpp
swxJson::Json::setArray()
void Json::setArray() { if (_type != JSON_Array) { clean(); _type = JSON_Array; _data = new std::list<JsonPtr>(); } else { std::list<JsonPtr>* data = (std::list<JsonPtr>*)_data; data->clear(); } }
subq $0x28, %rsp movq %rdi, 0x20(%rsp) movq 0x20(%rsp), %rax movq %rax, 0x10(%rsp) cmpl $0x1, (%rax) je 0x38745 movq 0x10(%rsp), %rdi callq 0x380b0 movq 0x10(%rsp), %rax movl $0x1, (%rax) movl $0x18, %edi callq 0x222b0 movq %rax, %rdi movq %rdi, 0x8(%rsp) xorl %esi, %esi movl $0x18, %edx callq 0x22130 movq 0x8(%rsp), %...
swxlion[P]swxJson/src/swxJson.cpp
swxJson::Json::pushNode(std::shared_ptr<swxJson::Json>)
bool Json::pushNode(JsonPtr node) { if (_type != JSON_Array) { if (_type == JSON_Uninit) setArray(); else return false; } std::list<JsonPtr>* data = (std::list<JsonPtr>*)_data; data->push_back(node); return true; }
subq $0x38, %rsp movq %rsi, 0x8(%rsp) movq %rdi, 0x28(%rsp) movq %rsi, 0x20(%rsp) movq 0x28(%rsp), %rax movq %rax, 0x10(%rsp) cmpl $0x1, (%rax) je 0x387b1 movq 0x10(%rsp), %rax cmpl $0x8, (%rax) jne 0x387a8 movq 0x10(%rsp), %rdi callq 0x386e0 jmp 0x387af movb $0x0, 0x37(%rsp) jmp 0x387d3 jmp 0x387b1 movq 0x8(%rsp), %rs...
swxlion[P]swxJson/src/swxJson.cpp
swxJson::Json::pushNull(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
void Json::pushNull(const std::string& path, const std::string& delim) { JsonPtr node = createNode(path, delim, true); if (node->pushNull()) return; throw JSON_ERROR_MSG(JsonNodeTypeMissMatchError, "Target node is not array."); }
subq $0x78, %rsp movq %rdi, 0x70(%rsp) movq %rsi, 0x68(%rsp) movq %rdx, 0x60(%rsp) movq 0x70(%rsp), %rsi movq 0x68(%rsp), %rdx movq 0x60(%rsp), %rcx leaq 0x50(%rsp), %rdi movq %rdi, 0x10(%rsp) movl $0x1, %r8d callq 0x375d0 movq 0x10(%rsp), %rdi callq 0x312a0 movq %rax, %rdi callq 0x387e0 movb %al, 0x1d(%rsp) jmp 0x38b9...
swxlion[P]swxJson/src/swxJson.cpp