Fixed size integers

58 views
Skip to first unread message

Ravi Teja Gudapati

unread,
Jun 22, 2016, 11:09:39 AM6/22/16
to Dartino Discuss
This is an issue with Dart even on command line  and browser applications. Embedded systems is full of byte and bit fiddling. How is this taken care of? Do we get primitive fixed size integers and arrays of them?

Thanks

Warren Strange

unread,
Jun 22, 2016, 12:01:27 PM6/22/16
to Dartino Discuss

I don't know about Dartino specifically, but Dart has a typed_data package that can be used to perform byte manipulation.

Søren Gjesse

unread,
Jun 23, 2016, 4:26:49 AM6/23/16
to Warren Strange, Dartino Discuss
Ravi,

In Dartino we have several options to work with byte and bit fiddling.

1. Direct access to memory through dartino:ffi's ForeignMemory interface

The dartino:ffi library expose direct access to memory through the ForeignMemory interface. ForeignMemory can be constructed from a pointer value (e.g. for manipulating peripherals) or by allocating on the C-heap. ForeignMemory provides access to bytes, 16-bit, 32-bit and 64-bit values through methods getInt8, setInt8, getUint8, setUint8, getInt16, etc. Unfortunately the documentation we currently generate does not include the builtin libraries, but the code with the interfaces can be found here.

You can take a look at the STM32 GPIO configuration code which this interface to configure STM32 GIPO.

2. The dart:typed_data library is supported

As Warren mentioned dart:typed_data provide a general Dart API for working with byte buffers. On Dartino all typed_data objects are backed by memory allocated on the C heap and not in the Dartino heap. That way typed_data objects can be used transparently with ffi

3. Having infinite precision integers is an option in Dartino

Dartino does support infinite precision integers as specified in the Dart language specification. However there is an option to turn that off. Currently through the .dartino-settings file, where adding "dartino.enable-bigint": "false"
to the "constants" map will do that.

When infinite precision integers are turned off Dartino support 64-bit signed integers. That means that handling 32-bit signed and unsigned integers is well supported.

Adding specific sized integer types (e.g. int32) to Dart at the language level has been discussed, but there is no final decision at the moment.

The Dartino support for infinite precision integers is provided through Dart code, and if support is turned on this Dart code will be part of the compiled code. This is quite substantial, and makes the image bigger (byte codes for the this are about 15kb), so maybe we should change the default to have infinite precision integers turned off. The current semantics for overflow is to throw an exception when infinite precision integers are turned off.

Regards,
Søren

---
Søren Gjesse
Software Engineer, Google Denmark
CVR nr. 28 86 69 84


--
You received this message because you are subscribed to the Google Groups "Dartino Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dartino-discu...@googlegroups.com.
To post to this group, send email to dartino...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dartino-discuss/7c21dfe5-cff3-4833-93eb-717be58de186%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages