Add control.panic and control.assert

This commit is contained in:
Michal Moskal 2016-04-11 19:44:49 -07:00
parent 3119bcc625
commit abc9e90cb9

View File

@ -18,4 +18,25 @@ namespace control {
export function eventValue(id: EventBusValue) : number {
return id;
}
/**
* Display specified error code and stop the program.
*/
//% shim=pxrt::panic
export function panic(code:number)
{
}
/**
* If the condition is false, display msg on serial console, and panic with code 098.
*/
export function assert(condition:boolean, msg?: string)
{
if (!condition) {
console.log("ASSERTION FAILED")
if (msg != null)
console.log(msg)
panic(98)
}
}
}