UNPKG

@awayfl/avm2

Version:

Virtual machine for executing AS3 code

20 lines (19 loc) 554 B
import { release } from '@awayfl/swf-loader'; import { assert } from '@awayjs/graphics'; import { nativeFunctions } from './nativeFunctions'; import { Natives } from './Natives'; /** * Searches for natives using a string path "a.b.c...". */ export function getNative(path) { var chain = path.split('.'); var v = Natives; for (var i = 0, j = chain.length; i < j; i++) { v = v && v[chain[i]]; } if (!v) { v = nativeFunctions[path]; } release || assert(v, 'getNative(' + path + ') not found.'); return v; }