@@ -4131,12 +4131,10 @@ doGetAddress(IRList *irl, AST *expr, bool isField)
41314131 {
41324132 Symbol * sym ;
41334133 Operand * res = NULL ;
4134- const char * name ;
41354134 Module * P ;
41364135 int off ;
41374136
4138- name = GetUserIdentifierName (expr -> right );
4139- sym = LookupMemberSymbol (expr , ExprType (expr -> left ), name , & P , NULL );
4137+ sym = LookupMethodRef (expr , & P , NULL );
41404138 if (sym ) {
41414139 if (sym -> kind == SYM_VARIABLE ) {
41424140 Operand * base = CompileExpression (irl , expr -> left , NULL );
@@ -4153,6 +4151,7 @@ doGetAddress(IRList *irl, AST *expr, bool isField)
41534151 }
41544152 }
41554153 if (!res ) {
4154+ const char * name = GetUserIdentifierName (expr -> right );
41564155 ERROR (expr , "Internal error, cannot take address of %s" , name );
41574156 res = OPERAND_DUMMY ;
41584157 } else if (flags ) {
@@ -4594,25 +4593,30 @@ CompileExpression(IRList *irl, AST *expr, Operand *dest)
45944593 int off = 0 ;
45954594 Module * P ;
45964595 const char * name ;
4596+
45974597 objtype = ExprType (expr -> left );
4598- if (curfunc && IsSpinLang (curfunc -> language ) && IsRefType (objtype )) {
4599- objtype = objtype -> left ;
4600- }
4601- name = GetUserIdentifierName (expr -> right );
4602- if (!objtype ) {
4603- ERROR (expr , "%s is not accessible in this context" , GetIdentifierName (expr -> left ));
4604- return EmptyOperand ();
4605- } else if (!IsClassType (objtype )) {
4606- ERROR (expr , "Request for member %s in something that is not a class" , name );
4607- return EmptyOperand ();
4608- }
4609- if (expr -> left && expr -> left -> kind == AST_OBJECT ) {
4610- // FIXME: we could potentially support calls of static class
4611- // member functions, but for now, punt
4612- ERROR (expr , "Use of class name in method references is not supported yet" );
4613- return EmptyOperand ();
4598+ if (objtype ) {
4599+ if (curfunc && IsSpinLang (curfunc -> language ) && IsRefType (objtype )) {
4600+ objtype = objtype -> left ;
4601+ }
4602+ name = GetUserIdentifierName (expr -> right );
4603+ if (!objtype ) {
4604+ ERROR (expr , "%s is not accessible in this context" , GetIdentifierName (expr -> left ));
4605+ return EmptyOperand ();
4606+ } else if (!IsClassType (objtype )) {
4607+ ERROR (expr , "Request for member %s in something that is not a class" , name );
4608+ return EmptyOperand ();
4609+ }
4610+ if (expr -> left && expr -> left -> kind == AST_OBJECT ) {
4611+ // FIXME: we could potentially support calls of static class
4612+ // member functions, but for now, punt
4613+ ERROR (expr , "Use of class name in method references is not supported yet" );
4614+ return EmptyOperand ();
4615+ }
4616+ sym = LookupMemberSymbol (expr , objtype , name , & P , NULL );
4617+ } else {
4618+ sym = LookupMethodRef (expr , & P , NULL );
46144619 }
4615- sym = LookupMemberSymbol (expr , objtype , name , & P , NULL );
46164620 if (sym && sym -> kind == SYM_FUNCTION ) {
46174621 Function * pf = (Function * )sym -> v .ptr ;
46184622 if (pf -> sym_funcptr ) {
@@ -4629,7 +4633,11 @@ CompileExpression(IRList *irl, AST *expr, Operand *dest)
46294633 base = LabelRef (irl , sym );
46304634 break ;
46314635 default :
4632- ERROR (expr , "Unable to dereference symbol %s in %s" , name , P -> classname );
4636+ if (P ) {
4637+ ERROR (expr , "Unable to dereference symbol %s in %s" , name , P -> classname );
4638+ } else {
4639+ ERROR (expr , "Unable to dereference symbol %s" , name );
4640+ }
46334641 return EmptyOperand ();
46344642 }
46354643 }
0 commit comments