Navigation Menu

Skip to content

Commit

Permalink
Remove hardcoded, absolute path
Browse files Browse the repository at this point in the history
  • Loading branch information
nickmqb committed Apr 8, 2019
1 parent 97eee37 commit d557c18
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions bootstrap/MuonInterpreter/EntryPoint.cs
Expand Up @@ -7,16 +7,14 @@

namespace MuonInterpreter {
class EntryPoint {
const string Root = "D:/muon/";

static CodeUnit Parse(string path) {
using (var reader = new StreamReader(path)) {
var source = reader.ReadToEnd();
return Parser.Parse(path, source);
}
}

static Program ParseCompiler() {
static Program ParseCompiler(string rootPath) {
var compilerSources = new[] {
"lib/core.mu",
"lib/basic.mu",
Expand All @@ -40,7 +38,7 @@ class EntryPoint {
"compiler/args_parser.mu",
"compiler/cpu_time_stopwatch.mu",
"compiler/mu.mu",
}.Select(p => Root + p).ToArray();
}.Select(p => Path.Combine(rootPath, p)).ToArray();
var units = compilerSources.Select(p => Parse(p)).ToArray();
return Linker.Link(units);
}
Expand All @@ -51,25 +49,25 @@ class EntryPoint {
return Interpreter.EvalFunction(ins, main);
}

static void BootstrapCompiler() {
var program = ParseCompiler();
static void BootstrapCompiler(string rootPath) {
var program = ParseCompiler(rootPath);
var args = new[] { "binary_name", "--args", "mu.args" }.ToArray();
Environment.CurrentDirectory = Root + "compiler";
Environment.CurrentDirectory = Path.Combine(rootPath, "compiler");
RunMain(program, args);
}

static void CompileDemo() {
var program = ParseCompiler();
static void CompileDemo(string rootPath) {
var program = ParseCompiler(rootPath);

var args = new[] { "binary_name" }.Concat(new[] {
"lib/core.mu",
"lib/basic.mu",
"lib/containers.mu",
"demo/demo6.mu",
}.Select(p => Root + p)).Concat(new[] {
"--args", Root + "vc_demo/demo.args",
}.Select(p => Path.Combine(rootPath, p))).Concat(new[] {
"--args", Path.Combine(rootPath, "vc_demo/demo.args"),
"--max-errors", "100",
"--output-file", Root + "vc_demo/demo.c",
"--output-file", Path.Combine(rootPath, "vc_demo/demo.c"),
"--run-command", "[[demo.exe 13579]]",
}).ToArray();

Expand All @@ -79,7 +77,7 @@ class EntryPoint {
static void Main(string[] args) {
// Note: this interpreter has many limitations, and is only used for bootstrapping the compiler.

BootstrapCompiler();
BootstrapCompiler("../../../..");
//CompileDemo();
}
}
Expand Down

0 comments on commit d557c18

Please sign in to comment.