AssemblyScript language preview
1. Inline add
@inline decorator and i32 params
horizon-dark
@inline
export function add(a: i32, b: i32): i32 {
return a + b;
} atom-one-dark
@inline
export function add(a: i32, b: i32): i32 {
return a + b;
} github-dark
@inline
export function add(a: i32, b: i32): i32 {
return a + b;
} dracula
@inline
export function add(a: i32, b: i32): i32 {
return a + b;
} nord
@inline
export function add(a: i32, b: i32): i32 {
return a + b;
} github
@inline
export function add(a: i32, b: i32): i32 {
return a + b;
} 2. changetype load
usize pointers with unchecked load
horizon-dark
export function loadX(ptr: usize): i32 {
return changetype<i32>(unchecked(load<i32>(ptr)));
} atom-one-dark
export function loadX(ptr: usize): i32 {
return changetype<i32>(unchecked(load<i32>(ptr)));
} github-dark
export function loadX(ptr: usize): i32 {
return changetype<i32>(unchecked(load<i32>(ptr)));
} dracula
export function loadX(ptr: usize): i32 {
return changetype<i32>(unchecked(load<i32>(ptr)));
} nord
export function loadX(ptr: usize): i32 {
return changetype<i32>(unchecked(load<i32>(ptr)));
} github
export function loadX(ptr: usize): i32 {
return changetype<i32>(unchecked(load<i32>(ptr)));
} 3. Memory grow
comments and memory.size / memory.grow
horizon-dark
// bump the heap
export function grow(): i32 {
const pages = memory.size();
return memory.grow(1);
} atom-one-dark
// bump the heap
export function grow(): i32 {
const pages = memory.size();
return memory.grow(1);
} github-dark
// bump the heap
export function grow(): i32 {
const pages = memory.size();
return memory.grow(1);
} dracula
// bump the heap
export function grow(): i32 {
const pages = memory.size();
return memory.grow(1);
} nord
// bump the heap
export function grow(): i32 {
const pages = memory.size();
return memory.grow(1);
} github
// bump the heap
export function grow(): i32 {
const pages = memory.size();
return memory.grow(1);
}