MCPcopy Create free account
hub / github.com/covscript/covscript / covscript_main

Function covscript_main

sources/interpreter.cpp:164–360  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

162}
163
164void covscript_main(int args_size, char *args[])
165{
166 int index = covscript_args(args_size, args);
167 cs::current_process->import_path += cs::path_delimiter + cs::get_import_path();
168 if (show_help_info) {
169 std::cout << "Usage:\n";
170 std::cout << " cs [options...] <FILE|STDIN> [arguments...]\n";
171 std::cout << " cs [options...]\n";
172 std::cout << std::endl;
173 std::cout << "Interpreter Options:" << std::endl;
174 std::cout << " Option Mnemonic Function\n";
175 std::cout << " --compile-only -c Only compile\n";
176 std::cout << " --dump-ast -d Export abstract syntax tree\n";
177 std::cout << " --dependency -r Export module dependency\n";
178 std::cout << " --csym <FILE> -g <FILE> Read cSYM from file\n";
179 std::cout << std::endl;
180 std::cout << "Interpreter REPL Options:" << std::endl;
181 std::cout << " Option Mnemonic Function\n";
182 std::cout << " --silent -s Close the command prompt\n";
183 std::cout << " --args <...> -a <...> Set the arguments\n";
184 std::cout << std::endl;
185 std::cout << "Common Options:" << std::endl;
186 std::cout << " Option Mnemonic Function\n";
187 std::cout << " --no-optimize -o Disable optimizer\n";
188 std::cout << " --help -h Show help infomation\n";
189 std::cout << " --version -v Show version infomation\n";
190 std::cout << " --wait-before-exit -w Wait before process exit\n";
191 std::cout << " --stack-resize <SIZE> -S <SIZE> Reset the size of runtime stack\n";
192 std::cout << " --log-path <PATH> -l <PATH> Set the log and AST exporting path\n";
193 std::cout << " --import-path <PATH> -i <PATH> Set the import path\n";
194 std::cout << std::endl;
195 return;
196 }
197 else if (show_version_info) {
198 std::cout << "Version: " << cs::current_process->version << std::endl;
199 std::cout << cs::copyright_info << std::endl;
200 std::cout << "\nMetadata:\n";
201 std::cout << " Import Path: " << cs::current_process->import_path << "\n";
202 std::cout << " STD Version: " << cs::current_process->std_version << "\n";
203 std::cout << " API Version: " << CS_GET_VERSION_STR(COVSCRIPT_API_VERSION) << "\n";
204 std::cout << " ABI Version: " << CS_GET_VERSION_STR(COVSCRIPT_ABI_VERSION) << "\n";
205 std::cout << " Runtime Env: " << COVSCRIPT_PLATFORM_NAME << "-" << COVSCRIPT_ARCH_NAME << "\n";
206 std::cout << " Compile Env: " << COVSCRIPT_COMPILER_NAME << "\n";
207 std::cout << std::endl;
208 return;
209 }
210 if (!repl && index != args_size) {
211#ifdef CS_ENABLE_PROFILING
212 std::cout << "CovScript: Perf mode, may slow down interpret speed." << std::endl;
213 std::memset((void *) &cs_impl::op_perf, 0, sizeof(cs_impl::op_perf));
214#endif
215 std::string path = cs::process_path(args[index]);
216 if (path != "STDIN") {
217 if (!cs_impl::file_system::exist(path) || cs_impl::file_system::is_dir(path) ||
218 !cs_impl::file_system::can_read(path))
219 throw cs::fatal_error("invalid input file.");
220 cs::prepend_import_path(path, cs::current_process);
221 }

Callers 1

mainFunction · 0.70

Calls 15

process_pathFunction · 0.85
is_dirFunction · 0.85
fatal_errorClass · 0.85
prepend_import_pathFunction · 0.85
create_contextFunction · 0.85
getlineFunction · 0.85
add_listenerMethod · 0.80
import_csymMethod · 0.80
compileMethod · 0.80
dump_astMethod · 0.80
interpretMethod · 0.80
relocate_to_csymMethod · 0.80

Tested by

no test coverage detected