MCPcopy Create free account
hub / github.com/WheretIB/nullc / main

Function main

nullcl/main.cpp:9–251  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7#include <stdlib.h>
8
9int main(int argc, char** argv)
10{
11 nullcInit("Modules/");
12
13 if(argc == 1)
14 {
15 printf("usage: nullcl [-o output.ncm] file.nc [-m module.name] [file2.nc [-m module.name] ...]\n");
16#ifdef NULLC_ENABLE_C_TRANSLATION
17 printf("usage: nullcl -c output.cpp file.nc\n");
18 printf("usage: nullcl -x output.exe file.nc\n");
19#endif
20 return 0;
21 }
22 int argIndex = 1;
23 FILE *mergeFile = NULL;
24 if(strcmp("-o", argv[argIndex]) == 0)
25 {
26 argIndex++;
27 if(argIndex == argc)
28 {
29 printf("Output file name not found after -o\n");
30 nullcTerminate();
31 return 0;
32 }
33 mergeFile = fopen(argv[argIndex], "wb");
34 if(!mergeFile)
35 {
36 printf("Cannot create output file %s\n", argv[argIndex]);
37 nullcTerminate();
38 return 0;
39 }
40 argIndex++;
41 }else if(strcmp("-c", argv[argIndex]) == 0 || strcmp("-x", argv[argIndex]) == 0){
42#ifdef NULLC_ENABLE_C_TRANSLATION
43 bool link = strcmp("-x", argv[argIndex]) == 0;
44 argIndex++;
45 if(argIndex == argc)
46 {
47 printf("Output file name not found after -o\n");
48 nullcTerminate();
49 return 0;
50 }
51 const char *outputName = argv[argIndex++];
52 const char *fileName = argv[argIndex++];
53 FILE *ncFile = fopen(fileName, "rb");
54 if(!ncFile)
55 {
56 printf("Cannot open file %s\n", fileName);
57 nullcTerminate();
58 return 0;
59 }
60
61 fseek(ncFile, 0, SEEK_END);
62 unsigned int textSize = ftell(ncFile);
63 fseek(ncFile, 0, SEEK_SET);
64 char *fileContent = new char[textSize+1];
65 fread(fileContent, 1, textSize, ncFile);
66 fileContent[textSize] = 0;

Callers

nothing calls this directly

Calls 10

nullcInitFunction · 0.85
strcmpFunction · 0.85
nullcTerminateFunction · 0.85
nullcCompileFunction · 0.85
nullcGetLastErrorFunction · 0.85
nullcTranslateToCFunction · 0.85
strstrFunction · 0.85
nullcGetBytecodeFunction · 0.85
strchrFunction · 0.85
nullcLoadModuleByBinaryFunction · 0.85

Tested by

no test coverage detected