goscript 0.0.60 → 0.0.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/compiler/analysis.go +974 -369
- package/compiler/assignment.go +72 -0
- package/compiler/compiler.go +74 -15
- package/compiler/composite-lit.go +29 -8
- package/compiler/decl.go +67 -98
- package/compiler/expr-call-async.go +26 -1
- package/compiler/expr-call-builtins.go +60 -4
- package/compiler/expr-call-helpers.go +182 -0
- package/compiler/expr-call-type-conversion.go +37 -5
- package/compiler/expr-call.go +25 -33
- package/compiler/expr-selector.go +71 -1
- package/compiler/expr-type.go +49 -3
- package/compiler/expr.go +37 -28
- package/compiler/index.test.ts +3 -1
- package/compiler/lit.go +13 -4
- package/compiler/spec-struct.go +42 -9
- package/compiler/spec-value.go +2 -2
- package/compiler/spec.go +42 -5
- package/compiler/stmt-assign.go +71 -0
- package/compiler/stmt-range.go +2 -2
- package/compiler/stmt.go +130 -10
- package/compiler/type-utils.go +40 -16
- package/compiler/type.go +50 -12
- package/dist/gs/builtin/builtin.d.ts +8 -1
- package/dist/gs/builtin/builtin.js +26 -1
- package/dist/gs/builtin/builtin.js.map +1 -1
- package/dist/gs/builtin/errors.d.ts +1 -0
- package/dist/gs/builtin/errors.js +8 -0
- package/dist/gs/builtin/errors.js.map +1 -1
- package/dist/gs/builtin/slice.d.ts +5 -4
- package/dist/gs/builtin/slice.js +51 -21
- package/dist/gs/builtin/slice.js.map +1 -1
- package/dist/gs/builtin/type.d.ts +28 -2
- package/dist/gs/builtin/type.js +132 -0
- package/dist/gs/builtin/type.js.map +1 -1
- package/dist/gs/bytes/reader.gs.d.ts +1 -1
- package/dist/gs/bytes/reader.gs.js +1 -1
- package/dist/gs/bytes/reader.gs.js.map +1 -1
- package/dist/gs/internal/byteorder/index.d.ts +6 -0
- package/dist/gs/internal/byteorder/index.js +34 -0
- package/dist/gs/internal/byteorder/index.js.map +1 -1
- package/dist/gs/reflect/index.d.ts +3 -3
- package/dist/gs/reflect/index.js +2 -2
- package/dist/gs/reflect/index.js.map +1 -1
- package/dist/gs/reflect/map.d.ts +3 -2
- package/dist/gs/reflect/map.js +37 -3
- package/dist/gs/reflect/map.js.map +1 -1
- package/dist/gs/reflect/type.d.ts +55 -8
- package/dist/gs/reflect/type.js +889 -23
- package/dist/gs/reflect/type.js.map +1 -1
- package/dist/gs/reflect/types.d.ts +11 -12
- package/dist/gs/reflect/types.js +26 -15
- package/dist/gs/reflect/types.js.map +1 -1
- package/dist/gs/reflect/value.d.ts +4 -4
- package/dist/gs/reflect/value.js +8 -2
- package/dist/gs/reflect/value.js.map +1 -1
- package/dist/gs/slices/slices.d.ts +32 -0
- package/dist/gs/slices/slices.js +81 -0
- package/dist/gs/slices/slices.js.map +1 -1
- package/dist/gs/sync/atomic/type.gs.d.ts +2 -2
- package/dist/gs/sync/atomic/type.gs.js +12 -2
- package/dist/gs/sync/atomic/type.gs.js.map +1 -1
- package/dist/gs/unicode/utf8/utf8.d.ts +2 -2
- package/dist/gs/unicode/utf8/utf8.js +10 -6
- package/dist/gs/unicode/utf8/utf8.js.map +1 -1
- package/go.mod +4 -4
- package/go.sum +8 -16
- package/gs/builtin/builtin.ts +27 -2
- package/gs/builtin/errors.ts +12 -0
- package/gs/builtin/slice.ts +77 -14
- package/gs/builtin/type.ts +167 -2
- package/gs/bytes/reader.gs.ts +2 -2
- package/gs/internal/byteorder/index.ts +40 -0
- package/gs/math/hypot.gs.test.ts +3 -1
- package/gs/math/pow10.gs.test.ts +5 -4
- package/gs/reflect/index.ts +6 -3
- package/gs/reflect/map.test.ts +7 -6
- package/gs/reflect/map.ts +49 -7
- package/gs/reflect/type.ts +1139 -43
- package/gs/reflect/types.ts +34 -21
- package/gs/reflect/value.ts +12 -6
- package/gs/slices/slices.ts +92 -0
- package/gs/sync/atomic/type.gs.ts +14 -5
- package/gs/sync/meta.json +1 -1
- package/gs/unicode/utf8/utf8.ts +12 -8
- package/package.json +13 -13
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { ReflectValue, StructField } from './types.js';
|
|
2
|
+
export { StructField };
|
|
2
3
|
import { MapIter } from './map.js';
|
|
4
|
+
import * as $ from '../builtin/index.js';
|
|
3
5
|
export declare class rtype {
|
|
4
6
|
kind: Kind;
|
|
5
7
|
constructor(kind: Kind);
|
|
@@ -61,16 +63,24 @@ export interface Type {
|
|
|
61
63
|
String(): string;
|
|
62
64
|
Kind(): Kind;
|
|
63
65
|
Size(): number;
|
|
64
|
-
Elem(): Type
|
|
66
|
+
Elem(): Type;
|
|
65
67
|
NumField(): number;
|
|
66
68
|
PkgPath?(): string;
|
|
67
|
-
Field
|
|
69
|
+
Field(i: number): StructField;
|
|
70
|
+
Key(): Type;
|
|
71
|
+
Name(): string;
|
|
72
|
+
Implements(u: Type | null): boolean;
|
|
68
73
|
common?(): rtype;
|
|
74
|
+
OverflowInt(x: number): boolean;
|
|
75
|
+
OverflowUint(x: number): boolean;
|
|
76
|
+
OverflowFloat(x: number): boolean;
|
|
77
|
+
NumMethod(): number;
|
|
78
|
+
Bits(): number;
|
|
69
79
|
}
|
|
70
80
|
export declare class Value {
|
|
71
81
|
private _value;
|
|
72
82
|
private _type;
|
|
73
|
-
constructor(
|
|
83
|
+
constructor(value?: ReflectValue | Record<string, never>, type?: Type | null);
|
|
74
84
|
clone(): Value;
|
|
75
85
|
Int(): number;
|
|
76
86
|
Uint(): number;
|
|
@@ -86,12 +96,18 @@ export declare class Value {
|
|
|
86
96
|
Bytes(): Uint8Array;
|
|
87
97
|
Elem(): Value;
|
|
88
98
|
NumField(): number;
|
|
89
|
-
Field(
|
|
99
|
+
Field(i: number): Value;
|
|
90
100
|
UnsafePointer(): unknown;
|
|
91
101
|
pointer(): unknown;
|
|
92
102
|
get ptr(): unknown;
|
|
93
103
|
get value(): ReflectValue;
|
|
94
104
|
Convert(t: Type): Value;
|
|
105
|
+
CanAddr(): boolean;
|
|
106
|
+
Addr(): Value;
|
|
107
|
+
CanSet(): boolean;
|
|
108
|
+
Set(x: Value): void;
|
|
109
|
+
Interface(): any;
|
|
110
|
+
IsZero(): boolean;
|
|
95
111
|
typ(): rtype | null;
|
|
96
112
|
get flag(): number;
|
|
97
113
|
MapRange(): MapIter<unknown, unknown> | null;
|
|
@@ -101,6 +117,23 @@ export declare class Value {
|
|
|
101
117
|
imag: number;
|
|
102
118
|
} | null;
|
|
103
119
|
Send(x: Value): void;
|
|
120
|
+
SetString(x: string): void;
|
|
121
|
+
SetInt(x: number): void;
|
|
122
|
+
SetUint(x: number): void;
|
|
123
|
+
SetBool(x: boolean): void;
|
|
124
|
+
SetFloat(x: number): void;
|
|
125
|
+
SetBytes(x: $.Slice<number>): void;
|
|
126
|
+
SetZero(): void;
|
|
127
|
+
SetLen(n: number): void;
|
|
128
|
+
SetMapIndex(key: Value, elem: Value): void;
|
|
129
|
+
Grow(n: number): void;
|
|
130
|
+
Cap(): number;
|
|
131
|
+
NumMethod(): number;
|
|
132
|
+
Equal(u: Value): boolean;
|
|
133
|
+
CanInterface(): boolean;
|
|
134
|
+
OverflowInt(x: number): boolean;
|
|
135
|
+
OverflowUint(x: number): boolean;
|
|
136
|
+
OverflowFloat(x: number): boolean;
|
|
104
137
|
}
|
|
105
138
|
export declare class BasicType implements Type {
|
|
106
139
|
private _kind;
|
|
@@ -110,20 +143,34 @@ export declare class BasicType implements Type {
|
|
|
110
143
|
String(): string;
|
|
111
144
|
Kind(): Kind;
|
|
112
145
|
Size(): number;
|
|
113
|
-
Elem(): Type
|
|
146
|
+
Elem(): Type;
|
|
114
147
|
NumField(): number;
|
|
115
148
|
PkgPath?(): string;
|
|
116
|
-
|
|
149
|
+
Name(): string;
|
|
150
|
+
Field(_i: number): StructField;
|
|
151
|
+
Key(): Type;
|
|
152
|
+
Implements(u: Type | null): boolean;
|
|
117
153
|
common?(): rtype;
|
|
154
|
+
OverflowInt(x: number): boolean;
|
|
155
|
+
OverflowUint(x: number): boolean;
|
|
156
|
+
OverflowFloat(x: number): boolean;
|
|
157
|
+
NumMethod(): number;
|
|
158
|
+
Bits(): number;
|
|
118
159
|
}
|
|
119
160
|
export declare function TypeOf(i: ReflectValue): Type;
|
|
120
161
|
export declare function ValueOf(i: ReflectValue): Value;
|
|
121
162
|
export declare function ArrayOf(length: number, elem: Type): Type;
|
|
122
163
|
export declare function SliceOf(t: Type): Type;
|
|
123
|
-
export declare function PointerTo(t: Type): Type;
|
|
124
|
-
export declare function PtrTo(t: Type): Type;
|
|
164
|
+
export declare function PointerTo(t: Type | null): Type | null;
|
|
165
|
+
export declare function PtrTo(t: Type | null): Type | null;
|
|
125
166
|
export declare function MapOf(key: Type, elem: Type): Type;
|
|
126
167
|
export declare function ChanOf(dir: ChanDir, t: Type): Type;
|
|
168
|
+
export declare function TypeFor(): Type;
|
|
169
|
+
/**
|
|
170
|
+
* getInterfaceTypeByName looks up a registered interface type by name
|
|
171
|
+
* and returns a Type for it. Returns an interface{} type if not found.
|
|
172
|
+
*/
|
|
173
|
+
export declare function getInterfaceTypeByName(name: string): Type;
|
|
127
174
|
export declare function canRangeFunc(t: Type): boolean;
|
|
128
175
|
export declare function canRangeFunc2(t: Type): boolean;
|
|
129
176
|
export declare function funcLayout(_t: Type, _rcvr: Type | null): {
|