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

📄 interpreter.cpp

📁 一个可视化的编译器
💻 CPP
字号:
#include "StdAfx.h"
#include "Interpreter.h"
namespace LeastLIDE {
using namespace System;
using namespace System::IO;
using namespace System::Diagnostics;


Interpreter::Interpreter():
	onRuning(false)	
{

}

void Interpreter::SetPath(String ^newPath) {
	this->path = newPath;
}

void Interpreter::SetParams(String ^newParams) {
	this->params = newParams;
}

String ^ Interpreter::GetPath() {
	return this->path;
}

String ^ Interpreter::GetParams() {
	return this->params;
}

bool Interpreter::IsRunning() {
	return this->onRuning;
}

void Interpreter::Run(int flag) {
	onRuning = true;
	Process ^interpreterProc = gcnew Process();
	interpreterProc->StartInfo->FileName = this->path;
	interpreterProc->StartInfo->RedirectStandardError = flag?false:true;
	interpreterProc->StartInfo->RedirectStandardInput = flag?false:true;
	interpreterProc->StartInfo->RedirectStandardOutput = flag?false:true;
	interpreterProc->StartInfo->UseShellExecute = flag?true:false;
	interpreterProc->StartInfo->CreateNoWindow = flag?false:true;
	interpreterProc->StartInfo->Arguments = this->params;
	interpreterProc->Exited += gcnew System::EventHandler(this, &Interpreter::onInterpreterExited);
	interpreterProc->Start();
	if (0 == flag) {
		input = interpreterProc->StandardInput;   
		output = interpreterProc->StandardOutput;  
	}
}

int Interpreter::Peek( ) {
	return output->Peek();
}

String ^ Interpreter::Read() {
	String ^buf = gcnew String("");  

	int peekSize = output->Peek();
	
	array<wchar_t> ^readBuf = gcnew array<wchar_t>(peekSize);
	output->Read(readBuf, 0, peekSize);
	String ^retBuf = gcnew String(readBuf);
 	
	return retBuf;
}

void Interpreter::Write(char data) {
	input->Write(data);
}

System::Void Interpreter::onInterpreterExited(System::Object^  sender, System::EventArgs^  e) {
	onRuning = false;
	input->Close();
	output->Close();
}

}

⌨️ 快捷键说明

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