<commit_before>/**********************************************************************/
/* Copyright 2014 RCF                                                 */ 
/*                                                                    */
/* Licensed under the Apache License, Version 2.0 (the "License");    */
/* you may not use this file except in compliance with the License.   */
/* You may obtain a copy of the License at                            */
/*                                                                    */
/*     http://www.apache.org/licenses/LICENSE-2.0                     */
/*                                                                    */
/* Unless required by applicable law or agreed to in writing,         */
/* software distributed under the License is distributed on an        */
/* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,       */
/* either express or implied.                                         */
/* See the License for the specific language governing permissions    */
/* and limitations under the License.                                 */
/**********************************************************************/

#ifndef HPP_VM_RVM_DEFINED
#define HPP_VM_RVM_DEFINED

// Default libraries
#include <stack>
#include <vector>
#include <iostream>
#include <unordered_map>

// Internal libraries
#include "State.hpp"
#include "Command.hpp"
#include "Stackable.hpp"

namespace vm
{
    class RVM
    {
        private:
            // Execution memory
            std::vector        <Command>         PROG  {};
            std::unordered_map <std::string,int> LABEL {};
            
            // Internal-use memory
            mutable int                                         PC    {};
            mutable std::stack         <int>                    CTRL  {};
            mutable std::deque         <stk::Stackable_ptr>     DATA  {};
            mutable std::unordered_map <int,stk::Stackable_ptr> RAM   {};
            
            mutable bool syscall   { false };
            mutable State activity { State::ACTIVE };
            
        public:
            RVM(std::vector<Command> PROG)
            {
                upload(PROG);
            }
            
            void upload(std::vector<Command> PROG)
            {
                this->PROG = std::move(PROG); //upload_labels();
            }
            
            void exec() const;
            void run()  const;
            
            friend std::ostream& 
            operator<<(std::ostream& os, const RVM& rvm);
            
            friend void 
            vm::push(const vm::RVM& rvm, const stk::Stackable_ptr& stk);
            
            friend stk::Stackable_ptr
            vm::pop(const vm::RVM& rvm);
            
            friend class Debug;
            
            template<typename Func>
            friend void operate(const RVM& rvm, Func func);
            
            inline void 
            STO(const vm::RVM& rvm, const stk::Stackable_ptr& stk);
            
            inline stk::Stackable_ptr
            RCL(const vm::RVM& rvm, const stk::Stackable_ptr& stk);
    };
    
    std::ostream& operator<<(std::ostream& os, const RVM& rvm);
}

#endif
<commit_msg>Removing old friend classes and adding new friend 'class Asm'<commit_after>/**********************************************************************/
/* Copyright 2014 RCF                                                 */ 
/*                                                                    */
/* Licensed under the Apache License, Version 2.0 (the "License");    */
/* you may not use this file except in compliance with the License.   */
/* You may obtain a copy of the License at                            */
/*                                                                    */
/*     http://www.apache.org/licenses/LICENSE-2.0                     */
/*                                                                    */
/* Unless required by applicable law or agreed to in writing,         */
/* software distributed under the License is distributed on an        */
/* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,       */
/* either express or implied.                                         */
/* See the License for the specific language governing permissions    */
/* and limitations under the License.                                 */
/**********************************************************************/

#ifndef HPP_VM_RVM_DEFINED
#define HPP_VM_RVM_DEFINED

// Default libraries
#include <stack>
#include <vector>
#include <iostream>
#include <unordered_map>

// Internal libraries
#include "State.hpp"
#include "Command.hpp"
#include "Stackable.hpp"

namespace vm
{
    class RVM
    {
        private:
            // Execution memory
            std::vector        <Command>         PROG  {};
            std::unordered_map <std::string,int> LABEL {};
            
            // Internal-use memory
            mutable int                                         PC    {};
            mutable std::stack         <int>                    CTRL  {};
            mutable std::deque         <stk::Stackable_ptr>     DATA  {};
            mutable std::unordered_map <int,stk::Stackable_ptr> RAM   {};
            
            mutable bool syscall   { false };
            mutable State activity { State::ACTIVE };
            
        public:
            RVM(std::vector<Command> PROG)
            {
                upload(PROG);
            }
            
            void upload(std::vector<Command> PROG)
            {
                this->PROG = std::move(PROG); //upload_labels();
            }
            
            void exec() const;
            void run()  const;
            
            friend std::ostream& 
            operator<<(std::ostream& os, const RVM& rvm);
            
            friend class Debug;
            friend class Asm;
    };
    
    std::ostream& operator<<(std::ostream& os, const RVM& rvm);
}

#endif

{'fraction_non_alphanumeric': 0.13818302607540275, 'fraction_numerical': 0.0026573658860654377, 'mean_word_length': 1.2537425149700598, 'pattern_counts': {'":': 0, '<': 34, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 22, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3696981', 'n_tokens_mistral': 1398, 'n_tokens_neox': 1355, 'n_words': 400}