📄 tmodule.c
字号:
/* TMODULE.C */
/*
Object modules are parsed via recursive descent as defined below:
obj_t_module:: obj_THEADR obj_seg_grp {obj_component} obj_modtail
obj_seg_grp:: {obj_LNAMES | obj_SEGDEF | obj_EXTDEF}
{obj_TYPDEF | obj_EXTDEF | obj_GRPDEF}
obj_component:: obj_data | obj_debug_record
obj_data:: obj_content_def | obj_thread_def | obj_COMDEF |
obj_TYPDEF | obj_PUBDEF | obj_EXTDEF |
obj_FORREF | obj_MODPUB | obj_MODEXT
obj_debug_record:: obj_LINNUM
obj_content_def:: obj_data_record {obj_FIXUPP}
obj_thread_def:: obj_FIXUPP (containing only thread fields)
obj_data_record:: obj_LIDATA | obj_LEDATA
obj_modtail:: obj_MODEND
*/
/*+-------------------------------------------------------------------------+
| |
| obj_COMDEF |
| |
+-------------------------------------------------------------------------+*/
bit_16 obj_COMDEF()
BeginDeclarations
bit_32 element_count;
bit_32 element_size;
bit_8 element_type;
bit_8 expected_type;
bit_16 len;
public_entry_ptr pub;
#define Pub (*pub)
EndDeclarations
BeginCode
If Current_record_header.rec_typ IsNot COMDEF_record
Then
return(False);
EndIf;
While obj_ptr.b8 IsNot end_of_record.b8
BeginWhile
If n_externals NotLessThan max_externals.val
Then
linker_error(12, "Internal limit exceeded:\n"
"\tModule: \"%Fs\"\n"
"\t File: \"%Fs\"\n"
"\tOffset: %lu\n"
"\t Error: Too many externals. Max of %u exceeded.\n"
"\t Retry with larger \"/maxexternals:n\" "
"switch.\n",
(*tmodule_name).symbol,
(*infile.file_info).filename,
current_record_offset,
max_externals.val);
EndIf;
len = obj_name_length();
If case_ignore.val
Then
far_to_lower(BytePtr(obj_ptr.b8), len);
EndIf;
pub = lookup_public(len, obj_ptr.b8, 0);
obj_ptr.b8 += len;
obj_name_length(); /* Eat the type index. */
externals[++n_externals] = pub;
element_type = *obj_ptr.b8++;
Using element_type
BeginCase
When 0x61:
expected_type = far_communal;
element_count = obj_leaf_descriptor();
element_size = obj_leaf_descriptor();
break;
When 0x62:
expected_type = near_communal;
element_size = obj_leaf_descriptor();
element_count = 1L;
break;
Otherwise:
linker_error(12, "Translator error:\n"
"\tModule: \"%Fs\"\n"
"\t File: \"%Fs\"\n"
"\tOffset: %lu\n"
"\t Error: Communal type of \"%02X\" is illegal.\n",
(*tmodule_name).symbol,
(*infile.file_info).filename,
current_record_offset,
element_type);
EndCase;
If Pub.type_entry Is unused
Then
Insert pub AtEnd InList external_list EndInsert;
Pub.type_entry = expected_type;
Pub.Communal.element_size = element_size;
Pub.Communal.element_count = element_count;
Using element_type
BeginCase
When 0x61:
Pub.Communal.next_communal = far_communals;
far_communals = pub;
break;
When 0x62:
Pub.Communal.next_communal = near_communals;
near_communals = pub;
break;
EndCase;
Else
If Pub.type_entry Is expected_type
Then
If (element_size * element_count) Exceeds
(Pub.Communal.element_size * Pub.Communal.element_count)
Then /* We need the largest common */
Pub.Communal.element_size = element_size;
Pub.Communal.element_count = element_count;
EndIf;
Else
If (Pub.type_entry Is near_communal) OrIf
(Pub.type_entry Is far_communal)
Then
linker_error(4, "Translator error:\n"
"\tModule: \"%Fs\"\n"
"\t File: \"%Fs\"\n"
"\tOffset: %lu\n"
"\t Error: Communal \"%Fs\" is declared both near "
"and far.\n",
(*tmodule_name).symbol,
(*infile.file_info).filename,
current_record_offset,
Pub.symbol);
EndIf;
EndIf;
EndIf;
EndWhile;
obj_next_record();
return(True);
EndCode
#undef Pub
/*+-------------------------------------------------------------------------+
| |
| obj_COMENT |
| |
+-------------------------------------------------------------------------+*/
bit_16 obj_COMENT()
BeginDeclarations
bit_8 comment_class;
EndDeclarations
BeginCode
If Current_record_header.rec_typ IsNot COMENT_record
Then
return(False);
EndIf;
obj_ptr.b8++;
comment_class = *obj_ptr.b8++;
Using comment_class
BeginCase
When 158:
DOSSEG.val = True;
break;
When 161:
codeview_information_present = True;
break;
Otherwise:
break;
EndCase;
return(True);
EndCode
/*+-------------------------------------------------------------------------+
| |
| obj_component |
| |
+-------------------------------------------------------------------------+*/
/* obj_component:: obj_data | obj_debug_record */
bit_16 obj_component()
BeginDeclarations
EndDeclarations
BeginCode
If obj_data() OrIf obj_debug_record()
Then
return(True);
EndIf;
return(False);
EndCode
/*+-------------------------------------------------------------------------+
| |
| obj_content_def |
| |
+-------------------------------------------------------------------------+*/
/* obj_content_def:: obj_data_record {obj_FIXUPP} */
bit_16 obj_content_def()
BeginDeclarations
EndDeclarations
BeginCode
If Not obj_data_record()
Then
return(False);
EndIf;
While obj_FIXUPP()
BeginWhile
EndWhile;
return(True);
EndCode
/*+-------------------------------------------------------------------------+
| |
| obj_data |
| |
+-------------------------------------------------------------------------+*/
/* obj_data:: obj_content_def |
obj_thread_def |
obj_TYPDEF |
obj_PUBDEF |
obj_EXTDEF */
bit_16 obj_data()
BeginDeclarations
EndDeclarations
BeginCode
If obj_content_def() OrIf
obj_thread_def() OrIf
obj_TYPDEF() OrIf
obj_PUBDEF() OrIf
obj_EXTDEF() OrIf
obj_FORREF() OrIf
obj_COMDEF() OrIf
obj_MODEXT() OrIf
obj_MODPUB()
Then
return(True);
EndIf;
return(False);
EndCode
/*+-------------------------------------------------------------------------+
| |
| obj_data_record |
| |
+-------------------------------------------------------------------------+*/
/* obj_data_record:: obj_LIDATA | obj_LEDATA */
bit_16 obj_data_record()
BeginDeclarations
EndDeclarations
BeginCode
If obj_LIDATA() OrIf obj_LEDATA()
Then
return(True);
EndIf;
return(False);
EndCode
/*+-------------------------------------------------------------------------+
| |
| obj_debug_record |
| |
+-------------------------------------------------------------------------+*/
/* obj_debug_record:: obj_LINNUM */
bit_16 obj_debug_record()
BeginDeclarations
EndDeclarations
BeginCode
If obj_LINNUM()
Then
return(True);
EndIf;
return(False);
EndCode
/*+-------------------------------------------------------------------------+
| |
| obj_EXTDEF |
| |
+-------------------------------------------------------------------------+*/
bit_16 obj_EXTDEF()
BeginDeclarations
bit_16 len;
public_entry_ptr pub;
#define Pub (*pub)
EndDeclarations
BeginCode
If Current_record_header.rec_typ IsNot EXTDEF_record
Then
return(False);
EndIf;
While obj_ptr.b8 IsNot end_of_record.b8
BeginWhile
If n_externals NotLessThan max_externals.val
Then
linker_error(12, "Internal limit exceeded:\n"
"\tModule: \"%Fs\"\n"
"\t File: \"%Fs\"\n"
"\tOffset: %lu\n"
"\t Error: Too many externals. Max of %u exceeded.\n"
"\t Retry with larger \"/maxexternals:n\" "
"switch.\n",
(*tmodule_name).symbol,
(*infile.file_info).filename,
current_record_offset,
max_externals.val);
EndIf;
len = obj_name_length();
If case_ignore.val
Then
far_to_lower(BytePtr(obj_ptr.b8), len);
EndIf;
pub = lookup_public(len, obj_ptr.b8, 0);
obj_ptr.b8 += len;
obj_name_length(); /* Eat the type index. */
externals[++n_externals] = pub;
If Pub.type_entry Is unused
Then
Insert pub AtEnd InList external_list EndInsert;
Pub.type_entry = external;
Else
If (Pub.type_entry Is public_in_library) AndIf
(Not Pub.Library.requested)
Then
library_request_count++;
(*Pub.Library.lib_file).request_count++;
Pub.Library.requested = True;
EndIf;
EndIf;
EndWhile;
obj_next_record();
return(True);
EndCode
#undef Pub
/*+-------------------------------------------------------------------------+
| |
| obj_FIXUPP |
| |
+-------------------------------------------------------------------------+*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -