Easy Compilation From TouchDevelop To ARM Cortex-M0 Using C++11 - Jonathan Protzenko - CppCon 2015
Easy Compilation From TouchDevelop To ARM Cortex-M0 Using C++11 - Jonathan Protzenko - CppCon 2015
J. Protzenko
Some background (1)
• The goal: introduce the CS curriculum using a fun & simple device
• Support from Computer At School (CAS) association
• Goal: engage teachers, parents, kids
C++
Compiler
mbed C++ SDK
2
ARM 2 User accepts download
of ARM binary
mbed compile service
ARM binary
Azure
TouchDevelop-the-language
void main() {
micro_bit::scrollString(
touch_develop::mk_string(
"I ♥ CppCon"), 150);
}
void main() {
Collection<Number> coll;
coll = create::collection_of<Number>();
collection::add(coll, 2015);
}
namespace user_types {
struct list_;
typedef ManagedType<list_> list;
// …
// every other type definition in the current program
}
namespace user_types {
struct list_ {
Number data;
user_types::list next;
};
}
Number length(user_types::list l) {
if (list::is_invalid(l)){
return 0;
} else {
return number::plus(
1,
length((l.get() != NULL ? l->next : (uBit.panic(…), l->next))));
}
}
Implement
closure-
Better use conversion?
C++11! Oh noes!
Ref<Number> y;
y = create::ref_of<Number>();
ref::_set(y, 0);
auto _body_0_ = [=] () -> void {
micro_bit::scrollNumber(ref::_get(y), 150);
};
auto _body_0 =
new std::function<void ()>(_body_0_);
micro_bit::onButtonPressed(
MICROBIT_ID_BUTTON_B, _body_0);
ref::_set(y, 1);
• The “ARMCC” killer. (GCC it is, now – just 300k wasted SRAM.)
Thanks!
9/21/2015 J. Protzenko: Compiling TouchDevelop to C++11 / CppCon’15 20