How to use copyBuffer method in wpt

Best JavaScript code snippet using wpt

assembler.js

Source:assembler.js Github

copy

Full Screen

...224 let immediate2;225 let keywordImmediates;226 switch (opText) {227 case "unreachable":228 this._output.copyBuffer([ OP_UNREACHABLE ]);229 break;230 case "nop":231 this._output.copyBuffer([ OP_NOP ]);232 break;233 case "block":234 this._output.copyBuffer([ OP_BLOCK ]);235 immediate1 = lineReader.readBlockType();236 this._output.copyBuffer([ immediate1 ]);237 break;238 case "loop":239 this._output.copyBuffer([ OP_LOOP ]);240 immediate1 = lineReader.readBlockType();241 this._output.copyBuffer([ immediate1 ]);242 break;243 case "if":244 this._output.copyBuffer([ OP_IF ]);245 immediate1 = lineReader.readBlockType();246 this._output.copyBuffer([ immediate1 ]);247 break;248 case "else":249 this._output.copyBuffer([ OP_ELSE ]);250 break;251 case "end":252 this._output.copyBuffer([ OP_END ]);253 break;254 case "br":255 this._output.copyBuffer([ OP_BR ]);256 immediate1 = lineReader.readInteger();257 this._output.copyBuffer(VarUint32ToArray(immediate1));258 break;259 case "br_if":260 this._output.copyBuffer([ OP_BR_IF ]);261 immediate1 = lineReader.readInteger();262 this._output.copyBuffer(VarUint32ToArray(immediate1));263 break;264 case "br_table":265 this._output.copyBuffer([ OP_BR_TABLE ]);266 let targetCount = lineReader.readInteger();267 this._output.copyBuffer(VarUint32ToArray(targetCount));268 for (let i = 0; i < targetCount; i++) {269 let tableEntry = lineReader.readInteger();270 this._output.copyBuffer(VarUint32ToArray(tableEntry));271 }272 let defaultTarget = lineReader.readInteger();273 this._output.copyBuffer(VarUint32ToArray(defaultTarget));274 break;275 case "return":276 this._output.copyBuffer([ OP_RETURN ]);277 break;278 case "call":279 this._output.copyBuffer([ OP_CALL ]);280 immediate1 = lineReader.readCallTarget();281 this._output.copyBuffer(VarUint32ToArray(immediate1));282 break;283 case "call_indirect":284 this._output.copyBuffer([ OP_CALL_INDIRECT ]);285 immediate1 = lineReader.readInteger();286 immediate2 = lineReader.readUint8();287 this._output.copyBuffer(VarUint32ToArray(immediate1));288 this._output.copyBuffer([ immediate2 ]);289 break;290 case "drop":291 this._output.copyBuffer([ OP_DROP ]);292 break;293 case "select":294 this._output.copyBuffer([ OP_SELECT ]);295 break;296 case "get_local":297 this._output.copyBuffer([ OP_GET_LOCAL ]);298 immediate1 = lineReader.readInteger();299 this._output.copyBuffer(VarUint32ToArray(immediate1));300 break;301 case "set_local":302 this._output.copyBuffer([ OP_SET_LOCAL ]);303 immediate1 = lineReader.readInteger();304 this._output.copyBuffer(VarUint32ToArray(immediate1));305 break;306 case "tee_local":307 this._output.copyBuffer([ OP_TEE_LOCAL ]);308 immediate1 = lineReader.readInteger();309 this._output.copyBuffer(VarUint32ToArray(immediate1));310 break;311 case "get_global":312 this._output.copyBuffer([ OP_GET_GLOBAL ]);313 immediate1 = lineReader.readInteger();314 this._output.copyBuffer(VarUint32ToArray(immediate1));315 break;316 case "set_global":317 this._output.copyBuffer([ OP_SET_GLOBAL ]);318 immediate1 = lineReader.readInteger();319 this._output.copyBuffer(VarUint32ToArray(immediate1));320 break;321 case "i32.load":322 this._output.copyBuffer([ OP_I32_LOAD ]);323 keywordImmediates = lineReader.readKeywords(["align", "offset"]);324 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[0]));325 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[1]));326 break;327 case "i64.load":328 this._output.copyBuffer([ OP_I64_LOAD ]);329 keywordImmediates = lineReader.readKeywords(["align", "offset"]);330 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[0]));331 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[1]));332 break;333 case "f32.load":334 this._output.copyBuffer([ OP_F32_LOAD ]);335 keywordImmediates = lineReader.readKeywords(["align", "offset"]);336 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[0]));337 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[1]));338 break;339 case "f64.load":340 this._output.copyBuffer([ OP_F64_LOAD ]);341 keywordImmediates = lineReader.readKeywords(["align", "offset"]);342 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[0]));343 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[1]));344 break;345 case "i32.load8_s":346 this._output.copyBuffer([ OP_I32_LOAD8_S ]);347 keywordImmediates = lineReader.readKeywords(["align", "offset"]);348 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[0]));349 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[1]));350 break;351 case "i32.load8_u":352 this._output.copyBuffer([ OP_I32_LOAD8_U ]);353 keywordImmediates = lineReader.readKeywords(["align", "offset"]);354 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[0]));355 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[1]));356 break;357 case "i32.load16_s":358 this._output.copyBuffer([ OP_I32_LOAD16_S ]);359 keywordImmediates = lineReader.readKeywords(["align", "offset"]);360 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[0]));361 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[1]));362 break;363 case "i32.load16_u":364 this._output.copyBuffer([ OP_I32_LOAD16_U ]);365 keywordImmediates = lineReader.readKeywords(["align", "offset"]);366 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[0]));367 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[1]));368 break;369 case "i64.load8_s":370 this._output.copyBuffer([ OP_I64_LOAD8_S ]);371 keywordImmediates = lineReader.readKeywords(["align", "offset"]);372 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[0]));373 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[1]));374 break;375 case "i64.load8_u":376 this._output.copyBuffer([ OP_I64_LOAD8_U ]);377 keywordImmediates = lineReader.readKeywords(["align", "offset"]);378 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[0]));379 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[1]));380 break;381 case "i64.load16_s":382 this._output.copyBuffer([ OP_I64_LOAD16_S ]);383 keywordImmediates = lineReader.readKeywords(["align", "offset"]);384 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[0]));385 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[1]));386 break;387 case "i64.load16_u":388 this._output.copyBuffer([ OP_I64_LOAD16_U ]);389 keywordImmediates = lineReader.readKeywords(["align", "offset"]);390 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[0]));391 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[1]));392 break;393 case "i64.load32_s":394 this._output.copyBuffer([ OP_I64_LOAD32_S ]);395 keywordImmediates = lineReader.readKeywords(["align", "offset"]);396 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[0]));397 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[1]));398 break;399 case "i64.load32_u":400 this._output.copyBuffer([ OP_I64_LOAD32_U ]);401 keywordImmediates = lineReader.readKeywords(["align", "offset"]);402 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[0]));403 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[1]));404 break;405 case "i32.store":406 this._output.copyBuffer([ OP_I32_STORE ]);407 keywordImmediates = lineReader.readKeywords(["align", "offset"]);408 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[0]));409 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[1]));410 break;411 case "i64.store":412 this._output.copyBuffer([ OP_I64_STORE ]);413 keywordImmediates = lineReader.readKeywords(["align", "offset"]);414 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[0]));415 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[1]));416 break;417 case "f32.store":418 this._output.copyBuffer([ OP_F32_STORE ]);419 keywordImmediates = lineReader.readKeywords(["align", "offset"]);420 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[0]));421 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[1]));422 break;423 case "f64.store":424 this._output.copyBuffer([ OP_F64_STORE ]);425 keywordImmediates = lineReader.readKeywords(["align", "offset"]);426 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[0]));427 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[1]));428 break;429 case "i32.store8":430 this._output.copyBuffer([ OP_I32_STORE8 ]);431 keywordImmediates = lineReader.readKeywords(["align", "offset"]);432 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[0]));433 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[1]));434 break;435 case "i32.store16":436 this._output.copyBuffer([ OP_I32_STORE16 ]);437 keywordImmediates = lineReader.readKeywords(["align", "offset"]);438 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[0]));439 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[1]));440 break;441 case "i64.store8":442 this._output.copyBuffer([ OP_I64_STORE8 ]);443 keywordImmediates = lineReader.readKeywords(["align", "offset"]);444 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[0]));445 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[1]));446 break;447 case "i64.store16":448 this._output.copyBuffer([ OP_I64_STORE16 ]);449 keywordImmediates = lineReader.readKeywords(["align", "offset"]);450 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[0]));451 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[1]));452 break;453 case "i64.store32":454 this._output.copyBuffer([ OP_I64_STORE32 ]);455 keywordImmediates = lineReader.readKeywords(["align", "offset"]);456 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[0]));457 this._output.copyBuffer(VarUint32ToArray(keywordImmediates[1]));458 break;459 case "memory_size":460 case "current_memory":461 this._output.copyBuffer([ OP_MEMORY_SIZE ]);462 immediate1 = lineReader.readUint1();463 this._output.copyBuffer([ immediate1 ]);464 break;465 case "memory_grow":466 case "grow_memory":467 this._output.copyBuffer([ OP_MEMORY_GROW ]);468 immediate1 = lineReader.readUint1();469 this._output.copyBuffer([ immediate1 ]);470 break;471 case "i32.const":472 this._output.copyBuffer([ OP_I32_CONST ]);473 immediate1 = lineReader.readInteger();474 this._output.copyBuffer(VarSint32ToArray(immediate1));475 break;476 case "i64.const":477 this._output.copyBuffer([ OP_I64_CONST ]);478 immediate1 = lineReader.readInteger();479 this._output.copyBuffer(VarSint32ToArray(immediate1));480 break;481 case "f32.const":482 this._output.copyBuffer([ OP_F32_CONST ]);483 immediate1 = lineReader.readFloat();484 const f32Array = new Float32Array([immediate1]);485 const f32Bytes = new Uint8Array(f32Array.buffer);486 this._output.copyBuffer(f32Bytes);487 break;488 case "f64.const":489 this._output.copyBuffer([ OP_F64_CONST ]);490 immediate1 = lineReader.readFloat();491 const f64Array = new Float64Array([immediate1]);492 const f64Bytes = new Uint8Array(f64Array.buffer);493 this._output.copyBuffer(f64Bytes);494 break;495 case "i32.eqz":496 this._output.copyBuffer([ OP_I32_EQZ ]);497 break;498 case "i32.eq":499 this._output.copyBuffer([ OP_I32_EQ ]);500 break;501 case "i32.ne":502 this._output.copyBuffer([ OP_I32_NE ]);503 break;504 case "i32.lt_s":505 this._output.copyBuffer([ OP_I32_LT_S ]);506 break;507 case "i32.lt_u":508 this._output.copyBuffer([ OP_I32_LT_U ]);509 break;510 case "i32.gt_s":511 this._output.copyBuffer([ OP_I32_GT_S ]);512 break;513 case "i32.gt_u":514 this._output.copyBuffer([ OP_I32_GT_U ]);515 break;516 case "i32.le_s":517 this._output.copyBuffer([ OP_I32_LE_S ]);518 break;519 case "i32.le_u":520 this._output.copyBuffer([ OP_I32_LE_U ]);521 break;522 case "i32.ge_s":523 this._output.copyBuffer([ OP_I32_GE_S ]);524 break;525 case "i32.ge_u":526 this._output.copyBuffer([ OP_I32_GE_U ]);527 break;528 case "i64.eqz":529 this._output.copyBuffer([ OP_I64_EQZ ]);530 break;531 case "i64.eq":532 this._output.copyBuffer([ OP_I64_EQ ]);533 break;534 case "i64.ne":535 this._output.copyBuffer([ OP_I64_NE ]);536 break;537 case "i64.lt_s":538 this._output.copyBuffer([ OP_I64_LT_S ]);539 break;540 case "i64.lt_u":541 this._output.copyBuffer([ OP_I64_LT_U ]);542 break;543 case "i64.gt_s":544 this._output.copyBuffer([ OP_I64_GT_S ]);545 break;546 case "i64.gt_u":547 this._output.copyBuffer([ OP_I64_GT_U ]);548 break;549 case "i64.le_s":550 this._output.copyBuffer([ OP_I64_LE_S ]);551 break;552 case "i64.le_u":553 this._output.copyBuffer([ OP_I64_LE_U ]);554 break;555 case "i64.ge_s":556 this._output.copyBuffer([ OP_I64_GE_S ]);557 break;558 case "i64.ge_u":559 this._output.copyBuffer([ OP_I64_GE_U ]);560 break;561 case "f32.eq":562 this._output.copyBuffer([ OP_F32_EQ ]);563 break;564 case "f32.ne":565 this._output.copyBuffer([ OP_F32_NE ]);566 break;567 case "f32.lt":568 this._output.copyBuffer([ OP_F32_LT ]);569 break;570 case "f32.gt":571 this._output.copyBuffer([ OP_F32_GT ]);572 break;573 case "f32.le":574 this._output.copyBuffer([ OP_F32_LE ]);575 break;576 case "f32.ge":577 this._output.copyBuffer([ OP_F32_GE ]);578 break;579 case "f64.eq":580 this._output.copyBuffer([ OP_F64_EQ ]);581 break;582 case "f64.ne":583 this._output.copyBuffer([ OP_F64_NE ]);584 break;585 case "f64.lt":586 this._output.copyBuffer([ OP_F64_LT ]);587 break;588 case "f64.gt":589 this._output.copyBuffer([ OP_F64_GT ]);590 break;591 case "f64.le":592 this._output.copyBuffer([ OP_F64_LE ]);593 break;594 case "f64.ge":595 this._output.copyBuffer([ OP_F64_GE ]);596 break;597 case "i32.clz":598 this._output.copyBuffer([ OP_I32_CLZ ]);599 break;600 case "i32.ctz":601 this._output.copyBuffer([ OP_I32_CTZ ]);602 break;603 case "i32.popcnt":604 this._output.copyBuffer([ OP_I32_POPCNT ]);605 break;606 case "i32.add":607 this._output.copyBuffer([ OP_I32_ADD ]);608 break;609 case "i32.sub":610 this._output.copyBuffer([ OP_I32_SUB ]);611 break;612 case "i32.mul":613 this._output.copyBuffer([ OP_I32_MUL ]);614 break;615 case "i32.div_s":616 this._output.copyBuffer([ OP_I32_DIV_S ]);617 break;618 case "i32.div_u":619 this._output.copyBuffer([ OP_I32_DIV_U ]);620 break;621 case "i32.rem_s":622 this._output.copyBuffer([ OP_I32_REM_S ]);623 break;624 case "i32.rem_u":625 this._output.copyBuffer([ OP_I32_REM_U ]);626 break;627 case "i32.and":628 this._output.copyBuffer([ OP_I32_AND ]);629 break;630 case "i32.or":631 this._output.copyBuffer([ OP_I32_OR ]);632 break;633 case "i32.xor":634 this._output.copyBuffer([ OP_I32_XOR ]);635 break;636 case "i32.shl":637 this._output.copyBuffer([ OP_I32_SHL ]);638 break;639 case "i32.shr_s":640 this._output.copyBuffer([ OP_I32_SHR_S ]);641 break;642 case "i32.shr_u":643 this._output.copyBuffer([ OP_I32_SHR_U ]);644 break;645 case "i32.rotl":646 this._output.copyBuffer([ OP_I32_ROTL ]);647 break;648 case "i32.rotr":649 this._output.copyBuffer([ OP_I32_ROTR ]);650 break;651 case "i64.clz":652 this._output.copyBuffer([ OP_I64_CLZ ]);653 break;654 case "i64.ctz":655 this._output.copyBuffer([ OP_I64_CTZ ]);656 break;657 case "i64.popcnt":658 this._output.copyBuffer([ OP_I64_POPCNT ]);659 break;660 case "i64.add":661 this._output.copyBuffer([ OP_I64_ADD ]);662 break;663 case "i64.sub":664 this._output.copyBuffer([ OP_I64_SUB ]);665 break;666 case "i64.mul":667 this._output.copyBuffer([ OP_I64_MUL ]);668 break;669 case "i64.div_s":670 this._output.copyBuffer([ OP_I64_DIV_S ]);671 break;672 case "i64.div_u":673 this._output.copyBuffer([ OP_I64_DIV_U ]);674 break;675 case "i64.rem_s":676 this._output.copyBuffer([ OP_I64_REM_S ]);677 break;678 case "i64.rem_u":679 this._output.copyBuffer([ OP_I64_REM_U ]);680 break;681 case "i64.and":682 this._output.copyBuffer([ OP_I64_AND ]);683 break;684 case "i64.or":685 this._output.copyBuffer([ OP_I64_OR ]);686 break;687 case "i64.xor":688 this._output.copyBuffer([ OP_I64_XOR ]);689 break;690 case "i64.shl":691 this._output.copyBuffer([ OP_I64_SHL ]);692 break;693 case "i64.shr_s":694 this._output.copyBuffer([ OP_I64_SHR_S ]);695 break;696 case "i64.shr_u":697 this._output.copyBuffer([ OP_I64_SHR_U ]);698 break;699 case "i64.rotl":700 this._output.copyBuffer([ OP_I64_ROTL ]);701 break;702 case "i64.rotr":703 this._output.copyBuffer([ OP_I64_ROTR ]);704 break;705 case "f32.abs":706 this._output.copyBuffer([ OP_F32_ABS ]);707 break;708 case "f32.neg":709 this._output.copyBuffer([ OP_F32_NEG ]);710 break;711 case "f32.ceil":712 this._output.copyBuffer([ OP_F32_CEIL ]);713 break;714 case "f32.floor":715 this._output.copyBuffer([ OP_F32_FLOOR ]);716 break;717 case "f32.trunc":718 this._output.copyBuffer([ OP_F32_TRUNC ]);719 break;720 case "f32.nearest":721 this._output.copyBuffer([ OP_F32_NEAREST ]);722 break;723 case "f32.sqrt":724 this._output.copyBuffer([ OP_F32_SQRT ]);725 break;726 case "f32.add":727 this._output.copyBuffer([ OP_F32_ADD ]);728 break;729 case "f32.sub":730 this._output.copyBuffer([ OP_F32_SUB ]);731 break;732 case "f32.mul":733 this._output.copyBuffer([ OP_F32_MUL ]);734 break;735 case "f32.div":736 this._output.copyBuffer([ OP_F32_DIV ]);737 break;738 case "f32.min":739 this._output.copyBuffer([ OP_F32_MIN ]);740 break;741 case "f32.max":742 this._output.copyBuffer([ OP_F32_MAX ]);743 break;744 case "f32.copysign":745 this._output.copyBuffer([ OP_F32_COPYSIGN ]);746 break;747 case "f64.abs":748 this._output.copyBuffer([ OP_F64_ABS ]);749 break;750 case "f64.neg":751 this._output.copyBuffer([ OP_F64_NEG ]);752 break;753 case "f64.ceil":754 this._output.copyBuffer([ OP_F64_CEIL ]);755 break;756 case "f64.floor":757 this._output.copyBuffer([ OP_F64_FLOOR ]);758 break;759 case "f64.trunc":760 this._output.copyBuffer([ OP_F64_TRUNC ]);761 break;762 case "f64.nearest":763 this._output.copyBuffer([ OP_F64_NEAREST ]);764 break;765 case "f64.sqrt":766 this._output.copyBuffer([ OP_F64_SQRT ]);767 break;768 case "f64.add":769 this._output.copyBuffer([ OP_F64_ADD ]);770 break;771 case "f64.sub":772 this._output.copyBuffer([ OP_F64_SUB ]);773 break;774 case "f64.mul":775 this._output.copyBuffer([ OP_F64_MUL ]);776 break;777 case "f64.div":778 this._output.copyBuffer([ OP_F64_DIV ]);779 break;780 case "f64.min":781 this._output.copyBuffer([ OP_F64_MIN ]);782 break;783 case "f64.max":784 this._output.copyBuffer([ OP_F64_MAX ]);785 break;786 case "f64.copysign":787 this._output.copyBuffer([ OP_F64_COPYSIGN ]);788 break;789 case "i32.wrap/i64":790 this._output.copyBuffer([ OP_I32_WRAP_I64 ]);791 break;792 case "i32.trunc_s/f32":793 this._output.copyBuffer([ OP_I32_TRUNC_S_F32 ]);794 break;795 case "i32.trunc_u/f32":796 this._output.copyBuffer([ OP_I32_TRUNC_U_F32 ]);797 break;798 case "i32.trunc_s/f64":799 this._output.copyBuffer([ OP_I32_TRUNC_S_F64 ]);800 break;801 case "i32.trunc_u/f64":802 this._output.copyBuffer([ OP_I32_TRUNC_U_F64 ]);803 break;804 case "i64.extend_s/i32":805 this._output.copyBuffer([ OP_I64_EXTEND_S_I32 ]);806 break;807 case "i64.extend_u/i32":808 this._output.copyBuffer([ OP_I64_EXTEND_U_I32 ]);809 break;810 case "i64.trunc_s/f32":811 this._output.copyBuffer([ OP_I64_TRUNC_S_F32 ]);812 break;813 case "i64.trunc_u/f32":814 this._output.copyBuffer([ OP_I64_TRUNC_U_F32 ]);815 break;816 case "i64.trunc_s/f64":817 this._output.copyBuffer([ OP_I64_TRUNC_S_F64 ]);818 break;819 case "i64.trunc_u/f64":820 this._output.copyBuffer([ OP_I64_TRUNC_U_F64 ]);821 break;822 case "f32.convert_s/i32":823 this._output.copyBuffer([ OP_F32_CONVERT_S_I32 ]);824 break;825 case "f32.convert_u/i32":826 this._output.copyBuffer([ OP_F32_CONVERT_U_I32 ]);827 break;828 case "f32.convert_s/i64":829 this._output.copyBuffer([ OP_F32_CONVERT_S_I64 ]);830 break;831 case "f32.convert_u/i64":832 this._output.copyBuffer([ OP_F32_CONVERT_U_I64 ]);833 break;834 case "f32.demote/f64":835 this._output.copyBuffer([ OP_F32_DEMOTE_F64 ]);836 break;837 case "f64.convert_s/i32":838 this._output.copyBuffer([ OP_F64_CONVERT_S_I32 ]);839 break;840 case "f64.convert_u/i32":841 this._output.copyBuffer([ OP_F64_CONVERT_U_I32 ]);842 break;843 case "f64.convert_s/i64":844 this._output.copyBuffer([ OP_F64_CONVERT_S_I64 ]);845 break;846 case "f64.convert_u/i64":847 this._output.copyBuffer([ OP_F64_CONVERT_U_I64 ]);848 break;849 case "f64.promote/f32":850 this._output.copyBuffer([ OP_F64_PROMOTE_F32 ]);851 break;852 case "i32.reinterpret/f32":853 this._output.copyBuffer([ OP_I32_REINTERPRET_F32 ]);854 break;855 case "i64.reinterpret/f64":856 this._output.copyBuffer([ OP_I64_REINTERPRET_F64 ]);857 break;858 case "f32.reinterpret/i32":859 this._output.copyBuffer([ OP_F32_REINTERPRET_I32 ]);860 break;861 case "f64.reinterpret/i64":862 this._output.copyBuffer([ OP_F64_REINTERPRET_I64 ]);863 break;864 default:865 throw new Error(`Bad instruction "${opText}"`);866 }867 return true;868 }...

Full Screen

Full Screen

engine.readTexture.ts

Source:engine.readTexture.ts Github

copy

Full Screen

1import { ThinEngine } from "../../Engines/thinEngine";2import type { InternalTexture } from "../../Materials/Textures/internalTexture";3import type { Nullable } from "../../types";4import { Constants } from "../constants";56declare module "../../Engines/thinEngine" {7 export interface ThinEngine {8 /** @hidden */9 _readTexturePixels(10 texture: InternalTexture,11 width: number,12 height: number,13 faceIndex?: number,14 level?: number,15 buffer?: Nullable<ArrayBufferView>,16 flushRenderer?: boolean,17 noDataConversion?: boolean,18 x?: number,19 y?: number20 ): Promise<ArrayBufferView>;2122 /** @hidden */23 _readTexturePixelsSync(24 texture: InternalTexture,25 width: number,26 height: number,27 faceIndex?: number,28 level?: number,29 buffer?: Nullable<ArrayBufferView>,30 flushRenderer?: boolean,31 noDataConversion?: boolean,32 x?: number,33 y?: number34 ): ArrayBufferView;35 }36}3738/**39 * Allocate a typed array depending on a texture type. Optionally can copy existing data in the buffer.40 * @param type type of the texture41 * @param sizeOrDstBuffer size of the array OR an existing buffer that will be used as the destination of the copy (if copyBuffer is provided)42 * @param sizeInBytes true if the size of the array is given in bytes, false if it is the number of elements of the array43 * @param copyBuffer if provided, buffer to copy into the destination buffer (either a newly allocated buffer if sizeOrDstBuffer is a number or use sizeOrDstBuffer as the destination buffer otherwise)44 * @returns the allocated buffer or sizeOrDstBuffer if the latter is an ArrayBuffer45 */46export function allocateAndCopyTypedBuffer(type: number, sizeOrDstBuffer: number | ArrayBuffer, sizeInBytes = false, copyBuffer?: ArrayBuffer): ArrayBufferView {47 switch (type) {48 case Constants.TEXTURETYPE_BYTE: {49 const buffer = sizeOrDstBuffer instanceof ArrayBuffer ? new Int8Array(sizeOrDstBuffer) : new Int8Array(sizeOrDstBuffer);50 if (copyBuffer) {51 buffer.set(new Int8Array(copyBuffer));52 }53 return buffer;54 }55 case Constants.TEXTURETYPE_UNSIGNED_BYTE: {56 const buffer = sizeOrDstBuffer instanceof ArrayBuffer ? new Uint8Array(sizeOrDstBuffer) : new Uint8Array(sizeOrDstBuffer);57 if (copyBuffer) {58 buffer.set(new Uint8Array(copyBuffer));59 }60 return buffer;61 }62 case Constants.TEXTURETYPE_SHORT: {63 const buffer = sizeOrDstBuffer instanceof ArrayBuffer ? new Int16Array(sizeOrDstBuffer) : new Int16Array(sizeInBytes ? sizeOrDstBuffer / 2 : sizeOrDstBuffer);64 if (copyBuffer) {65 buffer.set(new Int16Array(copyBuffer));66 }67 return buffer;68 }69 case Constants.TEXTURETYPE_UNSIGNED_SHORT:70 case Constants.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:71 case Constants.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:72 case Constants.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:73 case Constants.TEXTURETYPE_HALF_FLOAT: {74 const buffer = sizeOrDstBuffer instanceof ArrayBuffer ? new Uint16Array(sizeOrDstBuffer) : new Uint16Array(sizeInBytes ? sizeOrDstBuffer / 2 : sizeOrDstBuffer);75 if (copyBuffer) {76 buffer.set(new Uint16Array(copyBuffer));77 }78 return buffer;79 }80 case Constants.TEXTURETYPE_INT: {81 const buffer = sizeOrDstBuffer instanceof ArrayBuffer ? new Int32Array(sizeOrDstBuffer) : new Int32Array(sizeInBytes ? sizeOrDstBuffer / 4 : sizeOrDstBuffer);82 if (copyBuffer) {83 buffer.set(new Int32Array(copyBuffer));84 }85 return buffer;86 }87 case Constants.TEXTURETYPE_UNSIGNED_INTEGER:88 case Constants.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:89 case Constants.TEXTURETYPE_UNSIGNED_INT_24_8:90 case Constants.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:91 case Constants.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:92 case Constants.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: {93 const buffer = sizeOrDstBuffer instanceof ArrayBuffer ? new Uint32Array(sizeOrDstBuffer) : new Uint32Array(sizeInBytes ? sizeOrDstBuffer / 4 : sizeOrDstBuffer);94 if (copyBuffer) {95 buffer.set(new Uint32Array(copyBuffer));96 }97 return buffer;98 }99 case Constants.TEXTURETYPE_FLOAT: {100 const buffer = sizeOrDstBuffer instanceof ArrayBuffer ? new Float32Array(sizeOrDstBuffer) : new Float32Array(sizeInBytes ? sizeOrDstBuffer / 4 : sizeOrDstBuffer);101 if (copyBuffer) {102 buffer.set(new Float32Array(copyBuffer));103 }104 return buffer;105 }106 }107108 const buffer = sizeOrDstBuffer instanceof ArrayBuffer ? new Uint8Array(sizeOrDstBuffer) : new Uint8Array(sizeOrDstBuffer);109 if (copyBuffer) {110 buffer.set(new Uint8Array(copyBuffer));111 }112 return buffer;113}114115ThinEngine.prototype._readTexturePixelsSync = function (116 texture: InternalTexture,117 width: number,118 height: number,119 faceIndex = -1,120 level = 0,121 buffer: Nullable<ArrayBufferView> = null,122 flushRenderer = true,123 noDataConversion = false,124 x = 0,125 y = 0126): ArrayBufferView {127 const gl = this._gl;128 if (!gl) {129 throw new Error("Engine does not have gl rendering context.");130 }131 if (!this._dummyFramebuffer) {132 const dummy = gl.createFramebuffer();133134 if (!dummy) {135 throw new Error("Unable to create dummy framebuffer");136 }137138 this._dummyFramebuffer = dummy;139 }140 gl.bindFramebuffer(gl.FRAMEBUFFER, this._dummyFramebuffer);141142 if (faceIndex > -1) {143 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture._hardwareTexture?.underlyingResource, level);144 } else {145 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._hardwareTexture?.underlyingResource, level);146 }147148 let readType = texture.type !== undefined ? this._getWebGLTextureType(texture.type) : gl.UNSIGNED_BYTE;149150 if (!noDataConversion) {151 switch (readType) {152 case gl.UNSIGNED_BYTE:153 if (!buffer) {154 buffer = new Uint8Array(4 * width * height);155 }156 readType = gl.UNSIGNED_BYTE;157 break;158 default:159 if (!buffer) {160 buffer = new Float32Array(4 * width * height);161 }162 readType = gl.FLOAT;163 break;164 }165 } else if (!buffer) {166 buffer = allocateAndCopyTypedBuffer(texture.type, 4 * width * height);167 }168169 if (flushRenderer) {170 this.flushFramebuffer();171 }172173 gl.readPixels(x, y, width, height, gl.RGBA, readType, <DataView>buffer);174 gl.bindFramebuffer(gl.FRAMEBUFFER, this._currentFramebuffer);175176 return buffer;177};178179ThinEngine.prototype._readTexturePixels = function (180 texture: InternalTexture,181 width: number,182 height: number,183 faceIndex = -1,184 level = 0,185 buffer: Nullable<ArrayBufferView> = null,186 flushRenderer = true,187 noDataConversion = false,188 x = 0,189 y = 0190): Promise<ArrayBufferView> {191 return Promise.resolve(this._readTexturePixelsSync(texture, width, height, faceIndex, level, buffer, flushRenderer, noDataConversion, x, y)); ...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const wptools = require('wptools');2const fs = require('fs');3const path = require('path');4const args = process.argv.slice(2);5const filename = args[0];6const directory = args[1];7const filepath = path.join(directory, filename);8const options = {9};10const wiki = wptools(options);11const output = wiki.copyBuffer();12const wptools = require('wptools');13const fs = require('fs');14const path = require('path');15const args = process.argv.slice(2);16const filename = args[0];17const directory = args[1];18const filepath = path.join(directory, filename);19const options = {20};21const wiki = wptools(options);22const output = wiki.copyBuffer();23const wptools = require('wptools');24const fs = require('fs');25const path = require('path');26const args = process.argv.slice(2);27const filename = args[0];28const directory = args[1];29const filepath = path.join(directory, filename);30const options = {31};32const wiki = wptools(options);33const output = wiki.copyBuffer();34const wptools = require('wptools');35const fs = require('fs');36const path = require('path');37const args = process.argv.slice(2);38const filename = args[0];39const directory = args[1];40const filepath = path.join(directory, filename);41const options = {

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var wp = new wptools('Barack Obama');3wp.get(function(err, data) {4 console.log(data);5});6The MIT License (MIT)

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var wpt = new WebPageTest('www.webpagetest.org');3var options = {4 videoParams: {5 }6};7wpt.runTest(options, function(err, data) {8 if (err) {9 console.log(err);10 } else {11 console.log(data);12 }13});14var options = {15 videoParams: {16 }17};18wpt.runTest(options, function(err, data) {19 if (err) {20 console.log(err);21 } else {22 console.log(data);23 wpt.copyBuffer(data.data.jsonUrl, function(err, data) {24 if (err) {25 console.log(err);26 } else {27 console.log(data);28 }29 });30 }31});32### getLocations([callback])33var wpt = require('wpt');34var wpt = new WebPageTest('www.webpagetest.org');35wpt.getLocations(function(err, data) {36 if (err) {37 console.log(err);38 } else {39 console.log(data);40 }41});42### getTesters([callback])43var wpt = require('wpt');44var wpt = new WebPageTest('www.webpagetest.org');45wpt.getTesters(function(err, data) {46 if (err) {47 console.log(err);48 }

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var wiki = wptools('Albert Einstein');3wiki.get(function(err, data){4 if(err) throw err;5 console.log(data);6 wiki.copyBuffer(data, 'Albert Einstein', 'png', function(err, data){7 if(err) throw err;8 console.log(data);9 });10});11{ 12 revisions: [ { contentformat: 'text/x-wiki', contentmodel: 'wikitext', '*' } ],

Full Screen

Using AI Code Generation

copy

Full Screen

1const wptools = require('wptools');2const fs = require('fs');3let wiki = new wptools('Albert Einstein');4wiki.copyBuffer('Albert Einstein', (err, data) => {5 if (err) {6 console.log(err);7 } else {8 fs.writeFile('wiki.txt', data, (err) => {9 if (err) {10 console.log(err);11 } else {12 console.log('File written successfully');13 }14 });15 }16});17Node.js | wptools module - getSummary()18Node.js | wptools module - getCategories()19Node.js | wptools module - getInfobox()20Node.js | wptools module - getImages()21Node.js | wptools module - getReferences()22Node.js | wptools module - getLinks()23Node.js | wptools module - getCoordinates()24Node.js | wptools module - getLanglinks()25Node.js | wptools module - getExtract()26Node.js | wptools module - getRevisions()27Node.js | wptools module - getRedirects()28Node.js | wptools module - getOutlinks()

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful