Commit 93bdffeb authored by johnvg@science.ru.nl's avatar johnvg@science.ru.nl

move functions from checksupport.c to comsupport.c and instructions.c (both,later specialized)

parent 05123ad5
#include "compiledefines.h"
#include "types.t"
#include "syntaxtr.t"
#include "comsupport.h"
#include "checksupport.h"
#include "settings.h"
#include "buildtree.h"
#include <ctype.h>
static void print_compiler_generated_function_name (char *name, char *name_end, unsigned line_nr, File file)
{
char *parsed_digits;
FPutS (name,file);
parsed_digits=NULL;
if (name_end[0]==';' && isdigit (name_end[1])){
char *s;
s=name_end+2;
while (isdigit (*s))
++s;
if (*s==';')
parsed_digits=s;
}
if (line_nr>0){
FPrintF (file,"[line: %u]", line_nr);
if (parsed_digits)
name_end=parsed_digits;
} else
if (parsed_digits){
char *d_p;
FPutS ("[line:",file);
for (d_p=name_end+1; d_p<parsed_digits; ++d_p)
FPutC (*d_p,file);
FPutC (']',file);
name_end=parsed_digits;
}
FPutS (name_end,file);
}
void PrintSymbolOfIdent (char *name, unsigned line_nr, File file)
{
char *name_end;
for (name_end=name; *name_end!=';' && *name_end!='\0'; ++name_end)
;
if (*name=='\\' && name+1==name_end){
print_compiler_generated_function_name ("<lambda>",name_end,line_nr,file);
return;
}
if (*name == '_'){
if (name+2==name_end && name[1]=='c')
print_compiler_generated_function_name ("<case>",name_end,line_nr,file);
else if (name+3==name_end && name[1]=='i' && name[2]=='f')
print_compiler_generated_function_name ("<if>",name_end,line_nr,file);
else
FPutS (name, file);
return;
}
if (line_nr > 0 && *name_end == ';' && isdigit (name_end[1])){
char *end_name;
for (; name!=name_end; name++)
FPutC (*name, file);
for (end_name = name_end + 2; *end_name!=';' && *end_name!='\0'; end_name++)
;
FPrintF (file, " [line: %u]", line_nr);
if (*end_name == '\0')
return;
name = end_name;
}
FPutS (name, file);
}
extern void PrintSymbolOfIdent (char *name,unsigned line_nr,File file);
......@@ -28,7 +28,6 @@
#include "codegen1.h"
#include "codegen2.h"
#include "instructions.h"
#include "checksupport.h"
#include "dbprint.h"
/* 'CurrentModule' contains the name of the module that is currently under examination. */
......@@ -335,6 +334,82 @@ static char *symbol_to_string (Symbol symbol)
}
}
static void print_compiler_generated_function_name (char *name, char *name_end, unsigned line_nr, File file)
{
char *parsed_digits;
FPutS (name,file);
parsed_digits=NULL;
if (name_end[0]==';' && isdigit (name_end[1])){
char *s;
s=name_end+2;
while (isdigit (*s))
++s;
if (*s==';')
parsed_digits=s;
}
if (line_nr>0){
FPrintF (file,"[line: %u]", line_nr);
if (parsed_digits)
name_end=parsed_digits;
} else
if (parsed_digits){
char *d_p;
FPutS ("[line:",file);
for (d_p=name_end+1; d_p<parsed_digits; ++d_p)
FPutC (*d_p,file);
FPutC (']',file);
name_end=parsed_digits;
}
FPutS (name_end,file);
}
static void PrintSymbolOfIdent (char *name, unsigned line_nr, File file)
{
char *name_end;
for (name_end=name; *name_end!=';' && *name_end!='\0'; ++name_end)
;
if (*name=='\\' && name+1==name_end){
print_compiler_generated_function_name ("<lambda>",name_end,line_nr,file);
return;
}
if (*name == '_'){
if (name+2==name_end && name[1]=='c'){
print_compiler_generated_function_name ("<case>",name_end,line_nr,file);
return;
} else if (name+3==name_end && name[1]=='i' && name[2]=='f'){
print_compiler_generated_function_name ("<if>",name_end,line_nr,file);
return;
}
} else
if (line_nr > 0 && *name_end == ';' && isdigit (name_end[1])){
char *end_name;
for (; name!=name_end; name++)
FPutC (*name, file);
for (end_name = name_end + 2; *end_name!=';' && *end_name!='\0'; end_name++)
;
FPrintF (file, " [line: %u]", line_nr);
if (*end_name == '\0')
return;
name = end_name;
}
FPutS (name, file);
}
void PrintSymbol (Symbol symbol, File file)
{
if (symbol->symb_kind==definition)
......
......@@ -6,7 +6,6 @@
#include "comsupport.h"
#include "settings.h"
#include "sizes.h"
#include "checksupport.h"
#include "dbprint.h"
#include "codegen_types.h"
......
......@@ -9,7 +9,6 @@
#include <ctype.h>
#include "syntaxtr.t"
#include "checksupport.h"
#include "settings.h"
#include "sizes.h"
......@@ -24,6 +23,8 @@
#define BINARY_ABC 0
#undef MEMORY_PROFILING_WITH_N_STRING
File OutFile;
#define PutSOutFile(s) FPutS ((s),OutFile)
#define PutCOutFile(s) FPutC ((s),OutFile)
......@@ -102,7 +103,6 @@ static void ConvertOptionsToString (char *optstring)
#define LOCAL_D_PREFIX "d"
File OutFile;
char *ABCFileName;
Bool OpenABCFile (char *fname)
......@@ -793,6 +793,82 @@ static void put_instruction_code (int instruction_code)
PutCOutFile (instruction_code);
}
static void print_compiler_generated_function_name (char *name, char *name_end, unsigned line_nr, File file)
{
char *parsed_digits;
FPutS (name,file);
parsed_digits=NULL;
if (name_end[0]==';' && isdigit (name_end[1])){
char *s;
s=name_end+2;
while (isdigit (*s))
++s;
if (*s==';')
parsed_digits=s;
}
if (line_nr>0){
FPrintF (file,"[line: %u]", line_nr);
if (parsed_digits)
name_end=parsed_digits;
} else
if (parsed_digits){
char *d_p;
FPutS ("[line:",file);
for (d_p=name_end+1; d_p<parsed_digits; ++d_p)
FPutC (*d_p,file);
FPutC (']',file);
name_end=parsed_digits;
}
FPutS (name_end,file);
}
static void PrintSymbolOfIdent (char *name, unsigned line_nr, File file)
{
char *name_end;
for (name_end=name; *name_end!=';' && *name_end!='\0'; ++name_end)
;
if (*name=='\\' && name+1==name_end){
print_compiler_generated_function_name ("<lambda>",name_end,line_nr,file);
return;
}
if (*name == '_'){
if (name+2==name_end && name[1]=='c'){
print_compiler_generated_function_name ("<case>",name_end,line_nr,file);
return;
} else if (name+3==name_end && name[1]=='i' && name[2]=='f'){
print_compiler_generated_function_name ("<if>",name_end,line_nr,file);
return;
}
} else
if (line_nr > 0 && *name_end == ';' && isdigit (name_end[1])){
char *end_name;
for (; name!=name_end; name++)
FPutC (*name, file);
for (end_name = name_end + 2; *end_name!=';' && *end_name!='\0'; end_name++)
;
FPrintF (file, " [line: %u]", line_nr);
if (*end_name == '\0')
return;
name = end_name;
}
FPutS (name, file);
}
static void GenGetWL (int offset)
{
put_instruction ("getWL");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment