• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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    EcmaLdfalse,
20    EcmaLdglobal,
21    EcmaLdhole,
22    EcmaLdinfinity,
23    EcmaLdnan,
24    EcmaLdnull,
25    EcmaLdsymbol,
26    EcmaLdtrue,
27    EcmaLdundefined,
28    StaDyn,
29    EcmaLdfunction
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 EcmaLdhole(),
37        new StaDyn(vreg)
38    ]
39}
40
41export function expandNaN(pandaGen: PandaGen): IRNode[] {
42    let vreg = getVregisterCache(pandaGen, CacheList.NaN);
43    return [
44        new EcmaLdnan(),
45        new StaDyn(vreg)
46    ];
47}
48
49export function expandInfinity(pandaGen: PandaGen): IRNode[] {
50    let vreg = getVregisterCache(pandaGen, CacheList.Infinity);
51    return [
52        new EcmaLdinfinity(),
53        new StaDyn(vreg)
54    ];
55}
56
57export function expandGlobal(pandaGen: PandaGen): IRNode[] {
58    let vreg = getVregisterCache(pandaGen, CacheList.Global);
59    return [
60        new EcmaLdglobal(),
61        new StaDyn(vreg)
62    ];
63}
64
65export function expandUndefined(pandaGen: PandaGen): IRNode[] {
66    let vreg = getVregisterCache(pandaGen, CacheList.undefined);
67    return [
68        new EcmaLdundefined(),
69        new StaDyn(vreg)
70    ];
71}
72
73export function expandSymbol(pandaGen: PandaGen): IRNode[] {
74    let vreg = getVregisterCache(pandaGen, CacheList.Symbol);
75    return [
76        new EcmaLdsymbol(),
77        new StaDyn(vreg)
78    ];
79}
80
81export function expandNull(pandaGen: PandaGen): IRNode[] {
82    let vreg = getVregisterCache(pandaGen, CacheList.Null);
83    return [
84        new EcmaLdnull(),
85        new StaDyn(vreg)
86    ];
87}
88
89export function expandTrue(pandaGen: PandaGen): IRNode[] {
90    let vreg = getVregisterCache(pandaGen, CacheList.True);
91    return [
92        new EcmaLdtrue(),
93        new StaDyn(vreg)
94    ];
95}
96
97export function expandFalse(pandaGen: PandaGen): IRNode[] {
98    let vreg = getVregisterCache(pandaGen, CacheList.False);
99    return [
100        new EcmaLdfalse(),
101        new StaDyn(vreg)
102    ];
103}
104
105export function expandFunc(pandaGen: PandaGen): IRNode[] {
106    let vreg = getVregisterCache(pandaGen, CacheList.FUNC);
107    return [
108        new EcmaLdfunction(),
109        new StaDyn(vreg)
110    ];
111}