1/* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16import { PandaGen } from "src/pandagen"; 17import { 18 IRNode, 19 Ldfalse, 20 Ldglobal, 21 Ldhole, 22 Ldinfinity, 23 Ldnan, 24 Ldnull, 25 Ldsymbol, 26 Ldtrue, 27 Ldundefined, 28 Sta, 29 Ldfunction 30} from "../irnodes"; 31import { CacheList, getVregisterCache } from "./vregisterCache"; 32 33export function expandHole(pandaGen: PandaGen): IRNode[] { 34 let vreg = getVregisterCache(pandaGen, CacheList.HOLE); 35 return [ 36 new Ldhole(), 37 new Sta(vreg) 38 ] 39} 40 41export function expandNaN(pandaGen: PandaGen): IRNode[] { 42 let vreg = getVregisterCache(pandaGen, CacheList.NAN); 43 return [ 44 new Ldnan(), 45 new Sta(vreg) 46 ]; 47} 48 49export function expandInfinity(pandaGen: PandaGen): IRNode[] { 50 let vreg = getVregisterCache(pandaGen, CacheList.INFINITY); 51 return [ 52 new Ldinfinity(), 53 new Sta(vreg) 54 ]; 55} 56 57export function expandGlobal(pandaGen: PandaGen): IRNode[] { 58 let vreg = getVregisterCache(pandaGen, CacheList.GLOBAL); 59 return [ 60 new Ldglobal(), 61 new Sta(vreg) 62 ]; 63} 64 65export function expandUndefined(pandaGen: PandaGen): IRNode[] { 66 let vreg = getVregisterCache(pandaGen, CacheList.UNDEFINED); 67 return [ 68 new Ldundefined(), 69 new Sta(vreg) 70 ]; 71} 72 73export function expandSymbol(pandaGen: PandaGen): IRNode[] { 74 let vreg = getVregisterCache(pandaGen, CacheList.SYMBOL); 75 return [ 76 new Ldsymbol(), 77 new Sta(vreg) 78 ]; 79} 80 81export function expandNull(pandaGen: PandaGen): IRNode[] { 82 let vreg = getVregisterCache(pandaGen, CacheList.NULL); 83 return [ 84 new Ldnull(), 85 new Sta(vreg) 86 ]; 87} 88 89export function expandTrue(pandaGen: PandaGen): IRNode[] { 90 let vreg = getVregisterCache(pandaGen, CacheList.TRUE); 91 return [ 92 new Ldtrue(), 93 new Sta(vreg) 94 ]; 95} 96 97export function expandFalse(pandaGen: PandaGen): IRNode[] { 98 let vreg = getVregisterCache(pandaGen, CacheList.FALSE); 99 return [ 100 new Ldfalse(), 101 new Sta(vreg) 102 ]; 103} 104 105export function expandFunc(pandaGen: PandaGen): IRNode[] { 106 let vreg = getVregisterCache(pandaGen, CacheList.FUNC); 107 return [ 108 new Ldfunction(), 109 new Sta(vreg) 110 ]; 111}