idlize
55 строк · 1.4 Кб
1/*
2* Copyright (c) 2022-2023 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 { log } from "./util.test"
17
18export class Node {
19}
20
21export class MutableState<T> {
22constructor(public value: T) {
23this.value = value
24}
25}
26
27export function __context(): Context {
28throw "__context() should not be called"
29}
30
31export function __id<Key>(): Key {
32throw "__id() should not be called"
33}
34
35export class Scope<T> {
36param<T>(index: number, value: T): MutableState<T> {
37return new MutableState(value)
38}
39recache<T>(value: T) { return value }
40get cached() {
41throw new Error("")
42}
43unchanged = false
44}
45export class Context {
46scope<T>(id: Key, paramCount: number = 0): Scope<T> { return new Scope<T>() }
47compute<T>(id: Key, lambda: () => T): T {
48return lambda()
49}
50}
51
52export type Key = string
53
54export type __memo_context_type = Context
55export type __memo_id_type = Key
56
57