@@ -999,7 +999,16 @@ static int EmitLongPtr(IRList *irl, Operand *op)
999
999
static int EmitStringNoTrailingZero (IRList * irl , AST * ast )
1000
1000
{
1001
1001
Operand * op ;
1002
+ int count = 0 ;
1002
1003
switch (ast -> kind ) {
1004
+ case AST_EXPRLIST :
1005
+ while (ast && ast -> kind == AST_EXPRLIST ) {
1006
+ count += EmitStringNoTrailingZero (irl , ast -> left );
1007
+ ast = ast -> right ;
1008
+ }
1009
+ return count ;
1010
+ case AST_STRINGPTR :
1011
+ return EmitStringNoTrailingZero (irl , ast -> left );
1003
1012
case AST_STRING :
1004
1013
if (irl ) {
1005
1014
op = NewOperand (IMM_STRING , ast -> d .string , 0 );
@@ -1012,6 +1021,22 @@ static int EmitStringNoTrailingZero(IRList *irl, AST *ast)
1012
1021
EmitOp1 (irl , OPC_BYTE , op );
1013
1022
}
1014
1023
return 1 ;
1024
+ case AST_IDENTIFIER :
1025
+ case AST_LOCAL_IDENTIFIER :
1026
+ {
1027
+ const char * name = GetIdentifierName (ast );
1028
+ Symbol * sym = LookupSymbol (name );
1029
+ if (!sym ) {
1030
+ ERROR (ast , "Unknown identifier `%s'" , name );
1031
+ return 0 ;
1032
+ }
1033
+ if (sym -> kind == SYM_CONSTANT || sym -> kind == SYM_ALIAS ) {
1034
+ return EmitStringNoTrailingZero (irl , (AST * )sym -> v .ptr );
1035
+ } else {
1036
+ ERROR (ast , "Expected a constant, found `%s'" , name );
1037
+ return 0 ;
1038
+ }
1039
+ }
1015
1040
default :
1016
1041
if (IsConstExpr (ast )) {
1017
1042
if (irl ) {
@@ -1028,10 +1053,6 @@ static int EmitStringNoTrailingZero(IRList *irl, AST *ast)
1028
1053
int EmitString (IRList * irl , AST * ast )
1029
1054
{
1030
1055
int count = 0 ;
1031
- while (ast && ast -> kind == AST_EXPRLIST ) {
1032
- count += EmitStringNoTrailingZero (irl , ast -> left );
1033
- ast = ast -> right ;
1034
- }
1035
1056
if (ast ) {
1036
1057
count += EmitStringNoTrailingZero (irl , ast );
1037
1058
}
@@ -6386,12 +6407,16 @@ CompileConstant(IRList *irl, AST *ast, bool skip_clkfreq, bool skip_clkmode)
6386
6407
return ;
6387
6408
}
6388
6409
expr = (AST * )sym -> v .ptr ;
6410
+ if (!expr ) return ;
6389
6411
if (skip_clkfreq && !strcasecmp (name , "_clkfreq" )) {
6390
6412
return ;
6391
6413
}
6392
6414
if (skip_clkmode && !strcasecmp (name , "_clkmode" )) {
6393
6415
return ;
6394
6416
}
6417
+ if (expr -> kind == AST_STRING ) {
6418
+ return ;
6419
+ }
6395
6420
CompileConstOperand (irl , name , expr );
6396
6421
}
6397
6422
0 commit comments