⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 module.cc

📁 一个mips虚拟机非常好代码,使用C++来编写的,希望大家多学学,
💻 CC
字号:
#include <string.h>#include "assert.hh"#include "checkpoint.hh"#include "cpu.hh"#include "module.hh"#include "simarg.hh"// Serialization support.Module::Module(Checkpoint &cp)    : Serializable(cp), BasicModule(extract_line(cp)){    // done.}voidModule::checkpoint(Checkpoint &cp, bool parent) const{    assert(!parent);    cp << name() << '\n';}// Tcl interfaces.Module::Module(const SimArgs &args)    : BasicModule(args[1]){    // done.}SimArgModule::install_module(const SimArgs &args){    if (args.length() < 2)	throw Error("\"sim::install\" expects at least two arguments.");    const char *name = args[0];    Serializable *obj = find_type(name).create(args);    if (!dynamic_cast<Module *>(obj))	throw Error("\"%#s\" is not a module type.", name);    if (dynamic_cast<CPU *>(obj) && args.length() < 3)	throw Error("No CPU speed specified.");    return "";}SimArgModule::reset_all(const SimArgs &args){    bool warm = false;    if (args.length() > 1)	throw Error("\"sim::reset\" expects at most one argument.");    else if (args.length() == 1) {	if (!strcmp(args[0], "cold"))	    warm = false;	else if (!strcmp(args[0], "warm"))	    warm = true;	else {	    throw Error("Invalid argument to \"sim::reset\".");	}    }    for (ObjectIterator i; i; ++i) {	Module *mod = dynamic_cast<Module *>(&*i);	if (mod) {	    mod->reset(warm);	}    }    return "";}// Search the object list for a module with the given name.Module *find_module(const char *name){    for (ObjectIterator i; i; ++i) {	Module *mod = dynamic_cast<Module *>(&*i);	if (mod && !strcmp(mod->name(), name))	    return mod;    }    return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -