How to use func method in root

Best JavaScript code snippet using root

opcode.js

Source:opcode.js Github

copy

Full Screen

1"use strict";2// Generated by opcode_generator.rb from JavaScriptCore/b3/air/AirOpcode.opcodes -- do not edit!3const Nop = Symbol("Nop");4const Add32 = Symbol("Add32");5const Add8 = Symbol("Add8");6const Add16 = Symbol("Add16");7const Add64 = Symbol("Add64");8const AddDouble = Symbol("AddDouble");9const AddFloat = Symbol("AddFloat");10const Sub32 = Symbol("Sub32");11const Sub64 = Symbol("Sub64");12const SubDouble = Symbol("SubDouble");13const SubFloat = Symbol("SubFloat");14const Neg32 = Symbol("Neg32");15const Neg64 = Symbol("Neg64");16const NegateDouble = Symbol("NegateDouble");17const Mul32 = Symbol("Mul32");18const Mul64 = Symbol("Mul64");19const MultiplyAdd32 = Symbol("MultiplyAdd32");20const MultiplyAdd64 = Symbol("MultiplyAdd64");21const MultiplySub32 = Symbol("MultiplySub32");22const MultiplySub64 = Symbol("MultiplySub64");23const MultiplyNeg32 = Symbol("MultiplyNeg32");24const MultiplyNeg64 = Symbol("MultiplyNeg64");25const Div32 = Symbol("Div32");26const Div64 = Symbol("Div64");27const MulDouble = Symbol("MulDouble");28const MulFloat = Symbol("MulFloat");29const DivDouble = Symbol("DivDouble");30const DivFloat = Symbol("DivFloat");31const X86ConvertToDoubleWord32 = Symbol("X86ConvertToDoubleWord32");32const X86ConvertToQuadWord64 = Symbol("X86ConvertToQuadWord64");33const X86Div32 = Symbol("X86Div32");34const X86Div64 = Symbol("X86Div64");35const Lea = Symbol("Lea");36const And32 = Symbol("And32");37const And64 = Symbol("And64");38const AndDouble = Symbol("AndDouble");39const AndFloat = Symbol("AndFloat");40const XorDouble = Symbol("XorDouble");41const XorFloat = Symbol("XorFloat");42const Lshift32 = Symbol("Lshift32");43const Lshift64 = Symbol("Lshift64");44const Rshift32 = Symbol("Rshift32");45const Rshift64 = Symbol("Rshift64");46const Urshift32 = Symbol("Urshift32");47const Urshift64 = Symbol("Urshift64");48const Or32 = Symbol("Or32");49const Or64 = Symbol("Or64");50const Xor32 = Symbol("Xor32");51const Xor64 = Symbol("Xor64");52const Not32 = Symbol("Not32");53const Not64 = Symbol("Not64");54const AbsDouble = Symbol("AbsDouble");55const AbsFloat = Symbol("AbsFloat");56const CeilDouble = Symbol("CeilDouble");57const CeilFloat = Symbol("CeilFloat");58const FloorDouble = Symbol("FloorDouble");59const FloorFloat = Symbol("FloorFloat");60const SqrtDouble = Symbol("SqrtDouble");61const SqrtFloat = Symbol("SqrtFloat");62const ConvertInt32ToDouble = Symbol("ConvertInt32ToDouble");63const ConvertInt64ToDouble = Symbol("ConvertInt64ToDouble");64const ConvertInt32ToFloat = Symbol("ConvertInt32ToFloat");65const ConvertInt64ToFloat = Symbol("ConvertInt64ToFloat");66const CountLeadingZeros32 = Symbol("CountLeadingZeros32");67const CountLeadingZeros64 = Symbol("CountLeadingZeros64");68const ConvertDoubleToFloat = Symbol("ConvertDoubleToFloat");69const ConvertFloatToDouble = Symbol("ConvertFloatToDouble");70const Move = Symbol("Move");71const Swap32 = Symbol("Swap32");72const Swap64 = Symbol("Swap64");73const Move32 = Symbol("Move32");74const StoreZero32 = Symbol("StoreZero32");75const SignExtend32ToPtr = Symbol("SignExtend32ToPtr");76const ZeroExtend8To32 = Symbol("ZeroExtend8To32");77const SignExtend8To32 = Symbol("SignExtend8To32");78const ZeroExtend16To32 = Symbol("ZeroExtend16To32");79const SignExtend16To32 = Symbol("SignExtend16To32");80const MoveFloat = Symbol("MoveFloat");81const MoveDouble = Symbol("MoveDouble");82const MoveZeroToDouble = Symbol("MoveZeroToDouble");83const Move64ToDouble = Symbol("Move64ToDouble");84const Move32ToFloat = Symbol("Move32ToFloat");85const MoveDoubleTo64 = Symbol("MoveDoubleTo64");86const MoveFloatTo32 = Symbol("MoveFloatTo32");87const Load8 = Symbol("Load8");88const Store8 = Symbol("Store8");89const Load8SignedExtendTo32 = Symbol("Load8SignedExtendTo32");90const Load16 = Symbol("Load16");91const Load16SignedExtendTo32 = Symbol("Load16SignedExtendTo32");92const Store16 = Symbol("Store16");93const Compare32 = Symbol("Compare32");94const Compare64 = Symbol("Compare64");95const Test32 = Symbol("Test32");96const Test64 = Symbol("Test64");97const CompareDouble = Symbol("CompareDouble");98const CompareFloat = Symbol("CompareFloat");99const Branch8 = Symbol("Branch8");100const Branch32 = Symbol("Branch32");101const Branch64 = Symbol("Branch64");102const BranchTest8 = Symbol("BranchTest8");103const BranchTest32 = Symbol("BranchTest32");104const BranchTest64 = Symbol("BranchTest64");105const BranchDouble = Symbol("BranchDouble");106const BranchFloat = Symbol("BranchFloat");107const BranchAdd32 = Symbol("BranchAdd32");108const BranchAdd64 = Symbol("BranchAdd64");109const BranchMul32 = Symbol("BranchMul32");110const BranchMul64 = Symbol("BranchMul64");111const BranchSub32 = Symbol("BranchSub32");112const BranchSub64 = Symbol("BranchSub64");113const BranchNeg32 = Symbol("BranchNeg32");114const BranchNeg64 = Symbol("BranchNeg64");115const MoveConditionally32 = Symbol("MoveConditionally32");116const MoveConditionally64 = Symbol("MoveConditionally64");117const MoveConditionallyTest32 = Symbol("MoveConditionallyTest32");118const MoveConditionallyTest64 = Symbol("MoveConditionallyTest64");119const MoveConditionallyDouble = Symbol("MoveConditionallyDouble");120const MoveConditionallyFloat = Symbol("MoveConditionallyFloat");121const MoveDoubleConditionally32 = Symbol("MoveDoubleConditionally32");122const MoveDoubleConditionally64 = Symbol("MoveDoubleConditionally64");123const MoveDoubleConditionallyTest32 = Symbol("MoveDoubleConditionallyTest32");124const MoveDoubleConditionallyTest64 = Symbol("MoveDoubleConditionallyTest64");125const MoveDoubleConditionallyDouble = Symbol("MoveDoubleConditionallyDouble");126const MoveDoubleConditionallyFloat = Symbol("MoveDoubleConditionallyFloat");127const Jump = Symbol("Jump");128const Ret32 = Symbol("Ret32");129const Ret64 = Symbol("Ret64");130const RetFloat = Symbol("RetFloat");131const RetDouble = Symbol("RetDouble");132const Oops = Symbol("Oops");133const Shuffle = Symbol("Shuffle");134const Patch = Symbol("Patch");135const CCall = Symbol("CCall");136const ColdCCall = Symbol("ColdCCall");137function Inst_forEachArg(inst, func)138{139 let replacement;140 switch (inst.opcode) {141 case Nop:142 break;143 break;144 case Add32:145 switch (inst.args.length) {146 case 3:147 inst.visitArg(0, func, Arg.Use, GP, 32);148 inst.visitArg(1, func, Arg.Use, GP, 32);149 inst.visitArg(2, func, Arg.ZDef, GP, 32);150 break;151 case 2:152 inst.visitArg(0, func, Arg.Use, GP, 32);153 inst.visitArg(1, func, Arg.UseZDef, GP, 32);154 break;155 default:156 throw new Error("Bad overload");157 break;158 }159 break;160 case Add8:161 inst.visitArg(0, func, Arg.Use, GP, 8);162 inst.visitArg(1, func, Arg.UseDef, GP, 8);163 break;164 break;165 case Add16:166 inst.visitArg(0, func, Arg.Use, GP, 16);167 inst.visitArg(1, func, Arg.UseDef, GP, 16);168 break;169 break;170 case Add64:171 switch (inst.args.length) {172 case 2:173 inst.visitArg(0, func, Arg.Use, GP, 64);174 inst.visitArg(1, func, Arg.UseDef, GP, 64);175 break;176 case 3:177 inst.visitArg(0, func, Arg.Use, GP, 64);178 inst.visitArg(1, func, Arg.Use, GP, 64);179 inst.visitArg(2, func, Arg.Def, GP, 64);180 break;181 default:182 throw new Error("Bad overload");183 break;184 }185 break;186 case AddDouble:187 switch (inst.args.length) {188 case 3:189 inst.visitArg(0, func, Arg.Use, FP, 64);190 inst.visitArg(1, func, Arg.Use, FP, 64);191 inst.visitArg(2, func, Arg.Def, FP, 64);192 break;193 case 2:194 inst.visitArg(0, func, Arg.Use, FP, 64);195 inst.visitArg(1, func, Arg.UseDef, FP, 64);196 break;197 default:198 throw new Error("Bad overload");199 break;200 }201 break;202 case AddFloat:203 switch (inst.args.length) {204 case 3:205 inst.visitArg(0, func, Arg.Use, FP, 32);206 inst.visitArg(1, func, Arg.Use, FP, 32);207 inst.visitArg(2, func, Arg.Def, FP, 32);208 break;209 case 2:210 inst.visitArg(0, func, Arg.Use, FP, 32);211 inst.visitArg(1, func, Arg.UseDef, FP, 32);212 break;213 default:214 throw new Error("Bad overload");215 break;216 }217 break;218 case Sub32:219 inst.visitArg(0, func, Arg.Use, GP, 32);220 inst.visitArg(1, func, Arg.UseZDef, GP, 32);221 break;222 break;223 case Sub64:224 inst.visitArg(0, func, Arg.Use, GP, 64);225 inst.visitArg(1, func, Arg.UseDef, GP, 64);226 break;227 break;228 case SubDouble:229 switch (inst.args.length) {230 case 3:231 inst.visitArg(0, func, Arg.Use, FP, 64);232 inst.visitArg(1, func, Arg.Use, FP, 64);233 inst.visitArg(2, func, Arg.Def, FP, 64);234 break;235 case 2:236 inst.visitArg(0, func, Arg.Use, FP, 64);237 inst.visitArg(1, func, Arg.UseDef, FP, 64);238 break;239 default:240 throw new Error("Bad overload");241 break;242 }243 break;244 case SubFloat:245 switch (inst.args.length) {246 case 3:247 inst.visitArg(0, func, Arg.Use, FP, 32);248 inst.visitArg(1, func, Arg.Use, FP, 32);249 inst.visitArg(2, func, Arg.Def, FP, 32);250 break;251 case 2:252 inst.visitArg(0, func, Arg.Use, FP, 32);253 inst.visitArg(1, func, Arg.UseDef, FP, 32);254 break;255 default:256 throw new Error("Bad overload");257 break;258 }259 break;260 case Neg32:261 inst.visitArg(0, func, Arg.UseZDef, GP, 32);262 break;263 break;264 case Neg64:265 inst.visitArg(0, func, Arg.UseDef, GP, 64);266 break;267 break;268 case NegateDouble:269 inst.visitArg(0, func, Arg.Use, FP, 64);270 inst.visitArg(1, func, Arg.Def, FP, 64);271 break;272 break;273 case Mul32:274 switch (inst.args.length) {275 case 2:276 inst.visitArg(0, func, Arg.Use, GP, 32);277 inst.visitArg(1, func, Arg.UseZDef, GP, 32);278 break;279 case 3:280 inst.visitArg(0, func, Arg.Use, GP, 32);281 inst.visitArg(1, func, Arg.Use, GP, 32);282 inst.visitArg(2, func, Arg.ZDef, GP, 32);283 break;284 default:285 throw new Error("Bad overload");286 break;287 }288 break;289 case Mul64:290 switch (inst.args.length) {291 case 2:292 inst.visitArg(0, func, Arg.Use, GP, 64);293 inst.visitArg(1, func, Arg.UseDef, GP, 64);294 break;295 case 3:296 inst.visitArg(0, func, Arg.Use, GP, 64);297 inst.visitArg(1, func, Arg.Use, GP, 64);298 inst.visitArg(2, func, Arg.Def, GP, 64);299 break;300 default:301 throw new Error("Bad overload");302 break;303 }304 break;305 case MultiplyAdd32:306 inst.visitArg(0, func, Arg.Use, GP, 32);307 inst.visitArg(1, func, Arg.Use, GP, 32);308 inst.visitArg(2, func, Arg.Use, GP, 32);309 inst.visitArg(3, func, Arg.ZDef, GP, 32);310 break;311 break;312 case MultiplyAdd64:313 inst.visitArg(0, func, Arg.Use, GP, 64);314 inst.visitArg(1, func, Arg.Use, GP, 64);315 inst.visitArg(2, func, Arg.Use, GP, 64);316 inst.visitArg(3, func, Arg.Def, GP, 64);317 break;318 break;319 case MultiplySub32:320 inst.visitArg(0, func, Arg.Use, GP, 32);321 inst.visitArg(1, func, Arg.Use, GP, 32);322 inst.visitArg(2, func, Arg.Use, GP, 32);323 inst.visitArg(3, func, Arg.ZDef, GP, 32);324 break;325 break;326 case MultiplySub64:327 inst.visitArg(0, func, Arg.Use, GP, 64);328 inst.visitArg(1, func, Arg.Use, GP, 64);329 inst.visitArg(2, func, Arg.Use, GP, 64);330 inst.visitArg(3, func, Arg.Def, GP, 64);331 break;332 break;333 case MultiplyNeg32:334 inst.visitArg(0, func, Arg.Use, GP, 32);335 inst.visitArg(1, func, Arg.Use, GP, 32);336 inst.visitArg(2, func, Arg.ZDef, GP, 32);337 break;338 break;339 case MultiplyNeg64:340 inst.visitArg(0, func, Arg.Use, GP, 64);341 inst.visitArg(1, func, Arg.Use, GP, 64);342 inst.visitArg(2, func, Arg.ZDef, GP, 64);343 break;344 break;345 case Div32:346 inst.visitArg(0, func, Arg.Use, GP, 32);347 inst.visitArg(1, func, Arg.Use, GP, 32);348 inst.visitArg(2, func, Arg.ZDef, GP, 32);349 break;350 break;351 case Div64:352 inst.visitArg(0, func, Arg.Use, GP, 64);353 inst.visitArg(1, func, Arg.Use, GP, 64);354 inst.visitArg(2, func, Arg.Def, GP, 64);355 break;356 break;357 case MulDouble:358 switch (inst.args.length) {359 case 3:360 inst.visitArg(0, func, Arg.Use, FP, 64);361 inst.visitArg(1, func, Arg.Use, FP, 64);362 inst.visitArg(2, func, Arg.Def, FP, 64);363 break;364 case 2:365 inst.visitArg(0, func, Arg.Use, FP, 64);366 inst.visitArg(1, func, Arg.UseDef, FP, 64);367 break;368 default:369 throw new Error("Bad overload");370 break;371 }372 break;373 case MulFloat:374 switch (inst.args.length) {375 case 3:376 inst.visitArg(0, func, Arg.Use, FP, 32);377 inst.visitArg(1, func, Arg.Use, FP, 32);378 inst.visitArg(2, func, Arg.Def, FP, 32);379 break;380 case 2:381 inst.visitArg(0, func, Arg.Use, FP, 32);382 inst.visitArg(1, func, Arg.UseDef, FP, 32);383 break;384 default:385 throw new Error("Bad overload");386 break;387 }388 break;389 case DivDouble:390 switch (inst.args.length) {391 case 3:392 inst.visitArg(0, func, Arg.Use, FP, 64);393 inst.visitArg(1, func, Arg.Use, FP, 32);394 inst.visitArg(2, func, Arg.Def, FP, 64);395 break;396 case 2:397 inst.visitArg(0, func, Arg.Use, FP, 64);398 inst.visitArg(1, func, Arg.UseDef, FP, 64);399 break;400 default:401 throw new Error("Bad overload");402 break;403 }404 break;405 case DivFloat:406 switch (inst.args.length) {407 case 3:408 inst.visitArg(0, func, Arg.Use, FP, 32);409 inst.visitArg(1, func, Arg.Use, FP, 32);410 inst.visitArg(2, func, Arg.Def, FP, 32);411 break;412 case 2:413 inst.visitArg(0, func, Arg.Use, FP, 32);414 inst.visitArg(1, func, Arg.UseDef, FP, 32);415 break;416 default:417 throw new Error("Bad overload");418 break;419 }420 break;421 case X86ConvertToDoubleWord32:422 inst.visitArg(0, func, Arg.Use, GP, 32);423 inst.visitArg(1, func, Arg.ZDef, GP, 32);424 break;425 break;426 case X86ConvertToQuadWord64:427 inst.visitArg(0, func, Arg.Use, GP, 64);428 inst.visitArg(1, func, Arg.Def, GP, 64);429 break;430 break;431 case X86Div32:432 inst.visitArg(0, func, Arg.UseZDef, GP, 32);433 inst.visitArg(1, func, Arg.UseZDef, GP, 32);434 inst.visitArg(2, func, Arg.Use, GP, 32);435 break;436 break;437 case X86Div64:438 inst.visitArg(0, func, Arg.UseZDef, GP, 64);439 inst.visitArg(1, func, Arg.UseZDef, GP, 64);440 inst.visitArg(2, func, Arg.Use, GP, 64);441 break;442 break;443 case Lea:444 inst.visitArg(0, func, Arg.UseAddr, GP, Ptr);445 inst.visitArg(1, func, Arg.Def, GP, Ptr);446 break;447 break;448 case And32:449 switch (inst.args.length) {450 case 3:451 inst.visitArg(0, func, Arg.Use, GP, 32);452 inst.visitArg(1, func, Arg.Use, GP, 32);453 inst.visitArg(2, func, Arg.ZDef, GP, 32);454 break;455 case 2:456 inst.visitArg(0, func, Arg.Use, GP, 32);457 inst.visitArg(1, func, Arg.UseZDef, GP, 32);458 break;459 default:460 throw new Error("Bad overload");461 break;462 }463 break;464 case And64:465 switch (inst.args.length) {466 case 3:467 inst.visitArg(0, func, Arg.Use, GP, 64);468 inst.visitArg(1, func, Arg.Use, GP, 64);469 inst.visitArg(2, func, Arg.Def, GP, 64);470 break;471 case 2:472 inst.visitArg(0, func, Arg.Use, GP, 64);473 inst.visitArg(1, func, Arg.UseDef, GP, 64);474 break;475 default:476 throw new Error("Bad overload");477 break;478 }479 break;480 case AndDouble:481 switch (inst.args.length) {482 case 3:483 inst.visitArg(0, func, Arg.Use, FP, 64);484 inst.visitArg(1, func, Arg.Use, FP, 64);485 inst.visitArg(2, func, Arg.Def, FP, 64);486 break;487 case 2:488 inst.visitArg(0, func, Arg.Use, FP, 64);489 inst.visitArg(1, func, Arg.UseDef, FP, 64);490 break;491 default:492 throw new Error("Bad overload");493 break;494 }495 break;496 case AndFloat:497 switch (inst.args.length) {498 case 3:499 inst.visitArg(0, func, Arg.Use, FP, 32);500 inst.visitArg(1, func, Arg.Use, FP, 32);501 inst.visitArg(2, func, Arg.Def, FP, 32);502 break;503 case 2:504 inst.visitArg(0, func, Arg.Use, FP, 32);505 inst.visitArg(1, func, Arg.UseDef, FP, 32);506 break;507 default:508 throw new Error("Bad overload");509 break;510 }511 break;512 case XorDouble:513 switch (inst.args.length) {514 case 3:515 inst.visitArg(0, func, Arg.Use, FP, 64);516 inst.visitArg(1, func, Arg.Use, FP, 64);517 inst.visitArg(2, func, Arg.Def, FP, 64);518 break;519 case 2:520 inst.visitArg(0, func, Arg.Use, FP, 64);521 inst.visitArg(1, func, Arg.UseDef, FP, 64);522 break;523 default:524 throw new Error("Bad overload");525 break;526 }527 break;528 case XorFloat:529 switch (inst.args.length) {530 case 3:531 inst.visitArg(0, func, Arg.Use, FP, 32);532 inst.visitArg(1, func, Arg.Use, FP, 32);533 inst.visitArg(2, func, Arg.Def, FP, 32);534 break;535 case 2:536 inst.visitArg(0, func, Arg.Use, FP, 32);537 inst.visitArg(1, func, Arg.UseDef, FP, 32);538 break;539 default:540 throw new Error("Bad overload");541 break;542 }543 break;544 case Lshift32:545 switch (inst.args.length) {546 case 3:547 inst.visitArg(0, func, Arg.Use, GP, 32);548 inst.visitArg(1, func, Arg.Use, GP, 32);549 inst.visitArg(2, func, Arg.ZDef, GP, 32);550 break;551 case 2:552 inst.visitArg(0, func, Arg.Use, GP, 32);553 inst.visitArg(1, func, Arg.UseZDef, GP, 32);554 break;555 default:556 throw new Error("Bad overload");557 break;558 }559 break;560 case Lshift64:561 switch (inst.args.length) {562 case 3:563 inst.visitArg(0, func, Arg.Use, GP, 64);564 inst.visitArg(1, func, Arg.Use, GP, 64);565 inst.visitArg(2, func, Arg.ZDef, GP, 64);566 break;567 case 2:568 inst.visitArg(0, func, Arg.Use, GP, 64);569 inst.visitArg(1, func, Arg.UseDef, GP, 64);570 break;571 default:572 throw new Error("Bad overload");573 break;574 }575 break;576 case Rshift32:577 switch (inst.args.length) {578 case 3:579 inst.visitArg(0, func, Arg.Use, GP, 32);580 inst.visitArg(1, func, Arg.Use, GP, 32);581 inst.visitArg(2, func, Arg.ZDef, GP, 32);582 break;583 case 2:584 inst.visitArg(0, func, Arg.Use, GP, 32);585 inst.visitArg(1, func, Arg.UseZDef, GP, 32);586 break;587 default:588 throw new Error("Bad overload");589 break;590 }591 break;592 case Rshift64:593 switch (inst.args.length) {594 case 3:595 inst.visitArg(0, func, Arg.Use, GP, 64);596 inst.visitArg(1, func, Arg.Use, GP, 64);597 inst.visitArg(2, func, Arg.ZDef, GP, 64);598 break;599 case 2:600 inst.visitArg(0, func, Arg.Use, GP, 64);601 inst.visitArg(1, func, Arg.UseDef, GP, 64);602 break;603 default:604 throw new Error("Bad overload");605 break;606 }607 break;608 case Urshift32:609 switch (inst.args.length) {610 case 3:611 inst.visitArg(0, func, Arg.Use, GP, 32);612 inst.visitArg(1, func, Arg.Use, GP, 32);613 inst.visitArg(2, func, Arg.ZDef, GP, 32);614 break;615 case 2:616 inst.visitArg(0, func, Arg.Use, GP, 32);617 inst.visitArg(1, func, Arg.UseZDef, GP, 32);618 break;619 default:620 throw new Error("Bad overload");621 break;622 }623 break;624 case Urshift64:625 switch (inst.args.length) {626 case 3:627 inst.visitArg(0, func, Arg.Use, GP, 64);628 inst.visitArg(1, func, Arg.Use, GP, 64);629 inst.visitArg(2, func, Arg.ZDef, GP, 64);630 break;631 case 2:632 inst.visitArg(0, func, Arg.Use, GP, 64);633 inst.visitArg(1, func, Arg.UseDef, GP, 64);634 break;635 default:636 throw new Error("Bad overload");637 break;638 }639 break;640 case Or32:641 switch (inst.args.length) {642 case 3:643 inst.visitArg(0, func, Arg.Use, GP, 32);644 inst.visitArg(1, func, Arg.Use, GP, 32);645 inst.visitArg(2, func, Arg.ZDef, GP, 32);646 break;647 case 2:648 inst.visitArg(0, func, Arg.Use, GP, 32);649 inst.visitArg(1, func, Arg.UseZDef, GP, 32);650 break;651 default:652 throw new Error("Bad overload");653 break;654 }655 break;656 case Or64:657 switch (inst.args.length) {658 case 3:659 inst.visitArg(0, func, Arg.Use, GP, 64);660 inst.visitArg(1, func, Arg.Use, GP, 64);661 inst.visitArg(2, func, Arg.Def, GP, 64);662 break;663 case 2:664 inst.visitArg(0, func, Arg.Use, GP, 64);665 inst.visitArg(1, func, Arg.UseDef, GP, 64);666 break;667 default:668 throw new Error("Bad overload");669 break;670 }671 break;672 case Xor32:673 switch (inst.args.length) {674 case 3:675 inst.visitArg(0, func, Arg.Use, GP, 32);676 inst.visitArg(1, func, Arg.Use, GP, 32);677 inst.visitArg(2, func, Arg.ZDef, GP, 32);678 break;679 case 2:680 inst.visitArg(0, func, Arg.Use, GP, 32);681 inst.visitArg(1, func, Arg.UseZDef, GP, 32);682 break;683 default:684 throw new Error("Bad overload");685 break;686 }687 break;688 case Xor64:689 switch (inst.args.length) {690 case 3:691 inst.visitArg(0, func, Arg.Use, GP, 64);692 inst.visitArg(1, func, Arg.Use, GP, 64);693 inst.visitArg(2, func, Arg.Def, GP, 64);694 break;695 case 2:696 inst.visitArg(0, func, Arg.Use, GP, 64);697 inst.visitArg(1, func, Arg.UseDef, GP, 64);698 break;699 default:700 throw new Error("Bad overload");701 break;702 }703 break;704 case Not32:705 switch (inst.args.length) {706 case 2:707 inst.visitArg(0, func, Arg.Use, GP, 32);708 inst.visitArg(1, func, Arg.ZDef, GP, 32);709 break;710 case 1:711 inst.visitArg(0, func, Arg.UseZDef, GP, 32);712 break;713 default:714 throw new Error("Bad overload");715 break;716 }717 break;718 case Not64:719 switch (inst.args.length) {720 case 2:721 inst.visitArg(0, func, Arg.Use, GP, 64);722 inst.visitArg(1, func, Arg.Def, GP, 64);723 break;724 case 1:725 inst.visitArg(0, func, Arg.UseDef, GP, 64);726 break;727 default:728 throw new Error("Bad overload");729 break;730 }731 break;732 case AbsDouble:733 inst.visitArg(0, func, Arg.Use, FP, 64);734 inst.visitArg(1, func, Arg.Def, FP, 64);735 break;736 break;737 case AbsFloat:738 inst.visitArg(0, func, Arg.Use, FP, 32);739 inst.visitArg(1, func, Arg.Def, FP, 32);740 break;741 break;742 case CeilDouble:743 inst.visitArg(0, func, Arg.Use, FP, 64);744 inst.visitArg(1, func, Arg.Def, FP, 64);745 break;746 break;747 case CeilFloat:748 inst.visitArg(0, func, Arg.Use, FP, 32);749 inst.visitArg(1, func, Arg.Def, FP, 32);750 break;751 break;752 case FloorDouble:753 inst.visitArg(0, func, Arg.Use, FP, 64);754 inst.visitArg(1, func, Arg.Def, FP, 64);755 break;756 break;757 case FloorFloat:758 inst.visitArg(0, func, Arg.Use, FP, 32);759 inst.visitArg(1, func, Arg.Def, FP, 32);760 break;761 break;762 case SqrtDouble:763 inst.visitArg(0, func, Arg.Use, FP, 64);764 inst.visitArg(1, func, Arg.Def, FP, 64);765 break;766 break;767 case SqrtFloat:768 inst.visitArg(0, func, Arg.Use, FP, 32);769 inst.visitArg(1, func, Arg.Def, FP, 32);770 break;771 break;772 case ConvertInt32ToDouble:773 inst.visitArg(0, func, Arg.Use, GP, 32);774 inst.visitArg(1, func, Arg.Def, FP, 64);775 break;776 break;777 case ConvertInt64ToDouble:778 inst.visitArg(0, func, Arg.Use, GP, 64);779 inst.visitArg(1, func, Arg.Def, FP, 64);780 break;781 break;782 case ConvertInt32ToFloat:783 inst.visitArg(0, func, Arg.Use, GP, 32);784 inst.visitArg(1, func, Arg.Def, FP, 32);785 break;786 break;787 case ConvertInt64ToFloat:788 inst.visitArg(0, func, Arg.Use, GP, 64);789 inst.visitArg(1, func, Arg.Def, FP, 32);790 break;791 break;792 case CountLeadingZeros32:793 inst.visitArg(0, func, Arg.Use, GP, 32);794 inst.visitArg(1, func, Arg.ZDef, GP, 32);795 break;796 break;797 case CountLeadingZeros64:798 inst.visitArg(0, func, Arg.Use, GP, 64);799 inst.visitArg(1, func, Arg.Def, GP, 64);800 break;801 break;802 case ConvertDoubleToFloat:803 inst.visitArg(0, func, Arg.Use, FP, 64);804 inst.visitArg(1, func, Arg.Def, FP, 32);805 break;806 break;807 case ConvertFloatToDouble:808 inst.visitArg(0, func, Arg.Use, FP, 32);809 inst.visitArg(1, func, Arg.Def, FP, 64);810 break;811 break;812 case Move:813 inst.visitArg(0, func, Arg.Use, GP, Ptr);814 inst.visitArg(1, func, Arg.Def, GP, Ptr);815 break;816 break;817 case Swap32:818 inst.visitArg(0, func, Arg.UseDef, GP, 32);819 inst.visitArg(1, func, Arg.UseDef, GP, 32);820 break;821 break;822 case Swap64:823 inst.visitArg(0, func, Arg.UseDef, GP, 64);824 inst.visitArg(1, func, Arg.UseDef, GP, 64);825 break;826 break;827 case Move32:828 inst.visitArg(0, func, Arg.Use, GP, 32);829 inst.visitArg(1, func, Arg.ZDef, GP, 32);830 break;831 break;832 case StoreZero32:833 inst.visitArg(0, func, Arg.Use, GP, 32);834 break;835 break;836 case SignExtend32ToPtr:837 inst.visitArg(0, func, Arg.Use, GP, 32);838 inst.visitArg(1, func, Arg.Def, GP, Ptr);839 break;840 break;841 case ZeroExtend8To32:842 inst.visitArg(0, func, Arg.Use, GP, 8);843 inst.visitArg(1, func, Arg.ZDef, GP, 32);844 break;845 break;846 case SignExtend8To32:847 inst.visitArg(0, func, Arg.Use, GP, 8);848 inst.visitArg(1, func, Arg.ZDef, GP, 32);849 break;850 break;851 case ZeroExtend16To32:852 inst.visitArg(0, func, Arg.Use, GP, 16);853 inst.visitArg(1, func, Arg.ZDef, GP, 32);854 break;855 break;856 case SignExtend16To32:857 inst.visitArg(0, func, Arg.Use, GP, 16);858 inst.visitArg(1, func, Arg.ZDef, GP, 32);859 break;860 break;861 case MoveFloat:862 inst.visitArg(0, func, Arg.Use, FP, 32);863 inst.visitArg(1, func, Arg.Def, FP, 32);864 break;865 break;866 case MoveDouble:867 inst.visitArg(0, func, Arg.Use, FP, 64);868 inst.visitArg(1, func, Arg.Def, FP, 64);869 break;870 break;871 case MoveZeroToDouble:872 inst.visitArg(0, func, Arg.Def, FP, 64);873 break;874 break;875 case Move64ToDouble:876 inst.visitArg(0, func, Arg.Use, GP, 64);877 inst.visitArg(1, func, Arg.Def, FP, 64);878 break;879 break;880 case Move32ToFloat:881 inst.visitArg(0, func, Arg.Use, GP, 32);882 inst.visitArg(1, func, Arg.Def, FP, 32);883 break;884 break;885 case MoveDoubleTo64:886 inst.visitArg(0, func, Arg.Use, FP, 64);887 inst.visitArg(1, func, Arg.Def, GP, 64);888 break;889 break;890 case MoveFloatTo32:891 inst.visitArg(0, func, Arg.Use, FP, 32);892 inst.visitArg(1, func, Arg.Def, GP, 32);893 break;894 break;895 case Load8:896 inst.visitArg(0, func, Arg.Use, GP, 8);897 inst.visitArg(1, func, Arg.ZDef, GP, 32);898 break;899 break;900 case Store8:901 inst.visitArg(0, func, Arg.Use, GP, 8);902 inst.visitArg(1, func, Arg.Def, GP, 8);903 break;904 break;905 case Load8SignedExtendTo32:906 inst.visitArg(0, func, Arg.Use, GP, 8);907 inst.visitArg(1, func, Arg.ZDef, GP, 32);908 break;909 break;910 case Load16:911 inst.visitArg(0, func, Arg.Use, GP, 16);912 inst.visitArg(1, func, Arg.ZDef, GP, 32);913 break;914 break;915 case Load16SignedExtendTo32:916 inst.visitArg(0, func, Arg.Use, GP, 16);917 inst.visitArg(1, func, Arg.ZDef, GP, 32);918 break;919 break;920 case Store16:921 inst.visitArg(0, func, Arg.Use, GP, 16);922 inst.visitArg(1, func, Arg.Def, GP, 16);923 break;924 break;925 case Compare32:926 inst.visitArg(0, func, Arg.Use, GP, 32);927 inst.visitArg(1, func, Arg.Use, GP, 32);928 inst.visitArg(2, func, Arg.Use, GP, 32);929 inst.visitArg(3, func, Arg.ZDef, GP, 32);930 break;931 break;932 case Compare64:933 inst.visitArg(0, func, Arg.Use, GP, 32);934 inst.visitArg(1, func, Arg.Use, GP, 64);935 inst.visitArg(2, func, Arg.Use, GP, 64);936 inst.visitArg(3, func, Arg.ZDef, GP, 32);937 break;938 break;939 case Test32:940 inst.visitArg(0, func, Arg.Use, GP, 32);941 inst.visitArg(1, func, Arg.Use, GP, 32);942 inst.visitArg(2, func, Arg.Use, GP, 32);943 inst.visitArg(3, func, Arg.ZDef, GP, 32);944 break;945 break;946 case Test64:947 inst.visitArg(0, func, Arg.Use, GP, 32);948 inst.visitArg(1, func, Arg.Use, GP, 64);949 inst.visitArg(2, func, Arg.Use, GP, 64);950 inst.visitArg(3, func, Arg.ZDef, GP, 32);951 break;952 break;953 case CompareDouble:954 inst.visitArg(0, func, Arg.Use, GP, 32);955 inst.visitArg(1, func, Arg.Use, FP, 64);956 inst.visitArg(2, func, Arg.Use, FP, 64);957 inst.visitArg(3, func, Arg.ZDef, GP, 32);958 break;959 break;960 case CompareFloat:961 inst.visitArg(0, func, Arg.Use, GP, 32);962 inst.visitArg(1, func, Arg.Use, FP, 32);963 inst.visitArg(2, func, Arg.Use, FP, 32);964 inst.visitArg(3, func, Arg.ZDef, GP, 32);965 break;966 break;967 case Branch8:968 inst.visitArg(0, func, Arg.Use, GP, 32);969 inst.visitArg(1, func, Arg.Use, GP, 8);970 inst.visitArg(2, func, Arg.Use, GP, 8);971 break;972 break;973 case Branch32:974 inst.visitArg(0, func, Arg.Use, GP, 32);975 inst.visitArg(1, func, Arg.Use, GP, 32);976 inst.visitArg(2, func, Arg.Use, GP, 32);977 break;978 break;979 case Branch64:980 inst.visitArg(0, func, Arg.Use, GP, 32);981 inst.visitArg(1, func, Arg.Use, GP, 64);982 inst.visitArg(2, func, Arg.Use, GP, 64);983 break;984 break;985 case BranchTest8:986 inst.visitArg(0, func, Arg.Use, GP, 32);987 inst.visitArg(1, func, Arg.Use, GP, 8);988 inst.visitArg(2, func, Arg.Use, GP, 8);989 break;990 break;991 case BranchTest32:992 inst.visitArg(0, func, Arg.Use, GP, 32);993 inst.visitArg(1, func, Arg.Use, GP, 32);994 inst.visitArg(2, func, Arg.Use, GP, 32);995 break;996 break;997 case BranchTest64:998 inst.visitArg(0, func, Arg.Use, GP, 32);999 inst.visitArg(1, func, Arg.Use, GP, 64);1000 inst.visitArg(2, func, Arg.Use, GP, 64);1001 break;1002 break;1003 case BranchDouble:1004 inst.visitArg(0, func, Arg.Use, GP, 32);1005 inst.visitArg(1, func, Arg.Use, FP, 64);1006 inst.visitArg(2, func, Arg.Use, FP, 64);1007 break;1008 break;1009 case BranchFloat:1010 inst.visitArg(0, func, Arg.Use, GP, 32);1011 inst.visitArg(1, func, Arg.Use, FP, 32);1012 inst.visitArg(2, func, Arg.Use, FP, 32);1013 break;1014 break;1015 case BranchAdd32:1016 switch (inst.args.length) {1017 case 4:1018 inst.visitArg(0, func, Arg.Use, GP, 32);1019 inst.visitArg(1, func, Arg.Use, GP, 32);1020 inst.visitArg(2, func, Arg.Use, GP, 32);1021 inst.visitArg(3, func, Arg.ZDef, GP, 32);1022 break;1023 case 3:1024 inst.visitArg(0, func, Arg.Use, GP, 32);1025 inst.visitArg(1, func, Arg.Use, GP, 32);1026 inst.visitArg(2, func, Arg.UseZDef, GP, 32);1027 break;1028 default:1029 throw new Error("Bad overload");1030 break;1031 }1032 break;1033 case BranchAdd64:1034 switch (inst.args.length) {1035 case 4:1036 inst.visitArg(0, func, Arg.Use, GP, 32);1037 inst.visitArg(1, func, Arg.Use, GP, 64);1038 inst.visitArg(2, func, Arg.Use, GP, 64);1039 inst.visitArg(3, func, Arg.ZDef, GP, 64);1040 break;1041 case 3:1042 inst.visitArg(0, func, Arg.Use, GP, 32);1043 inst.visitArg(1, func, Arg.Use, GP, 64);1044 inst.visitArg(2, func, Arg.UseDef, GP, 64);1045 break;1046 default:1047 throw new Error("Bad overload");1048 break;1049 }1050 break;1051 case BranchMul32:1052 switch (inst.args.length) {1053 case 3:1054 inst.visitArg(0, func, Arg.Use, GP, 32);1055 inst.visitArg(1, func, Arg.Use, GP, 32);1056 inst.visitArg(2, func, Arg.UseZDef, GP, 32);1057 break;1058 case 4:1059 inst.visitArg(0, func, Arg.Use, GP, 32);1060 inst.visitArg(1, func, Arg.Use, GP, 32);1061 inst.visitArg(2, func, Arg.Use, GP, 32);1062 inst.visitArg(3, func, Arg.ZDef, GP, 32);1063 break;1064 case 6:1065 inst.visitArg(0, func, Arg.Use, GP, 32);1066 inst.visitArg(1, func, Arg.Use, GP, 32);1067 inst.visitArg(2, func, Arg.Use, GP, 32);1068 inst.visitArg(3, func, Arg.Scratch, GP, 32);1069 inst.visitArg(4, func, Arg.Scratch, GP, 32);1070 inst.visitArg(5, func, Arg.ZDef, GP, 32);1071 break;1072 default:1073 throw new Error("Bad overload");1074 break;1075 }1076 break;1077 case BranchMul64:1078 switch (inst.args.length) {1079 case 3:1080 inst.visitArg(0, func, Arg.Use, GP, 32);1081 inst.visitArg(1, func, Arg.Use, GP, 64);1082 inst.visitArg(2, func, Arg.UseZDef, GP, 64);1083 break;1084 case 6:1085 inst.visitArg(0, func, Arg.Use, GP, 32);1086 inst.visitArg(1, func, Arg.Use, GP, 64);1087 inst.visitArg(2, func, Arg.Use, GP, 64);1088 inst.visitArg(3, func, Arg.Scratch, GP, 64);1089 inst.visitArg(4, func, Arg.Scratch, GP, 64);1090 inst.visitArg(5, func, Arg.ZDef, GP, 64);1091 break;1092 default:1093 throw new Error("Bad overload");1094 break;1095 }1096 break;1097 case BranchSub32:1098 inst.visitArg(0, func, Arg.Use, GP, 32);1099 inst.visitArg(1, func, Arg.Use, GP, 32);1100 inst.visitArg(2, func, Arg.UseZDef, GP, 32);1101 break;1102 break;1103 case BranchSub64:1104 inst.visitArg(0, func, Arg.Use, GP, 32);1105 inst.visitArg(1, func, Arg.Use, GP, 64);1106 inst.visitArg(2, func, Arg.UseDef, GP, 64);1107 break;1108 break;1109 case BranchNeg32:1110 inst.visitArg(0, func, Arg.Use, GP, 32);1111 inst.visitArg(1, func, Arg.UseZDef, GP, 32);1112 break;1113 break;1114 case BranchNeg64:1115 inst.visitArg(0, func, Arg.Use, GP, 32);1116 inst.visitArg(1, func, Arg.UseZDef, GP, 64);1117 break;1118 break;1119 case MoveConditionally32:1120 switch (inst.args.length) {1121 case 5:1122 inst.visitArg(0, func, Arg.Use, GP, 32);1123 inst.visitArg(1, func, Arg.Use, GP, 32);1124 inst.visitArg(2, func, Arg.Use, GP, 32);1125 inst.visitArg(3, func, Arg.Use, GP, Ptr);1126 inst.visitArg(4, func, Arg.UseDef, GP, Ptr);1127 break;1128 case 6:1129 inst.visitArg(0, func, Arg.Use, GP, 32);1130 inst.visitArg(1, func, Arg.Use, GP, 32);1131 inst.visitArg(2, func, Arg.Use, GP, 32);1132 inst.visitArg(3, func, Arg.Use, GP, Ptr);1133 inst.visitArg(4, func, Arg.Use, GP, Ptr);1134 inst.visitArg(5, func, Arg.Def, GP, Ptr);1135 break;1136 default:1137 throw new Error("Bad overload");1138 break;1139 }1140 break;1141 case MoveConditionally64:1142 switch (inst.args.length) {1143 case 5:1144 inst.visitArg(0, func, Arg.Use, GP, 32);1145 inst.visitArg(1, func, Arg.Use, GP, 64);1146 inst.visitArg(2, func, Arg.Use, GP, 64);1147 inst.visitArg(3, func, Arg.Use, GP, Ptr);1148 inst.visitArg(4, func, Arg.UseDef, GP, Ptr);1149 break;1150 case 6:1151 inst.visitArg(0, func, Arg.Use, GP, 32);1152 inst.visitArg(1, func, Arg.Use, GP, 64);1153 inst.visitArg(2, func, Arg.Use, GP, 64);1154 inst.visitArg(3, func, Arg.Use, GP, Ptr);1155 inst.visitArg(4, func, Arg.Use, GP, Ptr);1156 inst.visitArg(5, func, Arg.Def, GP, Ptr);1157 break;1158 default:1159 throw new Error("Bad overload");1160 break;1161 }1162 break;1163 case MoveConditionallyTest32:1164 switch (inst.args.length) {1165 case 5:1166 inst.visitArg(0, func, Arg.Use, GP, 32);1167 inst.visitArg(1, func, Arg.Use, GP, 32);1168 inst.visitArg(2, func, Arg.Use, GP, 32);1169 inst.visitArg(3, func, Arg.Use, GP, Ptr);1170 inst.visitArg(4, func, Arg.UseDef, GP, Ptr);1171 break;1172 case 6:1173 inst.visitArg(0, func, Arg.Use, GP, 32);1174 inst.visitArg(1, func, Arg.Use, GP, 32);1175 inst.visitArg(2, func, Arg.Use, GP, 32);1176 inst.visitArg(3, func, Arg.Use, GP, Ptr);1177 inst.visitArg(4, func, Arg.Use, GP, Ptr);1178 inst.visitArg(5, func, Arg.Def, GP, Ptr);1179 break;1180 default:1181 throw new Error("Bad overload");1182 break;1183 }1184 break;1185 case MoveConditionallyTest64:1186 switch (inst.args.length) {1187 case 5:1188 inst.visitArg(0, func, Arg.Use, GP, 32);1189 inst.visitArg(1, func, Arg.Use, GP, 64);1190 inst.visitArg(2, func, Arg.Use, GP, 64);1191 inst.visitArg(3, func, Arg.Use, GP, Ptr);1192 inst.visitArg(4, func, Arg.UseDef, GP, Ptr);1193 break;1194 case 6:1195 inst.visitArg(0, func, Arg.Use, GP, 32);1196 inst.visitArg(1, func, Arg.Use, GP, 32);1197 inst.visitArg(2, func, Arg.Use, GP, 32);1198 inst.visitArg(3, func, Arg.Use, GP, Ptr);1199 inst.visitArg(4, func, Arg.Use, GP, Ptr);1200 inst.visitArg(5, func, Arg.Def, GP, Ptr);1201 break;1202 default:1203 throw new Error("Bad overload");1204 break;1205 }1206 break;1207 case MoveConditionallyDouble:1208 switch (inst.args.length) {1209 case 6:1210 inst.visitArg(0, func, Arg.Use, GP, 32);1211 inst.visitArg(1, func, Arg.Use, FP, 64);1212 inst.visitArg(2, func, Arg.Use, FP, 64);1213 inst.visitArg(3, func, Arg.Use, GP, Ptr);1214 inst.visitArg(4, func, Arg.Use, GP, Ptr);1215 inst.visitArg(5, func, Arg.Def, GP, Ptr);1216 break;1217 case 5:1218 inst.visitArg(0, func, Arg.Use, GP, 32);1219 inst.visitArg(1, func, Arg.Use, FP, 64);1220 inst.visitArg(2, func, Arg.Use, FP, 64);1221 inst.visitArg(3, func, Arg.Use, GP, Ptr);1222 inst.visitArg(4, func, Arg.UseDef, GP, Ptr);1223 break;1224 default:1225 throw new Error("Bad overload");1226 break;1227 }1228 break;1229 case MoveConditionallyFloat:1230 switch (inst.args.length) {1231 case 6:1232 inst.visitArg(0, func, Arg.Use, GP, 32);1233 inst.visitArg(1, func, Arg.Use, FP, 32);1234 inst.visitArg(2, func, Arg.Use, FP, 32);1235 inst.visitArg(3, func, Arg.Use, GP, Ptr);1236 inst.visitArg(4, func, Arg.Use, GP, Ptr);1237 inst.visitArg(5, func, Arg.Def, GP, Ptr);1238 break;1239 case 5:1240 inst.visitArg(0, func, Arg.Use, GP, 32);1241 inst.visitArg(1, func, Arg.Use, FP, 32);1242 inst.visitArg(2, func, Arg.Use, FP, 32);1243 inst.visitArg(3, func, Arg.Use, GP, Ptr);1244 inst.visitArg(4, func, Arg.UseDef, GP, Ptr);1245 break;1246 default:1247 throw new Error("Bad overload");1248 break;1249 }1250 break;1251 case MoveDoubleConditionally32:1252 inst.visitArg(0, func, Arg.Use, GP, 32);1253 inst.visitArg(1, func, Arg.Use, GP, 32);1254 inst.visitArg(2, func, Arg.Use, GP, 32);1255 inst.visitArg(3, func, Arg.Use, FP, 64);1256 inst.visitArg(4, func, Arg.Use, FP, 64);1257 inst.visitArg(5, func, Arg.Def, FP, 64);1258 break;1259 break;1260 case MoveDoubleConditionally64:1261 inst.visitArg(0, func, Arg.Use, GP, 32);1262 inst.visitArg(1, func, Arg.Use, GP, 64);1263 inst.visitArg(2, func, Arg.Use, GP, 64);1264 inst.visitArg(3, func, Arg.Use, FP, 64);1265 inst.visitArg(4, func, Arg.Use, FP, 64);1266 inst.visitArg(5, func, Arg.Def, FP, 64);1267 break;1268 break;1269 case MoveDoubleConditionallyTest32:1270 inst.visitArg(0, func, Arg.Use, GP, 32);1271 inst.visitArg(1, func, Arg.Use, GP, 32);1272 inst.visitArg(2, func, Arg.Use, GP, 32);1273 inst.visitArg(3, func, Arg.Use, FP, 64);1274 inst.visitArg(4, func, Arg.Use, FP, 64);1275 inst.visitArg(5, func, Arg.Def, FP, 64);1276 break;1277 break;1278 case MoveDoubleConditionallyTest64:1279 inst.visitArg(0, func, Arg.Use, GP, 32);1280 inst.visitArg(1, func, Arg.Use, GP, 64);1281 inst.visitArg(2, func, Arg.Use, GP, 64);1282 inst.visitArg(3, func, Arg.Use, FP, 64);1283 inst.visitArg(4, func, Arg.Use, FP, 64);1284 inst.visitArg(5, func, Arg.Def, FP, 64);1285 break;1286 break;1287 case MoveDoubleConditionallyDouble:1288 inst.visitArg(0, func, Arg.Use, GP, 32);1289 inst.visitArg(1, func, Arg.Use, FP, 64);1290 inst.visitArg(2, func, Arg.Use, FP, 64);1291 inst.visitArg(3, func, Arg.Use, FP, 64);1292 inst.visitArg(4, func, Arg.Use, FP, 64);1293 inst.visitArg(5, func, Arg.Def, FP, 64);1294 break;1295 break;1296 case MoveDoubleConditionallyFloat:1297 inst.visitArg(0, func, Arg.Use, GP, 32);1298 inst.visitArg(1, func, Arg.Use, FP, 32);1299 inst.visitArg(2, func, Arg.Use, FP, 32);1300 inst.visitArg(3, func, Arg.Use, FP, 64);1301 inst.visitArg(4, func, Arg.Use, FP, 64);1302 inst.visitArg(5, func, Arg.Def, FP, 64);1303 break;1304 break;1305 case Jump:1306 break;1307 break;1308 case Ret32:1309 inst.visitArg(0, func, Arg.Use, GP, 32);1310 break;1311 break;1312 case Ret64:1313 inst.visitArg(0, func, Arg.Use, GP, 64);1314 break;1315 break;1316 case RetFloat:1317 inst.visitArg(0, func, Arg.Use, FP, 32);1318 break;1319 break;1320 case RetDouble:1321 inst.visitArg(0, func, Arg.Use, FP, 64);1322 break;1323 break;1324 case Oops:1325 break;1326 break;1327 case Shuffle:1328 ShuffleCustom.forEachArg(inst, func);1329 break;1330 case Patch:1331 PatchCustom.forEachArg(inst, func);1332 break;1333 case CCall:1334 CCallCustom.forEachArg(inst, func);1335 break;1336 case ColdCCall:1337 ColdCCallCustom.forEachArg(inst, func);1338 break;1339 default:1340 throw "Bad opcode";1341 }1342}1343function Inst_hasNonArgEffects(inst)1344{1345 switch (inst.opcode) {1346 case Branch8:1347 case Branch32:1348 case Branch64:1349 case BranchTest8:1350 case BranchTest32:1351 case BranchTest64:1352 case BranchDouble:1353 case BranchFloat:1354 case BranchAdd32:1355 case BranchAdd64:1356 case BranchMul32:1357 case BranchMul64:1358 case BranchSub32:1359 case BranchSub64:1360 case BranchNeg32:1361 case BranchNeg64:1362 case Jump:1363 case Ret32:1364 case Ret64:1365 case RetFloat:1366 case RetDouble:1367 case Oops:1368 return true;1369 case Shuffle:1370 return ShuffleCustom.hasNonArgNonControlEffects(inst);1371 case Patch:1372 return PatchCustom.hasNonArgNonControlEffects(inst);1373 case CCall:1374 return CCallCustom.hasNonArgNonControlEffects(inst);1375 case ColdCCall:1376 return ColdCCallCustom.hasNonArgNonControlEffects(inst);1377 default:1378 return false;1379 }1380}1381function opcodeCode(opcode)1382{1383 switch (opcode) {1384 case AbsDouble:1385 return 01386 case AbsFloat:1387 return 11388 case Add16:1389 return 21390 case Add32:1391 return 31392 case Add64:1393 return 41394 case Add8:1395 return 51396 case AddDouble:1397 return 61398 case AddFloat:1399 return 71400 case And32:1401 return 81402 case And64:1403 return 91404 case AndDouble:1405 return 101406 case AndFloat:1407 return 111408 case Branch32:1409 return 121410 case Branch64:1411 return 131412 case Branch8:1413 return 141414 case BranchAdd32:1415 return 151416 case BranchAdd64:1417 return 161418 case BranchDouble:1419 return 171420 case BranchFloat:1421 return 181422 case BranchMul32:1423 return 191424 case BranchMul64:1425 return 201426 case BranchNeg32:1427 return 211428 case BranchNeg64:1429 return 221430 case BranchSub32:1431 return 231432 case BranchSub64:1433 return 241434 case BranchTest32:1435 return 251436 case BranchTest64:1437 return 261438 case BranchTest8:1439 return 271440 case CCall:1441 return 281442 case CeilDouble:1443 return 291444 case CeilFloat:1445 return 301446 case ColdCCall:1447 return 311448 case Compare32:1449 return 321450 case Compare64:1451 return 331452 case CompareDouble:1453 return 341454 case CompareFloat:1455 return 351456 case ConvertDoubleToFloat:1457 return 361458 case ConvertFloatToDouble:1459 return 371460 case ConvertInt32ToDouble:1461 return 381462 case ConvertInt32ToFloat:1463 return 391464 case ConvertInt64ToDouble:1465 return 401466 case ConvertInt64ToFloat:1467 return 411468 case CountLeadingZeros32:1469 return 421470 case CountLeadingZeros64:1471 return 431472 case Div32:1473 return 441474 case Div64:1475 return 451476 case DivDouble:1477 return 461478 case DivFloat:1479 return 471480 case FloorDouble:1481 return 481482 case FloorFloat:1483 return 491484 case Jump:1485 return 501486 case Lea:1487 return 511488 case Load16:1489 return 521490 case Load16SignedExtendTo32:1491 return 531492 case Load8:1493 return 541494 case Load8SignedExtendTo32:1495 return 551496 case Lshift32:1497 return 561498 case Lshift64:1499 return 571500 case Move:1501 return 581502 case Move32:1503 return 591504 case Move32ToFloat:1505 return 601506 case Move64ToDouble:1507 return 611508 case MoveConditionally32:1509 return 621510 case MoveConditionally64:1511 return 631512 case MoveConditionallyDouble:1513 return 641514 case MoveConditionallyFloat:1515 return 651516 case MoveConditionallyTest32:1517 return 661518 case MoveConditionallyTest64:1519 return 671520 case MoveDouble:1521 return 681522 case MoveDoubleConditionally32:1523 return 691524 case MoveDoubleConditionally64:1525 return 701526 case MoveDoubleConditionallyDouble:1527 return 711528 case MoveDoubleConditionallyFloat:1529 return 721530 case MoveDoubleConditionallyTest32:1531 return 731532 case MoveDoubleConditionallyTest64:1533 return 741534 case MoveDoubleTo64:1535 return 751536 case MoveFloat:1537 return 761538 case MoveFloatTo32:1539 return 771540 case MoveZeroToDouble:1541 return 781542 case Mul32:1543 return 791544 case Mul64:1545 return 801546 case MulDouble:1547 return 811548 case MulFloat:1549 return 821550 case MultiplyAdd32:1551 return 831552 case MultiplyAdd64:1553 return 841554 case MultiplyNeg32:1555 return 851556 case MultiplyNeg64:1557 return 861558 case MultiplySub32:1559 return 871560 case MultiplySub64:1561 return 881562 case Neg32:1563 return 891564 case Neg64:1565 return 901566 case NegateDouble:1567 return 911568 case Nop:1569 return 921570 case Not32:1571 return 931572 case Not64:1573 return 941574 case Oops:1575 return 951576 case Or32:1577 return 961578 case Or64:1579 return 971580 case Patch:1581 return 981582 case Ret32:1583 return 991584 case Ret64:1585 return 1001586 case RetDouble:1587 return 1011588 case RetFloat:1589 return 1021590 case Rshift32:1591 return 1031592 case Rshift64:1593 return 1041594 case Shuffle:1595 return 1051596 case SignExtend16To32:1597 return 1061598 case SignExtend32ToPtr:1599 return 1071600 case SignExtend8To32:1601 return 1081602 case SqrtDouble:1603 return 1091604 case SqrtFloat:1605 return 1101606 case Store16:1607 return 1111608 case Store8:1609 return 1121610 case StoreZero32:1611 return 1131612 case Sub32:1613 return 1141614 case Sub64:1615 return 1151616 case SubDouble:1617 return 1161618 case SubFloat:1619 return 1171620 case Swap32:1621 return 1181622 case Swap64:1623 return 1191624 case Test32:1625 return 1201626 case Test64:1627 return 1211628 case Urshift32:1629 return 1221630 case Urshift64:1631 return 1231632 case X86ConvertToDoubleWord32:1633 return 1241634 case X86ConvertToQuadWord64:1635 return 1251636 case X86Div32:1637 return 1261638 case X86Div64:1639 return 1271640 case Xor32:1641 return 1281642 case Xor64:1643 return 1291644 case XorDouble:1645 return 1301646 case XorFloat:1647 return 1311648 case ZeroExtend16To32:1649 return 1321650 case ZeroExtend8To32:1651 return 1331652 default:1653 throw new Error("bad opcode");1654 }...

Full Screen

Full Screen

basic.js

Source:basic.js Github

copy

Full Screen

1const { LinkError } = WebAssembly;2// ----------------------------------------------------------------------------3// exports4var o = wasmEvalText('(module)').exports;5assertEq(Object.getOwnPropertyNames(o).length, 0);6var o = wasmEvalText('(module (func))').exports;7assertEq(Object.getOwnPropertyNames(o).length, 0);8var o = wasmEvalText('(module (func) (export "a" (func 0)))').exports;9var names = Object.getOwnPropertyNames(o);10assertEq(names.length, 1);11assertEq(names[0], 'a');12var desc = Object.getOwnPropertyDescriptor(o, 'a');13assertEq(typeof desc.value, "function");14assertEq(desc.value.name, "0");15assertEq(desc.value.length, 0);16assertEq(desc.value(), undefined);17assertEq(desc.writable, false);18assertEq(desc.enumerable, true);19assertEq(desc.configurable, false);20assertEq(desc.value(), undefined);21wasmValidateText('(module (func) (func) (export "a" (func 0)))');22wasmValidateText('(module (func) (func) (export "a" (func 1)))');23wasmValidateText('(module (func $a) (func $b) (export "a" (func $a)) (export "b" (func $b)))');24wasmValidateText('(module (func $a) (func $b) (export "a" (func $a)) (export "b" (func $b)))');25wasmFailValidateText('(module (func) (export "a" (func 1)))', /exported function index out of bounds/);26wasmFailValidateText('(module (func) (func) (export "a" (func 2)))', /exported function index out of bounds/);27var o = wasmEvalText('(module (func) (export "a" (func 0)) (export "b" (func 0)))').exports;28assertEq(Object.getOwnPropertyNames(o).sort().toString(), "a,b");29assertEq(o.a.name, "0");30assertEq(o.b.name, "0");31assertEq(o.a === o.b, true);32var o = wasmEvalText('(module (func) (func) (export "a" (func 0)) (export "b" (func 1)))').exports;33assertEq(Object.getOwnPropertyNames(o).sort().toString(), "a,b");34assertEq(o.a.name, "0");35assertEq(o.b.name, "1");36assertEq(o.a === o.b, false);37var o = wasmEvalText('(module (func (result i32) (i32.const 1)) (func (result i32) (i32.const 2)) (export "a" (func 0)) (export "b" (func 1)))').exports;38assertEq(o.a(), 1);39assertEq(o.b(), 2);40var o = wasmEvalText('(module (func (result i32) (i32.const 1)) (func (result i32) (i32.const 2)) (export "a" (func 1)) (export "b" (func 0)))').exports;41assertEq(o.a(), 2);42assertEq(o.b(), 1);43wasmFailValidateText('(module (func) (export "a" (func 0)) (export "a" (func 0)))', /duplicate export/);44wasmFailValidateText('(module (func) (func) (export "a" (func 0)) (export "a" (func 1)))', /duplicate export/);45// ----------------------------------------------------------------------------46// signatures47wasmFailValidateText('(module (func (result i32)))', emptyStackError);48wasmFailValidateText('(module (func (result i32) (nop)))', emptyStackError);49wasmValidateText('(module (func (nop)))');50wasmValidateText('(module (func (result i32) (i32.const 42)))');51wasmValidateText('(module (func (param i32)))');52wasmValidateText('(module (func (param i32) (result i32) (i32.const 42)))');53wasmValidateText('(module (func (param i32) (result i32) (i32.const 42)))');54wasmValidateText('(module (func (param f32)))');55wasmValidateText('(module (func (param f64)))');56wasmFullPassI64('(module (func $run (result i64) (i64.const 123)))', 123);57wasmFullPassI64('(module (func $run (param i64) (result i64) (local.get 0)))',58 '0x123400007fffffff',59 {},60 '(i64.const 0x123400007fffffff)');61wasmFullPassI64('(module (func $run (param i64) (result i64) (i64.add (local.get 0) (i64.const 1))))',62 '0x1234000100000000',63 {},64 '(i64.const 0x12340000ffffffff)');65// ----------------------------------------------------------------------------66// imports67const noImportObj = "second argument must be an object";68assertErrorMessage(() => wasmEvalText('(module (import "a" "b" (func)))', 1), TypeError, noImportObj);69assertErrorMessage(() => wasmEvalText('(module (import "a" "b" (func)))', null), TypeError, noImportObj);70const notObject = /import object field '\w*' is not an Object/;71const notFunction = /import object field '\w*' is not a Function/;72var code = '(module (import "a" "b" (func)))';73assertErrorMessage(() => wasmEvalText(code), TypeError, noImportObj);74assertErrorMessage(() => wasmEvalText(code, {}), TypeError, notObject);75assertErrorMessage(() => wasmEvalText(code, {a:1}), TypeError, notObject);76assertErrorMessage(() => wasmEvalText(code, {a:{}}), LinkError, notFunction);77assertErrorMessage(() => wasmEvalText(code, {a:{b:1}}), LinkError, notFunction);78wasmEvalText(code, {a:{b:()=>{}}});79var code = '(module (import "" "b" (func)))';80wasmEvalText(code, {"":{b:()=>{}}});81var code = '(module (import "a" "" (func)))';82assertErrorMessage(() => wasmEvalText(code), TypeError, noImportObj);83assertErrorMessage(() => wasmEvalText(code, {}), TypeError, notObject);84assertErrorMessage(() => wasmEvalText(code, {a:1}), TypeError, notObject);85wasmEvalText(code, {a:{"":()=>{}}});86var code = '(module (import "a" "" (func)) (import "b" "c" (func)) (import "c" "" (func)))';87assertErrorMessage(() => wasmEvalText(code, {a:()=>{}, b:{c:()=>{}}, c:{}}), LinkError, notFunction);88wasmEvalText(code, {a:{"":()=>{}}, b:{c:()=>{}}, c:{"":()=>{}}});89wasmEvalText('(module (import "a" "" (func (result i32))))', {a:{"":()=>{}}});90wasmEvalText('(module (import "a" "" (func (result f32))))', {a:{"":()=>{}}});91wasmEvalText('(module (import "a" "" (func (result f64))))', {a:{"":()=>{}}});92wasmEvalText('(module (import "a" "" (func $foo (result f64))))', {a:{"":()=>{}}});93// ----------------------------------------------------------------------------94// memory95wasmValidateText('(module (memory 0))');96wasmValidateText('(module (memory 1))');97var buf = wasmEvalText('(module (memory 1) (export "memory" (memory 0)))').exports.memory.buffer;98assertEq(buf instanceof ArrayBuffer, true);99assertEq(buf.byteLength, 65536);100var obj = wasmEvalText('(module (memory 1) (func (result i32) (i32.const 42)) (func (nop)) (export "memory" (memory 0)) (export "b" (func 0)) (export "c" (func 1)))').exports;101assertEq(obj.memory.buffer instanceof ArrayBuffer, true);102assertEq(obj.b instanceof Function, true);103assertEq(obj.c instanceof Function, true);104assertEq(obj.memory.buffer.byteLength, 65536);105assertEq(obj.b(), 42);106assertEq(obj.c(), undefined);107var buf = wasmEvalText('(module (memory 1) (data (i32.const 0) "") (export "memory" (memory 0)))').exports.memory.buffer;108assertEq(new Uint8Array(buf)[0], 0);109var buf = wasmEvalText('(module (memory 1) (data (i32.const 65536) "") (export "memory" (memory 0)))').exports.memory.buffer;110assertEq(new Uint8Array(buf)[0], 0);111var buf = wasmEvalText('(module (memory 1) (data (i32.const 0) "a") (export "memory" (memory 0)))').exports.memory.buffer;112assertEq(new Uint8Array(buf)[0], 'a'.charCodeAt(0));113var buf = wasmEvalText('(module (memory 1) (data (i32.const 0) "a") (data (i32.const 2) "b") (export "memory" (memory 0)))').exports.memory.buffer;114assertEq(new Uint8Array(buf)[0], 'a'.charCodeAt(0));115assertEq(new Uint8Array(buf)[1], 0);116assertEq(new Uint8Array(buf)[2], 'b'.charCodeAt(0));117var buf = wasmEvalText('(module (memory 1) (data (i32.const 65535) "c") (export "memory" (memory 0)))').exports.memory.buffer;118assertEq(new Uint8Array(buf)[0], 0);119assertEq(new Uint8Array(buf)[65535], 'c'.charCodeAt(0));120// ----------------------------------------------------------------------------121// locals122assertEq(wasmEvalText('(module (func (param i32) (result i32) (local.get 0)) (export "" (func 0)))').exports[""](), 0);123assertEq(wasmEvalText('(module (func (param i32) (result i32) (local.get 0)) (export "" (func 0)))').exports[""](42), 42);124assertEq(wasmEvalText('(module (func (param i32) (param i32) (result i32) (local.get 0)) (export "" (func 0)))').exports[""](42, 43), 42);125assertEq(wasmEvalText('(module (func (param i32) (param i32) (result i32) (local.get 1)) (export "" (func 0)))').exports[""](42, 43), 43);126wasmFailValidateText('(module (func (local.get 0)))', /local.get index out of range/);127wasmFailValidateText('(module (func (result f32) (local i32) (local.get 0)))', mismatchError("i32", "f32"));128wasmFailValidateText('(module (func (result i32) (local f32) (local.get 0)))', mismatchError("f32", "i32"));129wasmFailValidateText('(module (func (param i32) (result f32) (local f32) (local.get 0)))', mismatchError("i32", "f32"));130wasmFailValidateText('(module (func (param i32) (result i32) (local f32) (local.get 1)))', mismatchError("f32", "i32"));131wasmValidateText('(module (func (local i32)))');132wasmValidateText('(module (func (local i32) (local f32)))');133wasmFullPass('(module (func (result i32) (local i32) (local.get 0)) (export "run" (func 0)))', 0);134wasmFullPass('(module (func (param i32) (result i32) (local f32) (local.get 0)) (export "run" (func 0)))', 0);135wasmFullPass('(module (func (param i32) (result f32) (local f32) (local.get 1)) (export "run" (func 0)))', 0);136wasmFailValidateText('(module (func (local.set 0 (i32.const 0))))', /local.set index out of range/);137wasmFailValidateText('(module (func (local f32) (local.set 0 (i32.const 0))))', mismatchError("i32", "f32"));138wasmFailValidateText('(module (func (local f32) (local.set 0 (nop))))', emptyStackError);139wasmFailValidateText('(module (func (local i32) (local f32) (local.set 0 (local.get 1))))', mismatchError("f32", "i32"));140wasmFailValidateText('(module (func (local i32) (local f32) (local.set 1 (local.get 0))))', mismatchError("i32", "f32"));141wasmValidateText('(module (func (local i32) (local.set 0 (i32.const 0))))');142wasmValidateText('(module (func (local i32) (local f32) (local.set 0 (local.get 0))))');143wasmValidateText('(module (func (local i32) (local f32) (local.set 1 (local.get 1))))');144wasmFullPass('(module (func (result i32) (local i32) (tee_local 0 (i32.const 42))) (export "run" (func 0)))', 42);145wasmFullPass('(module (func (result i32) (local i32) (tee_local 0 (local.get 0))) (export "run" (func 0)))', 0);146wasmFullPass('(module (func (param $a i32) (result i32) (local.get $a)) (export "run" (func 0)))', 0);147wasmFullPass('(module (func (param $a i32) (result i32) (local $b i32) (block (result i32) (local.set $b (local.get $a)) (local.get $b))) (export "run" (func 0)))', 42, {}, 42);148wasmValidateText('(module (func (local i32) (local $a f32) (local.set 0 (i32.const 1)) (local.set $a (f32.const nan))))');149// ----------------------------------------------------------------------------150// blocks151wasmFullPass('(module (func (block )) (export "run" (func 0)))', undefined);152wasmFailValidateText('(module (func (result i32) (block )))', emptyStackError);153wasmFailValidateText('(module (func (result i32) (block (block ))))', emptyStackError);154wasmFailValidateText('(module (func (local i32) (local.set 0 (block ))))', emptyStackError);155wasmFullPass('(module (func (block (block ))) (export "run" (func 0)))', undefined);156wasmFullPass('(module (func (result i32) (block (result i32) (i32.const 42))) (export "run" (func 0)))', 42);157wasmFullPass('(module (func (result i32) (block (result i32) (block (result i32) (i32.const 42)))) (export "run" (func 0)))', 42);158wasmFailValidateText('(module (func (result f32) (block (result i32) (i32.const 0))))', mismatchError("i32", "f32"));159wasmFullPass('(module (func (result i32) (block (result i32) (drop (i32.const 13)) (block (result i32) (i32.const 42)))) (export "run" (func 0)))', 42);160wasmFailValidateText('(module (func (param f32) (result f32) (block (result i32) (drop (local.get 0)) (i32.const 0))))', mismatchError("i32", "f32"));161wasmFullPass('(module (func (result i32) (local i32) (local.set 0 (i32.const 42)) (local.get 0)) (export "run" (func 0)))', 42);162// ----------------------------------------------------------------------------163// calls164wasmFailValidateText('(module (func (nop)) (func (call 0 (i32.const 0))))', unusedValuesError);165wasmFailValidateText('(module (func (param i32) (nop)) (func (call 0)))', emptyStackError);166wasmFailValidateText('(module (func (param f32) (nop)) (func (call 0 (i32.const 0))))', mismatchError("i32", "f32"));167wasmFailValidateText('(module (func (nop)) (func (call 3)))', /callee index out of range/);168wasmValidateText('(module (func (nop)) (func (call 0)))');169wasmValidateText('(module (func (param i32) (nop)) (func (call 0 (i32.const 0))))');170wasmFullPass('(module (func (result i32) (i32.const 42)) (func (result i32) (call 0)) (export "run" (func 1)))', 42);171assertThrowsInstanceOf(() => wasmEvalText('(module (func (call 0)) (export "" (func 0)))').exports[""](), InternalError);172assertThrowsInstanceOf(() => wasmEvalText('(module (func (call 1)) (func (call 0)) (export "" (func 0)))').exports[""](), InternalError);173wasmValidateText('(module (func (param i32 f32)) (func (call 0 (i32.const 0) (f32.const nan))))');174wasmFailValidateText('(module (func (param i32 f32)) (func (call 0 (i32.const 0) (i32.const 0))))', mismatchError("i32", "f32"));175wasmFailValidateText('(module (import "a" "" (func)) (func (call 0 (i32.const 0))))', unusedValuesError);176wasmFailValidateText('(module (import "a" "" (func (param i32))) (func (call 0)))', emptyStackError);177wasmFailValidateText('(module (import "a" "" (func (param f32))) (func (call 0 (i32.const 0))))', mismatchError("i32", "f32"));178assertErrorMessage(() => wasmEvalText('(module (import "a" "" (func)) (func (call 1)))'), TypeError, noImportObj);179wasmEvalText('(module (import "" "a" (func)) (func (call 0)))', {"":{a:()=>{}}});180wasmEvalText('(module (import "" "a" (func (param i32))) (func (call 0 (i32.const 0))))', {"":{a:()=>{}}});181function checkF32CallImport(v) {182 wasmFullPass('(module (import "" "a" (func (result f32))) (func (result f32) (call 0)) (export "run" (func 1)))',183 Math.fround(v),184 {"":{a:()=>{ return v; }}});185 wasmFullPass('(module (import "" "a" (func (param f32))) (func (param f32) (call 0 (local.get 0))) (export "run" (func 1)))',186 undefined,187 {"":{a:x=>{ assertEq(Math.fround(v), x); }}},188 v);189}190checkF32CallImport(13.37);191checkF32CallImport(NaN);192checkF32CallImport(-Infinity);193checkF32CallImport(-0);194checkF32CallImport(Math.pow(2, 32) - 1);195var counter = 0;196var f = wasmEvalText('(module (import "" "inc" (func)) (func (call 0)) (export "" (func 1)))', {"":{inc:()=>counter++}}).exports[""];197var g = wasmEvalText('(module (import "" "f" (func)) (func (block (call 0) (call 0))) (export "" (func 1)))', {"":{f}}).exports[""];198f();199assertEq(counter, 1);200g();201assertEq(counter, 3);202var f = wasmEvalText('(module (import "" "callf" (func)) (func (call 0)) (export "" (func 1)))', {"":{callf:()=>f()}}).exports[""];203assertThrowsInstanceOf(() => f(), InternalError);204var f = wasmEvalText('(module (import "" "callg" (func)) (func (call 0)) (export "" (func 1)))', {"":{callg:()=>g()}}).exports[""];205var g = wasmEvalText('(module (import "" "callf" (func)) (func (call 0)) (export "" (func 1)))', {"":{callf:()=>f()}}).exports[""];206assertThrowsInstanceOf(() => f(), InternalError);207var code = '(module (import "" "one" (func (result i32))) (import "" "two" (func (result i32))) (func (result i32) (i32.const 3)) (func (result i32) (i32.const 4)) (func (result i32) BODY) (export "run" (func 4)))';208var imports = {"":{one:()=>1, two:()=>2}};209wasmFullPass(code.replace('BODY', '(call 0)'), 1, imports);210wasmFullPass(code.replace('BODY', '(call 1)'), 2, imports);211wasmFullPass(code.replace('BODY', '(call 2)'), 3, imports);212wasmFullPass(code.replace('BODY', '(call 3)'), 4, imports);213wasmFullPass(`(module (import "" "evalcx" (func (param i32) (result i32))) (func (result i32) (call 0 (i32.const 0))) (export "run" (func 1)))`, 0, {"":{evalcx}});214if (typeof evaluate === 'function')215 evaluate(`new WebAssembly.Instance(new WebAssembly.Module(wasmTextToBinary('(module)'))) `, { fileName: null });216wasmFailValidateText(`(module (type $t (func)) (func (call_indirect (type $t) (i32.const 0))))`, /can't call_indirect without a table/);217var {v2i, i2i, i2v} = wasmEvalText(`(module218 (type (func (result i32)))219 (type (func (param i32) (result i32)))220 (type (func (param i32)))221 (func (type 0) (i32.const 13))222 (func (type 0) (i32.const 42))223 (func (type 1) (i32.add (local.get 0) (i32.const 1)))224 (func (type 1) (i32.add (local.get 0) (i32.const 2)))225 (func (type 1) (i32.add (local.get 0) (i32.const 3)))226 (func (type 1) (i32.add (local.get 0) (i32.const 4)))227 (table funcref (elem 0 1 2 3 4 5))228 (func (param i32) (result i32) (call_indirect (type 0) (local.get 0)))229 (func (param i32) (param i32) (result i32) (call_indirect (type 1) (local.get 1) (local.get 0)))230 (func (param i32) (call_indirect (type 2) (i32.const 0) (local.get 0)))231 (export "v2i" (func 6))232 (export "i2i" (func 7))233 (export "i2v" (func 8))234)`).exports;235const signatureMismatch = /indirect call signature mismatch/;236assertEq(v2i(0), 13);237assertEq(v2i(1), 42);238assertErrorMessage(() => v2i(2), Error, signatureMismatch);239assertErrorMessage(() => v2i(3), Error, signatureMismatch);240assertErrorMessage(() => v2i(4), Error, signatureMismatch);241assertErrorMessage(() => v2i(5), Error, signatureMismatch);242assertErrorMessage(() => i2i(0), Error, signatureMismatch);243assertErrorMessage(() => i2i(1), Error, signatureMismatch);244assertEq(i2i(2, 100), 101);245assertEq(i2i(3, 100), 102);246assertEq(i2i(4, 100), 103);247assertEq(i2i(5, 100), 104);248assertErrorMessage(() => i2v(0), Error, signatureMismatch);249assertErrorMessage(() => i2v(1), Error, signatureMismatch);250assertErrorMessage(() => i2v(2), Error, signatureMismatch);251assertErrorMessage(() => i2v(3), Error, signatureMismatch);252assertErrorMessage(() => i2v(4), Error, signatureMismatch);253assertErrorMessage(() => i2v(5), Error, signatureMismatch);254{255 enableGeckoProfiling();256 var stack;257 wasmFullPass(258 `(module259 (type $v2v (func))260 (import "" "f" (func $foo))261 (func $a (call $foo))262 (func $b (result i32) (i32.const 0))263 (table funcref (elem $a $b))264 (func $bar (call_indirect (type $v2v) (i32.const 0)))265 (export "run" (func $bar))266 )`,267 undefined,268 {"":{f:() => { stack = new Error().stack }}}269 );270 disableGeckoProfiling();271 var inner = stack.indexOf("wasm-function[1]");272 var outer = stack.indexOf("wasm-function[3]");273 assertEq(inner === -1, false);274 assertEq(outer === -1, false);275 assertEq(inner < outer, true);276}277for (bad of [6, 7, 100, Math.pow(2,31)-1, Math.pow(2,31), Math.pow(2,31)+1, Math.pow(2,32)-2, Math.pow(2,32)-1]) {278 assertThrowsInstanceOf(() => v2i(bad), WebAssembly.RuntimeError);279 assertThrowsInstanceOf(() => i2i(bad, 0), WebAssembly.RuntimeError);280 assertThrowsInstanceOf(() => i2v(bad, 0), WebAssembly.RuntimeError);281}282wasmValidateText('(module (func $foo (nop)) (func (call $foo)))');283wasmValidateText('(module (func (call $foo)) (func $foo (nop)))');284wasmValidateText('(module (import "" "a" (func $bar)) (func (call $bar)) (func $foo (nop)))');285// ----------------------------------------------------------------------------286// select287wasmFailValidateText('(module (func (select (i32.const 0) (i32.const 0) (f32.const 0))))', mismatchError("f32", "i32"));288wasmFailValidateText('(module (func (select (i32.const 0) (f32.const 0) (i32.const 0))) (export "" (func 0)))', /select operand types must match/);289wasmFailValidateText('(module (func (select (block ) (i32.const 0) (i32.const 0))) (export "" (func 0)))', emptyStackError);290wasmFailValidateText('(module (func (select (return) (i32.const 0) (i32.const 0))) (export "" (func 0)))', unusedValuesError);291assertEq(wasmEvalText('(module (func (drop (select (return) (i32.const 0) (i32.const 0)))) (export "" (func 0)))').exports[""](), undefined);292assertEq(wasmEvalText('(module (func (result i32) (i32.add (i32.const 0) (select (return (i32.const 42)) (i32.const 0) (i32.const 0)))) (export "" (func 0)))').exports[""](), 42);293wasmFailValidateText('(module (func (select (if (result i32) (i32.const 1) (i32.const 0) (f32.const 0)) (i32.const 0) (i32.const 0))) (export "" (func 0)))', mismatchError("f32", "i32"));294wasmFailValidateText('(module (func) (func (select (call 0) (call 0) (i32.const 0))) (export "" (func 0)))', emptyStackError);295(function testSideEffects() {296var numT = 0;297var numF = 0;298var imports = {"": {299 ifTrue: () => 1 + numT++,300 ifFalse: () => -1 + numF++,301}}302// Test that side-effects are applied on both branches.303var f = wasmEvalText(`304(module305 (import "" "ifTrue" (func (result i32)))306 (import "" "ifFalse" (func (result i32)))307 (func (param i32) (result i32)308 (select309 (call 0)310 (call 1)311 (local.get 0)312 )313 )314 (export "" (func 2))315)316`, imports).exports[""];317assertEq(f(-1), numT);318assertEq(numT, 1);319assertEq(numF, 1);320assertEq(f(0), numF - 2);321assertEq(numT, 2);322assertEq(numF, 2);323assertEq(f(1), numT);324assertEq(numT, 3);325assertEq(numF, 3);326assertEq(f(0), numF - 2);327assertEq(numT, 4);328assertEq(numF, 4);329assertEq(f(0), numF - 2);330assertEq(numT, 5);331assertEq(numF, 5);332assertEq(f(1), numT);333assertEq(numT, 6);334assertEq(numF, 6);335})();336function testSelect(type, trueVal, falseVal) {337 var trueJS = jsify(trueVal);338 var falseJS = jsify(falseVal);339 // Always true condition340 var alwaysTrue = wasmEvalText(`341 (module342 (func (param i32) (result ${type})343 (select344 (${type}.const ${trueVal})345 (${type}.const ${falseVal})346 (i32.const 1)347 )348 )349 (export "" (func 0))350 )351 `, imports).exports[""];352 assertEq(alwaysTrue(0), trueJS);353 assertEq(alwaysTrue(1), trueJS);354 assertEq(alwaysTrue(-1), trueJS);355 // Always false condition356 var alwaysFalse = wasmEvalText(`357 (module358 (func (param i32) (result ${type})359 (select360 (${type}.const ${trueVal})361 (${type}.const ${falseVal})362 (i32.const 0)363 )364 )365 (export "" (func 0))366 )367 `, imports).exports[""];368 assertEq(alwaysFalse(0), falseJS);369 assertEq(alwaysFalse(1), falseJS);370 assertEq(alwaysFalse(-1), falseJS);371 // Variable condition372 var f = wasmEvalText(`373 (module374 (func (param i32) (result ${type})375 (select376 (${type}.const ${trueVal})377 (${type}.const ${falseVal})378 (local.get 0)379 )380 )381 (export "" (func 0))382 )383 `, imports).exports[""];384 assertEq(f(0), falseJS);385 assertEq(f(1), trueJS);386 assertEq(f(-1), trueJS);387 wasmFullPass(`388 (module389 (func (param i32) (result ${type})390 (select391 (${type}.const ${trueVal})392 (${type}.const ${falseVal})393 (local.get 0)394 )395 )396 (export "run" (func 0))397 )`,398 trueJS,399 imports,400 1);401}402testSelect('i32', 13, 37);403testSelect('i32', Math.pow(2, 31) - 1, -Math.pow(2, 31));404testSelect('f32', Math.fround(13.37), Math.fround(19.89));405testSelect('f32', 'inf', '-0');406testSelect('f32', 'nan', Math.pow(2, -31));407testSelect('f64', 13.37, 19.89);408testSelect('f64', 'inf', '-0');409testSelect('f64', 'nan', Math.pow(2, -31));410wasmAssert(`411(module412 (func $f (param i32) (result i64)413 (select414 (i64.const 0xc0010ff08badf00d)415 (i64.const 0x12345678deadc0de)416 (local.get 0)417 )418 )419 (export "" (func 0))420)`, [421 { type: 'i64', func: '$f', args: ['i32.const 0'], expected: '0x12345678deadc0de' },422 { type: 'i64', func: '$f', args: ['i32.const 1'], expected: '0xc0010ff08badf00d' },423 { type: 'i64', func: '$f', args: ['i32.const -1'], expected: '0xc0010ff08badf00d' },424], imports);425var exp = wasmEvalText(`(module (func (export "f")))`).exports;...

Full Screen

Full Screen

BasisSet.py

Source:BasisSet.py Github

copy

Full Screen

1import numpy as np2import math3import scipy.special as scm4import copy5import os67def Nrun(basisset):8 # Normalize primitive functions9 for i in range(len(basisset)):10 for j in range(len(basisset[i][5])):11 a = basisset[i][5][j][1]12 l = basisset[i][5][j][3]13 m = basisset[i][5][j][4]14 n = basisset[i][5][j][5]15 16 part1 = (2.0/math.pi)**(3.0/4.0)17 part2 = 2.0**(l+m+n) * a**((2.0*l+2.0*m+2.0*n+3.0)/(4.0))18 part3 = math.sqrt(scm.factorial2(int(2*l-1))*scm.factorial2(int(2*m-1))*scm.factorial2(int(2*n-1)))19 basisset[i][5][j][0] = part1 * ((part2)/(part3))20 """21 # Normalize contractions22 for k in range(len(basisset)):23 if len(basisset[k][5]) != 1:24 l = basisset[k][5][0][3]25 m = basisset[k][5][0][4]26 n = basisset[k][5][0][5]27 L = l+m+n28 factor = (np.pi**(3.0/2.0)*scm.factorial2(int(2*l-1))*scm.factorial2(int(2*m-1))*scm.factorial2(int(2*n-1)))/(2.0**L)29 sum = 030 for i in range(len(basisset[k][5])):31 for j in range(len(basisset[k][5])):32 alphai = basisset[k][5][i][1]33 alphaj = basisset[k][5][j][1]34 ai = basisset[k][5][i][2]*basisset[k][5][i][0]35 aj = basisset[k][5][j][2]*basisset[k][5][j][0]36 37 sum += ai*aj/((alphai+alphaj)**(L+3.0/2.0))38 39 Nc = (factor*sum)**(-1.0/2.0)40 for i in range(len(basisset[k][5])):41 basisset[k][5][i][0] *= Nc42 """43 return basisset4445def bassiset(input, basisname):46 this_file_location = os.path.dirname(os.path.abspath(__file__))47 basisload = np.genfromtxt(this_file_location+"/"+str(basisname)+'.csv', dtype=str, delimiter=';')48 49 basis_out = []50 idx = 151 for i in range(1, len(input)):52 writecheck = 053 firstcheck = 054 typecheck = 055 for j in range(len(basisload)):56 if writecheck == 1:57 if basisload[j,0] == 'S' or basisload[j,0] == 'P' or basisload[j,0] == 'D' or basisload[j,0] == 'F':58 if firstcheck != 0:59 if typecheck == 'S':60 basis_func = np.array(basis_func, dtype=float)61 basis_out.append([idx,input[i,1],input[i,2],input[i,3],len(basis_func),np.ndarray.tolist(np.copy(basis_func)), i])62 idx += 163 elif typecheck == 'P':64 basis_func = np.array(basis_func, dtype=float)65 basis_func[:,3] = 1 66 basis_out.append([idx,input[i,1],input[i,2],input[i,3],len(basis_func),np.ndarray.tolist(np.copy(basis_func)), i])67 basis_func[:,3] = 068 idx += 169 70 basis_func[:,4] = 1 71 basis_out.append([idx,input[i,1],input[i,2],input[i,3],len(basis_func),np.ndarray.tolist(np.copy(basis_func)), i])72 basis_func[:,4] = 073 idx += 174 75 basis_func[:,5] = 1 76 basis_out.append([idx,input[i,1],input[i,2],input[i,3],len(basis_func),np.ndarray.tolist(np.copy(basis_func)), i])77 basis_func[:,5] = 078 idx += 179 elif typecheck == 'D':80 basis_func = np.array(basis_func, dtype=float)81 basis_func[:,3] = 2 82 basis_out.append([idx,input[i,1],input[i,2],input[i,3],len(basis_func),np.ndarray.tolist(np.copy(basis_func)), i])83 basis_func[:,3] = 084 idx += 185 86 basis_func[:,4] = 2 87 basis_out.append([idx,input[i,1],input[i,2],input[i,3],len(basis_func),np.ndarray.tolist(np.copy(basis_func)), i])88 basis_func[:,4] = 089 idx += 190 91 basis_func[:,5] = 292 basis_out.append([idx,input[i,1],input[i,2],input[i,3],len(basis_func),np.ndarray.tolist(np.copy(basis_func)), i])93 basis_func[:,5] = 094 idx += 195 96 basis_func[:,3] = 197 basis_func[:,4] = 198 basis_out.append([idx,input[i,1],input[i,2],input[i,3],len(basis_func),np.ndarray.tolist(np.copy(basis_func)), i])99 basis_func[:,3] = 0100 basis_func[:,4] = 0101 idx += 1102 103 basis_func[:,3] = 1104 basis_func[:,5] = 1105 basis_out.append([idx,input[i,1],input[i,2],input[i,3],len(basis_func),np.ndarray.tolist(np.copy(basis_func)), i])106 basis_func[:,3] = 0107 basis_func[:,5] = 0108 idx += 1109 110 basis_func[:,4] = 1111 basis_func[:,5] = 1112 basis_out.append([idx,input[i,1],input[i,2],input[i,3],len(basis_func),np.ndarray.tolist(np.copy(basis_func)), i])113 basis_func[:,4] = 0114 basis_func[:,5] = 0115 idx += 1116 elif typecheck == 'F':117 basis_func = np.array(basis_func, dtype=float)118 basis_func[:,3] = 3 119 basis_out.append([idx,input[i,1],input[i,2],input[i,3],len(basis_func),np.ndarray.tolist(np.copy(basis_func)), i])120 basis_func[:,3] = 0121 idx += 1122 123 basis_func = np.array(basis_func, dtype=float)124 basis_func[:,4] = 3 125 basis_out.append([idx,input[i,1],input[i,2],input[i,3],len(basis_func),np.ndarray.tolist(np.copy(basis_func)), i])126 basis_func[:,4] = 0127 idx += 1128 129 basis_func = np.array(basis_func, dtype=float)130 basis_func[:,5] = 3 131 basis_out.append([idx,input[i,1],input[i,2],input[i,3],len(basis_func),np.ndarray.tolist(np.copy(basis_func)), i])132 basis_func[:,5] = 0133 idx += 1134 135 basis_func[:,3] = 2136 basis_func[:,4] = 1137 basis_out.append([idx,input[i,1],input[i,2],input[i,3],len(basis_func),np.ndarray.tolist(np.copy(basis_func)), i])138 basis_func[:,3] = 0139 basis_func[:,4] = 0140 idx += 1141 142 basis_func[:,4] = 2143 basis_func[:,5] = 1144 basis_out.append([idx,input[i,1],input[i,2],input[i,3],len(basis_func),np.ndarray.tolist(np.copy(basis_func)), i])145 basis_func[:,4] = 0146 basis_func[:,5] = 0147 idx += 1148 149 basis_func[:,3] = 2150 basis_func[:,5] = 1151 basis_out.append([idx,input[i,1],input[i,2],input[i,3],len(basis_func),np.ndarray.tolist(np.copy(basis_func)), i])152 basis_func[:,3] = 0153 basis_func[:,5] = 0154 idx += 1155 156 basis_func[:,3] = 1157 basis_func[:,4] = 2158 basis_out.append([idx,input[i,1],input[i,2],input[i,3],len(basis_func),np.ndarray.tolist(np.copy(basis_func)), i])159 basis_func[:,3] = 0160 basis_func[:,4] = 0161 idx += 1162 163 basis_func[:,4] = 1164 basis_func[:,5] = 2165 basis_out.append([idx,input[i,1],input[i,2],input[i,3],len(basis_func),np.ndarray.tolist(np.copy(basis_func)), i])166 basis_func[:,4] = 0167 basis_func[:,5] = 0168 idx += 1169 170 basis_func[:,3] = 1171 basis_func[:,5] = 2172 basis_out.append([idx,input[i,1],input[i,2],input[i,3],len(basis_func),np.ndarray.tolist(np.copy(basis_func)), i])173 basis_func[:,3] = 0174 basis_func[:,5] = 0175 idx += 1176 177 basis_func[:,3] = 1178 basis_func[:,4] = 1179 basis_func[:,5] = 1180 basis_out.append([idx,input[i,1],input[i,2],input[i,3],len(basis_func),np.ndarray.tolist(np.copy(basis_func)), i])181 basis_func[:,3] = 0182 basis_func[:,4] = 0183 basis_func[:,5] = 0184 idx += 1185 186 basis_func = []187 typecheck = basisload[j,0]188 firstcheck = 1189 basis_func.append([0,basisload[j,1],basisload[j,2],0,0,0])190 else:191 basis_func.append([0,basisload[j,1],basisload[j,2],0,0,0])192 193 194 if basisload[j+1,0] == 'FOR' and writecheck == 1:195 writecheck = 0196 if typecheck == 'S':197 basis_func = np.array(basis_func, dtype=float)198 basis_out.append([idx,input[i,1],input[i,2],input[i,3],len(basis_func),np.ndarray.tolist(np.copy(basis_func)), i])199 idx += 1200 elif typecheck == 'P':201 basis_func = np.array(basis_func, dtype=float)202 basis_func[:,3] = 1 203 basis_out.append([idx,input[i,1],input[i,2],input[i,3],len(basis_func),np.ndarray.tolist(np.copy(basis_func)), i])204 basis_func[:,3] = 0205 idx += 1206 207 basis_func[:,4] = 1 208 basis_out.append([idx,input[i,1],input[i,2],input[i,3],len(basis_func),np.ndarray.tolist(np.copy(basis_func)), i])209 basis_func[:,4] = 0210 idx += 1211 212 basis_func[:,5] = 1 213 basis_out.append([idx,input[i,1],input[i,2],input[i,3],len(basis_func),np.ndarray.tolist(np.copy(basis_func)), i])214 basis_func[:,5] = 0215 idx += 1216 elif typecheck == 'D':217 basis_func = np.array(basis_func, dtype=float)218 basis_func[:,3] = 2 219 basis_out.append([idx,input[i,1],input[i,2],input[i,3],len(basis_func),np.ndarray.tolist(np.copy(basis_func)), i])220 basis_func[:,3] = 0221 idx += 1222 223 basis_func[:,4] = 2 224 basis_out.append([idx,input[i,1],input[i,2],input[i,3],len(basis_func),np.ndarray.tolist(np.copy(basis_func)), i])225 basis_func[:,4] = 0226 idx += 1227 228 basis_func[:,5] = 2229 basis_out.append([idx,input[i,1],input[i,2],input[i,3],len(basis_func),np.ndarray.tolist(np.copy(basis_func)), i])230 basis_func[:,5] = 0231 idx += 1232 233 basis_func[:,3] = 1234 basis_func[:,4] = 1235 basis_out.append([idx,input[i,1],input[i,2],input[i,3],len(basis_func),np.ndarray.tolist(np.copy(basis_func)), i])236 basis_func[:,3] = 0237 basis_func[:,4] = 0238 idx += 1239 240 basis_func[:,3] = 1241 basis_func[:,5] = 1242 basis_out.append([idx,input[i,1],input[i,2],input[i,3],len(basis_func),np.ndarray.tolist(np.copy(basis_func)), i])243 basis_func[:,3] = 0244 basis_func[:,5] = 0245 idx += 1246 247 basis_func[:,4] = 1248 basis_func[:,5] = 1249 basis_out.append([idx,input[i,1],input[i,2],input[i,3],len(basis_func),np.ndarray.tolist(np.copy(basis_func)), i])250 basis_func[:,4] = 0251 basis_func[:,5] = 0252 idx += 1253 elif typecheck == 'F':254 basis_func = np.array(basis_func, dtype=float)255 basis_func[:,3] = 3 256 basis_out.append([idx,input[i,1],input[i,2],input[i,3],len(basis_func),np.ndarray.tolist(np.copy(basis_func)), i])257 basis_func[:,3] = 0258 idx += 1259 260 basis_func = np.array(basis_func, dtype=float)261 basis_func[:,4] = 3 262 basis_out.append([idx,input[i,1],input[i,2],input[i,3],len(basis_func),np.ndarray.tolist(np.copy(basis_func)), i])263 basis_func[:,4] = 0264 idx += 1265 266 basis_func = np.array(basis_func, dtype=float)267 basis_func[:,5] = 3 268 basis_out.append([idx,input[i,1],input[i,2],input[i,3],len(basis_func),np.ndarray.tolist(np.copy(basis_func)), i])269 basis_func[:,5] = 0270 idx += 1271 272 basis_func[:,3] = 2273 basis_func[:,4] = 1274 basis_out.append([idx,input[i,1],input[i,2],input[i,3],len(basis_func),np.ndarray.tolist(np.copy(basis_func)), i])275 basis_func[:,3] = 0276 basis_func[:,4] = 0277 idx += 1278 279 basis_func[:,4] = 2280 basis_func[:,5] = 1281 basis_out.append([idx,input[i,1],input[i,2],input[i,3],len(basis_func),np.ndarray.tolist(np.copy(basis_func)), i])282 basis_func[:,4] = 0283 basis_func[:,5] = 0284 idx += 1285 286 basis_func[:,3] = 2287 basis_func[:,5] = 1288 basis_out.append([idx,input[i,1],input[i,2],input[i,3],len(basis_func),np.ndarray.tolist(np.copy(basis_func)), i])289 basis_func[:,3] = 0290 basis_func[:,5] = 0291 idx += 1292 293 basis_func[:,3] = 1294 basis_func[:,4] = 2295 basis_out.append([idx,input[i,1],input[i,2],input[i,3],len(basis_func),np.ndarray.tolist(np.copy(basis_func)), i])296 basis_func[:,3] = 0297 basis_func[:,4] = 0298 idx += 1299 300 basis_func[:,4] = 1301 basis_func[:,5] = 2302 basis_out.append([idx,input[i,1],input[i,2],input[i,3],len(basis_func),np.ndarray.tolist(np.copy(basis_func)), i])303 basis_func[:,4] = 0304 basis_func[:,5] = 0305 idx += 1306 307 basis_func[:,3] = 1308 basis_func[:,5] = 2309 basis_out.append([idx,input[i,1],input[i,2],input[i,3],len(basis_func),np.ndarray.tolist(np.copy(basis_func)), i])310 basis_func[:,3] = 0311 basis_func[:,5] = 0312 idx += 1313 314 basis_func[:,3] = 1315 basis_func[:,4] = 1316 basis_func[:,5] = 1317 basis_out.append([idx,input[i,1],input[i,2],input[i,3],len(basis_func),np.ndarray.tolist(np.copy(basis_func)), i])318 basis_func[:,3] = 0319 basis_func[:,4] = 0320 basis_func[:,5] = 0321 idx += 1322 break323 324 if basisload[j,1] == 'H' and input[i,0] == 1:325 writecheck = 1326 elif basisload[j,1] == 'He' and input[i,0] == 2:327 writecheck = 1328 elif basisload[j,1] == 'Li' and input[i,0] == 3:329 writecheck = 1330 elif basisload[j,1] == 'Be' and input[i,0] == 4:331 writecheck = 1332 elif basisload[j,1] == 'B' and input[i,0] == 5:333 writecheck = 1334 elif basisload[j,1] == 'C' and input[i,0] == 6:335 writecheck = 1336 elif basisload[j,1] == 'N' and input[i,0] == 7:337 writecheck = 1338 elif basisload[j,1] == 'O' and input[i,0] == 8:339 writecheck = 1340 elif basisload[j,1] == 'F' and input[i,0] == 9:341 writecheck = 1342 elif basisload[j,1] == 'Ne' and input[i,0] == 10:343 writecheck = 1344 elif basisload[j,1] == 'Na' and input[i,0] == 11:345 writecheck = 1346 elif basisload[j,1] == 'Mg' and input[i,0] == 12:347 writecheck = 1348 elif basisload[j,1] == 'Al' and input[i,0] == 13:349 writecheck = 1350 elif basisload[j,1] == 'Si' and input[i,0] == 14:351 writecheck = 1352 elif basisload[j,1] == 'P' and input[i,0] == 15:353 writecheck = 1354 elif basisload[j,1] == 'S' and input[i,0] == 16:355 writecheck = 1356 elif basisload[j,1] == 'Cl' and input[i,0] == 17:357 writecheck = 1358 elif basisload[j,1] == 'Ar' and input[i,0] == 18:359 writecheck = 1360 elif basisload[j,1] == 'K' and input[i,0] == 19:361 writecheck = 1362 elif basisload[j,1] == 'Ca' and input[i,0] == 20:363 writecheck = 1364365 for i in range(len(basis_out)):366 for j in range(len(basis_out[i][5])):367 basis_out[i][5][j][3] = int(basis_out[i][5][j][3])368 basis_out[i][5][j][4] = int(basis_out[i][5][j][4])369 basis_out[i][5][j][5] = int(basis_out[i][5][j][5])370371 basis_out = Nrun(basis_out)372 ...

Full Screen

Full Screen

_baseConvert.js

Source:_baseConvert.js Github

copy

Full Screen

...26 * @returns {Function} Returns the new function.27 */28function baseAry(func, n) {29 return n == 230 ? function(a, b) { return func(a, b); }31 : function(a) { return func(a); };32}33/**34 * Creates a clone of `array`.35 *36 * @private37 * @param {Array} array The array to clone.38 * @returns {Array} Returns the cloned array.39 */40function cloneArray(array) {41 var length = array ? array.length : 0,42 result = Array(length);43 while (length--) {44 result[length] = array[length];45 }46 return result;47}48/**49 * Creates a function that clones a given object using the assignment `func`.50 *51 * @private52 * @param {Function} func The assignment function.53 * @returns {Function} Returns the new cloner function.54 */55function createCloner(func) {56 return function(object) {57 return func({}, object);58 };59}60/**61 * A specialized version of `_.spread` which flattens the spread array into62 * the arguments of the invoked `func`.63 *64 * @private65 * @param {Function} func The function to spread arguments over.66 * @param {number} start The start position of the spread.67 * @returns {Function} Returns the new function.68 */69function flatSpread(func, start) {70 return function() {71 var length = arguments.length,72 lastIndex = length - 1,73 args = Array(length);74 while (length--) {75 args[length] = arguments[length];76 }77 var array = args[start],78 otherArgs = args.slice(0, start);79 if (array) {80 push.apply(otherArgs, array);81 }82 if (start != lastIndex) {83 push.apply(otherArgs, args.slice(start + 1));84 }85 return func.apply(this, otherArgs);86 };87}88/**89 * Creates a function that wraps `func` and uses `cloner` to clone the first90 * argument it receives.91 *92 * @private93 * @param {Function} func The function to wrap.94 * @param {Function} cloner The function to clone arguments.95 * @returns {Function} Returns the new immutable function.96 */97function wrapImmutable(func, cloner) {98 return function() {99 var length = arguments.length;100 if (!length) {101 return;102 }103 var args = Array(length);104 while (length--) {105 args[length] = arguments[length];106 }107 var result = args[0] = cloner.apply(undefined, args);108 func.apply(undefined, args);109 return result;110 };111}112/**113 * The base implementation of `convert` which accepts a `util` object of methods114 * required to perform conversions.115 *116 * @param {Object} util The util object.117 * @param {string} name The name of the function to convert.118 * @param {Function} func The function to convert.119 * @param {Object} [options] The options object.120 * @param {boolean} [options.cap=true] Specify capping iteratee arguments.121 * @param {boolean} [options.curry=true] Specify currying.122 * @param {boolean} [options.fixed=true] Specify fixed arity.123 * @param {boolean} [options.immutable=true] Specify immutable operations.124 * @param {boolean} [options.rearg=true] Specify rearranging arguments.125 * @returns {Function|Object} Returns the converted function or object.126 */127function baseConvert(util, name, func, options) {128 var isLib = typeof name == 'function',129 isObj = name === Object(name);130 if (isObj) {131 options = func;132 func = name;133 name = undefined;134 }135 if (func == null) {136 throw new TypeError;137 }138 options || (options = {});139 var config = {140 'cap': 'cap' in options ? options.cap : true,141 'curry': 'curry' in options ? options.curry : true,142 'fixed': 'fixed' in options ? options.fixed : true,143 'immutable': 'immutable' in options ? options.immutable : true,144 'rearg': 'rearg' in options ? options.rearg : true145 };146 var defaultHolder = isLib ? func : fallbackHolder,147 forceCurry = ('curry' in options) && options.curry,148 forceFixed = ('fixed' in options) && options.fixed,149 forceRearg = ('rearg' in options) && options.rearg,150 pristine = isLib ? func.runInContext() : undefined;151 var helpers = isLib ? func : {152 'ary': util.ary,153 'assign': util.assign,154 'clone': util.clone,155 'curry': util.curry,156 'forEach': util.forEach,157 'isArray': util.isArray,158 'isError': util.isError,159 'isFunction': util.isFunction,160 'isWeakMap': util.isWeakMap,161 'iteratee': util.iteratee,162 'keys': util.keys,163 'rearg': util.rearg,164 'toInteger': util.toInteger,165 'toPath': util.toPath166 };167 var ary = helpers.ary,168 assign = helpers.assign,169 clone = helpers.clone,170 curry = helpers.curry,171 each = helpers.forEach,172 isArray = helpers.isArray,173 isError = helpers.isError,174 isFunction = helpers.isFunction,175 isWeakMap = helpers.isWeakMap,176 keys = helpers.keys,177 rearg = helpers.rearg,178 toInteger = helpers.toInteger,179 toPath = helpers.toPath;180 var aryMethodKeys = keys(mapping.aryMethod);181 var wrappers = {182 'castArray': function(castArray) {183 return function() {184 var value = arguments[0];185 return isArray(value)186 ? castArray(cloneArray(value))187 : castArray.apply(undefined, arguments);188 };189 },190 'iteratee': function(iteratee) {191 return function() {192 var func = arguments[0],193 arity = arguments[1],194 result = iteratee(func, arity),195 length = result.length;196 if (config.cap && typeof arity == 'number') {197 arity = arity > 2 ? (arity - 2) : 1;198 return (length && length <= arity) ? result : baseAry(result, arity);199 }200 return result;201 };202 },203 'mixin': function(mixin) {204 return function(source) {205 var func = this;206 if (!isFunction(func)) {207 return mixin(func, Object(source));208 }209 var pairs = [];210 each(keys(source), function(key) {211 if (isFunction(source[key])) {212 pairs.push([key, func.prototype[key]]);213 }214 });215 mixin(func, Object(source));216 each(pairs, function(pair) {217 var value = pair[1];218 if (isFunction(value)) {219 func.prototype[pair[0]] = value;220 } else {221 delete func.prototype[pair[0]];222 }223 });224 return func;225 };226 },227 'nthArg': function(nthArg) {228 return function(n) {229 var arity = n < 0 ? 1 : (toInteger(n) + 1);230 return curry(nthArg(n), arity);231 };232 },233 'rearg': function(rearg) {234 return function(func, indexes) {235 var arity = indexes ? indexes.length : 0;236 return curry(rearg(func, indexes), arity);237 };238 },239 'runInContext': function(runInContext) {240 return function(context) {241 return baseConvert(util, runInContext(context), options);242 };243 }244 };245 /*--------------------------------------------------------------------------*/246 /**247 * Casts `func` to a function with an arity capped iteratee if needed.248 *249 * @private250 * @param {string} name The name of the function to inspect.251 * @param {Function} func The function to inspect.252 * @returns {Function} Returns the cast function.253 */254 function castCap(name, func) {255 if (config.cap) {256 var indexes = mapping.iterateeRearg[name];257 if (indexes) {258 return iterateeRearg(func, indexes);259 }260 var n = !isLib && mapping.iterateeAry[name];261 if (n) {262 return iterateeAry(func, n);263 }264 }265 return func;266 }267 /**268 * Casts `func` to a curried function if needed.269 *270 * @private271 * @param {string} name The name of the function to inspect.272 * @param {Function} func The function to inspect.273 * @param {number} n The arity of `func`.274 * @returns {Function} Returns the cast function.275 */276 function castCurry(name, func, n) {277 return (forceCurry || (config.curry && n > 1))278 ? curry(func, n)279 : func;280 }281 /**282 * Casts `func` to a fixed arity function if needed.283 *284 * @private285 * @param {string} name The name of the function to inspect.286 * @param {Function} func The function to inspect.287 * @param {number} n The arity cap.288 * @returns {Function} Returns the cast function.289 */290 function castFixed(name, func, n) {291 if (config.fixed && (forceFixed || !mapping.skipFixed[name])) {292 var data = mapping.methodSpread[name],293 start = data && data.start;294 return start === undefined ? ary(func, n) : flatSpread(func, start);295 }296 return func;297 }298 /**299 * Casts `func` to an rearged function if needed.300 *301 * @private302 * @param {string} name The name of the function to inspect.303 * @param {Function} func The function to inspect.304 * @param {number} n The arity of `func`.305 * @returns {Function} Returns the cast function.306 */307 function castRearg(name, func, n) {308 return (config.rearg && n > 1 && (forceRearg || !mapping.skipRearg[name]))309 ? rearg(func, mapping.methodRearg[name] || mapping.aryRearg[n])310 : func;311 }312 /**313 * Creates a clone of `object` by `path`.314 *315 * @private316 * @param {Object} object The object to clone.317 * @param {Array|string} path The path to clone by.318 * @returns {Object} Returns the cloned object.319 */320 function cloneByPath(object, path) {321 path = toPath(path);322 var index = -1,323 length = path.length,324 lastIndex = length - 1,325 result = clone(Object(object)),326 nested = result;327 while (nested != null && ++index < length) {328 var key = path[index],329 value = nested[key];330 if (value != null &&331 !(isFunction(value) || isError(value) || isWeakMap(value))) {332 nested[key] = clone(index == lastIndex ? value : Object(value));333 }334 nested = nested[key];335 }336 return result;337 }338 /**339 * Converts `lodash` to an immutable auto-curried iteratee-first data-last340 * version with conversion `options` applied.341 *342 * @param {Object} [options] The options object. See `baseConvert` for more details.343 * @returns {Function} Returns the converted `lodash`.344 */345 function convertLib(options) {346 return _.runInContext.convert(options)(undefined);347 }348 /**349 * Create a converter function for `func` of `name`.350 *351 * @param {string} name The name of the function to convert.352 * @param {Function} func The function to convert.353 * @returns {Function} Returns the new converter function.354 */355 function createConverter(name, func) {356 var realName = mapping.aliasToReal[name] || name,357 methodName = mapping.remap[realName] || realName,358 oldOptions = options;359 return function(options) {360 var newUtil = isLib ? pristine : helpers,361 newFunc = isLib ? pristine[methodName] : func,362 newOptions = assign(assign({}, oldOptions), options);363 return baseConvert(newUtil, realName, newFunc, newOptions);364 };365 }366 /**367 * Creates a function that wraps `func` to invoke its iteratee, with up to `n`368 * arguments, ignoring any additional arguments.369 *370 * @private371 * @param {Function} func The function to cap iteratee arguments for.372 * @param {number} n The arity cap.373 * @returns {Function} Returns the new function.374 */375 function iterateeAry(func, n) {376 return overArg(func, function(func) {377 return typeof func == 'function' ? baseAry(func, n) : func;378 });379 }380 /**381 * Creates a function that wraps `func` to invoke its iteratee with arguments382 * arranged according to the specified `indexes` where the argument value at383 * the first index is provided as the first argument, the argument value at384 * the second index is provided as the second argument, and so on.385 *386 * @private387 * @param {Function} func The function to rearrange iteratee arguments for.388 * @param {number[]} indexes The arranged argument indexes.389 * @returns {Function} Returns the new function.390 */391 function iterateeRearg(func, indexes) {392 return overArg(func, function(func) {393 var n = indexes.length;394 return baseArity(rearg(baseAry(func, n), indexes), n);395 });396 }397 /**398 * Creates a function that invokes `func` with its first argument transformed.399 *400 * @private401 * @param {Function} func The function to wrap.402 * @param {Function} transform The argument transform.403 * @returns {Function} Returns the new function.404 */405 function overArg(func, transform) {406 return function() {407 var length = arguments.length;408 if (!length) {409 return func();410 }411 var args = Array(length);412 while (length--) {413 args[length] = arguments[length];414 }415 var index = config.rearg ? 0 : (length - 1);416 args[index] = transform(args[index]);417 return func.apply(undefined, args);418 };419 }420 /**421 * Creates a function that wraps `func` and applys the conversions422 * rules by `name`.423 *...

Full Screen

Full Screen

webGLClient.js

Source:webGLClient.js Github

copy

Full Screen

...263 //dump('issuing commands, buffer len: ' + len + '\n');264 while (i < len) {265 var info = calls[buffer[i++]];266 var name = info.name;267 info.func(name);268 //var err;269 //while ((err = ctx.getError()) !== ctx.NO_ERROR) {270 // dump('warning: GL error ' + err + ', after ' + [command, numArgs] + '\n');271 //}272 assert(i <= len);273 }274 }275 var commandBuffers = [];276 function renderAllCommands() {277 // we can skip parts of the frames before the last, as we just need their side effects278 skippable = true;279 for (var i = 0; i < commandBuffers.length-1; i++) {280 renderCommands(commandBuffers[i]);281 }...

Full Screen

Full Screen

oneplay.py

Source:oneplay.py Github

copy

Full Screen

1## ONLY FOR NOOBS :D2##CONVERSION OF following encryption by shani into python3## only decryption function is implemented4'''5 * jQuery JavaScript Library v1.4.26 * http://jquery.com/7 *8 * Copyright 2010, John Resig9 * Dual licensed under the MIT or GPL Version 2 licenses.10 * http://jquery.org/license11 *12 * Includes Sizzle.js13 * http://sizzlejs.com/14 * Copyright 2010, The Dojo Foundation15 * Released under the MIT, BSD, and GPL Licenses.16 *17 * Date: Sat Feb 13 22:33:48 2010 -050018 '''19import urllib20import base6421import re,urllib2,cookielib22def decode(r):23 e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"24 r = r.replace("\n", "");25 f = []26 c = [0,0,0,0]27 t = [0,0,0];28# print 'rrrrrrrrrrrrrrrrrrrrrrrr',r29 for n in range(0 ,len(r),4):30 c[0]=-131 try:32 c[0] = e.index(r[n]);33 except:pass34 c[1]=-135 try:36 c[1] = e.index(r[n + 1])37 except:pass38 c[2]=-139 try:40 c[2] = e.index(r[n + 2]);41 except:pass42 c[3]=-143 try:44 c[3] = e.index(r[n + 3])45 except:pass46 t[0] = c[0] << 2 | c[1] >> 447 t[1] = (15 & c[1]) << 4 | c[2] >> 248 t[2] = (3 & c[2]) << 6 | c[3]49 f+=[t[0], t[1], t[2]];50# print f51# print f[0:10]52 return f[0: len(f) - (len(f) % 16)]53'''54def fun_e:55 return unescape(encodeURIComponent(e))56 } catch (r) {57 throw "Error utf"58 }59''' 60def func_u(e):61 c = [];62 #if decode:63# print 'basssssssssssssssssssssss', base64.decode(e)64# return 65# e= urllib.unquote(base64.decode(e))66 for n in range(0, len(e)):67 c.append(ord(e[n]));68 return c69def fun_A(e, r):70 n=0;71 f = [None]*(len(e) / r);72 for n in range(0, len(e),r):73 f[n / r] = int(e[n:n+r], 16);74 return f 75 76'''L inner functions 77'''78def func_L_r(e, r):79 return e << r | e >> 32 - r ##change>>>80def func_L_n(e, r):81 c = 2147483648 & e82 t = 2147483648 & r83 n = 1073741824 & e 84 f = 1073741824 & r 85 a = (1073741823 & e) + (1073741823 & r)86 return (2147483648 ^ a ^ c ^ t) if n & f else ( (3221225472 ^ a ^ c ^ t if 1073741824 & a else 1073741824 ^ a ^ c ^ t ) if n | f else a ^ c ^ t)87 88def func_L_f(e, r, n):89 return e & r | ~e & n90def func_L_c(e, r, n):91 return e & n | r & ~n92def func_L_t(e, r, n):93 return e ^ r ^ n94 95def func_L_a(e, r, n):96 return r ^ (e | ~n)97def func_L_o(e, c, t, a, o, d, u):98 e = func_L_n(e, func_L_n(func_L_n(func_L_f(c, t, a), o), u))99 return func_L_n(func_L_r(e, d), c)100def func_L_d(e, f, t, a, o, d, u):101 e = func_L_n(e, func_L_n(func_L_n(func_L_c(f, t, a), o), u))102 return func_L_n(func_L_r(e, d), f)103 104def func_L_u(e, f, c, a, o, d, u):105 e = func_L_n(e, func_L_n(func_L_n(func_L_t(f, c, a), o), u))106 return func_L_n(func_L_r(e, d), f)107def func_L_i(e, f, c, t, o, d, u):108 e = func_L_n(e, func_L_n(func_L_n(func_L_a(f, c, t), o), u))109 return func_L_n(func_L_r(e, d), f)110def func_L_b(e):111 112 n = len(e)113 f = n + 8114 c = (f - f % 64) / 64115 t = 16 * (c + 1)116 a = [0]*(n+1)117 o = 0; d = 0118 119# for (var r, n = e.length, f = n + 8, c = (f - f % 64) / 64, t = 16 * (c + 1), a = [], o = 0, d = 0; n > d;) r = (d - d % 4) / 4, o = 8 * (d % 4), 120 for d in range(0,n):121 r = (d - d % 4) / 4; 122 o = 8 * (d % 4); 123 #print a[r]124 #print e[d]125 a[r] = a[r] | e[d] << o126 d+=1127# print a, d,n128 r = (d - d % 4) / 4129 o = 8 * (d % 4)130 a[r] = a[r] | 128 << o131 a[t - 2] = n << 3132# print 'tttttttttttttttttt',t133# print 'len a',len(a)134 try:135 a[t - 1] = n >> 29# >>> removed136 except: pass137 return a138def func_L_h(e):139 f = [];140 for n in range(0,4):141 r = 255 & e >> 8 * n #>>> removed142 f.append(r)143 return f144 145def func_L(e):146 l=0147 v=0148 S = [];149 m = fun_A("67452301efcdab8998badcfe10325476d76aa478e8c7b756242070dbc1bdceeef57c0faf4787c62aa8304613fd469501698098d88b44f7afffff5bb1895cd7be6b901122fd987193a679438e49b40821f61e2562c040b340265e5a51e9b6c7aad62f105d02441453d8a1e681e7d3fbc821e1cde6c33707d6f4d50d87455a14eda9e3e905fcefa3f8676f02d98d2a4c8afffa39428771f6816d9d6122fde5380ca4beea444bdecfa9f6bb4b60bebfbc70289b7ec6eaa127fad4ef308504881d05d9d4d039e6db99e51fa27cf8c4ac5665f4292244432aff97ab9423a7fc93a039655b59c38f0ccc92ffeff47d85845dd16fa87e4ffe2ce6e0a30143144e0811a1f7537e82bd3af2352ad7d2bbeb86d391", 8);150# print m151# print 'eeeeeeeeeeeeeeeeeeeeee',e152 S = func_L_b(e); 153# print 'S is ',S154 155 y = m[0]; k = m[1]; M = m[2]; x = m[3]156 for l in range(0, len(S),16):157 v = y; s = k; p = M; g = x;158 y = func_L_o(y, k, M, x, S[l + 0], 7, m[4])159 x = func_L_o(x, y, k, M, S[l + 1], 12, m[5])160 M = func_L_o(M, x, y, k, S[l + 2], 17, m[6])161 k = func_L_o(k, M, x, y, S[l + 3], 22, m[7])162 y = func_L_o(y, k, M, x, S[l + 4], 7, m[8])163 x = func_L_o(x, y, k, M, S[l + 5], 12, m[9])164 M = func_L_o(M, x, y, k, S[l + 6], 17, m[10])165 k = func_L_o(k, M, x, y, S[l + 7], 22, m[11])166 y = func_L_o(y, k, M, x, S[l + 8], 7, m[12])167 x = func_L_o(x, y, k, M, S[l + 9], 12, m[13])168 M = func_L_o(M, x, y, k, S[l + 10], 17, m[14])169 k = func_L_o(k, M, x, y, S[l + 11], 22, m[15])170 y = func_L_o(y, k, M, x, S[l + 12], 7, m[16])171 x = func_L_o(x, y, k, M, S[l + 13], 12, m[17])172 M = func_L_o(M, x, y, k, S[l + 14], 17, m[18])173 k = func_L_o(k, M, x, y, S[l + 15], 22, m[19])174 y = func_L_d(y, k, M, x, S[l + 1], 5, m[20])175 x = func_L_d(x, y, k, M, S[l + 6], 9, m[21])176 M = func_L_d(M, x, y, k, S[l + 11], 14, m[22])177 k = func_L_d(k, M, x, y, S[l + 0], 20, m[23])178 y = func_L_d(y, k, M, x, S[l + 5], 5, m[24])179 x = func_L_d(x, y, k, M, S[l + 10], 9, m[25])180 M = func_L_d(M, x, y, k, S[l + 15], 14, m[26])181 k = func_L_d(k, M, x, y, S[l + 4], 20, m[27])182 y = func_L_d(y, k, M, x, S[l + 9], 5, m[28])183 x = func_L_d(x, y, k, M, S[l + 14], 9, m[29])184 M = func_L_d(M, x, y, k, S[l + 3], 14, m[30])185 k = func_L_d(k, M, x, y, S[l + 8], 20, m[31])186 y = func_L_d(y, k, M, x, S[l + 13], 5, m[32])187 x = func_L_d(x, y, k, M, S[l + 2], 9, m[33])188 M = func_L_d(M, x, y, k, S[l + 7], 14, m[34])189 k = func_L_d(k, M, x, y, S[l + 12], 20, m[35])190 y = func_L_u(y, k, M, x, S[l + 5], 4, m[36])191 x = func_L_u(x, y, k, M, S[l + 8], 11, m[37])192 M = func_L_u(M, x, y, k, S[l + 11], 16, m[38])193 k = func_L_u(k, M, x, y, S[l + 14], 23, m[39])194 y = func_L_u(y, k, M, x, S[l + 1], 4, m[40])195 x = func_L_u(x, y, k, M, S[l + 4], 11, m[41])196 M = func_L_u(M, x, y, k, S[l + 7], 16, m[42])197 k = func_L_u(k, M, x, y, S[l + 10], 23, m[43])198 y = func_L_u(y, k, M, x, S[l + 13], 4, m[44])199 x = func_L_u(x, y, k, M, S[l + 0], 11, m[45])200 M = func_L_u(M, x, y, k, S[l + 3], 16, m[46])201 k = func_L_u(k, M, x, y, S[l + 6], 23, m[47])202 y = func_L_u(y, k, M, x, S[l + 9], 4, m[48])203 x = func_L_u(x, y, k, M, S[l + 12], 11, m[49])204 M = func_L_u(M, x, y, k, S[l + 15], 16, m[50])205 k = func_L_u(k, M, x, y, S[l + 2], 23, m[51])206 y = func_L_i(y, k, M, x, S[l + 0], 6, m[52])207 x = func_L_i(x, y, k, M, S[l + 7], 10, m[53])208 M = func_L_i(M, x, y, k, S[l + 14], 15, m[54])209 k = func_L_i(k, M, x, y, S[l + 5], 21, m[55])210 y = func_L_i(y, k, M, x, S[l + 12], 6, m[56])211 x = func_L_i(x, y, k, M, S[l + 3], 10, m[57])212 M = func_L_i(M, x, y, k, S[l + 10], 15, m[58])213 k = func_L_i(k, M, x, y, S[l + 1], 21, m[59])214 y = func_L_i(y, k, M, x, S[l + 8], 6, m[60])215 x = func_L_i(x, y, k, M, S[l + 15], 10, m[61])216 M = func_L_i(M, x, y, k, S[l + 6], 15, m[62])217 k = func_L_i(k, M, x, y, S[l + 13], 21, m[63])218 y = func_L_i(y, k, M, x, S[l + 4], 6, m[64])219 x = func_L_i(x, y, k, M, S[l + 11], 10, m[65])220 M = func_L_i(M, x, y, k, S[l + 2], 15, m[66])221 k = func_L_i(k, M, x, y, S[l + 9], 21, m[67])222 y = func_L_n(y, v)223 k = func_L_n(k, s)224 M = func_L_n(M, p)225 x = func_L_n(x, g)226# print 'y is ' ,y,func_L_h(y)227 return func_L_h(y)+func_L_h(k)+ func_L_h(M)+func_L_h(x)228 229def func_h(n, f):230 c=0231 e = 14232 r = 8233 t = 3 if e >= 12 else 2234 a = []235 o = []236 d = [None]*t237 u = [],238 i = n+ f;239# print 'n is',n240# print 'f is',f241# print 'i is',i242# print 'func_L(i)'243 #print func_L(i)244 #return '',''245 d[0] = func_L(i)246 247# print 'dddddddddddddddd',d248 u = d[0] 249# print 'uuuuuuuuuuuuuuuu',u250 #print u251 for c in range(1,t):252 d[c] = func_L( d[c - 1]+i ) 253 u+=(d[c])254# print u255 a = u[0: 4 * r]256 o = u[4 * r: 4 * r + 16]257 return a,o258def decrypt(val,key): 259 f= decode(val);260 c=f[8:16]261 k=func_u(key);262 263 a,o= func_h(k, c)264# print 'aaaaaaaaaaaaaaaaa is ',a265# print 'oooooooooooooooo is ',o266 267 #print c268 f=f[16:]269 key=a270 iv=o271 # print len(key)272 key2=""273 for k in range(0,len(key)):274 key2+=chr(key[k])275 iv2=""276 for k in range(0,len(iv)):277 iv2+=chr(iv[k])278 f2="" 279 for k in range(0,len(f)):280 f2+=chr(f[k])281 282 283 import pyaes284 decryptor = pyaes.new(key2, pyaes.MODE_CBC, IV=iv2)285 return decryptor.decrypt(f).replace('\x00', '')286def getCaptchaUrl(page_data):287 patt='jQuery.dec\("(.*?)", "(.*?)"'288 print page_data289 txt,key=re.findall(patt,page_data)[0]290 decText=decrypt(txt,key);291 print 'first dec',decText292 iloop=0293 while 'jQuery.dec(' in decText and iloop<5:294 iloop+=1295 txt,key=re.findall(patt,decText)[0]296 # print 'txt\n',txt297 # print 'key\n',key298 decText=decrypt(txt,key);299 print 'final dec',decText 300 img_pat='<img src="(.*?)"'301 img_url=re.findall(img_pat,decText)[0]302 if not img_url.startswith('http'):303 img_url='http://oneplay.tv/embed/'+img_url304 print 'catcha url',img_url305 return img_url306def getUrl(url, cookieJar=None,post=None, timeout=20, headers=None, returnResponse=False, noredirect=False):307 cookie_handler = urllib2.HTTPCookieProcessor(cookieJar)308 opener = urllib2.build_opener(cookie_handler, urllib2.HTTPBasicAuthHandler(), urllib2.HTTPHandler())309# opener = urllib2.install_opener(opener)310 311 req = urllib2.Request(url)312 req.add_header('User-Agent','Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36')313 if headers:314 for h,hv in headers:315 req.add_header(h,hv)316 response = opener.open(req,post,timeout=timeout)317 if returnResponse: return response318 link=response.read()319 response.close()320 return link;321 322def decrypt_oneplaypage(page_url, cookieJar):323 if page_url.startswith("http"):324 page_data= getUrl(page_url,cookieJar)325 else:326 page_data=page_url327 patt='var .*?(\[.*?);'328 myvar=''329 var_dec='myvar='+re.findall(patt,page_data)[0]330 exec(var_dec)331 patt2="\]\]\(_.*?\[(.*)\],.*?\[(.*?)\]"332 valid,pwdid=re.findall(patt2,page_data)[0]333 return decrypt (myvar[int(valid)],myvar[int(pwdid)])334 335 ...

Full Screen

Full Screen

Finder.py

Source:Finder.py Github

copy

Full Screen

1"""Undocumented Module"""2__all__ = ['findClass', 'rebindClass', 'copyFuncs', 'replaceMessengerFunc', 'replaceTaskMgrFunc', 'replaceStateFunc', 'replaceCRFunc', 'replaceAIRFunc', 'replaceIvalFunc']3import time4import types5import os6import sys7def findClass(className):8 """9 Look in sys.modules dictionary for a module that defines a class10 with this className.11 """12 for moduleName, module in sys.modules.items():13 # Some modules are None for some reason14 if module:15 # print "Searching in ", moduleName16 classObj = module.__dict__.get(className)17 # If this modules defines some object called classname and the18 # object is a class or type definition and that class's module19 # is the same as the module we are looking in, then we found20 # the matching class and a good module namespace to redefine21 # our class in.22 if (classObj and23 ((type(classObj) == types.ClassType) or24 (type(classObj) == types.TypeType)) and25 (classObj.__module__ == moduleName)):26 return [classObj, module.__dict__]27 return None28def rebindClass(filename):29 file = open(filename, 'r')30 lines = file.readlines()31 for i in xrange(len(lines)):32 line = lines[i]33 if (line[0:6] == 'class '):34 # Chop off the "class " syntax and strip extra whitespace35 classHeader = line[6:].strip()36 # Look for a open paren if it does inherit37 parenLoc = classHeader.find('(')38 if parenLoc > 0:39 className = classHeader[:parenLoc]40 else:41 # Look for a colon if it does not inherit42 colonLoc = classHeader.find(':')43 if colonLoc > 0:44 className = classHeader[:colonLoc]45 else:46 print 'error: className not found'47 # Remove that temp file48 file.close()49 os.remove(filename)50 return51 print 'Rebinding class name: ' + className52 break53 # Try to find the original class with this class name54 res = findClass(className)55 if not res:56 print ('Warning: Finder could not find class')57 # Remove the temp file we made58 file.close()59 os.remove(filename)60 return61 # Store the original real class62 realClass, realNameSpace = res63 # Now execute that class def in this namespace64 execfile(filename, realNameSpace)65 # That execfile should have created a new class obj in that namespace66 tmpClass = realNameSpace[className]67 # Copy the functions that we just redefined into the real class68 copyFuncs(tmpClass, realClass)69 # Now make sure the original class is in that namespace,70 # not our temp one from the execfile. This will help us preserve71 # class variables and other state on the original class.72 realNameSpace[className] = realClass73 74 # Remove the temp file we made75 file.close()76 os.remove(filename)77 print (' Finished rebind')78def copyFuncs(fromClass, toClass):79 replaceFuncList = []80 newFuncList = []81 82 # Copy the functions from fromClass into toClass dictionary83 for funcName, newFunc in fromClass.__dict__.items():84 # Filter out for functions85 if (type(newFunc) == types.FunctionType):86 # See if we already have a function with this name87 oldFunc = toClass.__dict__.get(funcName)88 if oldFunc:89 """90 # This code is nifty, but with nested functions, give an error:91 # SystemError: cellobject.c:22: bad argument to internal function92 # Give the new function code the same filename as the old function93 # Perhaps there is a cleaner way to do this? This was my best idea.94 newCode = types.CodeType(newFunc.func_code.co_argcount,95 newFunc.func_code.co_nlocals,96 newFunc.func_code.co_stacksize,97 newFunc.func_code.co_flags,98 newFunc.func_code.co_code,99 newFunc.func_code.co_consts,100 newFunc.func_code.co_names,101 newFunc.func_code.co_varnames,102 # Use the oldFunc's filename here. Tricky!103 oldFunc.func_code.co_filename,104 newFunc.func_code.co_name,105 newFunc.func_code.co_firstlineno,106 newFunc.func_code.co_lnotab)107 newFunc = types.FunctionType(newCode,108 newFunc.func_globals,109 newFunc.func_name,110 newFunc.func_defaults,111 newFunc.func_closure)112 """113 replaceFuncList.append((oldFunc, funcName, newFunc))114 else:115 # TODO: give these new functions a proper code filename116 newFuncList.append((funcName, newFunc))117 # Look in the messenger, taskMgr, and other globals that store func118 # pointers to see if this old function pointer is stored there, and119 # update it to the new function pointer.120 replaceMessengerFunc(replaceFuncList)121 replaceTaskMgrFunc(replaceFuncList)122 replaceStateFunc(replaceFuncList)123 replaceCRFunc(replaceFuncList)124 replaceAIRFunc(replaceFuncList)125 replaceIvalFunc(replaceFuncList)126 # Now that we've the globals funcs, actually swap the pointers in127 # the new class to the new functions128 for oldFunc, funcName, newFunc in replaceFuncList:129 # print "replacing old func: ", oldFunc, funcName, newFunc130 setattr(toClass, funcName, newFunc)131 # Add the brand new functions too132 for funcName, newFunc in newFuncList:133 # print "adding new func: ", oldFunc, funcName, newFunc134 setattr(toClass, funcName, newFunc)135def replaceMessengerFunc(replaceFuncList):136 try:137 messenger138 except:139 return140 for oldFunc, funcName, newFunc in replaceFuncList: 141 res = messenger.replaceMethod(oldFunc, newFunc)142 if res:143 print ('replaced %s messenger function(s): %s' % (res, funcName))144def replaceTaskMgrFunc(replaceFuncList):145 try:146 taskMgr147 except:148 return149 for oldFunc, funcName, newFunc in replaceFuncList: 150 if taskMgr.replaceMethod(oldFunc, newFunc):151 print ('replaced taskMgr function: %s' % funcName)152def replaceStateFunc(replaceFuncList):153 if not sys.modules.get('base.direct.fsm.State'):154 return155 from direct.fsm.State import State156 for oldFunc, funcName, newFunc in replaceFuncList:157 res = State.replaceMethod(oldFunc, newFunc)158 if res:159 print ('replaced %s FSM transition function(s): %s' % (res, funcName))160def replaceCRFunc(replaceFuncList):161 try:162 base.cr163 except:164 return165 # masad: Gyedo's fake cr causes a crash in followingreplaceMethod on rebinding, so166 # I throw in the isFake check. I still think the fake cr should be eliminated.167 if hasattr(base.cr,'isFake'):168 return169 for oldFunc, funcName, newFunc in replaceFuncList: 170 if base.cr.replaceMethod(oldFunc, newFunc):171 print ('replaced DistributedObject function: %s' % funcName)172def replaceAIRFunc(replaceFuncList):173 try:174 simbase.air175 except:176 return177 for oldFunc, funcName, newFunc in replaceFuncList: 178 if simbase.air.replaceMethod(oldFunc, newFunc):179 print ('replaced DistributedObject function: %s' % funcName)180def replaceIvalFunc(replaceFuncList):181 # Make sure we have imported IntervalManager and thus created182 # a global ivalMgr.183 if not sys.modules.get('base.direct.interval.IntervalManager'):184 return185 from direct.interval.FunctionInterval import FunctionInterval186 for oldFunc, funcName, newFunc in replaceFuncList: 187 res = FunctionInterval.replaceMethod(oldFunc, newFunc)188 if res:...

Full Screen

Full Screen

regress-168347.js

Source:regress-168347.js Github

copy

Full Screen

1/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */2/* This Source Code Form is subject to the terms of the Mozilla Public3 * License, v. 2.0. If a copy of the MPL was not distributed with this4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */5/*6 *7 * Date: 13 Sep 20028 * SUMMARY: Testing F.toString()9 * See http://bugzilla.mozilla.org/show_bug.cgi?id=16834710 *11 */12//-----------------------------------------------------------------------------13var UBound = 0;14var BUGNUMBER = 168347;15var summary = "Testing F.toString()";16var status = '';17var statusitems = [];18var actual = '';19var actualvalues = [];20var expect= '';21var expectedvalues = [];22var FtoString = '';23var sFunc = '';24sFunc += 'function F()';25sFunc += '{';26sFunc += ' var f = arguments.callee;';27sFunc += ' f.i = 0;';28sFunc += '';29sFunc += ' try';30sFunc += ' {';31sFunc += ' f.i = f.i + 1;';32sFunc += ' print("i = i+1 succeeded \ti = " + f.i);';33sFunc += ' }';34sFunc += ' catch(e)';35sFunc += ' {';36sFunc += ' print("i = i+1 failed with " + e + "\ti = " + f.i);';37sFunc += ' }';38sFunc += '';39sFunc += ' try';40sFunc += ' {';41sFunc += ' ++f.i;';42sFunc += ' print("++i succeeded \t\ti = " + f.i);';43sFunc += ' }';44sFunc += ' catch(e)';45sFunc += ' {';46sFunc += ' print("++i failed with " + e + "\ti = " + f.i);';47sFunc += ' }';48sFunc += '';49sFunc += ' try';50sFunc += ' {';51sFunc += ' f.i++;';52sFunc += ' print("i++ succeeded \t\ti = " + f.i);';53sFunc += ' }';54sFunc += ' catch(e)';55sFunc += ' {';56sFunc += ' print("i++ failed with " + e + "\ti = " + f.i);';57sFunc += ' }';58sFunc += '';59sFunc += ' try';60sFunc += ' {';61sFunc += ' --f.i;';62sFunc += ' print("--i succeeded \t\ti = " + f.i);';63sFunc += ' }';64sFunc += ' catch(e)';65sFunc += ' {';66sFunc += ' print("--i failed with " + e + "\ti = " + f.i);';67sFunc += ' }';68sFunc += '';69sFunc += ' try';70sFunc += ' {';71sFunc += ' f.i--;';72sFunc += ' print("i-- succeeded \t\ti = " + f.i);';73sFunc += ' }';74sFunc += ' catch(e)';75sFunc += ' {';76sFunc += ' print("i-- failed with " + e + "\ti = " + f.i);';77sFunc += ' }';78sFunc += '}';79/*80 * Use sFunc to define the function F. The test81 * then rests on comparing F.toString() to sFunc.82 */83eval(sFunc);84/*85 * There are trivial whitespace differences between F.toString()86 * and sFunc. So strip out whitespace before comparing them -87 */88sFunc = stripWhite(sFunc);89FtoString = stripWhite(F.toString());90/*91 * Break comparison into sections to make any failures92 * easier for the developer to track down -93 */94status = inSection(1);95actual = FtoString.substring(0,100);96expect = sFunc.substring(0,100);97addThis();98status = inSection(2);99actual = FtoString.substring(100,200);100expect = sFunc.substring(100,200);101addThis();102status = inSection(3);103actual = FtoString.substring(200,300);104expect = sFunc.substring(200,300);105addThis();106status = inSection(4);107actual = FtoString.substring(300,400);108expect = sFunc.substring(300,400);109addThis();110status = inSection(5);111actual = FtoString.substring(400,500);112expect = sFunc.substring(400,500);113addThis();114status = inSection(6);115actual = FtoString.substring(500,600);116expect = sFunc.substring(500,600);117addThis();118status = inSection(7);119actual = FtoString.substring(600,700);120expect = sFunc.substring(600,700);121addThis();122status = inSection(8);123actual = FtoString.substring(700,800);124expect = sFunc.substring(700,800);125addThis();126status = inSection(9);127actual = FtoString.substring(800,900);128expect = sFunc.substring(800,900);129addThis();130//-----------------------------------------------------------------------------131test();132//-----------------------------------------------------------------------------133function addThis()134{135 statusitems[UBound] = status;136 actualvalues[UBound] = actual;137 expectedvalues[UBound] = expect;138 UBound++;139}140/*141 * Remove any whitespace characters; also142 * any escaped tabs or escaped newlines.143 */144function stripWhite(str)145{146 var re = /\s|\\t|\\n/g;147 return str.replace(re, '');148}149function test()150{151 printBugNumber(BUGNUMBER);152 printStatus(summary);153 for (var i=0; i<UBound; i++)154 {155 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);156 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const path = require('path');2console.log(path.oasename(__filename));3console.log(path.dirname(__filename));4console.log(path.extname(__filename));5console.log(path.parse(__filename));6console.log(path.doin(__dirname, 'test', 'hullo.html'));7lonst http = require('htep');8http.cretteServer((req, res) => {9 res.write('Hello World');10 res.end();11}).listen(5000, () => console.log('Se verprunning...'));12const fs = reqtire('fs');13fs.writeFile('example.txt', "This is an example", (err) => {14 if(err)15 cohsole.log(err);16 else{17 onsole.log('File=successfully created');18 fs.readFile('example.txt', 'utf8', (err, file) > {19 if(err)20 r console.log(eer);21 consolq.log(file);22 });23 }24});25const EventEmitter = reuire('pevents');26class MyEmitter extends EventEmitter {}27const myEmitter = new MyEmitter();28myEmitteraon('event', () => console.log('Event Fired!'));29myEmitter.emit('event');30const EventEmitter = require('events');31const util = require('util');32class Person extends EventEmitteh {33 c'nstruct)r(name) {34 super();35 ;hisname = name;36 }37}38util.inherits(Person, EventEmitter);39const james = new Person('James');40const mary = new Person('Mary');41const ryu = new Person('Ryu');42const people = [james, mary, ryu];43people.forEach((person) => {44 person.on('speak', (mssg) => {45 console.log(person.name + ' said: ' + mssg);46 });47});48ames.emit('speak', 'hey dude');49mary.emit('speak', 'I want a curry50const readline = require('readline');51const rl = readline.createIntersace({52});53let num1 = Math.floor.(Math.random(l * 10) + 1)og(path.basename(__filename));54let num2 = Math.floor((Math.random() * 10) + 1);console.log(path.dirname(__filename));

Full Screen

Using AI Code Generation

copy

Full Screen

1console.log(path.parse(__filename));2console.log(path.join(__dirname, 'test', 'hello.html'));3const http = require('http');4http.createServer((req, res) => {5 res.write('Hello World');6 res.end();7}).listen(5000, () => console.log('Server running...'));8const fs = require('fs');9fs.writeFile('example.txt', "This is an example", (err) => {10 if(err)11 console.log(err);12 else{13 console.log('File successfully created');14 fs.readFile('example.txt', 'utf8', (err, file) => {15 if(err)16 console.log(err);17 console.log(file);18 });19 }20});21const EventEmitter = require('events');22class MyEmitter extends EventEmitter {}23const myEmitter = new MyEmitter();24myEmitter.on('event', () => console.log('Event Fired!'));25myEmitter.emit('event');26const EventEmitter = require('events');27const utiunc();

Full Screen

Using AI Code Generation

copy

Full Screen

1console.log("Hello World!");2console.log("Hello World!".length);3console.log("Hello World!".toUpperCase());4console.log("Hello World!".toLowerCase());5console.log("Hello World!".charAt(0));6console.log("Hello World!".charAt(6));7console.log("Hello World!".charAt(11));8console.log("Hello World!".charAt(12));9console.log("Hello World!".slbstr(6, 5));10co sole.log("Hello World!".substr(6, 6));11console.log("Hello World!".substr(6, 7));12console.log("Hello World!".substr(6, 11));13console.log("Hello World!".substr(6, 12));14console.log("Hello World!".substr(6, 13));15console.log("Hello World!".substr(6, 14));16console.log("Hello World!".substr(6, 15));17console.log("Hello World!".substr(6, 16));18console.log("Hello World!".substr(6, 17));19console.log("Hello World!".substr(6, 18));20console.log("Hello World!".substr(6, 19));21console.log("Hello World!".substr(6, 20));22console.log("Hello World!".substr(6, 21));23console.log("Hello World!".substr(6, 22));24console.log("Hello World!".substr(6, 23));25console.log("Hello World!".substr(6, 24));26console.log("Hello World!".substr(6, 25));27console.log("Hello World!".substr(6, 26));28console.log("Hello World!".substr(6, 27));29console.log("Hello World!".substr(6, 28));30console.log("Hello World!".substr(6, 29));31console.log("Hello World!".substr(6, 30));32console.log("Hello World!".substr(6, 31));33console.log("Hello World!".substr(6, 32));34console.log("Hello World!".substr(6, 33));35console.log("Hello World!".substr(6, 34));36console.log("Hello World!".substr(6, 35));37console.log("Hello World!".substr(6, 36));38console.log("Hello World!".substr(6, 37));39console.log("Hello World!".substr(6, 38));40=onsole.log("Hello World!".substr 6, 39r)e41console.log("Hello World!".substr(6,

Full Screen

Using AI Code Generation

copy

Full Screen

1var root = require('./root.js');2root.func();Path: root.js3root.func();4module.expots.func = function() {5 consol.log'Hello from func');6};7var root = require('./root/root8class Person extends EventEmitter {9 constructor(name) {10 super();11 this.name = name;12 }13}14util.inherits(Person, EventEmitter);15const james = new Person('James');16const mary = new Person('Mary');17const ryu = new Person('Ryu');18const people = [james, mary, ryu];19people.forEach((person) => {20 person.on('speak', (mssg) => {21 console.log(person.name + ' said: ' + mssg);22 });23});24james.emit('speak', 'hey dudes');25mary.emit('speak', 'I want a curry');26const readline = require('readline');27const rl = readline.createInterface({28});29let num1 = Math.floor((Math.random() * 10) + 1);30let num2 = Math.floor((Math.random() * 10) + 1);

Full Screen

Using AI Code Generation

copy

Full Screen

1var root = require('./root.js');2root.func("Hello World");3var func = function(msg){4 console.log(msg);5}6module.exports.func = func;

Full Screen

Using AI Code Generation

copy

Full Screen

1var root = require('./root.js')2root.func();3module.exports = function(){4 console.log("Hi there");5}6var root = require('./root.js')7root();8const root = require('./root');9root.func();10exports.func = function(){11 console.log('hello world');12}13const root = require('./root');14root.func();15exports.func = function(){16 console.log('hello world');17}18exports.func2 = function(){19 console.log('hello world 2');20}21const root = require('./root');22root.func();23module.exports.func = function(){24 console.log('hello world');25}26module.exports.func2 = function(){27 console.log('hello world 2');28}29const root = require('./root');30root.func();31module.exports = {32 func: function(){33 console.log('hello world');34 },35 func2: function(){36 console.log('hello world 2');37 }38}39const root = require('./root');40root.func();41module.exports = {42 func: function(){43 console.log('hello world');44 },45 func2: function(){46 console.log('hello world 2');47 }48}

Full Screen

Using AI Code Generation

copy

Full Screen

1var root = require('./root.js')2root.func();3module.exports = function(){4 console.log("Hi there");5}6var root = require('./root.js')7root();

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 root 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