Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
PolyProgrammist committed Nov 13, 2023
1 parent 6d3d741 commit f50d66f
Show file tree
Hide file tree
Showing 8 changed files with 1,278 additions and 68 deletions.
126 changes: 126 additions & 0 deletions generated.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
import { Builder } from "../boc/Builder"

Check failure on line 1 in generated.ts

View workflow job for this annotation

GitHub Actions / build (14.x)

Cannot find module '../boc/Builder' or its corresponding type declarations.

Check failure on line 1 in generated.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

Cannot find module '../boc/Builder' or its corresponding type declarations.

Check failure on line 1 in generated.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Cannot find module '../boc/Builder' or its corresponding type declarations.

Check failure on line 1 in generated.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Cannot find module '../boc/Builder' or its corresponding type declarations.
import { Slice } from "../boc/Slice"

Check failure on line 2 in generated.ts

View workflow job for this annotation

GitHub Actions / build (14.x)

Cannot find module '../boc/Slice' or its corresponding type declarations.

Check failure on line 2 in generated.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

Cannot find module '../boc/Slice' or its corresponding type declarations.

Check failure on line 2 in generated.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Cannot find module '../boc/Slice' or its corresponding type declarations.

Check failure on line 2 in generated.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Cannot find module '../boc/Slice' or its corresponding type declarations.
export type X = {
a: number;
b: number;
};
export function loadX(slice: Slice): X {
return {
a: slice.loadUint(32),
b: slice.loadUint(32)
};
}
export function storeX(x: X): Builder {
return (builder: Builder) => {
builder.storeUint(x.a, 32);
builder.storeUint(x.b, 32);
};
}
export type Bool = Bool_bool_false | Bool_bool_true;
export type Bool_bool_false = {
a: number;
b: number;
c: number;
};
export type Bool_bool_true = {
b: number;
};
export function loadBool(slice: Slice): Bool {

Check failure on line 28 in generated.ts

View workflow job for this annotation

GitHub Actions / build (14.x)

Function lacks ending return statement and return type does not include 'undefined'.

Check failure on line 28 in generated.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

Function lacks ending return statement and return type does not include 'undefined'.

Check failure on line 28 in generated.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Function lacks ending return statement and return type does not include 'undefined'.

Check failure on line 28 in generated.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Function lacks ending return statement and return type does not include 'undefined'.
if (slice.preloadUint(1) == 0b0) {
return {
a: slice.loadUint(32),
b: slice.loadUint(7),
c: slice.loadUint(32)
};
};
if (slice.preloadUint(1) == 0b1) {
return {
b: slice.loadUint(32)
};
};
}
export function storeBool(bool: Bool): Builder {
if (bool instanceof Bool_bool_false) {

Check failure on line 43 in generated.ts

View workflow job for this annotation

GitHub Actions / build (14.x)

'Bool_bool_false' only refers to a type, but is being used as a value here.

Check failure on line 43 in generated.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

'Bool_bool_false' only refers to a type, but is being used as a value here.

Check failure on line 43 in generated.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

'Bool_bool_false' only refers to a type, but is being used as a value here.

Check failure on line 43 in generated.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

'Bool_bool_false' only refers to a type, but is being used as a value here.
return (builder: Builder) => {
builder.storeUint(bool.a, 32);

Check failure on line 45 in generated.ts

View workflow job for this annotation

GitHub Actions / build (14.x)

Property 'a' does not exist on type 'Bool'.

Check failure on line 45 in generated.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

Property 'a' does not exist on type 'Bool'.

Check failure on line 45 in generated.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Property 'a' does not exist on type 'Bool'.

Check failure on line 45 in generated.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Property 'a' does not exist on type 'Bool'.
builder.storeUint(bool.b, 7);
builder.storeUint(bool.c, 32);

Check failure on line 47 in generated.ts

View workflow job for this annotation

GitHub Actions / build (14.x)

Property 'c' does not exist on type 'Bool'.

Check failure on line 47 in generated.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

Property 'c' does not exist on type 'Bool'.

Check failure on line 47 in generated.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Property 'c' does not exist on type 'Bool'.

Check failure on line 47 in generated.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Property 'c' does not exist on type 'Bool'.
};
};
if (bool instanceof Bool_bool_true) {

Check failure on line 50 in generated.ts

View workflow job for this annotation

GitHub Actions / build (14.x)

'Bool_bool_true' only refers to a type, but is being used as a value here.

Check failure on line 50 in generated.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

'Bool_bool_true' only refers to a type, but is being used as a value here.

Check failure on line 50 in generated.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

'Bool_bool_true' only refers to a type, but is being used as a value here.

Check failure on line 50 in generated.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

'Bool_bool_true' only refers to a type, but is being used as a value here.
return (builder: Builder) => {
builder.storeUint(bool.b, 32);
};
};
}
export type Y = {
y: number;
};
export function loadY(slice: Slice): Y {
return {
y: slice.loadUint(5)
};
}
export function storeY(y: Y): Builder {
return (builder: Builder) => {
builder.storeUint(y.y, 5);
};
}
export type C = {
y: Y;
c: number;
};
export function loadC(slice: Slice): C {
return {
y: loadY(slice),
c: slice.loadUint(32)
};
}
export function storeC(c: C): Builder {
return (builder: Builder) => {
storeY(c.y)(builder);
builder.storeUint(c.c, 32);
};
}
export type D = {
y: Y;
c: number;
};
export function loadD(slice: Slice): D {
return {
y: loadY(slice),
c: slice.loadUint(32)
};
}
export function storeD(d: D): Builder {
return (builder: Builder) => {
storeY(d.y)(builder);
builder.storeUint(d.c, 32);
};
}
export type Maybe<TheType> = {
value: TheType;
};
export function loadMaybe<TheType>(slice: Slice, loadTheType: (slice: Slice) => TheType): Maybe<TheType> {
return {
value: loadTheType(slice)
};
}
export function storeMaybe<TheType>(maybe: Maybe<TheType>, storeTheType: (theType: TheType) => (builder: Builder) => void): Builder {
return (builder: Builder) => {
storeTheType(maybe.value)(builder);
};
}
export type TheJust = {
x: Maybe;

Check failure on line 115 in generated.ts

View workflow job for this annotation

GitHub Actions / build (14.x)

Generic type 'Maybe' requires 1 type argument(s).

Check failure on line 115 in generated.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

Generic type 'Maybe' requires 1 type argument(s).

Check failure on line 115 in generated.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Generic type 'Maybe' requires 1 type argument(s).

Check failure on line 115 in generated.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Generic type 'Maybe' requires 1 type argument(s).
};
export function loadTheJust(slice: Slice): TheJust {
return {
x: loadMaybe(slice)

Check failure on line 119 in generated.ts

View workflow job for this annotation

GitHub Actions / build (14.x)

Expected 2 arguments, but got 1.

Check failure on line 119 in generated.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

Expected 2 arguments, but got 1.

Check failure on line 119 in generated.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Expected 2 arguments, but got 1.

Check failure on line 119 in generated.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Expected 2 arguments, but got 1.
};
}
export function storeTheJust(theJust: TheJust): Builder {
return (builder: Builder) => {
storeMaybe(theJust.x)(builder);

Check failure on line 124 in generated.ts

View workflow job for this annotation

GitHub Actions / build (14.x)

Expected 2 arguments, but got 1.

Check failure on line 124 in generated.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

Expected 2 arguments, but got 1.

Check failure on line 124 in generated.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Expected 2 arguments, but got 1.

Check failure on line 124 in generated.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Expected 2 arguments, but got 1.
};
}
41 changes: 41 additions & 0 deletions maybe.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

export type Maybe<TheType> = {
value: TheType;
};

export function loadMaybe<TheType>(slice: Slice, loadTheType: (slice: Slice) => TheType): Maybe<TheType> {
return {
value: loadTheType(slice)
};
}

export function storeMaybe<TheType>(maybe: Maybe<TheType>, storeSubType: (TheType: TheType) => ((builder: Builder) => void)): Builder {
return (builder: Builder) => {
storeSubType(maybe.value)(builder);
};
}

export type TheJust = {
x: Maybe<number>
};

function loadTheNumber(slice: Slice): number {
return slice.loadUint(32);
}

function storeTheNumber(n: number): ((builder: Builder) => void) {
return (builder: Builder) => {
builder.storeUint(n, 32);
}
}

export function loadTheJust(slice: Slice): TheJust {
return {
x: loadMaybe<number>(slice, loadTheNumber)
};
}
export function storeTheJust(theJust: TheJust): Builder {
return (builder: Builder) => {
storeMaybe<number>(theJust.x, storeTheNumber)(builder);
};
}
Loading

0 comments on commit f50d66f

Please sign in to comment.