📄 edsel.c
字号:
voidcadillac_finish_enum (type) tree type;{ Connection *conn = cadillacObj.conn; tree name = TYPE_NAME (type); if (TREE_CODE (name) == TYPE_DECL) name = DECL_NAME (name); if (context_stack) switch (TREE_CODE (context_stack->context)) { case FUNCTION_DECL: return; case RECORD_TYPE: case UNION_TYPE: CWriteHeader (conn, EndDefMType, 0); CWriteLength (conn); break; default: my_friendly_abort (30); } else { CWriteHeader (conn, EndDefMType, 0); CWriteLength (conn); cadillac_printf ("finish top-level enum", IDENTIFIER_POINTER (name)); CWriteTopLevel (conn, StopMType); } CWriteRequestBuffer (conn); cadillac_process_requests (conn);}voidcadillac_start_struct (type) tree type;{ Connection *conn = cadillacObj.conn; tree name = TYPE_NAME (type); if (TREE_CODE (name) == TYPE_DECL) name = DECL_NAME (name); if (context_stack) switch (TREE_CODE (context_stack->context)) { case FUNCTION_DECL: return; case RECORD_TYPE: case UNION_TYPE: return; default: my_friendly_abort (31); } else { cadillac_printf ("start struct", IDENTIFIER_POINTER (name)); CWriteTopLevel (conn, StartMType); } context_stack = push_context_level (context_stack, &cadillac_obstack); context_stack->context = type; CWriteLanguageType (conn, type, TYPE_LANG_SPECIFIC (type) && CLASSTYPE_DECLARED_CLASS (type) ? ClassOType : tree_to_cadillac_map[TREE_CODE (type)]);}voidcadillac_finish_struct (type) tree type;{ Connection *conn = cadillacObj.conn; tree name = TYPE_NAME (type); if (TREE_CODE (name) == TYPE_DECL) name = DECL_NAME (name); context_stack = pop_context_level (context_stack); if (context_stack) return; cadillac_printf ("finish struct", IDENTIFIER_POINTER (name)); CWriteHeader (conn, EndDefMType, 0); CWriteLength (conn); CWriteTopLevel (conn, StopMType); CWriteRequestBuffer (conn); cadillac_process_requests (conn);}voidcadillac_finish_exception (type) tree type;{ Connection *conn = cadillacObj.conn; fatal ("cadillac_finish_exception"); CWriteHeader (conn, EndDefMType, 0); CWriteLength (conn); CWriteTopLevel (conn, StopMType); CWriteRequestBuffer (conn); cadillac_process_requests (conn);}voidcadillac_push_class (type) tree type;{}voidcadillac_pop_class (){}voidcadillac_push_lang (name) tree name;{ Connection *conn = cadillacObj.conn; CLinkLanguageType m; if (name == lang_name_cplusplus) m = LinkCPlus; else if (name == lang_name_c) m = LinkC; else my_friendly_abort (32); CWriteHeader (conn, ForeignLinkageMType, m); CWriteRequestBuffer (conn); cadillac_process_requests (conn);}voidcadillac_pop_lang (){ Connection *conn = cadillacObj.conn; CWriteHeader (conn, ForeignLinkageMType, LinkPop); CWriteRequestBuffer (conn); cadillac_process_requests (conn);}voidcadillac_finish_stmt (){}voidcadillac_note_source (){ cadillacObj.lineno = lineno; cadillacObj.filename = input_filename;}static voidCWriteTopLevel (conn, m) Connection *conn; CMessageSubType m;{ static context_id = 0; CWriteHeader (conn, TopLevelFormMType, m); cadillac_note_filepos (); /* Eventually, this will point somewhere into the digest file. */ context_id += 1; CWriteSomething (conn, &context_id, sizeof (BITS32)); CWriteSomething (conn, &cadillacObj.iflevel, sizeof (BITS32)); CWriteLength (conn);}static voidcadillac_note_filepos (){ extern FILE *finput; int pos = ftell (finput); CWriteSomething (cadillacObj.conn, &pos, sizeof (BITS32));}voidcadillac_switch_source (startflag) int startflag;{ Connection *conn = cadillacObj.conn; /* Send out the name of the source file being compiled. */ CWriteHeader (conn, SourceFileMType, startflag ? StartMType : StopMType); CWriteSomething (conn, &cadillacObj.depth, sizeof (BITS16)); CWriteVstring0 (conn, input_filename); CWriteLength (conn); CWriteRequestBuffer (conn); cadillac_process_requests (conn);}voidcadillac_push_source (){ cadillacObj.depth += 1; cadillac_switch_source (1);}voidcadillac_pop_source (){ cadillacObj.depth -= 1; cadillac_switch_source (0);}struct cadillac_mdep{ short object_type; char linkage; char access; short length;};static voidCWriteLanguageElem (conn, p, name) Connection *conn; struct cadillac_mdep *p; char *name;{ CWriteSomething (conn, &p->object_type, sizeof (BITS16)); CWriteSomething (conn, &p->linkage, sizeof (BITS8)); CWriteSomething (conn, &p->access, sizeof (BITS8)); CWriteSomething (conn, &p->length, sizeof (BITS16)); CWriteVstring0 (conn, name);#if 0 /* Don't write date_type. */ CWriteVstring0 (conn, "");#endif CWriteLength (conn);}static voidCWriteLanguageDecl (conn, decl, object_type) Connection *conn; tree decl; CObjectType object_type;{ struct cadillac_mdep foo; tree name; CWriteHeader (conn, LanguageElementMType, StartDefineMType); foo.object_type = object_type; if (decl_type_context (decl)) { foo.linkage = ParentLinkage; if (TREE_PRIVATE (decl)) foo.access = PrivateAccess; else if (TREE_PROTECTED (decl)) foo.access = ProtectedAccess; else foo.access = PublicAccess; } else { if (TREE_PUBLIC (decl)) foo.linkage = GlobalLinkage; else foo.linkage = FileLinkage; foo.access = PublicAccess; } name = DECL_NAME (decl); foo.length = IDENTIFIER_LENGTH (name); CWriteLanguageElem (conn, &foo, IDENTIFIER_POINTER (name)); CWriteRequestBuffer (conn); cadillac_process_requests (conn);}static voidCWriteLanguageType (conn, type, object_type) Connection *conn; tree type; CObjectType object_type;{ struct cadillac_mdep foo; tree name = TYPE_NAME (type); CWriteHeader (conn, LanguageElementMType, StartDefineMType); foo.object_type = object_type; if (current_class_type) { foo.linkage = ParentLinkage; if (TREE_PRIVATE (type)) foo.access = PrivateAccess; else if (TREE_PROTECTED (type)) foo.access = ProtectedAccess; else foo.access = PublicAccess; } else { foo.linkage = NoLinkage; foo.access = PublicAccess; } if (TREE_CODE (name) == TYPE_DECL) name = DECL_NAME (name); foo.length = IDENTIFIER_LENGTH (name); CWriteLanguageElem (conn, &foo, IDENTIFIER_POINTER (name)); CWriteRequestBuffer (conn); cadillac_process_requests (conn);}static voidCWriteUseObject (conn, type, object_type, use) Connection *conn; tree type; CObjectType object_type; CMessageSubType use;{ struct cadillac_mdep foo; tree name = NULL_TREE; CWriteHeader (conn, LanguageElementMType, use); foo.object_type = object_type; if (current_class_type) { foo.linkage = ParentLinkage; if (TREE_PRIVATE (type)) foo.access = PrivateAccess; else if (TREE_PROTECTED (type)) foo.access = ProtectedAccess; else foo.access = PublicAccess; } else { foo.linkage = NoLinkage; foo.access = PublicAccess; } switch (TREE_CODE (type)) { case VAR_DECL: case FIELD_DECL: case TYPE_DECL: case CONST_DECL: case FUNCTION_DECL: name = DECL_NAME (type); break; default: my_friendly_abort (33); } foo.length = IDENTIFIER_LENGTH (name); CWriteLanguageElem (conn, &foo, IDENTIFIER_POINTER (name)); CWriteRequestBuffer (conn); cadillac_process_requests (conn);}/* Here's how we exit under cadillac. */static voidexit_cadillac (){ extern int errorcount; Connection *conn = cadillacObj.conn; if (flag_cadillac) { CCompilerMessage *req; CWriteHeader (conn, FinishedMType, errorcount ? 0 : CsObjectWritten | CsComplete); /* Bye, bye! */ CWriteRequestBuffer (conn); /* Block on read. */ while (! readable_p (cadillacObj.fd_input)) { if (exiting) my_friendly_abort (34); exiting = 1; } exiting = 1; req = CReadCompilerMessage (conn); cadillac_process_request (&cadillacObj, req); }}#else/* Stubs. */void init_cadillac () {}void cadillac_start () {}void cadillac_start_decl (decl) tree decl;{}voidcadillac_finish_decl (decl) tree decl;{}voidcadillac_start_function (fndecl) tree fndecl;{}voidcadillac_finish_function (fndecl) tree fndecl;{}voidcadillac_finish_anon_union (decl) tree decl;{}voidcadillac_start_enum (type) tree type;{}voidcadillac_finish_enum (type) tree type;{}voidcadillac_start_struct (type) tree type;{}voidcadillac_finish_struct (type) tree type;{}voidcadillac_finish_exception (type) tree type;{}voidcadillac_push_class (type) tree type;{}voidcadillac_pop_class (){}voidcadillac_push_lang (name) tree name;{}voidcadillac_pop_lang (){}voidcadillac_note_source (){}voidcadillac_finish_stmt (){}voidcadillac_switch_source (){}voidcadillac_push_source (){}voidcadillac_pop_source (){}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -