Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

[[ Bug 20931 ]] Bridge values in LCB assign-array and assign-list ops#6310

Merged
livecodepanos merged 7 commits into
livecode:develop-9.0from
runrevmark:bugfix-20931
Jun 6, 2018
Merged

[[ Bug 20931 ]] Bridge values in LCB assign-array and assign-list ops#6310
livecodepanos merged 7 commits into
livecode:develop-9.0from
runrevmark:bugfix-20931

Conversation

@runrevmark

Copy link
Copy Markdown
Contributor

This patch fixes a bug where the behavior of code built using the
[ ... ] and { ... } syntax in LCB is different from that when using
explicit code.

A new method 'Bridge' has been added to the VM's execute context.
This method performs a 'convert to optional any' on the input value
resulting in bridgeable foreign values being imported, and all other
values being retained.

This method is now called on the input values in the assign-list
and assign-array opcodes meaning that foreign values being built
into lists will bridge.

Additionally, an extra compiler check has been added to variadic
arguments (i.e. arguments to the variadic portion of a C variadic
handler). This check restricts such arguments to being variable
identifiers where the variable has an explicit type declaration.
This is necessary to ensure that code explicitly states the type
which is being passed in variadic positions as there is no other
means for the compiler or the VM to know what the type should be.

This patch fixes a bug where the behavior of code built using the
[ ... ] and { ... } syntax in LCB is different from that when using
explicit code.

A new method 'Bridge' has been added to the VM's execute context.
This method performs a 'convert to optional any' on the input value
resulting in bridgeable foreign values being imported, and all other
values being retained.

This method is now called on the input values in the assign-list
and assign-array opcodes meaning that foreign values being built
into lists will bridge.

Additionally, an extra compiler check has been added to variadic
arguments (i.e. arguments to the variadic portion of a C variadic
handler). This check restricts such arguments to being variable
identifiers where the variable has an explicit type declaration.
This is necessary to ensure that code explicitly states the type
which is being passed in variadic positions as there is no other
means for the compiler or the VM to know what the type should be.
@peter-b

peter-b commented Feb 1, 2018

Copy link
Copy Markdown
Contributor

One possible concern (that I'm sure you've considered) is that this change may make it harder to manage collections of foreign values without paying the cost of bridging.

@runrevmark

Copy link
Copy Markdown
Contributor Author

@peter-b : Hehe - indeed! The idea here is that the VM has three kinds of slot - temporary which hold values as they are, typed which convert a value on assignment and untyped which bridge but do not convert. As lcb doesn't yet have typed lists, we take the element of type of lists as they are now as 'untyped'. In the future lists of foreign values will be managed by being able to specify list of . I.e. Foreign values only stay foreign if bring places in temporary or types slots.

@livecodeali

Copy link
Copy Markdown
Member

All apparently explicitly typed params to variadic functions now seem to be failing, eg:

      variable tInt as SInt16
      variable tLong as SInt32
      variable tLongLong as SInt64
      variable tFloat as CFloat
      variable tDouble as CDouble
      put 1000 into tInt
      put 1000000000 into tLong
      put tLong * 1000000 into tLongLong
      put 3.5 into tFloat
      put 7.5 into tDouble
      sprintf(tOutputBuffer, "%d %ld %lld %.1f %.1lf", tInt, tLong, tLongLong, tFloat, tDouble)
  • all of these are causing this kind of error
lcb/vm/foreign-invoke.lcb:48:56: error: Variadic arguments must be an explicitly-typed variable
       sprintf(tOutputBuffer, "%d %ld %lld %.1f %.1lf", tInt, tLong, tLongLong, tFloat, tDouble)

@livecodeali livecodeali modified the milestones: 9.0.0-rc-1, 9.0.1-rc-1 Mar 19, 2018
@livecodeali livecodeali changed the base branch from develop to develop-9.0 March 19, 2018 10:38
Comment thread tests/lcb/vm/assign-ops.lcb Outdated
put false into tVar

variable tValue as Pointer
put MCProperListFetchElementAtIndex([tVar], 1) into tValue

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The index to MCProperListFetchElementAtIndex should be 0 no?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes! Thanks, fixed.

@livecodeian

Copy link
Copy Markdown
Contributor

@livecode-vulcan review ok 615a87b

@livecode-vulcan

Copy link
Copy Markdown
Contributor

💙 review by @livecodeian ok 615a87b

livecode-vulcan added a commit that referenced this pull request Jun 6, 2018
[[ Bug 20931 ]] Bridge values in LCB assign-array and assign-list ops

This patch fixes a bug where the behavior of code built using the
[ ... ] and { ... } syntax in LCB is different from that when using
explicit code.

A new method 'Bridge' has been added to the VM's execute context.
This method performs a 'convert to optional any' on the input value
resulting in bridgeable foreign values being imported, and all other
values being retained.

This method is now called on the input values in the assign-list
and assign-array opcodes meaning that foreign values being built
into lists will bridge.

Additionally, an extra compiler check has been added to variadic
arguments (i.e. arguments to the variadic portion of a C variadic
handler). This check restricts such arguments to being variable
identifiers where the variable has an explicit type declaration.
This is necessary to ensure that code explicitly states the type
which is being passed in variadic positions as there is no other
means for the compiler or the VM to know what the type should be.
@livecode-vulcan

Copy link
Copy Markdown
Contributor

😎 test success 615a87b

  • try-community-armv6-android-api8: success
  • try-community-armv6-android-api9: success
  • try-community-js-emscripten-sdk1.35: success
  • try-community-universal-ios-iphoneos11.4: success
  • try-community-universal-ios-iphonesimulator11.4: success
  • try-community-universal-mac-macosx10.6: success
  • try-community-universal-mac-macosx10.9: success
  • try-community-x86-linux-debian7: success
  • try-community-x86-linux-debian8: success
  • try-community-x86_64-linux-debian7: success
  • try-community-x86_64-linux-debian8: success
  • try-community-x86-win32: success
  • try-community-x86_64-win32: success

@livecodepanos livecodepanos merged commit 07474c7 into livecode:develop-9.0 Jun 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants