postfix_token* Parser::copy_postfix_tokens(postfix_token* toks, int ntokens) { postfix_token *pfcopy = new postfix_token[ntokens]; for (int i=0; i<ntokens; i++) { pfcopy[i] = toks[i]; if (pfcopy[i].type==TOK_STRING) symbol_reference(pfcopy[i].v.symbolid); } return pfcopy; }
//--------------------------------------------------------------------------------------- // Merges symbols described by binary byte stream into existing symbol table. // [See as_binary() for byte stream composition.] // Arg binary_pp - Pointer to address to fill and increment. Its size *must* be // large enough to fit all the binary data. Use the get_binary_length() // method to determine the size needed prior to passing binary_pp to this // method. // See: as_binary(), assign_binary(), ASymbol::table_from_binary() // Author(s): Conan Reis void ASymbolTable::merge_binary(const void ** binary_pp) { uint32_t init_length = m_sym_refs.get_length(); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // If table is empty, don't do any special merge code if (init_length == 0u) { assign_binary(binary_pp); return; } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Merge in symbols from binary // 4 bytes - number of symbols uint32_t length = A_BYTE_STREAM_UI32_INC(binary_pp); // Assume that there will be no overlap m_sym_refs.ensure_size(init_length + length); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Repeating in symbol id order uint32_t sym_id; uint32_t str_len; while (length) { // 4 bytes - symbol id sym_id = A_BYTE_STREAM_UI32_INC(binary_pp); // 1 byte - length of string str_len = A_BYTE_STREAM_UI8_INC(binary_pp); // n bytes - string symbol_reference(sym_id, (const char *)*binary_pp, str_len, ATerm_short); (*(uint8_t **)binary_pp) += str_len; length--; } }