MCPcopy Create free account
hub / github.com/chigraph/chigraph / main

Function main

test/error/errorchecker.cpp:34–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32}
33
34int main(int argc, char** argv) {
35 const char* mode = argv[1];
36 const char* file = argv[2];
37 const char* expectedErr = argv[3];
38
39 assert(boost::filesystem::is_regular_file(file) && "Pass a real file");
40
41 std::ifstream ifile(file);
42 std::string str((std::istreambuf_iterator<char>(ifile)), std::istreambuf_iterator<char>());
43
44 json newData;
45 try {
46 newData = json::parse(str);
47 } catch (std::exception& e) {
48 std::cerr << "Error parsing: " << e.what();
49 return 1;
50 }
51 Context c;
52 Result res;
53
54 if (strcmp(mode, "mod") == 0) {
55 GraphModule* mod;
56 res += jsonToGraphModule(c, newData, "main", &mod);
57
58 int ret = checkForErrors(res, expectedErr);
59 if (ret != 1) return ret;
60
61 std::unique_ptr<llvm::Module> llmod = nullptr;
62 res += c.compileModule(mod->fullName(), true, &llmod);
63
64 ret = checkForErrors(res, expectedErr);
65 if (ret != 1) return ret;
66
67 return 1;
68
69 } else if (strcmp(mode, "func") == 0) {
70 auto mod = c.newGraphModule("main");
71 mod->addDependency("lang");
72
73 GraphFunction* func;
74 res += createGraphFunctionDeclarationFromJson(*mod, newData, &func);
75
76 int ret = checkForErrors(res, expectedErr);
77 if (ret != 1) return ret;
78
79 res += jsonToGraphFunction(*func, newData);
80
81 ret = checkForErrors(res, expectedErr);
82 if (ret != 1) return ret;
83
84 // create module for the functions
85 std::unique_ptr<llvm::Module> llmod;
86
87 res += c.compileModule("main", true, &llmod);
88
89 ret = checkForErrors(res, expectedErr);
90 if (ret != 1) return ret;
91

Callers

nothing calls this directly

Calls 9

parseFunction · 0.85
jsonToGraphModuleFunction · 0.85
checkForErrorsFunction · 0.85
jsonToGraphFunctionFunction · 0.85
compileModuleMethod · 0.80
fullNameMethod · 0.80
newGraphModuleMethod · 0.80
addDependencyMethod · 0.80

Tested by

no test coverage detected