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

Method RunCode

tests/TestBase.cpp:70–333  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68}
69
70bool Tests::RunCode(const char *code, unsigned int executor, const char* expected, const char* message, bool execShouldFail)
71{
72 lastMessage = message;
73#ifndef NULLC_BUILD_X86_JIT
74 if(executor != NULLC_VM)
75 return false;
76#endif
77 if(message && messageVerbose && executor == NULLC_VM)
78 printf("%s\n", message);
79
80 nullcSetExecutor(executor);
81
82 char buf[256];
83 sprintf(buf, "%s", executor == NULLC_VM ? "VM " : executor == NULLC_X86 ? "X86" : "LLVM");
84
85 double time = myGetPreciseTime();
86 nullres good = nullcCompile(code);
87 double timePassed = myGetPreciseTime() - time;
88 timeCompile += timePassed;
89// if(timePassed > 1.0)
90// printf("%s took %fms\n", message, timePassed);
91
92 time = myGetPreciseTime();
93 nullcSaveListing("asm.txt");
94 timeGetListing += myGetPreciseTime() - time;
95
96 if(!good)
97 {
98 if(message && !messageVerbose)
99 printf("%s\n", message);
100 printf("%s Compilation failed: %s\r\n", buf, nullcGetLastError());
101 return false;
102 }else{
103 char *bytecode;
104 time = myGetPreciseTime();
105 nullcGetBytecode(&bytecode);
106 timeGetBytecode += myGetPreciseTime() - time;
107 time = myGetPreciseTime();
108 nullcClean();
109 timeClean += myGetPreciseTime() - time;
110 time = myGetPreciseTime();
111 int linkgood = nullcLinkCode(bytecode);
112 timeLinkCode += myGetPreciseTime() - time;
113 delete[] bytecode;
114
115 if(!linkgood)
116 {
117 if(message && !messageVerbose)
118 printf("%s\n", message);
119 printf("%s Link failed: %s\r\n", buf, nullcGetLastError());
120 return false;
121 }
122
123 time = myGetPreciseTime();
124 nullres goodRun = nullcRun();
125 timeRun += myGetPreciseTime() - time;
126 if(goodRun)
127 {

Callers

nothing calls this directly

Calls 15

nullcSetExecutorFunction · 0.85
nullcCompileFunction · 0.85
nullcSaveListingFunction · 0.85
nullcGetLastErrorFunction · 0.85
nullcGetBytecodeFunction · 0.85
nullcCleanFunction · 0.85
nullcLinkCodeFunction · 0.85
nullcRunFunction · 0.85
nullcGetResultFunction · 0.85
nullcGetVariableDataFunction · 0.85
nullcFinalizeFunction · 0.85
strcmpFunction · 0.85

Tested by

no test coverage detected