Skip to content

Conversation

@jayrm
Copy link
Member

@jayrm jayrm commented Jun 20, 2018

  • added hResolveRefToRefInitializer() called from hCheckAndBuildByrefInitializer()
  • allows initializing a reference variable by referring to another reference variable.
  • was discussed briefly in forum topic Dim Byref Syntax

jayrm added 3 commits June 20, 2018 00:43
- hCMPI was generate invalid ASM if operands were IMM (constant) and OFS (offset to shared/static)
- dim shared X as integer: if( @x <> 0 ) then ... to produce the error
ostr = "cmp " + dst + COMMA + src
outp ostr

'' immediate and offset? it's invalid for CMP so use a temp reg
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somehow this issue seemed familiar - cc8638c

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's perfect. Almost the same problem. Will revert emit_x86.bas and let IR handle it.

'' immediate and offset? it's invalid for CMP so use a temp reg
if( (svreg->typ = IR_VREGTYPE_IMM) and (dvreg->typ = IR_VREGTYPE_OFS) ) then

dim reg as integer, isfree as integer, rname as string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inner rname is shadowing the outer rname here, might be better to split into an extra function


if( expr andalso astIsDEREF( expr ) ) then
if( expr->l andalso astIsVAR( expr->l ) ) then
if( expr->l->sym andalso symbIsRef( expr->l->sym ) ) then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be helpful to also check symbIsVar, since the symbIsRef flag can apply to other symbol types too, i.e. procedures for "return byref", and looking at astNewVAR() it refers to the procedure symbol in case of function pointers.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added symbIsVar check. Thanks. I think for the correct sym.

@@ -1,4 +1,4 @@
' TEST_MODE : COMPILE_ONLY_FAIL
' TEST_MODE : COMPILE_ONLY_OK
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can probably remove this now, since the scenario is better covered by the new unit test

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@jayrm jayrm merged commit 248da04 into freebasic:master Jun 22, 2018
@jayrm jayrm deleted the byref-init-byref branch June 22, 2018 01:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants