mirror of
https://git.wuffs.org/MWCC
synced 2025-12-11 14:42:04 +00:00
a bunch of compiler stuff
This commit is contained in:
921
compiler_and_linker/FrontEnd/C/CPrep.c
Normal file
921
compiler_and_linker/FrontEnd/C/CPrep.c
Normal file
@@ -0,0 +1,921 @@
|
||||
#include "compiler.h"
|
||||
#include "compiler/CError.h"
|
||||
#include "compiler/tokens.h"
|
||||
#include "cos.h"
|
||||
|
||||
extern SInt16 *CLT_filesp;
|
||||
extern CPrepFileInfo **CLT_filestack;
|
||||
|
||||
//#define OPT_OFFSET(optname) ((short) (((char *) (&copts.optname)) - ((char *) &copts)))
|
||||
#define OPT_OFFSET(optname) ((short) ( &((COpts *)0)->optname ))
|
||||
enum {
|
||||
OPT_FLAG_2000 = 0x2000,
|
||||
OPT_FLAG_4000 = 0x4000
|
||||
};
|
||||
|
||||
struct {
|
||||
char *name;
|
||||
short bits;
|
||||
} compileroptions[138] = {
|
||||
"little_endian", OPT_FLAG_4000 | OPT_OFFSET(little_endian),
|
||||
"longlong", OPT_OFFSET(longlong),
|
||||
"traceback", OPT_OFFSET(traceback),
|
||||
"disable_registers", OPT_OFFSET(disable_registers),
|
||||
"fp_contract", OPT_OFFSET(fp_contract),
|
||||
"no_common", OPT_OFFSET(no_common),
|
||||
"no_implicit_templates", OPT_OFFSET(no_implicit_templates),
|
||||
"absolutepath", OPT_OFFSET(absolutepath),
|
||||
"debug_listing", OPT_OFFSET(debuglisting),
|
||||
"profile", OPT_OFFSET(profile),
|
||||
"optimizewithasm", OPT_OFFSET(optimizewithasm),
|
||||
"use_lmw_stmw", OPT_OFFSET(use_lmw_stmw),
|
||||
"no_register_save_helpers", OPT_OFFSET(no_register_save_helpers),
|
||||
"ppc_opt_bclr_bcctr", OPT_OFFSET(ppc_opt_bclr_bcctr),
|
||||
"misaligned_mem_access", OPT_OFFSET(misaligned_mem_access),
|
||||
"switch_tables", OPT_OFFSET(switch_tables),
|
||||
"prepare_compress", OPT_OFFSET(prepare_compress),
|
||||
"asmsemicolcomment", OPT_OFFSET(asmsemicolcomment),
|
||||
"asmpoundcomment", OPT_OFFSET(asmpoundcomment),
|
||||
"cplusplus", OPT_OFFSET(cplusplus),
|
||||
"ecplusplus", OPT_OFFSET(ecplusplus),
|
||||
"objective_c", OPT_OFFSET(objective_c),
|
||||
"objc_strict", OPT_OFFSET(objc_strict),
|
||||
"ARM_conform", OPT_OFFSET(ARM_conform),
|
||||
"ARM_scoping", OPT_OFFSET(ARM_scoping),
|
||||
"require_prototypes", OPT_OFFSET(require_prototypes),
|
||||
"trigraphs", OPT_OFFSET(trigraphs),
|
||||
"only_std_keywords", OPT_OFFSET(only_std_keywords),
|
||||
"enumsalwaysint", OPT_OFFSET(enumsalwaysint),
|
||||
"ANSI_strict", OPT_OFFSET(ANSI_strict),
|
||||
"mpwc_relax", OPT_OFFSET(mpwc_relax),
|
||||
"mpwc_newline", OPT_OFFSET(mpwc_newline),
|
||||
"ignore_oldstyle", OPT_OFFSET(ignore_oldstyle),
|
||||
"cpp_extensions", OPT_OFFSET(cpp_extensions),
|
||||
"pointercast_lvalue", OPT_OFFSET(pointercast_lvalue),
|
||||
"RTTI", OPT_OFFSET(useRTTI),
|
||||
"delete_exception", OPT_OFFSET(delete_exception),
|
||||
"oldalignment", OPT_OFFSET(oldalignment),
|
||||
"multibyteaware", OPT_OFFSET(multibyteaware),
|
||||
"unsigned_char", OPT_OFFSET(unsignedchars),
|
||||
"auto_inline", OPT_OFFSET(autoinline),
|
||||
"inline_bottom_up", OPT_OFFSET(inline_bottom_up),
|
||||
"defer_codegen", OPT_OFFSET(defer_codegen),
|
||||
"direct_to_som", OPT_OFFSET(direct_to_som),
|
||||
"SOMCheckEnvironment", OPT_OFFSET(som_env_check),
|
||||
"SOMCallOptimization", OPT_OFFSET(som_call_opt),
|
||||
"bool", OPT_OFFSET(booltruefalse),
|
||||
"old_enum_mangler", OPT_OFFSET(old_enum_mangler),
|
||||
"longlong_enums", OPT_OFFSET(longlong_enums),
|
||||
"no_tfuncinline", OPT_OFFSET(no_tfuncinline),
|
||||
"flat_include", OPT_OFFSET(flat_include),
|
||||
"syspath_once", OPT_OFFSET(syspath_once),
|
||||
"always_import", OPT_OFFSET(always_import),
|
||||
"simple_class_byval", OPT_OFFSET(simple_class_byval),
|
||||
"wchar_type", OPT_OFFSET(wchar_type),
|
||||
"vbase_ctor_offset", OPT_OFFSET(vbase_ctor_offset),
|
||||
"vbase_abi_v2", OPT_OFFSET(vbase_abi_v2),
|
||||
"def_inherited", OPT_OFFSET(def_inherited),
|
||||
"template_patch", OPT_OFFSET(template_patch),
|
||||
"template_friends", OPT_OFFSET(template_friends),
|
||||
"faster_pch_gen", OPT_OFFSET(faster_pch_gen),
|
||||
"array_new_delete", OPT_OFFSET(array_new_delete),
|
||||
"dollar_identifiers", OPT_OFFSET(dollar_identifiers),
|
||||
"def_inline_tfuncs", OPT_OFFSET(def_inline_tfuncs),
|
||||
"arg_dep_lookup", OPT_OFFSET(arg_dep_lookup),
|
||||
"simple_prepdump", OPT_OFFSET(simple_prepdump),
|
||||
"line_prepdump", OPT_OFFSET(line_prepdump),
|
||||
"fullpath_prepdump", OPT_OFFSET(fullpath_prepdump),
|
||||
"old_mtemplparser", OPT_OFFSET(old_mtemplparser),
|
||||
"suppress_init_code", OPT_OFFSET(suppress_init_code),
|
||||
"reverse_bitfields", OPT_OFFSET(reverse_bitfields),
|
||||
"c9x", OPT_OFFSET(c9x),
|
||||
"float_constants", OPT_OFFSET(float_constants),
|
||||
"no_static_dtors", OPT_OFFSET(no_static_dtors),
|
||||
"longlong_prepeval", OPT_OFFSET(longlong_prepeval),
|
||||
"const_strings", OPT_OFFSET(const_strings),
|
||||
"dumpir", OPT_OFFSET(dumpir),
|
||||
"experimental", OPT_OFFSET(experimental),
|
||||
"gcc_extensions", OPT_OFFSET(gcc_extensions),
|
||||
"stdc_fp_contract", OPT_OFFSET(stdc_fp_contract),
|
||||
"stdc_fenv_access", OPT_OFFSET(stdc_fenv_access),
|
||||
"stdc_cx_limitedr", OPT_OFFSET(stdc_cx_limitedr),
|
||||
"old_argmatch", OPT_OFFSET(old_argmatch),
|
||||
"optEH", OPT_OFFSET(optEH),
|
||||
"optEH2", OPT_OFFSET(optEH2),
|
||||
"new_mangler", OPT_OFFSET(new_mangler),
|
||||
"microsoft_exceptions", OPT_OFFSET(microsoft),
|
||||
"microsoft_RTTI", OPT_OFFSET(microsoft),
|
||||
"warning_errors", OPT_OFFSET(warningerrors),
|
||||
"extended_errorcheck", OPT_OFFSET(pedantic),
|
||||
"check_header_flags", OPT_OFFSET(check_header_flags),
|
||||
"supress_warnings", OPT_OFFSET(supress_warnings),
|
||||
"warn_illpragma", OPT_OFFSET(warn_illpragma),
|
||||
"warn_emptydecl", OPT_OFFSET(warn_emptydecl),
|
||||
"warn_possunwant", OPT_OFFSET(warn_possunwant),
|
||||
"warn_unusedvar", OPT_OFFSET(warn_unusedvar),
|
||||
"warn_unusedarg", OPT_OFFSET(warn_unusedarg),
|
||||
"warn_extracomma", OPT_OFFSET(warn_extracomma),
|
||||
"warn_hidevirtual", OPT_OFFSET(warn_hidevirtual),
|
||||
"warn_largeargs", OPT_OFFSET(warn_largeargs),
|
||||
"warn_implicitconv", OPT_OFFSET(warn_implicitconv),
|
||||
"warn_notinlined", OPT_OFFSET(warn_notinlined),
|
||||
"warn_structclass", OPT_OFFSET(warn_structclass),
|
||||
"warn_padding", OPT_OFFSET(warn_padding),
|
||||
"warn_no_side_effect", OPT_OFFSET(warn_no_side_effect),
|
||||
"warn_resultnotused", OPT_OFFSET(warn_resultnotused),
|
||||
"warn_ptr_int_conv", OPT_OFFSET(warn_ptr_int_conv),
|
||||
"align_array_members", OPT_OFFSET(align_array_members),
|
||||
"dont_reuse_strings", OPT_OFFSET(dont_reuse_strings),
|
||||
"pool_strings", OPT_OFFSET(pool_strings),
|
||||
"explicit_zero_data", OPT_OFFSET(explicit_zero_data),
|
||||
"readonly_strings", OPT_OFFSET(readonly_strings),
|
||||
"opt_common_subs", OPT_OFFSET(opt_common_subs),
|
||||
"opt_loop_invariants", OPT_OFFSET(opt_loop_invariants),
|
||||
"opt_propagation", OPT_OFFSET(opt_propagation),
|
||||
"opt_unroll_loops", OPT_OFFSET(opt_unroll_loops),
|
||||
"opt_lifetimes", OPT_OFFSET(opt_lifetimes),
|
||||
"opt_strength_reduction", OPT_OFFSET(opt_strength_reduction),
|
||||
"opt_strength_reduction_strict", OPT_OFFSET(opt_strength_reduction_strict),
|
||||
"opt_dead_code", OPT_OFFSET(opt_dead_code),
|
||||
"opt_dead_assignments", OPT_OFFSET(opt_dead_assignments),
|
||||
"opt_vectorize_loops", OPT_OFFSET(opt_vectorize_loops),
|
||||
"opt_pointer_analysis", OPT_OFFSET(opt_pointer_analysis),
|
||||
"exceptions", OPT_OFFSET(exceptions),
|
||||
"dont_inline", OPT_OFFSET(dont_inline),
|
||||
"always_inline", OPT_OFFSET(always_inline),
|
||||
"optimize_for_size", OPT_OFFSET(optimize_for_size),
|
||||
"peephole", OPT_OFFSET(peephole),
|
||||
"global_optimizer", OPT_OFFSET(global_optimizer),
|
||||
"side_effects", OPT_OFFSET(side_effects),
|
||||
"internal", OPT_FLAG_2000 | OPT_OFFSET(internal),
|
||||
"import", OPT_FLAG_2000 | OPT_OFFSET(import),
|
||||
"export", OPT_FLAG_2000 | OPT_OFFSET(export),
|
||||
"lib_export", OPT_FLAG_2000 | OPT_OFFSET(lib_export),
|
||||
"nosyminline", OPT_OFFSET(nosyminline),
|
||||
"force_active", OPT_OFFSET(force_active),
|
||||
"sym", OPT_OFFSET(isGeneratingDebugInfo),
|
||||
NULL, 0
|
||||
};
|
||||
|
||||
CParams *cparamblkptr;
|
||||
short tk;
|
||||
CInt64 tkintconst;
|
||||
Float tkfloatconst;
|
||||
char *tkstring;
|
||||
HashNameNode *tkidentifier;
|
||||
SInt32 tksize;
|
||||
short ispascalstring;
|
||||
short nlflag;
|
||||
SInt32 lines;
|
||||
Boolean spaceskip;
|
||||
Macro **macrohashtable;
|
||||
Boolean cprep_nomem_exit;
|
||||
Boolean cprep_nostring;
|
||||
Boolean cprep_eoltokens;
|
||||
static void *ifstack[100]; // TODO type+size
|
||||
static short iflevel;
|
||||
TokenStack tokenstack[128];
|
||||
short tokenstacklevel;
|
||||
SInt32 cprep_cursymfile; // might be a ptr?
|
||||
char *pos;
|
||||
char *macropos;
|
||||
char *nextcharpos;
|
||||
char CPrep_SkipNewCommentChar;
|
||||
Boolean preprocessing_only;
|
||||
Handle stringmem;
|
||||
SInt32 maxstringsize;
|
||||
char cprep_idarray[256];
|
||||
Boolean was_escchar;
|
||||
Boolean macrocheck;
|
||||
Boolean widestring;
|
||||
Boolean at_linestart;
|
||||
char *prep_file_start;
|
||||
char *prep_file_end;
|
||||
char *macrostart;
|
||||
Boolean cprep_strconcat;
|
||||
CPrepFileInfo *prep_file;
|
||||
short filesp;
|
||||
SInt32 linenumber;
|
||||
static CPrepFileInfo *filestack[32];
|
||||
static void *cprep_files; // TODO type
|
||||
static SInt32 linetick;
|
||||
static Boolean waslockedmacro;
|
||||
static Boolean include_once;
|
||||
static time_t now_time;
|
||||
static SInt32 lineoffset;
|
||||
static Boolean was_prep_error;
|
||||
static Boolean cprep_hasprepline;
|
||||
static Boolean cprep_incondexpr;
|
||||
static void *cprep_packstack[100]; // TODO type+size
|
||||
static short cprep_packstackp;
|
||||
static Macro lineM;
|
||||
static Macro fileM;
|
||||
static Macro dateM;
|
||||
static Macro timeM;
|
||||
static Macro stdcM;
|
||||
static Macro stcvM;
|
||||
static Macro stchM;
|
||||
static Macro casmM;
|
||||
static Macro cpplM;
|
||||
static Macro MWRSM;
|
||||
static Macro dtsomM;
|
||||
static Macro ecppM;
|
||||
static Macro optiM;
|
||||
static Macro trgtM;
|
||||
GList pplist;
|
||||
struct COptsPush {
|
||||
struct COptsPush *next;
|
||||
COpts opts;
|
||||
};
|
||||
static struct COptsPush *coptpushs;
|
||||
static void *coptpush; // TODO type
|
||||
static void *coptssave; // TODO type
|
||||
static Boolean dofreeaheap;
|
||||
static GList mlist;
|
||||
static Handle ts_buffer;
|
||||
static TStreamElement *ts_first;
|
||||
static TStreamElement *ts_last;
|
||||
TStreamElement *ts_current;
|
||||
static SInt32 ts_elements;
|
||||
SInt32 ts_preread_elements;
|
||||
static SInt32 gDirectiveStart;
|
||||
static SInt32 high_mem_mark;
|
||||
// static TStreamElement dummyelement; // in CPrep_CurStreamElement
|
||||
static short exprtk;
|
||||
|
||||
static void cannotopenerror(StringPtr filename, Boolean err) {
|
||||
static char fname[64];
|
||||
|
||||
short len = filename[0];
|
||||
if (len > 63)
|
||||
len = 63;
|
||||
memcpy(fname, filename + 1, len);
|
||||
fname[len] = 0;
|
||||
|
||||
CError_ResetErrorSkip();
|
||||
|
||||
if (prep_file) {
|
||||
was_prep_error = 1;
|
||||
CError_Error(151, fname);
|
||||
if (err)
|
||||
longjmp(errorreturn, 1);
|
||||
} else {
|
||||
CError_CannotOpen();
|
||||
}
|
||||
}
|
||||
|
||||
static void insertmacro(Macro *macro) {
|
||||
macro->next = macrohashtable[macro->name->hashval];
|
||||
macrohashtable[macro->name->hashval] = macro;
|
||||
macro->xF = 0;
|
||||
}
|
||||
|
||||
void CPrep_InsertSpecialMacro(Macro *macro, char *name) {
|
||||
macro->name = GetHashNameNodeExport(name);
|
||||
macro->is_special = 1;
|
||||
insertmacro(macro);
|
||||
}
|
||||
|
||||
void CPrep_InsertSpecialMacros() {
|
||||
CPrep_InsertSpecialMacro(&lineM, "__LINE__");
|
||||
CPrep_InsertSpecialMacro(&fileM, "__FILE__");
|
||||
CPrep_InsertSpecialMacro(&dateM, "__DATE__");
|
||||
CPrep_InsertSpecialMacro(&timeM, "__TIME__");
|
||||
CPrep_InsertSpecialMacro(&stdcM, "__STDC__");
|
||||
CPrep_InsertSpecialMacro(&stcvM, "__STDC_VERSION__");
|
||||
CPrep_InsertSpecialMacro(&stchM, "__STDC_HOSTED__");
|
||||
CPrep_InsertSpecialMacro(&casmM, "__CASM__");
|
||||
CPrep_InsertSpecialMacro(&cpplM, "__cplusplus");
|
||||
CPrep_InsertSpecialMacro(&MWRSM, "__MWERKS__");
|
||||
CPrep_InsertSpecialMacro(&dtsomM, "__SOM_ENABLED__");
|
||||
CPrep_InsertSpecialMacro(&ecppM, "__embedded_cplusplus");
|
||||
CPrep_InsertSpecialMacro(&optiM, "__option");
|
||||
CPrep_InsertSpecialMacro(&trgtM, "__ide_target");
|
||||
CodeGen_InsertSpecialMacros();
|
||||
}
|
||||
|
||||
void CPrep_RemoveSpecialMacros() {
|
||||
Macro **scan;
|
||||
int x;
|
||||
|
||||
for (x = 0; x < 2048; x++) {
|
||||
scan = ¯ohashtable[x];
|
||||
while (*scan) {
|
||||
if ((*scan)->is_special) {
|
||||
*scan = (*scan)->next;
|
||||
} else {
|
||||
scan = &(*scan)->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void CPrep_Reconfig() {
|
||||
cprep_idarray['$'] = copts.dollar_identifiers != 0;
|
||||
}
|
||||
|
||||
Boolean setupprep() {
|
||||
int x;
|
||||
|
||||
now_time = time(NULL);
|
||||
lineoffset = 0;
|
||||
include_once = 0;
|
||||
cprep_eoltokens = 0;
|
||||
cprep_nostring = 0;
|
||||
cprep_incondexpr = 0;
|
||||
filesp = -1;
|
||||
linetick = 0;
|
||||
lines = 0;
|
||||
dofreeaheap = 1;
|
||||
macrocheck = 1;
|
||||
maxstringsize = 256;
|
||||
iflevel = 0;
|
||||
tokenstacklevel = 0;
|
||||
cprep_cursymfile = 0;
|
||||
cprep_files = 0;
|
||||
CLT_filesp = &filesp;
|
||||
CLT_filestack = filestack;
|
||||
anyerrors = 0;
|
||||
fatalerrors = 0;
|
||||
was_prep_error = 0;
|
||||
cprep_strconcat = 0;
|
||||
|
||||
GListErrorProc = CError_NoMem;
|
||||
mlist.data = NULL;
|
||||
pplist.data = NULL;
|
||||
if (InitGList(&mlist, 10000))
|
||||
CError_NoMem();
|
||||
|
||||
stringmem = COS_NewHandle(256);
|
||||
if (!stringmem)
|
||||
CError_NoMem();
|
||||
ts_buffer = COS_NewHandle(1024 * sizeof(TStreamElement));
|
||||
if (!ts_buffer)
|
||||
CError_NoMem();
|
||||
COS_LockHandleHi(ts_buffer);
|
||||
ts_first = (TStreamElement *) *ts_buffer;
|
||||
ts_last = ts_first + 1023;
|
||||
ts_current = ts_first;
|
||||
ts_elements = 1024;
|
||||
ts_preread_elements = 0;
|
||||
|
||||
macrohashtable = galloc(sizeof(Macro *) * 2048);
|
||||
memclrw(macrohashtable, sizeof(Macro *) * 2048);
|
||||
CPrep_InsertSpecialMacros();
|
||||
|
||||
for (x = 0; x < 256; x++)
|
||||
cprep_idarray[x] = 0;
|
||||
|
||||
for (x = 'a'; ; x++) {
|
||||
cprep_idarray[x] = 1;
|
||||
if (x == 'z') break;
|
||||
}
|
||||
|
||||
for (x = 'A'; ; x++) {
|
||||
cprep_idarray[x] = 1;
|
||||
if (x == 'Z') break;
|
||||
}
|
||||
|
||||
for (x = '0'; ; x++) {
|
||||
cprep_idarray[x] = 2;
|
||||
if (x == '9') break;
|
||||
}
|
||||
|
||||
cprep_idarray['_'] = 1;
|
||||
|
||||
CPrep_Reconfig();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void cleanupprep() {
|
||||
while (filesp >= 0)
|
||||
popfile();
|
||||
|
||||
high_mem_mark = CTool_TotalHeapSize();
|
||||
releaseheaps();
|
||||
GListErrorProc = NULL;
|
||||
FreeGList(&mlist);
|
||||
FreeGList(&pplist);
|
||||
|
||||
if (stringmem) {
|
||||
COS_FreeHandle(stringmem);
|
||||
stringmem = NULL;
|
||||
}
|
||||
|
||||
if (ts_buffer) {
|
||||
COS_FreeHandle(ts_buffer);
|
||||
ts_buffer = NULL;
|
||||
}
|
||||
ts_current = NULL;
|
||||
ts_first = ts_last = NULL;
|
||||
}
|
||||
|
||||
static char *getfiledata(FSSpec *spec) {
|
||||
const char *text;
|
||||
SInt32 textlength;
|
||||
short filedatatype;
|
||||
|
||||
if (CWGetFileText(cparamblkptr->context, spec, &text, &textlength, &filedatatype) != cwNoErr) {
|
||||
Str255 filename;
|
||||
COS_FileGetFSSpecInfo(spec, NULL, NULL, filename);
|
||||
cannotopenerror(filename, 1);
|
||||
return NULL;
|
||||
} else {
|
||||
return (char *) text;
|
||||
}
|
||||
}
|
||||
|
||||
static Boolean setupfile(StringPtr filename, Boolean flag1, Boolean flag2) {
|
||||
CPrepFileInfo prepinfo;
|
||||
CWFileInfo fileinfo;
|
||||
Str255 file_filename;
|
||||
char myfilename[256];
|
||||
OSType file_type;
|
||||
SInt32 file_size;
|
||||
SInt32 file_dirid;
|
||||
CWMemHandle cache_hnd;
|
||||
void *cache;
|
||||
SInt16 refnum;
|
||||
SInt16 file_vrefnum;
|
||||
char *extpos;
|
||||
|
||||
if (filesp >= 31) {
|
||||
was_prep_error = 1;
|
||||
CError_ErrorTerm(243);
|
||||
return 0;
|
||||
}
|
||||
|
||||
memclrw(&prepinfo, sizeof(CPrepFileInfo));
|
||||
prepinfo.unkfield126 = !flag1; // may be wrong field!
|
||||
if (filename) {
|
||||
memclrw(&fileinfo, sizeof(CWFileInfo));
|
||||
fileinfo.fullsearch = flag2;
|
||||
fileinfo.dependencyType = cwNormalDependency;
|
||||
fileinfo.isdependentoffile = -1;
|
||||
memcpy(myfilename, &filename[1], filename[0]);
|
||||
myfilename[filename[0]] = 0;
|
||||
|
||||
if (CWFindAndLoadFile(cparamblkptr->context, myfilename, &fileinfo) != cwNoErr) {
|
||||
if (filename[0] + strlen(".framework/Headers") < 255) {
|
||||
if ((extpos = strchr(myfilename, '/'))) {
|
||||
// Do Me! 37D8C
|
||||
} else {
|
||||
cannotopenerror(filename, 0);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
cannotopenerror(filename, 0);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ((flag2 || include_once) && fileinfo.alreadyincluded)
|
||||
return 1;
|
||||
|
||||
prepinfo.textfile = fileinfo.filespec;
|
||||
prepinfo.nameNode = CTool_GetPathName(&fileinfo.filespec, &prepinfo.fileModDate);
|
||||
if (fileinfo.filedata) {
|
||||
if (fileinfo.filedatatype == cwFileTypeText) {
|
||||
prepinfo.textbuffer = (char *) fileinfo.filedata;
|
||||
prepinfo.textlength = fileinfo.filedatalength;
|
||||
prepinfo.fileID = fileinfo.fileID;
|
||||
prepinfo.recordbrowseinfo = fileinfo.recordbrowseinfo;
|
||||
} else if (fileinfo.filedatatype == cwFileTypePrecompiledHeader) {
|
||||
PrecompilerRead(0, (void *) fileinfo.filedata);
|
||||
return 1;
|
||||
} else {
|
||||
cannotopenerror(filename, 0);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
COS_FileGetFSSpecInfo(&prepinfo.textfile, &file_vrefnum, &file_dirid, file_filename);
|
||||
if (COS_FileOpen(&prepinfo.textfile, &refnum)) {
|
||||
cannotopenerror(filename, 0);
|
||||
return 0;
|
||||
}
|
||||
if (COS_FileGetType(&prepinfo.textfile, &file_type) || COS_FileGetSize(refnum, &file_size)) {
|
||||
COS_FileClose(refnum);
|
||||
cannotopenerror(filename, 0);
|
||||
return 0;
|
||||
}
|
||||
if (file_type == copts.pchType) {
|
||||
if (cparamblkptr->isCachingPrecompiledHeaders) {
|
||||
if (CWAllocMemHandle(cparamblkptr->context, file_size, 1, &cache_hnd) != cwNoErr) {
|
||||
if (CWAllocMemHandle(cparamblkptr->context, file_size, 0, &cache_hnd) != cwNoErr) {
|
||||
COS_FileClose(refnum);
|
||||
CError_NoMem();
|
||||
}
|
||||
}
|
||||
|
||||
CWLockMemHandle(cparamblkptr->context, cache_hnd, 0, &cache);
|
||||
if (COS_FileRead(refnum, cache, file_size)) {
|
||||
COS_FileClose(refnum);
|
||||
CWFreeMemHandle(cparamblkptr->context, cache_hnd);
|
||||
cannotopenerror(filename, 0);
|
||||
return 0;
|
||||
}
|
||||
COS_FileClose(refnum);
|
||||
CWCachePrecompiledHeader(cparamblkptr->context, &prepinfo.textfile, cache_hnd);
|
||||
PrecompilerRead(0, cache);
|
||||
CWUnlockMemHandle(cparamblkptr->context, cache_hnd);
|
||||
return 1;
|
||||
} else {
|
||||
PrecompilerRead(refnum, 0);
|
||||
COS_FileClose(refnum);
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
COS_FileClose(refnum);
|
||||
cannotopenerror(filename, 0);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!cparamblkptr->mainFileText) {
|
||||
COS_FileGetFSSpecInfo(&cparamblkptr->mainFileSpec, &file_vrefnum, &file_dirid, file_filename);
|
||||
cannotopenerror(file_filename, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
prepinfo.textfile = cparamblkptr->mainFileSpec;
|
||||
prepinfo.textbuffer = (char *) cparamblkptr->mainFileText;
|
||||
prepinfo.textlength = cparamblkptr->mainFileTextLength;
|
||||
prepinfo.fileID = cparamblkptr->mainFileID;
|
||||
prepinfo.recordbrowseinfo = cparamblkptr->field276;
|
||||
}
|
||||
|
||||
if (filesp >= 0) {
|
||||
filestack[filesp]->linenumber = linenumber;
|
||||
filestack[filesp]->hasprepline = cprep_hasprepline;
|
||||
filestack[filesp]->pos = pos - filestack[filesp]->textbuffer;
|
||||
}
|
||||
|
||||
pos = prepinfo.textbuffer;
|
||||
linenumber = 1;
|
||||
at_linestart = 1;
|
||||
filestack[++filesp] = galloc(sizeof(CPrepFileInfo));
|
||||
*filestack[filesp] = prepinfo;
|
||||
prep_file = filestack[filesp];
|
||||
prep_file_start = prep_file->textbuffer;
|
||||
prep_file_end = prep_file->textbuffer + prep_file->textlength;
|
||||
if (preprocessing_only && !copts.simple_prepdump)
|
||||
CPrep_PreprocessDumpFileInfo(1);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void CPrep_TSBufferGrow(int amount) {
|
||||
int current_offset = ts_current - ts_first;
|
||||
COS_UnlockHandle(ts_buffer);
|
||||
if (!COS_ResizeHandle(ts_buffer, sizeof(TStreamElement) * (ts_elements + amount)))
|
||||
CError_NoMem();
|
||||
COS_LockHandleHi(ts_buffer);
|
||||
ts_elements += amount;
|
||||
ts_first = (TStreamElement *) *ts_buffer;
|
||||
ts_last = ts_first + (ts_elements - 1);
|
||||
ts_current = ts_first + current_offset;
|
||||
}
|
||||
|
||||
void CPrep_TokenStreamGetState(SInt32 *state) {
|
||||
*state = ts_current - ts_first;
|
||||
}
|
||||
|
||||
void CPrep_TokenStreamSetState(SInt32 *state) {
|
||||
ts_preread_elements += ts_current - ts_first - *state;
|
||||
ts_current = ts_first + *state;
|
||||
}
|
||||
|
||||
void CPrep_UnLex() {
|
||||
++ts_preread_elements;
|
||||
--ts_current;
|
||||
#line 900
|
||||
CError_ASSERT(ts_current >= ts_first);
|
||||
}
|
||||
|
||||
void CPrep_TokenStreamSetCurState(SInt32 *state) {
|
||||
ts_preread_elements += ts_current - ts_first - (*state - 1);
|
||||
ts_current = ts_first + (*state - 1);
|
||||
tk = lex();
|
||||
}
|
||||
|
||||
static void CPrep_StreamSkipToBrace() {}
|
||||
static void CPrep_StreamSkipBlock() {}
|
||||
void CPrep_StreamGetBlock() {}
|
||||
void CPrep_StreamGetSemicolon() {}
|
||||
void CPrep_StreamGetTemplate() {}
|
||||
void CPrep_StreamInsert() {}
|
||||
void CPrep_StreamRemove() {}
|
||||
void CPrep_RemoveTokens() {}
|
||||
void CPrep_TokenStreamFlush() {}
|
||||
static void CPrep_TokenSize() {}
|
||||
void CPrep_CurStreamElement() {}
|
||||
|
||||
void CPrep_GetTokenContext(TStreamElement *token, CPrepFileInfo **tokenfile, SInt32 *selectionoffset, short *tokensize, SInt32 *linenumber, char *buf1, short *tokenoffset, short *tokenlength, char *buf2, short *lastarg) {
|
||||
}
|
||||
|
||||
void CPrep_Error(short code) {
|
||||
Boolean save = in_assembler;
|
||||
in_assembler = 0;
|
||||
if (code == 102 && (tokenstacklevel > 0 || pos < prep_file_end))
|
||||
code = 105;
|
||||
was_prep_error = 1;
|
||||
CError_Error(code);
|
||||
in_assembler = save;
|
||||
}
|
||||
|
||||
void CPrep_ErrorName(short code, const char *name) {
|
||||
Boolean save = in_assembler;
|
||||
in_assembler = 0;
|
||||
was_prep_error = 1;
|
||||
if (code == 102 && (tokenstacklevel > 0 || pos < prep_file_end))
|
||||
CError_Error(105, name);
|
||||
else
|
||||
CError_Error(code, name);
|
||||
in_assembler = save;
|
||||
}
|
||||
|
||||
void CPrep_Warning(short code) {
|
||||
Boolean save = in_assembler;
|
||||
in_assembler = 0;
|
||||
was_prep_error = 1;
|
||||
CError_Warning(code);
|
||||
in_assembler = save;
|
||||
}
|
||||
|
||||
void CPrep_WarningName(short code, const char *name) {
|
||||
Boolean save = in_assembler;
|
||||
in_assembler = 0;
|
||||
was_prep_error = 1;
|
||||
CError_Warning(code, name);
|
||||
in_assembler = save;
|
||||
}
|
||||
|
||||
void CPrep_ErrorMessage(int errTable, char *str, Boolean flag1, Boolean flag2) {
|
||||
Boolean save = in_assembler;
|
||||
in_assembler = 0;
|
||||
was_prep_error = 1;
|
||||
CError_ErrorMessage(errTable, str, flag1, flag2);
|
||||
in_assembler = save;
|
||||
}
|
||||
|
||||
void CPrep_ErrorMessageVA(int code, const char *format, va_list list, Boolean flag1, Boolean flag2) {
|
||||
Boolean save = in_assembler;
|
||||
in_assembler = 0;
|
||||
was_prep_error = 1;
|
||||
CError_ErrorMessageVA(code, format, list, flag1, flag2);
|
||||
in_assembler = save;
|
||||
}
|
||||
|
||||
void popfile() {
|
||||
// r5 and r6 are swapped, not sure why
|
||||
if (filesp >= 0) {
|
||||
CWReleaseFileText(cparamblkptr->context, prep_file->textbuffer);
|
||||
prep_file->textbuffer = NULL;
|
||||
if (--filesp >= 0) {
|
||||
prep_file = filestack[filesp];
|
||||
prep_file_start = prep_file->textbuffer;
|
||||
prep_file_end = prep_file->textbuffer + prep_file->textlength;
|
||||
pos = prep_file_start + prep_file->pos;
|
||||
linenumber = prep_file->linenumber;
|
||||
cprep_hasprepline = prep_file->hasprepline;
|
||||
at_linestart = 1;
|
||||
}
|
||||
if (preprocessing_only && !copts.simple_prepdump)
|
||||
CPrep_PreprocessDumpFileInfo(1);
|
||||
}
|
||||
}
|
||||
|
||||
static void prepoffset() {}
|
||||
static void prepoffset2() {}
|
||||
void CPrep_SetSourceFile() {}
|
||||
void CPrep_GetSourceFilePath() {}
|
||||
void CPrep_NewFileOffsetInfo() {}
|
||||
void CPrep_GetFileOffsetInfo() {}
|
||||
void CPrep_GetFileOffsetInfo2() {}
|
||||
void CPrep_ResetFileInfo() {}
|
||||
void CPrep_GetPrepPos() {}
|
||||
Boolean C_Compiler(CParams *param) {}
|
||||
|
||||
static void pushtokenseq(Macro *macro) {
|
||||
if (tokenstacklevel >= 128) {
|
||||
was_prep_error = 1;
|
||||
CError_ErrorTerm(111);
|
||||
} else {
|
||||
tokenstack[tokenstacklevel].pos = pos;
|
||||
tokenstack[tokenstacklevel].macrostart = macrostart;
|
||||
tokenstack[tokenstacklevel].macro = macro;
|
||||
if (macro)
|
||||
macro->xF = 1;
|
||||
tokenstack[tokenstacklevel].macrocheck = macrocheck;
|
||||
tokenstacklevel++;
|
||||
}
|
||||
}
|
||||
|
||||
void poptokenseq() {
|
||||
if (!--tokenstacklevel && dofreeaheap)
|
||||
freeaheap();
|
||||
|
||||
pos = tokenstack[tokenstacklevel].pos;
|
||||
macrostart = tokenstack[tokenstacklevel].macrostart;
|
||||
if (tokenstack[tokenstacklevel].macro)
|
||||
tokenstack[tokenstacklevel].macro->xF = 0;
|
||||
macrocheck = tokenstack[tokenstacklevel].macrocheck;
|
||||
spaceskip = 1;
|
||||
}
|
||||
|
||||
static void is_nextchar() {}
|
||||
static void ismacroname() {}
|
||||
static void ismacroname2() {}
|
||||
static void ismacroname5() {}
|
||||
static void ismacroname3() {}
|
||||
static void ismacroname4() {}
|
||||
void foundnl() {}
|
||||
void newline() {}
|
||||
static void gotonexttoken() {}
|
||||
short notendofline() {}
|
||||
static void CPrep_MacroRedefError() {}
|
||||
static void goendofline() {}
|
||||
static void CPrep_Define() {}
|
||||
static void prepundefine() {}
|
||||
static Boolean CPrep_CheckTarget() {}
|
||||
static Boolean CPrep_CheckOption() {}
|
||||
static void CPrep_XpandDefinedCheck() {}
|
||||
static void XpandString() {}
|
||||
char *CPrep_GetFileName(char *buffer, Boolean flag1, Boolean flag2) {
|
||||
}
|
||||
|
||||
static char *XpandSpecialMacro(Macro *macro) {
|
||||
char buf[512];
|
||||
char smallbuf[32];
|
||||
char *strptr;
|
||||
struct tm *tm;
|
||||
|
||||
if (macro == &optiM) {
|
||||
return CPrep_CheckOption() ? "1" : "0";
|
||||
} else if (macro == &trgtM) {
|
||||
return CPrep_CheckTarget() ? "1" : "0";
|
||||
} else if (macro == &lineM) {
|
||||
sprintf(buf, "%ld", linenumber);
|
||||
do_string:
|
||||
strptr = aalloc(strlen(buf) + 1);
|
||||
strcpy(strptr, buf);
|
||||
return strptr;
|
||||
} else if (macro == &fileM) {
|
||||
CPrep_GetFileName(buf, 0, 1);
|
||||
goto do_string;
|
||||
} else if (macro == &dateM) {
|
||||
tm = localtime(&now_time);
|
||||
strftime(buf, 64, "\"%b ", tm);
|
||||
strftime(smallbuf, 32, "%d", tm);
|
||||
if (smallbuf[0] == '0')
|
||||
smallbuf[0] = ' ';
|
||||
strcat(buf, smallbuf);
|
||||
strftime(smallbuf, 32, " %Y\"", tm);
|
||||
strcat(buf, smallbuf);
|
||||
goto do_string;
|
||||
} else if (macro == &timeM) {
|
||||
strftime(buf, 64, "\"%H:%M:%S\"", localtime(&now_time));
|
||||
goto do_string;
|
||||
} else if (macro == &stdcM) {
|
||||
return "1";
|
||||
} else if (macro == &casmM || macro == &MWRSM) {
|
||||
return "0x2405";
|
||||
} else if (macro == &cpplM) {
|
||||
return "199711L";
|
||||
} else if (macro == &dtsomM) {
|
||||
return copts.direct_to_som ? "1" : "0";
|
||||
} else if (macro == &ecppM) {
|
||||
return copts.ecplusplus ? "1" : "0";
|
||||
} else if (macro == &stcvM) {
|
||||
return copts.c9x ? "199901L" : "199409L";
|
||||
} else if (macro == &stchM) {
|
||||
return "0";
|
||||
} else {
|
||||
return CodeGen_ExpandSpecialMacro(macro);
|
||||
}
|
||||
}
|
||||
|
||||
static void XpandMacro() {}
|
||||
static void prepmacro() {}
|
||||
void macrotest() {}
|
||||
void CPrep_PragmaLex() {}
|
||||
void CPrep_PushOption() {}
|
||||
void CPrep_PopOption() {}
|
||||
static void CPrep_PragmaImExport() {}
|
||||
static void pragma_on_off_reset() {}
|
||||
static void CPrep_PragmaOnceName() {}
|
||||
static void pragma_precompile_target() {}
|
||||
static void CPrep_DefinePragmaOnceMacro() {}
|
||||
static void CPrep_PragmaOnce() {}
|
||||
static void CPrep_PragmaUnused() {}
|
||||
static void CPrep_PragmaInlineDepth() {}
|
||||
static void CPrep_PragmaInlineMaxSize() {}
|
||||
static void CPrep_PragmaInlineMaxTotalSize() {}
|
||||
|
||||
static void pragma_segment() {
|
||||
short i;
|
||||
short t;
|
||||
char name[256];
|
||||
|
||||
if (notendofline()) {
|
||||
for (i = 0; i < 255; i++) {
|
||||
spaceskip = 0;
|
||||
t = prepskipnextchar();
|
||||
if (spaceskip)
|
||||
break;
|
||||
if (t <= ' ')
|
||||
break;
|
||||
name[i] = t;
|
||||
pos = nextcharpos;
|
||||
}
|
||||
name[i] = 0;
|
||||
|
||||
if (!i || i >= 255)
|
||||
CPrep_Warning(186);
|
||||
|
||||
copts.forcedSegment = GetHashNameNodeExport(name);
|
||||
ObjGen_SegmentName();
|
||||
} else {
|
||||
if (copts.warn_illpragma)
|
||||
CPrep_Warning(186);
|
||||
}
|
||||
}
|
||||
|
||||
static void pragma_options() {}
|
||||
|
||||
static void pragma_push() {
|
||||
struct COptsPush *push;
|
||||
|
||||
push = galloc(sizeof(struct COptsPush));
|
||||
push->next = coptpushs;
|
||||
coptpushs = push;
|
||||
|
||||
push->opts = copts;
|
||||
}
|
||||
|
||||
static void pragma_pop() {
|
||||
if (coptpushs) {
|
||||
copts = coptpushs->opts;
|
||||
coptpushs = coptpushs->next;
|
||||
CMach_Configure();
|
||||
} else {
|
||||
CPrep_Error(237);
|
||||
}
|
||||
}
|
||||
|
||||
static void pragma_overload() {}
|
||||
static void pragma_optimization_level() {}
|
||||
static void pragma_opt_unroll_count() {}
|
||||
static void pragma_opt_unroll_instr_count() {}
|
||||
static void pragma_pack() {}
|
||||
static void pragma_comment() {}
|
||||
static void pragma_message() {}
|
||||
static void preppragma() {}
|
||||
static void prepinclude() {}
|
||||
static void prepline() {}
|
||||
static void CPrep_GetPrepType() {}
|
||||
static void CPrep_ParseUnary() {}
|
||||
static void CPrep_ParseBinary() {}
|
||||
static void CPrep_ParseCond() {}
|
||||
static void doevalconstexpr() {}
|
||||
static void pushifstate() {}
|
||||
static void popifstate() {}
|
||||
static void positiveif() {}
|
||||
static void negativeif() {}
|
||||
static void prepif() {}
|
||||
static void prepifdef() {}
|
||||
static void prepifndef() {}
|
||||
static void prepelif() {}
|
||||
static void prepelse() {}
|
||||
static void prependif() {}
|
||||
static void prepifskip() {}
|
||||
void preprocessor() {}
|
||||
void CPrep_BrowserTokenOffset() {}
|
||||
void CPrep_BrowserFileOffset() {}
|
||||
|
||||
void CPrep_BrowserFilePosition(CPrepFileInfo **fileinfo, SInt32 *offset) {
|
||||
CPrepFileInfo *file;
|
||||
|
||||
if (ts_first < ts_current) {
|
||||
file = ts_current[-1].tokenfile;
|
||||
*offset = ts_current[-1].tokenoffset + 1;
|
||||
} else {
|
||||
file = filestack[filesp];
|
||||
if (tokenstacklevel) {
|
||||
*offset = tokenstack[0].pos - filestack[filesp]->textbuffer;
|
||||
} else {
|
||||
*offset = pos - filestack[filesp]->textbuffer;
|
||||
}
|
||||
}
|
||||
|
||||
if (file && file->fileID > 0 && (file->recordbrowseinfo || gForceSourceLoc)) {
|
||||
*fileinfo = file;
|
||||
} else {
|
||||
*fileinfo = NULL;
|
||||
*offset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
CPrepFileInfo *CPrep_BrowserCurrentFile() {
|
||||
return prep_file;
|
||||
}
|
||||
166
compiler_and_linker/FrontEnd/C/CPrepTokenizer.c
Normal file
166
compiler_and_linker/FrontEnd/C/CPrepTokenizer.c
Normal file
@@ -0,0 +1,166 @@
|
||||
#include "compiler.h"
|
||||
#include "compiler/tokens.h"
|
||||
|
||||
static Boolean prepnextstringchar_foundnl;
|
||||
|
||||
short prepskipnextchar() {
|
||||
|
||||
}
|
||||
|
||||
short prepnextchar() {
|
||||
|
||||
}
|
||||
|
||||
short prepnextstringchar(char *str, Boolean flag) {
|
||||
|
||||
}
|
||||
|
||||
void CPrep_MatchChar(char ch, Boolean flag) {
|
||||
|
||||
}
|
||||
|
||||
char *CPrep_MatchChar2(char *str, char ch, Boolean flag) {
|
||||
|
||||
}
|
||||
|
||||
short prepcurchar() {
|
||||
|
||||
}
|
||||
|
||||
static short prepcurstringchar(char *str) {
|
||||
}
|
||||
|
||||
static void prepcurstringchar_skip() {
|
||||
}
|
||||
|
||||
char *ReadIdentifier(char *str) {
|
||||
}
|
||||
|
||||
static short intsuffix(short token, Boolean flag) {
|
||||
}
|
||||
|
||||
static short floatsuffix(short token) {
|
||||
}
|
||||
|
||||
static short tohex(short token) {
|
||||
}
|
||||
|
||||
static short nextchar(char *str) {
|
||||
}
|
||||
|
||||
char *CPrep_SkipNewComment(char *str) {
|
||||
|
||||
}
|
||||
|
||||
Boolean skipendoflinematch(char *str, Boolean flag) {
|
||||
}
|
||||
|
||||
void skipendofline() {
|
||||
}
|
||||
|
||||
void CPrep_SkipAsmComment() {
|
||||
}
|
||||
|
||||
static short tille() {}
|
||||
static short tcret() {}
|
||||
static short tapos() {}
|
||||
static short tquot() {}
|
||||
static short thash() {}
|
||||
static short tmult() {}
|
||||
static short tcolo() {}
|
||||
static short tless() {}
|
||||
static short tequa() {}
|
||||
static short tgrea() {}
|
||||
static short tatsg() {}
|
||||
static short tperc() {}
|
||||
static short texcl() {}
|
||||
static short tplus() {}
|
||||
static short tminu() {}
|
||||
static short torrr() {}
|
||||
static short tampe() {}
|
||||
static short tpowe() {}
|
||||
static short tdivi() {}
|
||||
static short tzero() {}
|
||||
static short tpoin() {}
|
||||
static short tnumb() {}
|
||||
static short tiden() {}
|
||||
static short tchrL() {}
|
||||
static short tchra() {}
|
||||
static short tchrb() {}
|
||||
static short tchrc() {}
|
||||
static short tchrd() {}
|
||||
static short tchre() {}
|
||||
static short tchrf() {}
|
||||
static short tchrg() {}
|
||||
static short tchri() {}
|
||||
static short tchrl() {}
|
||||
static short tchrm() {}
|
||||
static short tchrn() {}
|
||||
static short tchro() {}
|
||||
static short tchrp() {}
|
||||
static short tchrr() {}
|
||||
static short tchrs() {}
|
||||
static short tchrt() {}
|
||||
static short tchru() {}
|
||||
static short tchrv() {}
|
||||
static short tchrw() {}
|
||||
static short tchrx() {}
|
||||
static short tchr_() {}
|
||||
static short token() {}
|
||||
static short tdoll() {}
|
||||
static short tisid() {}
|
||||
static short tnull() {}
|
||||
static short t0x1a() {}
|
||||
|
||||
static short (*cprep_tokenize[256])() = {
|
||||
&tnull, &tille, &tille, &tille, &tisid, &tisid, &tille, &tille,
|
||||
&tille, &tille, &tille, &tille, &tille, &tcret, &tille, &tille,
|
||||
&tille, &tille, &tille, &tille, &tille, &tille, &tille, &tille,
|
||||
&tille, &tille, &t0x1a, &tille, &tille, &tille, &tille, &tille,
|
||||
&tille, &texcl, &tquot, &thash, &tdoll, &tperc, &tampe, &tapos,
|
||||
&token, &token, &tmult, &tplus, &token, &tminu, &tpoin, &tdivi,
|
||||
&tzero, &tnumb, &tnumb, &tnumb, &tnumb, &tnumb, &tnumb, &tnumb,
|
||||
&tnumb, &tnumb, &tcolo, &token, &tless, &tequa, &tgrea, &token,
|
||||
&tatsg, &tiden, &tiden, &tiden, &tiden, &tiden, &tiden, &tiden,
|
||||
&tiden, &tiden, &tiden, &tiden, &tchrL, &tiden, &tchrn, &tiden,
|
||||
&tchrp, &tiden, &tiden, &tiden, &tiden, &tiden, &tiden, &tiden,
|
||||
&tchrx, &tiden, &tiden, &token, &token, &token, &tpowe, &tchr_,
|
||||
&token, &tchra, &tchrb, &tchrc, &tchrd, &tchre, &tchrf, &tchrg,
|
||||
&tiden, &tchri, &tiden, &tiden, &tchrl, &tchrm, &tchrn, &tchro,
|
||||
&tchrp, &tiden, &tchrr, &tchrs, &tchrt, &tchru, &tchrv, &tchrw,
|
||||
&tchrx, &tiden, &tiden, &token, &torrr, &token, &token, &tille,
|
||||
&tille, &tille, &tille, &tille, &tille, &tille, &tille, &tille,
|
||||
&tille, &tille, &tille, &tille, &tille, &tille, &tille, &tille,
|
||||
&tille, &tille, &tille, &tille, &tille, &tille, &tille, &tille,
|
||||
&tille, &tille, &tille, &tille, &tille, &tille, &tille, &tille,
|
||||
&tille, &tille, &tille, &tille, &tille, &tille, &tille, &tille,
|
||||
&tille, &tille, &tille, &tille, &tille, &tille, &tille, &tille,
|
||||
&tille, &tille, &tille, &tille, &tille, &tille, &tille, &tille,
|
||||
&tille, &tille, &tille, &tille, &tille, &tille, &tille, &tille,
|
||||
&tille, &tille, &tille, &tille, &tille, &tille, &tille, &tille,
|
||||
&tille, &tille, &tille, &tille, &tille, &tille, &tille, &tille,
|
||||
&tille, &tille, &tille, &tille, &tille, &tille, &tille, &tille,
|
||||
&tille, &tille, &tille, &tille, &tille, &tille, &tille, &tille,
|
||||
&tille, &tille, &tille, &tille, &tille, &tille, &tille, &tille,
|
||||
&tille, &tille, &tille, &tille, &tille, &tille, &tille, &tille,
|
||||
&tille, &tille, &tille, &tille, &tille, &tille, &tille, &tille,
|
||||
&tille, &tille, &tille, &tille, &tille, &tille, &tille, &tille
|
||||
};
|
||||
|
||||
short lookahead() {
|
||||
}
|
||||
|
||||
short lookahead_noeol() {
|
||||
}
|
||||
|
||||
static void CPrep_StringConCat(Boolean flag) {
|
||||
}
|
||||
|
||||
short lex() {
|
||||
}
|
||||
|
||||
short plex() {
|
||||
}
|
||||
|
||||
short lexidentifier() {
|
||||
}
|
||||
2690
compiler_and_linker/FrontEnd/C/CScope.c
Normal file
2690
compiler_and_linker/FrontEnd/C/CScope.c
Normal file
File diff suppressed because it is too large
Load Diff
1216
compiler_and_linker/FrontEnd/Common/CompilerTools.c
Normal file
1216
compiler_and_linker/FrontEnd/Common/CompilerTools.c
Normal file
File diff suppressed because it is too large
Load Diff
255
compiler_and_linker/unsorted/CCompiler.c
Normal file
255
compiler_and_linker/unsorted/CCompiler.c
Normal file
@@ -0,0 +1,255 @@
|
||||
#include "compiler/common.h"
|
||||
#include "compiler.h"
|
||||
#include "compiler/types.h"
|
||||
#include "pref_structs.h"
|
||||
#include "compiler/CompilerTools.h"
|
||||
|
||||
Boolean systemHandles;
|
||||
|
||||
static Boolean using_license_manager;
|
||||
Boolean crippled;
|
||||
SInt32 license_cookie;
|
||||
CParams cparams;
|
||||
|
||||
// TODO move me to CParser.c, or maybe CMachine.c?
|
||||
Type sttemplexpr = {TYPETEMPLDEPEXPR, 0};
|
||||
Type stillegal = {TYPEILLEGAL, 1};
|
||||
Type stvoid = {TYPEVOID, 0};
|
||||
TypePointer void_ptr = {TYPEPOINTER, 0, &stvoid, 0};
|
||||
TypeFunc rt_func = {TYPEFUNC, 0, NULL, NULL, &stvoid, 0, 0};
|
||||
// TODO move me to CParser.c
|
||||
|
||||
static void get_extension(ConstStringPtr src, char *dst) {
|
||||
int ep;
|
||||
|
||||
dst[0] = 0;
|
||||
for (ep = src[0]; src[ep] != '.'; ep--) {}
|
||||
|
||||
if (ep >= 2) {
|
||||
int x;
|
||||
for (x = 0; (x + ep) <= src[0]; x++)
|
||||
dst[x] = src[x + ep];
|
||||
dst[x] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int setup_param_block(CWPluginContext context) {
|
||||
static char target_name[128];
|
||||
CWTargetInfo tinfo;
|
||||
|
||||
memset(&cparams, 0, sizeof(CParams));
|
||||
cparams.context = context;
|
||||
|
||||
if (CWGetPluginRequest(context, &cparams.pluginRequest) != cwNoErr)
|
||||
return 0;
|
||||
if (CWGetAPIVersion(context, &cparams.apiVersion) != cwNoErr)
|
||||
return 0;
|
||||
if (CWGetProjectFile(context, &cparams.projectFile) != cwNoErr)
|
||||
return 0;
|
||||
if (CWGetProjectFileCount(context, &cparams.projectFileCount) != cwNoErr)
|
||||
return 0;
|
||||
if (CWGetMainFileNumber(context, &cparams.mainFileNumber) != cwNoErr)
|
||||
return 0;
|
||||
if (CWGetMainFileSpec(context, &cparams.mainFileSpec) != cwNoErr)
|
||||
return 0;
|
||||
if (CWGetMainFileText(context, &cparams.mainFileText, &cparams.mainFileTextLength) != cwNoErr)
|
||||
return 0;
|
||||
if (CWIsPrecompiling(context, &cparams.isPrecompiling) != cwNoErr)
|
||||
return 0;
|
||||
if (CWIsAutoPrecompiling(context, &cparams.isAutoPrecompiling) != cwNoErr)
|
||||
return 0;
|
||||
if (CWIsPreprocessing(context, &cparams.isPreprocessing) != cwNoErr)
|
||||
return 0;
|
||||
if (CWIsGeneratingDebugInfo(context, &cparams.isGeneratingDebugInfo) != cwNoErr)
|
||||
return 0;
|
||||
if (CWIsCachingPrecompiledHeaders(context, &cparams.isCachingPrecompiledHeaders) != cwNoErr)
|
||||
return 0;
|
||||
if (CWGetBrowseOptions(context, &cparams.browseOptions) != cwNoErr)
|
||||
return 0;
|
||||
cparams.field276 = cparams.isPreprocessing == 0;
|
||||
if (CWGetMainFileID(context, &cparams.mainFileID) != cwNoErr)
|
||||
return 0;
|
||||
if (CWGetTargetInfo(context, &tinfo) != cwNoErr)
|
||||
return 0;
|
||||
|
||||
cparams.targetOS = tinfo.targetOS;
|
||||
cparams.targetCPU = tinfo.targetCPU;
|
||||
cparams.targetName = target_name;
|
||||
return CWGetTargetName(context, target_name, sizeof(target_name)) == cwNoErr;
|
||||
}
|
||||
|
||||
static short store_compile_results() {
|
||||
CWResult result;
|
||||
|
||||
if (cparams.objectDataHandle)
|
||||
CWSecretAttachHandle(cparams.context, cparams.objectDataHandle, &cparams.objectdata.objectdata);
|
||||
if (cparams.browseDataHandle)
|
||||
CWSecretAttachHandle(cparams.context, cparams.browseDataHandle, &cparams.objectdata.browsedata);
|
||||
|
||||
if (cparams.isPreprocessing) {
|
||||
if (cparams.objectdata.objectdata) {
|
||||
CWNewTextDocumentInfo docinfo;
|
||||
memset(&docinfo, 0, sizeof(CWNewTextDocumentInfo));
|
||||
docinfo.text = cparams.objectdata.objectdata;
|
||||
cparams.objectdata.objectdata = NULL;
|
||||
result = CWCreateNewTextDocument(cparams.context, &docinfo);
|
||||
}
|
||||
} else {
|
||||
result = CWStoreObjectData(cparams.context, cparams.mainFileNumber, &cparams.objectdata);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void initialize_compiler_options(CParams *params) {
|
||||
static PFrontEndC pFrontEnd;
|
||||
PWarningC pWarningC;
|
||||
PGlobalOptimizer pGlobalOptimizer;
|
||||
Handle prefsdata;
|
||||
char extension[256];
|
||||
|
||||
memclrw(&copts, sizeof(COpts));
|
||||
|
||||
CWSecretGetNamedPreferences(cparams.context, "C/C++ Compiler", &prefsdata);
|
||||
pFrontEnd = *((PFrontEndC *) *prefsdata);
|
||||
|
||||
copts.little_endian = 0;
|
||||
copts.cplusplus = 1;
|
||||
copts.objective_c = pFrontEnd.objective_c;
|
||||
get_extension(params->mainFileSpec.name, extension);
|
||||
if (!strcmp(extension, ".c") || !strcmp(extension, ".h") || !strcmp(extension, ".pch")) {
|
||||
copts.cplusplus = pFrontEnd.cplusplus;
|
||||
} else if (!strcmp(extension, ".m")) {
|
||||
copts.cplusplus = pFrontEnd.cplusplus;
|
||||
copts.objective_c = 1;
|
||||
} else if (!strcmp(extension, ".mm") || !strcmp(extension, ".M")) {
|
||||
copts.cplusplus = 1;
|
||||
copts.objective_c = 1;
|
||||
}
|
||||
|
||||
copts.require_prototypes = pFrontEnd.checkprotos;
|
||||
copts.ARM_conform = pFrontEnd.arm;
|
||||
copts.ARM_scoping = pFrontEnd.arm;
|
||||
copts.trigraphs = pFrontEnd.trigraphs;
|
||||
copts.only_std_keywords = pFrontEnd.onlystdkeywords;
|
||||
copts.enumsalwaysint = pFrontEnd.enumsalwaysint;
|
||||
copts.mpwc_relax = pFrontEnd.mpwpointerstyle;
|
||||
copts.ANSI_strict = pFrontEnd.ansistrict;
|
||||
copts.mpwc_newline = pFrontEnd.mpwcnewline;
|
||||
copts.exceptions = pFrontEnd.enableexceptions;
|
||||
copts.dont_reuse_strings = pFrontEnd.dontreusestrings;
|
||||
copts.pool_strings = pFrontEnd.poolstrings;
|
||||
copts.dont_inline = pFrontEnd.dontinline;
|
||||
copts.useRTTI = pFrontEnd.useRTTI;
|
||||
copts.oldprefixname = pFrontEnd.oldprefixname;
|
||||
copts.multibyteaware = pFrontEnd.multibyteaware;
|
||||
copts.unsignedchars = pFrontEnd.unsignedchars;
|
||||
copts.autoinline = pFrontEnd.autoinline;
|
||||
copts.direct_to_som = pFrontEnd.direct_to_som;
|
||||
copts.som_env_check = pFrontEnd.som_env_check;
|
||||
copts.booltruefalse = pFrontEnd.booltruefalse;
|
||||
copts.always_inline = pFrontEnd.alwaysinline;
|
||||
copts.inlinelevel = pFrontEnd.inlinelevel;
|
||||
copts.wchar_type = pFrontEnd.wchar_type;
|
||||
copts.ecplusplus = pFrontEnd.ecplusplus;
|
||||
copts.defer_codegen = pFrontEnd.defer_codegen;
|
||||
copts.inline_max_size = 512;
|
||||
copts.inline_max_total_size = 100000;
|
||||
|
||||
CWSecretGetNamedPreferences(cparams.context, "C/C++ Warnings", &prefsdata);
|
||||
pWarningC = *((PWarningC *) *prefsdata);
|
||||
|
||||
copts.warn_illpragma = pWarningC.warn_illpragma;
|
||||
copts.warn_emptydecl = pWarningC.warn_emptydecl;
|
||||
copts.warn_possunwant = pWarningC.warn_possunwant;
|
||||
copts.warn_unusedvar = pWarningC.warn_unusedvar;
|
||||
copts.warn_unusedarg = pWarningC.warn_unusedarg;
|
||||
copts.warn_extracomma = pWarningC.warn_extracomma;
|
||||
copts.pedantic = pWarningC.pedantic;
|
||||
copts.warningerrors = pWarningC.warningerrors;
|
||||
copts.warn_hidevirtual = pWarningC.warn_hidevirtual;
|
||||
copts.warn_implicitconv = pWarningC.warn_implicitconv;
|
||||
copts.warn_notinlined = pWarningC.warn_notinlined;
|
||||
copts.warn_structclass = pWarningC.warn_structclass;
|
||||
|
||||
CWSecretGetNamedPreferences(cparams.context, "PPC Global Optimizer", &prefsdata);
|
||||
pGlobalOptimizer = *((PGlobalOptimizer *) *prefsdata);
|
||||
|
||||
copts.optimizationlevel = pGlobalOptimizer.optimizationlevel;
|
||||
copts.optimize_for_size = (Boolean) (pGlobalOptimizer.optfor == 1);
|
||||
|
||||
copts.crippled = crippled;
|
||||
copts.loop_unroll_count = 8;
|
||||
copts.loop_unroll_size_threshold = 100;
|
||||
copts.isGeneratingDebugInfo = params->isGeneratingDebugInfo;
|
||||
copts.pchCreator = CWFOURCHAR('C','W','I','E');
|
||||
copts.pchType = CWFOURCHAR('M','M','C','H');
|
||||
copts.text = CWFOURCHAR('T','E','X','T');
|
||||
}
|
||||
|
||||
static void GetLicense() {
|
||||
if (!license_cookie) {
|
||||
crippled = 1;
|
||||
CWCheckoutLicense(cparams.context, "MacOS_Plugins_MacOS_Unlimited", "7", 2, NULL, &license_cookie);
|
||||
if (license_cookie) {
|
||||
CWCheckinLicense(cparams.context, license_cookie);
|
||||
crippled = 0;
|
||||
}
|
||||
|
||||
CWCheckoutLicense(cparams.context, "MacOS_Plugins_MacOS_Limited", "7", 0, NULL, &license_cookie);
|
||||
using_license_manager = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void ReleaseLicense() {
|
||||
if (license_cookie && using_license_manager)
|
||||
CWCheckinLicense(cparams.context, license_cookie);
|
||||
using_license_manager = 0;
|
||||
license_cookie = 0;
|
||||
}
|
||||
|
||||
CWPLUGIN_ENTRY(MWC_main)(CWPluginContext context) {
|
||||
CWResult result;
|
||||
SInt32 request;
|
||||
|
||||
result = cwNoErr;
|
||||
CWGetPluginRequest(context, &request);
|
||||
|
||||
switch (request) {
|
||||
case reqInitialize:
|
||||
cparams.context = context;
|
||||
license_cookie = 0;
|
||||
CodeGen_InitCompiler();
|
||||
break;
|
||||
case reqTerminate:
|
||||
cparams.context = context;
|
||||
CodeGen_TermCompiler();
|
||||
ReleaseLicense();
|
||||
break;
|
||||
case reqCompile:
|
||||
setup_param_block(context);
|
||||
GetLicense();
|
||||
if (license_cookie) {
|
||||
initialize_compiler_options(&cparams);
|
||||
CodeGen_UpdateOptimizerOptions();
|
||||
CodeGen_InitBackEndOptions();
|
||||
CodeGen_UpdateOptimizerOptions();
|
||||
CodeGen_UpdateBackEndOptions();
|
||||
if (C_Compiler(&cparams))
|
||||
result = store_compile_results();
|
||||
else
|
||||
result = cwErrRequestFailed;
|
||||
} else {
|
||||
result = cwErrSilent;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return CWDonePluginRequest(context, result);
|
||||
}
|
||||
|
||||
void PrintProgressFunction(const char *str) {
|
||||
char buf[96];
|
||||
sprintf(buf, "Compiling function:\t%.64s", str);
|
||||
CWShowStatus(cparams.context, buf, "");
|
||||
}
|
||||
1096
compiler_and_linker/unsorted/CError.c
Normal file
1096
compiler_and_linker/unsorted/CError.c
Normal file
File diff suppressed because it is too large
Load Diff
892
compiler_and_linker/unsorted/CInt64.c
Normal file
892
compiler_and_linker/unsorted/CInt64.c
Normal file
@@ -0,0 +1,892 @@
|
||||
#include "compiler/CInt64.h"
|
||||
|
||||
const CInt64 cint64_negone = {0xFFFFFFFF, 0xFFFFFFFF};
|
||||
const CInt64 cint64_zero = {0, 0};
|
||||
const CInt64 cint64_one = {0, 1};
|
||||
const CInt64 cint64_max = {0x7FFFFFFF, 0xFFFFFFFF};
|
||||
const CInt64 cint64_min = {0x80000000, 0};
|
||||
|
||||
#define SHIFT_LEFT_ONE(a, b) do { a <<= 1; if (b & 0x80000000) { a |= 1; } b <<= 1; } while(0)
|
||||
|
||||
void CInt64_Init() {
|
||||
}
|
||||
|
||||
CInt64 CInt64_Not(CInt64 input) {
|
||||
CInt64 output;
|
||||
Boolean c;
|
||||
|
||||
c = (input.hi == 0 && input.lo == 0);
|
||||
CInt64_SetLong(&output, c);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
CInt64 CInt64_Inv(CInt64 input) {
|
||||
CInt64 output;
|
||||
output.hi = ~input.hi;
|
||||
output.lo = ~input.lo;
|
||||
return output;
|
||||
}
|
||||
|
||||
CInt64 CInt64_Add(CInt64 lhs, CInt64 rhs) {
|
||||
if (lhs.lo & 0x80000000) {
|
||||
if (rhs.lo & 0x80000000) {
|
||||
lhs.lo += rhs.lo;
|
||||
lhs.hi += 1;
|
||||
} else {
|
||||
lhs.lo += rhs.lo;
|
||||
if (!(lhs.lo & 0x80000000))
|
||||
lhs.hi += 1;
|
||||
}
|
||||
} else {
|
||||
if (rhs.lo & 0x80000000) {
|
||||
lhs.lo += rhs.lo;
|
||||
if (!(lhs.lo & 0x80000000))
|
||||
lhs.hi += 1;
|
||||
} else {
|
||||
lhs.lo += rhs.lo;
|
||||
}
|
||||
}
|
||||
lhs.hi += rhs.hi;
|
||||
return lhs;
|
||||
}
|
||||
|
||||
CInt64 CInt64_Neg(CInt64 input) {
|
||||
CInt64 result;
|
||||
result = CInt64_Add(CInt64_Inv(input), cint64_one);
|
||||
return result;
|
||||
}
|
||||
|
||||
CInt64 CInt64_Sub(CInt64 lhs, CInt64 rhs) {
|
||||
lhs = CInt64_Add(lhs, CInt64_Neg(rhs));
|
||||
return lhs;
|
||||
}
|
||||
|
||||
CInt64 CInt64_MulU(CInt64 lhs, CInt64 rhs) {
|
||||
CInt64 result;
|
||||
CInt64 work1;
|
||||
UInt32 aaaa;
|
||||
UInt32 bbbb;
|
||||
UInt32 cccc;
|
||||
UInt32 dddd;
|
||||
UInt32 eeee;
|
||||
|
||||
aaaa = rhs.lo;
|
||||
result.hi = result.lo = 0;
|
||||
bbbb = lhs.lo;
|
||||
cccc = rhs.hi;
|
||||
dddd = rhs.lo;
|
||||
|
||||
while (bbbb != 0) {
|
||||
if (bbbb & 1) {
|
||||
work1.hi = cccc;
|
||||
work1.lo = dddd;
|
||||
result = CInt64_Add(result, work1);
|
||||
}
|
||||
cccc <<= 1;
|
||||
if (dddd & 0x80000000)
|
||||
cccc |= 1;
|
||||
dddd <<= 1;
|
||||
bbbb >>= 1;
|
||||
}
|
||||
|
||||
eeee = lhs.hi;
|
||||
while (eeee != 0 && aaaa != 0) {
|
||||
if (eeee & 1)
|
||||
result.hi += aaaa;
|
||||
aaaa <<= 1;
|
||||
eeee >>= 1;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
CInt64 CInt64_Mul(CInt64 lhs, CInt64 rhs) {
|
||||
if (CInt64_IsNegative(&rhs)) {
|
||||
if (CInt64_IsNegative(&lhs)) {
|
||||
return CInt64_MulU(CInt64_Neg(lhs), CInt64_Neg(rhs));
|
||||
}
|
||||
return CInt64_Neg(CInt64_MulU(lhs, CInt64_Neg(rhs)));
|
||||
}
|
||||
if (CInt64_IsNegative(&lhs)) {
|
||||
return CInt64_Neg(CInt64_MulU(CInt64_Neg(lhs), rhs));
|
||||
}
|
||||
return CInt64_MulU(lhs, rhs);
|
||||
}
|
||||
|
||||
void CInt64_DivMod(const CInt64 *lhs, const CInt64 *rhs, CInt64 *pDiv, CInt64 *pMod) {
|
||||
Boolean bad;
|
||||
UInt32 workA;
|
||||
UInt32 workB;
|
||||
UInt32 leftA;
|
||||
UInt32 leftB;
|
||||
UInt32 rightA;
|
||||
UInt32 rightB;
|
||||
UInt32 outA;
|
||||
UInt32 outB;
|
||||
CInt64 work;
|
||||
int counter;
|
||||
|
||||
bad = (rhs->hi == 0) && (rhs->lo == 0);
|
||||
if (!bad) {
|
||||
workA = 0;
|
||||
workB = 0;
|
||||
leftA = lhs->hi;
|
||||
leftB = lhs->lo;
|
||||
rightA = rhs->hi;
|
||||
rightB = rhs->lo;
|
||||
outA = 0;
|
||||
outB = 0;
|
||||
counter = 0;
|
||||
|
||||
do {
|
||||
workA <<= 1;
|
||||
if (workB & 0x80000000)
|
||||
workA |= 1;
|
||||
workB <<= 1;
|
||||
if (leftA & 0x80000000)
|
||||
workB |= 1;
|
||||
leftA <<= 1;
|
||||
if (leftB & 0x80000000)
|
||||
leftA |= 1;
|
||||
leftB <<= 1;
|
||||
|
||||
outA <<= 1;
|
||||
if (outB & 0x80000000)
|
||||
outA |= 1;
|
||||
outB <<= 1;
|
||||
|
||||
if (workA <= rightA) {
|
||||
if (workA != rightA)
|
||||
continue;
|
||||
if (workB < rightB)
|
||||
continue;
|
||||
}
|
||||
|
||||
outB |= 1;
|
||||
|
||||
work.hi = workA;
|
||||
work.lo = workB;
|
||||
work = CInt64_Sub(work, *rhs);
|
||||
workA = work.hi;
|
||||
workB = work.lo;
|
||||
} while (++counter < 64);
|
||||
|
||||
if (pDiv) {
|
||||
pDiv->hi = outA;
|
||||
pDiv->lo = outB;
|
||||
}
|
||||
if (pMod) {
|
||||
pMod->hi = workA;
|
||||
pMod->lo = workB;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CInt64 CInt64_Div(CInt64 lhs, CInt64 rhs) {
|
||||
CInt64 result;
|
||||
if (CInt64_IsNegative(&rhs)) {
|
||||
rhs = CInt64_Neg(rhs);
|
||||
if (CInt64_IsNegative(&lhs)) {
|
||||
lhs = CInt64_Neg(lhs);
|
||||
CInt64_DivMod(&lhs, &rhs, &result, 0);
|
||||
return result;
|
||||
} else {
|
||||
CInt64_DivMod(&lhs, &rhs, &result, 0);
|
||||
return CInt64_Neg(result);
|
||||
}
|
||||
} else {
|
||||
if (CInt64_IsNegative(&lhs)) {
|
||||
lhs = CInt64_Neg(lhs);
|
||||
CInt64_DivMod(&lhs, &rhs, &result, 0);
|
||||
return CInt64_Neg(result);
|
||||
} else {
|
||||
CInt64_DivMod(&lhs, &rhs, &result, 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CInt64 CInt64_DivU(CInt64 lhs, CInt64 rhs) {
|
||||
CInt64 result;
|
||||
CInt64_DivMod(&lhs, &rhs, &result, 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
CInt64 CInt64_Mod(CInt64 lhs, CInt64 rhs) {
|
||||
CInt64 result;
|
||||
if (CInt64_IsNegative(&lhs)) {
|
||||
lhs = CInt64_Neg(lhs);
|
||||
if (CInt64_IsNegative(&rhs))
|
||||
rhs = CInt64_Neg(rhs);
|
||||
CInt64_DivMod(&lhs, &rhs, 0, &result);
|
||||
return CInt64_Neg(result);
|
||||
} else {
|
||||
if (CInt64_IsNegative(&rhs))
|
||||
rhs = CInt64_Neg(rhs);
|
||||
CInt64_DivMod(&lhs, &rhs, 0, &result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
CInt64 CInt64_ModU(CInt64 lhs, CInt64 rhs) {
|
||||
CInt64 result;
|
||||
CInt64_DivMod(&lhs, &rhs, 0, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
CInt64 CInt64_Shl(CInt64 lhs, CInt64 rhs) {
|
||||
int counter;
|
||||
UInt32 a;
|
||||
UInt32 b;
|
||||
|
||||
if (rhs.hi == 0 && rhs.lo < 64) {
|
||||
a = lhs.hi;
|
||||
b = lhs.lo;
|
||||
for (counter = rhs.lo; counter != 0; --counter) {
|
||||
a <<= 1;
|
||||
if (b & 0x80000000)
|
||||
a |= 1;
|
||||
b <<= 1;
|
||||
}
|
||||
lhs.hi = a;
|
||||
lhs.lo = b;
|
||||
} else {
|
||||
lhs.hi = 0;
|
||||
lhs.lo = 0;
|
||||
}
|
||||
return lhs;
|
||||
}
|
||||
|
||||
CInt64 CInt64_Shr(CInt64 lhs, CInt64 rhs) {
|
||||
int counter;
|
||||
SInt32 a;
|
||||
UInt32 b;
|
||||
|
||||
if (rhs.hi == 0 && rhs.lo < 64) {
|
||||
a = lhs.hi;
|
||||
b = lhs.lo;
|
||||
for (counter = rhs.lo; counter != 0; --counter) {
|
||||
b >>= 1;
|
||||
if (a & 1)
|
||||
b |= 0x80000000;
|
||||
a >>= 1;
|
||||
}
|
||||
lhs.hi = a;
|
||||
lhs.lo = b;
|
||||
} else {
|
||||
if (lhs.hi & 0x80000000) {
|
||||
lhs.hi = 0xFFFFFFFF;
|
||||
lhs.lo = 0xFFFFFFFF;
|
||||
} else {
|
||||
lhs.hi = 0;
|
||||
lhs.lo = 0;
|
||||
}
|
||||
}
|
||||
return lhs;
|
||||
}
|
||||
|
||||
CInt64 CInt64_ShrU(CInt64 lhs, CInt64 rhs) {
|
||||
int counter;
|
||||
UInt32 a;
|
||||
UInt32 b;
|
||||
|
||||
if (rhs.hi == 0 && rhs.lo < 64) {
|
||||
a = lhs.hi;
|
||||
b = lhs.lo;
|
||||
for (counter = rhs.lo; counter != 0; --counter) {
|
||||
b >>= 1;
|
||||
if (a & 1)
|
||||
b |= 0x80000000;
|
||||
a >>= 1;
|
||||
}
|
||||
lhs.hi = a;
|
||||
lhs.lo = b;
|
||||
} else {
|
||||
lhs.hi = 0;
|
||||
lhs.lo = 0;
|
||||
}
|
||||
return lhs;
|
||||
}
|
||||
|
||||
int CInt64_UnsignedCompare(const CInt64 *lhs, const CInt64 *rhs) {
|
||||
if (lhs->hi == rhs->hi) {
|
||||
if (lhs->lo < rhs->lo)
|
||||
return -1;
|
||||
else
|
||||
return lhs->lo > rhs->lo;
|
||||
} else {
|
||||
return ((UInt32) lhs->hi < rhs->hi) ? -1 : 1;
|
||||
}
|
||||
}
|
||||
|
||||
int CInt64_SignedCompare(const CInt64 *lhs, const CInt64 *rhs) {
|
||||
CInt64 lhs_;
|
||||
CInt64 rhs_;
|
||||
|
||||
lhs_ = CInt64_Xor(*lhs, cint64_min);
|
||||
rhs_ = CInt64_Xor(*rhs, cint64_min);
|
||||
return CInt64_UnsignedCompare(&lhs_, &rhs_);
|
||||
}
|
||||
|
||||
Boolean CInt64_Less(CInt64 lhs, CInt64 rhs) {
|
||||
return CInt64_SignedCompare(&lhs, &rhs) < 0;
|
||||
}
|
||||
|
||||
Boolean CInt64_LessU(CInt64 lhs, CInt64 rhs) {
|
||||
return CInt64_UnsignedCompare(&lhs, &rhs) < 0;
|
||||
}
|
||||
|
||||
Boolean CInt64_Greater(CInt64 lhs, CInt64 rhs) {
|
||||
return CInt64_SignedCompare(&lhs, &rhs) > 0;
|
||||
}
|
||||
|
||||
Boolean CInt64_GreaterU(CInt64 lhs, CInt64 rhs) {
|
||||
return CInt64_UnsignedCompare(&lhs, &rhs) > 0;
|
||||
}
|
||||
|
||||
Boolean CInt64_LessEqual(CInt64 lhs, CInt64 rhs) {
|
||||
return CInt64_SignedCompare(&lhs, &rhs) <= 0;
|
||||
}
|
||||
|
||||
Boolean CInt64_LessEqualU(CInt64 lhs, CInt64 rhs) {
|
||||
return CInt64_UnsignedCompare(&lhs, &rhs) <= 0;
|
||||
}
|
||||
|
||||
Boolean CInt64_GreaterEqual(CInt64 lhs, CInt64 rhs) {
|
||||
return CInt64_SignedCompare(&lhs, &rhs) >= 0;
|
||||
}
|
||||
|
||||
Boolean CInt64_GreaterEqualU(CInt64 lhs, CInt64 rhs) {
|
||||
return CInt64_UnsignedCompare(&lhs, &rhs) >= 0;
|
||||
}
|
||||
|
||||
Boolean CInt64_Equal(CInt64 lhs, CInt64 rhs) {
|
||||
return lhs.hi == rhs.hi && lhs.lo == rhs.lo;
|
||||
}
|
||||
|
||||
Boolean CInt64_NotEqual(CInt64 lhs, CInt64 rhs) {
|
||||
return lhs.hi != rhs.hi || lhs.lo != rhs.lo;
|
||||
}
|
||||
|
||||
Boolean CInt64_IsInRange(CInt64 value, short len) {
|
||||
CInt64 bound;
|
||||
|
||||
if (value.hi & 0x80000000) {
|
||||
switch (len) {
|
||||
case 1:
|
||||
bound.lo = 0xFFFFFF80;
|
||||
bound.hi = 0xFFFFFFFF;
|
||||
break;
|
||||
case 2:
|
||||
bound.lo = 0xFFFF8000;
|
||||
bound.hi = 0xFFFFFFFF;
|
||||
break;
|
||||
case 4:
|
||||
bound.lo = 0x80000000;
|
||||
bound.hi = 0xFFFFFFFF;
|
||||
break;
|
||||
case 8:
|
||||
return 1;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return CInt64_GreaterEqual(value, bound);
|
||||
} else {
|
||||
switch (len) {
|
||||
case 1:
|
||||
bound.lo = 0x7F;
|
||||
bound.hi = 0;
|
||||
break;
|
||||
case 2:
|
||||
bound.lo = 0x7FFF;
|
||||
bound.hi = 0;
|
||||
break;
|
||||
case 4:
|
||||
bound.lo = 0x7FFFFFFF;
|
||||
bound.hi = 0;
|
||||
break;
|
||||
case 8:
|
||||
return 1;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return CInt64_LessEqual(value, bound);
|
||||
}
|
||||
}
|
||||
|
||||
Boolean CInt64_IsInURange(CInt64 value, short len) {
|
||||
switch (len) {
|
||||
case 1:
|
||||
return value.hi == 0 && (value.lo & 0xFFFFFF00) == 0;
|
||||
case 2:
|
||||
return value.hi == 0 && (value.lo & 0xFFFF0000) == 0;
|
||||
case 4:
|
||||
return value.hi == 0;
|
||||
case 8:
|
||||
return 1;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
CInt64 CInt64_And(CInt64 lhs, CInt64 rhs) {
|
||||
lhs.hi &= rhs.hi;
|
||||
lhs.lo &= rhs.lo;
|
||||
return lhs;
|
||||
}
|
||||
|
||||
CInt64 CInt64_Xor(CInt64 lhs, CInt64 rhs) {
|
||||
lhs.hi ^= rhs.hi;
|
||||
lhs.lo ^= rhs.lo;
|
||||
return lhs;
|
||||
}
|
||||
|
||||
CInt64 CInt64_Or(CInt64 lhs, CInt64 rhs) {
|
||||
lhs.hi |= rhs.hi;
|
||||
lhs.lo |= rhs.lo;
|
||||
return lhs;
|
||||
}
|
||||
|
||||
void CInt64_ConvertInt32(CInt64 *i) {
|
||||
CInt64_Extend32(i);
|
||||
}
|
||||
|
||||
void CInt64_ConvertUInt32(CInt64 *i) {
|
||||
CInt64_SetULong(i, (UInt32) i->lo);
|
||||
}
|
||||
|
||||
void CInt64_ConvertInt16(CInt64 *i) {
|
||||
i->lo = (SInt32) i->lo;
|
||||
CInt64_Extend32(i);
|
||||
}
|
||||
|
||||
void CInt64_ConvertUInt16(CInt64 *i) {
|
||||
CInt64_SetULong(i, (UInt16) i->lo);
|
||||
}
|
||||
|
||||
void CInt64_ConvertInt8(CInt64 *i) {
|
||||
i->lo = (SInt8) i->lo;
|
||||
CInt64_Extend32(i);
|
||||
}
|
||||
|
||||
void CInt64_ConvertUInt8(CInt64 *i) {
|
||||
CInt64_SetULong(i, (UInt8) i->lo);
|
||||
}
|
||||
|
||||
void CInt64_ConvertUFromLongDouble(CInt64 *pResult, double value) {
|
||||
union { float f; UInt32 l; } cvt;
|
||||
UInt32 a, b;
|
||||
float threshold;
|
||||
int bits;
|
||||
|
||||
if (value <= 0.0) {
|
||||
pResult->hi = 0;
|
||||
pResult->lo = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
cvt.l = 0x5F800000;
|
||||
if (value >= cvt.f) {
|
||||
pResult->hi = 0xFFFFFFFF;
|
||||
pResult->lo = 0xFFFFFFFF;
|
||||
return;
|
||||
}
|
||||
|
||||
a = b = 0;
|
||||
for (bits = 63; bits >= 0; bits--) {
|
||||
a <<= 1;
|
||||
if (b & 0x80000000)
|
||||
a |= 1;
|
||||
b <<= 1;
|
||||
|
||||
if ((short) bits == 0) {
|
||||
threshold = 1.0f;
|
||||
} else {
|
||||
cvt.l = (((short) bits + 127) & 255) << 23;
|
||||
threshold = cvt.f;
|
||||
}
|
||||
|
||||
if (threshold <= value) {
|
||||
b |= 1;
|
||||
value -= threshold;
|
||||
}
|
||||
}
|
||||
|
||||
pResult->hi = a;
|
||||
pResult->lo = b;
|
||||
}
|
||||
|
||||
void CInt64_ConvertFromLongDouble(CInt64 *pResult, double value) {
|
||||
if (value < 0.0) {
|
||||
CInt64_ConvertUFromLongDouble(pResult, -value);
|
||||
*pResult = CInt64_Neg(*pResult);
|
||||
} else {
|
||||
CInt64_ConvertUFromLongDouble(pResult, value);
|
||||
}
|
||||
}
|
||||
|
||||
double CInt64_ConvertUToLongDouble(const CInt64 *value) {
|
||||
Boolean bad;
|
||||
UInt32 work;
|
||||
int counter;
|
||||
double result;
|
||||
|
||||
bad = (value->hi == 0) && (value->lo == 0);
|
||||
if (bad) {
|
||||
return 0.0;
|
||||
} else {
|
||||
result = 0.0;
|
||||
|
||||
work = value->hi;
|
||||
if (work != 0) {
|
||||
for (counter = 0; counter < 32; counter++) {
|
||||
result += result;
|
||||
if (work & 0x80000000)
|
||||
result += 1.0;
|
||||
work <<= 1;
|
||||
}
|
||||
}
|
||||
|
||||
counter = 0;
|
||||
work = value->lo;
|
||||
for (; counter < 32; counter++) {
|
||||
result += result;
|
||||
if (work & 0x80000000)
|
||||
result += 1.0;
|
||||
work <<= 1;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
double CInt64_ConvertToLongDouble(const CInt64 *value) {
|
||||
CInt64 tmp;
|
||||
if (value->hi & 0x80000000) {
|
||||
tmp = CInt64_Neg(*value);
|
||||
return -CInt64_ConvertUToLongDouble(&tmp);
|
||||
} else {
|
||||
return CInt64_ConvertUToLongDouble(value);
|
||||
}
|
||||
}
|
||||
|
||||
char *CInt64_ScanOctString(CInt64 *pResult, char *str, Boolean *pFail) {
|
||||
int ch;
|
||||
CInt64 tmp;
|
||||
UInt32 a;
|
||||
UInt32 b;
|
||||
|
||||
*pFail = 0;
|
||||
pResult->hi = pResult->lo = 0;
|
||||
|
||||
while ((ch = *str) >= '0' && *str <= '7') {
|
||||
a = pResult->hi;
|
||||
b = pResult->lo;
|
||||
if (a & 0xE0000000)
|
||||
*pFail = 1;
|
||||
|
||||
SHIFT_LEFT_ONE(a, b);
|
||||
SHIFT_LEFT_ONE(a, b);
|
||||
SHIFT_LEFT_ONE(a, b);
|
||||
|
||||
pResult->hi = a;
|
||||
pResult->lo = b;
|
||||
|
||||
CInt64_SetLong(&tmp, ch - '0');
|
||||
*pResult = CInt64_Add(*pResult, tmp);
|
||||
++str;
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
char *CInt64_ScanDecString(CInt64 *pResult, char *str, Boolean *pFail) {
|
||||
int ch;
|
||||
CInt64 tmp;
|
||||
UInt32 a;
|
||||
UInt32 b;
|
||||
|
||||
*pFail = 0;
|
||||
pResult->hi = pResult->lo = 0;
|
||||
|
||||
while ((ch = *str) >= '0' && *str <= '9') {
|
||||
a = pResult->hi;
|
||||
b = pResult->lo;
|
||||
if (a & 0xE0000000)
|
||||
*pFail = 1;
|
||||
|
||||
SHIFT_LEFT_ONE(a, b);
|
||||
tmp.hi = a;
|
||||
tmp.lo = b;
|
||||
SHIFT_LEFT_ONE(a, b);
|
||||
SHIFT_LEFT_ONE(a, b);
|
||||
pResult->hi = a;
|
||||
pResult->lo = b;
|
||||
|
||||
if (CInt64_IsNegative(pResult)) {
|
||||
*pResult = CInt64_Add(*pResult, tmp);
|
||||
if (!CInt64_IsNegative(pResult))
|
||||
*pFail = 1;
|
||||
} else {
|
||||
*pResult = CInt64_Add(*pResult, tmp);
|
||||
}
|
||||
|
||||
CInt64_SetLong(&tmp, ch - '0');
|
||||
if (CInt64_IsNegative(pResult)) {
|
||||
*pResult = CInt64_Add(*pResult, tmp);
|
||||
if (!CInt64_IsNegative(pResult))
|
||||
*pFail = 1;
|
||||
} else {
|
||||
*pResult = CInt64_Add(*pResult, tmp);
|
||||
}
|
||||
|
||||
++str;
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
char *CInt64_ScanHexString(CInt64 *pResult, char *str, Boolean *pFail) {
|
||||
/* NOT MATCHING */
|
||||
int digit;
|
||||
CInt64 tmp;
|
||||
UInt32 a;
|
||||
UInt32 b;
|
||||
|
||||
*pFail = 0;
|
||||
pResult->hi = pResult->lo = 0;
|
||||
|
||||
for (;;) {
|
||||
if ((digit = str[0]) >= '0' && digit <= '9')
|
||||
digit = digit - '0';
|
||||
else if (digit >= 'A' && digit <= 'F')
|
||||
digit = digit - 'A' + 10;
|
||||
else if (digit >= 'a' && digit <= 'f')
|
||||
digit = digit - 'a' + 10;
|
||||
else
|
||||
break;
|
||||
|
||||
a = pResult->hi;
|
||||
b = pResult->lo;
|
||||
++str;
|
||||
|
||||
if (a & 0xF0000000)
|
||||
*pFail = 1;
|
||||
|
||||
SHIFT_LEFT_ONE(a, b);
|
||||
SHIFT_LEFT_ONE(a, b);
|
||||
SHIFT_LEFT_ONE(a, b);
|
||||
SHIFT_LEFT_ONE(a, b);
|
||||
|
||||
pResult->hi = a;
|
||||
pResult->lo = b;
|
||||
|
||||
CInt64_SetLong(&tmp, (char) digit);
|
||||
*pResult = CInt64_Add(*pResult, tmp);
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
char *CInt64_ScanBinString(CInt64 *pResult, char *str, Boolean *pFail) {
|
||||
char digit;
|
||||
UInt32 a;
|
||||
UInt32 b;
|
||||
|
||||
*pFail = 0;
|
||||
pResult->hi = pResult->lo = 0;
|
||||
|
||||
for (;;) {
|
||||
if (*str == '0')
|
||||
digit = 0;
|
||||
else if (*str == '1')
|
||||
digit = 1;
|
||||
else
|
||||
break;
|
||||
|
||||
a = pResult->hi;
|
||||
b = pResult->lo;
|
||||
++str;
|
||||
|
||||
if (a & 0x80000000)
|
||||
*pFail = 1;
|
||||
|
||||
SHIFT_LEFT_ONE(a, b);
|
||||
|
||||
pResult->hi = a;
|
||||
pResult->lo = b;
|
||||
|
||||
if (digit == 1)
|
||||
*pResult = CInt64_Add(*pResult, cint64_one);
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
char *CInt64_ScanAsmNumber(CInt64 *pResult, char *str, Boolean *pFail) {
|
||||
Boolean isMaybeBin;
|
||||
Boolean isOct;
|
||||
Boolean isMaybeDec;
|
||||
Boolean isBin;
|
||||
char *p;
|
||||
|
||||
isMaybeBin = 1;
|
||||
isOct = *str == '0';
|
||||
isMaybeDec = 1;
|
||||
isBin = 0;
|
||||
p = str;
|
||||
|
||||
for (;;) {
|
||||
if (*p == 0)
|
||||
break;
|
||||
|
||||
if (strchr("01", p[0])) {
|
||||
if (isBin)
|
||||
isMaybeBin = 0;
|
||||
} else if (strchr("bB", p[0])) {
|
||||
isBin = 1;
|
||||
isMaybeDec = 0;
|
||||
isOct = 0;
|
||||
} else if (strchr("234567", p[0])) {
|
||||
isMaybeBin = 0;
|
||||
} else if (strchr("89", p[0])) {
|
||||
isOct = 0;
|
||||
isMaybeBin = 0;
|
||||
} else if (strchr("acdefACEDF", p[0])) {
|
||||
isMaybeDec = 0;
|
||||
isMaybeBin = 0;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
++p;
|
||||
}
|
||||
|
||||
if (isMaybeBin && isBin) {
|
||||
return CInt64_ScanBinString(pResult, str, pFail) + 1;
|
||||
} else if (p[0] == 'h' || p[0] == 'H') {
|
||||
return CInt64_ScanHexString(pResult, str, pFail) + 1;
|
||||
} else if (isOct) {
|
||||
return CInt64_ScanOctString(pResult, str, pFail);
|
||||
} else if (isMaybeDec) {
|
||||
return CInt64_ScanDecString(pResult, str, pFail);
|
||||
} else {
|
||||
*pFail = 1;
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
||||
int CInt64_PrintDec(char *output, CInt64 value) {
|
||||
int length;
|
||||
CInt64 rem;
|
||||
CInt64 divisor;
|
||||
char buf[40];
|
||||
char *bufp;
|
||||
|
||||
length = 0;
|
||||
if (CInt64_IsNegative(&value)) {
|
||||
value = CInt64_Neg(value);
|
||||
*output = '-';
|
||||
length++;
|
||||
output++;
|
||||
}
|
||||
|
||||
if (!CInt64_IsZero(&value)) {
|
||||
divisor.lo = 10;
|
||||
divisor.hi = 0;
|
||||
|
||||
bufp = buf;
|
||||
for (;;) {
|
||||
rem = CInt64_ModU(value, divisor);
|
||||
*(bufp++) = rem.lo + '0';
|
||||
value = CInt64_DivU(value, divisor);
|
||||
if (CInt64_IsZero(&value) != 0)
|
||||
break;
|
||||
}
|
||||
|
||||
while (--bufp >= buf) {
|
||||
*(output++) = *bufp;
|
||||
length++;
|
||||
}
|
||||
} else {
|
||||
*(output++) = '0';
|
||||
length++;
|
||||
}
|
||||
|
||||
*output = 0;
|
||||
return length;
|
||||
}
|
||||
|
||||
int CInt64_PrintHex(char *output, CInt64 value) {
|
||||
int length;
|
||||
CInt64 rem;
|
||||
CInt64 shift;
|
||||
CInt64 mask;
|
||||
char buf[32];
|
||||
char *bufp;
|
||||
|
||||
length = 0;
|
||||
if (!CInt64_IsZero(&value)) {
|
||||
shift.lo = 4;
|
||||
shift.hi = 0;
|
||||
mask.lo = 0xF;
|
||||
mask.hi = 0;
|
||||
|
||||
bufp = buf;
|
||||
for (;;) {
|
||||
rem = CInt64_And(value, mask);
|
||||
if ((SInt32) rem.lo >= 10)
|
||||
*(bufp++) = rem.lo + 'A';
|
||||
else
|
||||
*(bufp++) = rem.lo + '0';
|
||||
value = CInt64_ShrU(value, shift);
|
||||
if (CInt64_IsZero(&value) != 0)
|
||||
break;
|
||||
}
|
||||
|
||||
while (--bufp >= buf) {
|
||||
*(output++) = *bufp;
|
||||
length++;
|
||||
}
|
||||
} else {
|
||||
*(output++) = '0';
|
||||
length++;
|
||||
}
|
||||
|
||||
*output = 0;
|
||||
return length;
|
||||
}
|
||||
|
||||
int CInt64_PrintBin(char *output, CInt64 value) {
|
||||
int length;
|
||||
CInt64 rem;
|
||||
char buf[64];
|
||||
char *bufp;
|
||||
|
||||
length = 0;
|
||||
if (!CInt64_IsZero(&value)) {
|
||||
bufp = buf;
|
||||
for (;;) {
|
||||
rem = CInt64_And(value, cint64_one);
|
||||
if (CInt64_Equal(rem, cint64_one))
|
||||
*(bufp++) = '1';
|
||||
else
|
||||
*(bufp++) = '0';
|
||||
value = CInt64_ShrU(value, cint64_one);
|
||||
if (CInt64_IsZero(&value) != 0)
|
||||
break;
|
||||
}
|
||||
|
||||
while (--bufp >= buf) {
|
||||
*(output++) = *bufp;
|
||||
length++;
|
||||
}
|
||||
} else {
|
||||
*(output++) = '0';
|
||||
length++;
|
||||
}
|
||||
|
||||
*output = 0;
|
||||
return length;
|
||||
}
|
||||
1499
compiler_and_linker/unsorted/CMachine.c
Normal file
1499
compiler_and_linker/unsorted/CMachine.c
Normal file
File diff suppressed because it is too large
Load Diff
2142
compiler_and_linker/unsorted/CPrec.c
Normal file
2142
compiler_and_linker/unsorted/CPrec.c
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user