edit

xiaoxiao2021-03-06  93

This program will automatically generate files required for MUDOS compile time. The following table describes what edit_source uses different parameters to enter files (files to be processed) and output files (after processing results):

Command parameter input file output file -configure configure.h -options options.h local_options options_incl.h option_def.c -malloc sysmalloc.c smalloc.c bsdmalloc.c wrappedmalloc.c debugmalloc.c malloc.c mallocwrapper.c -process grammar. y.pre grammar.y.pre grammar.y -build_spec "gcc -E" some files func_spec.c packages in func_spec.cpp -build_efuns func_spec.cpp efunctions.h opc.h opcodes.h efun_protos.h efun_defs.c

In fact, some commands cannot be used alone, because the results of -Options will be saved in memory - a Hash Talbe, which will determine the processing mode based on the precompiled instructions stored in this Hash Table. The correct command format should be:

l Edit_Source -Configure

This command will generate configure.h according to the compilation environment of the location:

If it is a Win32 environment, some default precompiled macros directly output, such as #define incl_stdlib_h, this macro is used in STD_INCL.H:

#ifdef incl_stdlib_h

# Include

#ENDIF

If it is an other environment, see the makefile script, first check if there are two files that exist for configure.h and configuration, exist, the program, if not, due to the difference between * NIX, you need to make a test to determine if the system is There is a LIB, such as judging whether there is stdlib.h: Mr. into a file comptest.c, this file is as follows:

#include "configure.h"

#include "std_incl.h"

#include "file_incl.h"

#include "stdlib.h"

Compile this file by calling the System function, determine whether there is a stdlib.h file in the system according to the return value of the System function. If there is, write #define incl_stdlib_h in configure.h.

This code also demonstrates how to determine if a file exists in a Win32 environment. Its practice is as follows:

INT Compile (char * command) {

File * tf = fopen ("trash_me.bat", "wt ");

FPRINTF (TF, "% S / N% S",

Command,

"if errorlevel == 1 goto error / n"

"DEL TRASH_ME.ERR> NUL / N"

"goto ok / n"

": Error / N"

"echo error> TRASH_ME.ERR / N"

": ok / n");

Fclose (TF);

IF (! "(" trash_me.bat ")) RETURN 1; IF (_Access (" trash_me.err ", 0)) Return 1;

Return 0;

}

l Edit_Source -Process grammar.y.pre

This instruction will parse the grammar.y.pre file, generate MUDOS's grammar file grammar.y, rules (these rules can use the VC Gadget WINDIFF comparison two files) as follows:

Encounter% Define DEFINES Add DEFINES to haveh Table;

Enabling% IFDEF Defines,% ELSE,% ENDIF, find this defines in Hash Table, then performs some contents to output some contents in the case where Conditions similar to C language is executed;

When you encounter% line, the line number in grammar.y.pre is output, such as "#LINE 3576 grammar.y.pre";

Export at the line number when you encounter the Action function "{" for a match-defined Action function, such as

Argument_list:

New_ARG

{

#Line 818 "grammar.y.pre"

When you encounter other content, it is directly output.

Edit_source -Process can also be used to generate a Makefile file, some of the files named .pre files in the MUDOS source code, which can be parsed by Edit_Source.

l Edit_Source -Options-Malloc -Build_Func_SPEC "GCC -E" -build_efuns

-Options Add macros in Options.h to the lathell.

-mallo Check the macro definition of memory allocation, decides to compile MUDOS, the library used (see "MUDOS in MUDOS"), such as defining the two macro of sysmalloc.c and debugmalloc, the program will put sysmalloc.c Copy the contents in Debugmalloc.c to Malloc.c and MallocWrapper.c, add these two files in Makefile and compile them - this is compiled under * NIX, but in the Release version The memory management library containing debug information is generally not used, so it is usually not required to add MallocWrapPer.c.

-build_func_spec "gcc -e" will generate func_spec.cpp files with "GCC -E FUNC_SPEC.C> FUNC_SPEC.CPP" instruction, "GCC -E" will indicate GCC to prepare FUNC_SPEC.C, output source code list to func_spec In .CPP, then check the macro definition related to Package, if you need to include a function package in the package, use the "GCC -E * .c >> FUNC_SPEC.CPP" instruction to add the source code list to FUNC_SPEC .CPP. Under the VC, you can use the "CL / E" instruction.

-build_efuns

An analysis of the FUNC_SPEC.CPP file is defined in Make_Func.y.

转载请注明原文地址:https://www.9cbs.com/read-123879.html

New Post(0)