1717
1818#include "cpreprocessor.h"
1919#include "debug.h"
20+ #include "dependency.h"
2021#include "entry.h"
2122#include "keyword.h"
2223#include "param.h"
3132* DATA DECLARATIONS
3233*/
3334typedef enum {
35+ K_PSUEDO_FOREIGN_LD_SCRIPT_SECTION = -3 ,
3436 K_PSUEDO_MACRO_END = -2 ,
3537 K_NONE = -1 , K_DEFINE , K_LABEL , K_MACRO , K_TYPE ,
36- K_SECTION ,
3738 K_PARAM ,
3839} AsmKind ;
3940
@@ -59,10 +60,6 @@ typedef enum {
5960 OP_LAST
6061} opKeyword ;
6162
62- typedef enum {
63- ASM_SECTION_PLACEMENT ,
64- } asmSectionRole ;
65-
6663typedef struct {
6764 opKeyword keyword ;
6865 AsmKind kind ;
@@ -83,17 +80,11 @@ static fieldDefinition AsmFields[] = {
8380*/
8481static langType Lang_asm ;
8582
86- static roleDefinition asmSectionRoles [] = {
87- { true, "placement" , "placement where the assembled code goes" },
88- };
89-
9083static kindDefinition AsmKinds [] = {
9184 { true, 'd' , "define" , "defines" },
9285 { true, 'l' , "label" , "labels" },
9386 { true, 'm' , "macro" , "macros" },
9487 { true, 't' , "type" , "types (structs and records)" },
95- { true, 's' , "section" , "sections" ,
96- .referenceOnly = true, ATTACH_ROLES (asmSectionRoles )},
9788 { false,'z' , "parameter" , "parameters for a macro" },
9889};
9990
@@ -138,7 +129,7 @@ static const opKind OpKinds [] = {
138129 { OP_PROC , K_LABEL },
139130 { OP_RECORD , K_TYPE },
140131 { OP_SECTIONS , K_NONE },
141- { OP_SECTION , K_SECTION },
132+ { OP_SECTION , K_PSUEDO_FOREIGN_LD_SCRIPT_SECTION },
142133 { OP_SET , K_DEFINE },
143134 { OP_STRUCT , K_TYPE }
144135};
@@ -212,6 +203,32 @@ static bool isDefineOperator (const vString *const operator)
212203 return result ;
213204}
214205
206+ static int makeTagForLdScriptSection (const char * section )
207+ {
208+ tagEntryInfo e ;
209+ static langType lang = LANG_AUTO ;
210+
211+ if (lang == LANG_AUTO )
212+ lang = getNamedLanguage ("LdScript" , 0 );
213+ if (lang == LANG_IGNORE )
214+ return CORK_NIL ;
215+
216+ static kindDefinition * kdef = NULL ;
217+ if (kdef == NULL )
218+ kdef = getLanguageKindForName (lang , "inputSection" );
219+ if (kdef == NULL )
220+ return CORK_NIL ;
221+
222+ static roleDefinition * rdef = NULL ;
223+ if (rdef == NULL )
224+ rdef = getLanguageRoleForName (lang , kdef -> id , "destination" );
225+ if (rdef == NULL )
226+ return CORK_NIL ;
227+
228+ initForeignRefTagEntry (& e , section , lang , kdef -> id , rdef -> id );
229+ return makeTagEntry (& e );
230+ }
231+
215232static int makeAsmTag (
216233 const vString * const name ,
217234 const vString * const operator ,
@@ -271,10 +288,8 @@ static int makeAsmTag (
271288 * macroScope = macro_tag -> extensionFields .scopeIndex ;
272289 }
273290 break ;
274- case K_SECTION :
275- r = makeSimpleRefTag (operator ,
276- kind_for_directive ,
277- ASM_SECTION_PLACEMENT );
291+ case K_PSUEDO_FOREIGN_LD_SCRIPT_SECTION :
292+ r = makeTagForLdScriptSection (vStringValue (operator ));
278293 break ;
279294 default :
280295 r = makeSimpleTag (operator , kind_for_directive );
@@ -769,7 +784,8 @@ static void findAsmTagsCommon (bool useCpp)
769784 }
770785 int r = makeAsmTag (name , operator , labelCandidate , nameFollows , directive , & macroScope );
771786 tagEntryInfo * e = getEntryInCorkQueue (r );
772- if (e && e -> kindIndex == K_MACRO && isRoleAssigned (e , ROLE_DEFINITION_INDEX ))
787+ if (e && e -> langType == Lang_asm
788+ && e -> kindIndex == K_MACRO && isRoleAssigned (e , ROLE_DEFINITION_INDEX ))
773789 readMacroParameters (r , e , cp );
774790 }
775791
@@ -869,7 +885,15 @@ extern parserDefinition* AsmParser (void)
869885 };
870886 static selectLanguage selectors [] = { selectByArrowOfR , NULL };
871887
888+ static parserDependency dependencies [] = {
889+ { DEPTYPE_FOREIGNER , "LdScript" , NULL },
890+ };
891+
872892 parserDefinition * def = parserNew ("Asm" );
893+ def -> versionCurrent = 1 ;
894+ def -> versionAge = 0 ;
895+ def -> dependencies = dependencies ;
896+ def -> dependencyCount = ARRAY_SIZE (dependencies );
873897 def -> kindTable = AsmKinds ;
874898 def -> kindCount = ARRAY_SIZE (AsmKinds );
875899 def -> extensions = extensions ;
0 commit comments