goscript 0.0.35 → 0.0.36
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/compiler/spec-struct.go +41 -8
- package/compiler/spec-value.go +4 -0
- package/dist/gs/maps/iter.d.ts +1 -1
- package/dist/gs/sync/atomic/doc.gs.d.ts +28 -0
- package/dist/gs/sync/atomic/doc.gs.js +265 -0
- package/dist/gs/sync/atomic/doc.gs.js.map +1 -0
- package/dist/gs/sync/atomic/doc_64.gs.d.ts +15 -0
- package/dist/gs/sync/atomic/doc_64.gs.js +165 -0
- package/dist/gs/sync/atomic/doc_64.gs.js.map +1 -0
- package/dist/gs/sync/atomic/index.d.ts +4 -0
- package/dist/gs/sync/atomic/index.js +5 -0
- package/dist/gs/sync/atomic/index.js.map +1 -0
- package/dist/gs/sync/atomic/type.gs.d.ts +130 -0
- package/dist/gs/sync/atomic/type.gs.js +433 -0
- package/dist/gs/sync/atomic/type.gs.js.map +1 -0
- package/dist/gs/sync/atomic/value.gs.d.ts +19 -0
- package/dist/gs/sync/atomic/value.gs.js +116 -0
- package/dist/gs/sync/atomic/value.gs.js.map +1 -0
- package/dist/gs/unsafe/unsafe.d.ts +1 -0
- package/dist/gs/unsafe/unsafe.js +5 -0
- package/dist/gs/unsafe/unsafe.js.map +1 -1
- package/gs/maps/iter.ts +1 -1
- package/gs/math/erfinv.gs.test.ts +2 -2
- package/gs/math/fma.gs.test.ts +5 -5
- package/gs/math/ldexp.gs.test.ts +5 -5
- package/gs/math/lgamma.gs.test.ts +2 -2
- package/gs/sync/atomic/doc.gs.ts +276 -0
- package/gs/sync/atomic/doc_64.gs.ts +168 -0
- package/gs/sync/atomic/index.ts +4 -0
- package/gs/sync/atomic/type.gs.ts +596 -0
- package/gs/sync/atomic/value.gs.ts +158 -0
- package/gs/unsafe/unsafe.ts +6 -0
- package/package.json +1 -1
package/compiler/spec-struct.go
CHANGED
|
@@ -56,6 +56,10 @@ func (c *GoToTSCompiler) WriteStructTypeSpec(a *ast.TypeSpec, t *ast.StructType)
|
|
|
56
56
|
}
|
|
57
57
|
for _, name := range field.Names {
|
|
58
58
|
fieldName := name.Name
|
|
59
|
+
// Skip underscore fields
|
|
60
|
+
if fieldName == "_" {
|
|
61
|
+
continue
|
|
62
|
+
}
|
|
59
63
|
fieldType := c.pkg.TypesInfo.TypeOf(field.Type)
|
|
60
64
|
if fieldType == nil {
|
|
61
65
|
fieldType = types.Typ[types.Invalid]
|
|
@@ -86,6 +90,10 @@ func (c *GoToTSCompiler) WriteStructTypeSpec(a *ast.TypeSpec, t *ast.StructType)
|
|
|
86
90
|
} else {
|
|
87
91
|
fieldKeyName = field.Name()
|
|
88
92
|
}
|
|
93
|
+
// Skip underscore fields
|
|
94
|
+
if fieldKeyName == "_" {
|
|
95
|
+
continue
|
|
96
|
+
}
|
|
89
97
|
fieldTsType := c.getTypeString(field.Type())
|
|
90
98
|
c.tsw.WriteLinef("%s: $.VarRef<%s>;", fieldKeyName, fieldTsType)
|
|
91
99
|
}
|
|
@@ -105,6 +113,7 @@ func (c *GoToTSCompiler) WriteStructTypeSpec(a *ast.TypeSpec, t *ast.StructType)
|
|
|
105
113
|
c.tsw.WriteLine("")
|
|
106
114
|
c.tsw.Indent(1)
|
|
107
115
|
|
|
116
|
+
firstFieldWritten := false
|
|
108
117
|
for i := range numFields {
|
|
109
118
|
field := underlyingStruct.Field(i)
|
|
110
119
|
fieldType := field.Type()
|
|
@@ -115,13 +124,20 @@ func (c *GoToTSCompiler) WriteStructTypeSpec(a *ast.TypeSpec, t *ast.StructType)
|
|
|
115
124
|
fieldKeyName = field.Name()
|
|
116
125
|
}
|
|
117
126
|
|
|
118
|
-
|
|
127
|
+
// Skip underscore fields
|
|
128
|
+
if fieldKeyName == "_" {
|
|
129
|
+
continue
|
|
130
|
+
}
|
|
119
131
|
|
|
120
|
-
if
|
|
132
|
+
if firstFieldWritten {
|
|
121
133
|
c.tsw.WriteLine(",")
|
|
122
|
-
} else {
|
|
123
|
-
c.tsw.WriteLine("")
|
|
124
134
|
}
|
|
135
|
+
|
|
136
|
+
c.writeVarRefedFieldInitializer(fieldKeyName, fieldType, field.Anonymous())
|
|
137
|
+
firstFieldWritten = true
|
|
138
|
+
}
|
|
139
|
+
if firstFieldWritten {
|
|
140
|
+
c.tsw.WriteLine("")
|
|
125
141
|
}
|
|
126
142
|
c.tsw.Indent(-1)
|
|
127
143
|
}
|
|
@@ -154,6 +170,7 @@ func (c *GoToTSCompiler) WriteStructTypeSpec(a *ast.TypeSpec, t *ast.StructType)
|
|
|
154
170
|
c.tsw.WriteLine("cloned._fields = {")
|
|
155
171
|
c.tsw.Indent(1)
|
|
156
172
|
|
|
173
|
+
firstFieldWritten := false
|
|
157
174
|
for i := range numFields {
|
|
158
175
|
field := underlyingStruct.Field(i)
|
|
159
176
|
fieldType := field.Type()
|
|
@@ -164,13 +181,20 @@ func (c *GoToTSCompiler) WriteStructTypeSpec(a *ast.TypeSpec, t *ast.StructType)
|
|
|
164
181
|
fieldKeyName = field.Name()
|
|
165
182
|
}
|
|
166
183
|
|
|
167
|
-
|
|
184
|
+
// Skip underscore fields
|
|
185
|
+
if fieldKeyName == "_" {
|
|
186
|
+
continue
|
|
187
|
+
}
|
|
168
188
|
|
|
169
|
-
if
|
|
189
|
+
if firstFieldWritten {
|
|
170
190
|
c.tsw.WriteLine(",")
|
|
171
|
-
} else {
|
|
172
|
-
c.tsw.WriteLine("")
|
|
173
191
|
}
|
|
192
|
+
|
|
193
|
+
c.writeClonedFieldInitializer(fieldKeyName, fieldType, field.Anonymous())
|
|
194
|
+
firstFieldWritten = true
|
|
195
|
+
}
|
|
196
|
+
if firstFieldWritten {
|
|
197
|
+
c.tsw.WriteLine("")
|
|
174
198
|
}
|
|
175
199
|
|
|
176
200
|
c.tsw.Indent(-1)
|
|
@@ -402,6 +426,10 @@ func (c *GoToTSCompiler) WriteStructTypeSpec(a *ast.TypeSpec, t *ast.StructType)
|
|
|
402
426
|
} else {
|
|
403
427
|
fieldKeyName = field.Name()
|
|
404
428
|
}
|
|
429
|
+
// Skip underscore fields
|
|
430
|
+
if fieldKeyName == "_" {
|
|
431
|
+
continue
|
|
432
|
+
}
|
|
405
433
|
// fieldTsType := c.getTypeString(field.Type())
|
|
406
434
|
if !firstField {
|
|
407
435
|
c.tsw.WriteLiterally(", ")
|
|
@@ -451,6 +479,11 @@ func (c *GoToTSCompiler) generateFlattenedInitTypeString(structType *types.Named
|
|
|
451
479
|
field := underlying.Field(i)
|
|
452
480
|
fieldName := field.Name()
|
|
453
481
|
|
|
482
|
+
// Skip underscore fields
|
|
483
|
+
if fieldName == "_" {
|
|
484
|
+
continue
|
|
485
|
+
}
|
|
486
|
+
|
|
454
487
|
if !field.Exported() && field.Pkg() != c.pkg.Types {
|
|
455
488
|
continue
|
|
456
489
|
}
|
package/compiler/spec-value.go
CHANGED
|
@@ -41,6 +41,10 @@ func (c *GoToTSCompiler) WriteValueSpec(a *ast.ValueSpec) error {
|
|
|
41
41
|
// Handle single variable declaration
|
|
42
42
|
if len(a.Names) == 1 {
|
|
43
43
|
name := a.Names[0]
|
|
44
|
+
// Skip underscore variables
|
|
45
|
+
if name.Name == "_" {
|
|
46
|
+
return nil
|
|
47
|
+
}
|
|
44
48
|
obj := c.pkg.TypesInfo.Defs[name]
|
|
45
49
|
if obj == nil {
|
|
46
50
|
return fmt.Errorf("could not resolve type: %v", name)
|
package/dist/gs/maps/iter.d.ts
CHANGED
|
@@ -4,4 +4,4 @@ export declare function All<K extends $.Comparable, V>(m: Map<K, V>): iter.Seq2<
|
|
|
4
4
|
export declare function Keys<K extends $.Comparable, V>(m: Map<K, V>): iter.Seq<K>;
|
|
5
5
|
export declare function Values<K extends $.Comparable, V>(m: Map<K, V>): iter.Seq<V>;
|
|
6
6
|
export declare function Insert<K extends $.Comparable, V>(m: Map<K, V>, seq: iter.Seq2<K, V>): void;
|
|
7
|
-
export declare function Collect<K extends $.Comparable, V
|
|
7
|
+
export declare function Collect<K extends $.Comparable, V>(seq: iter.Seq2<K, V>): Map<K, V>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as $ from "@goscript/builtin/builtin.js";
|
|
2
|
+
export type uintptr = number;
|
|
3
|
+
export type Pointer = any;
|
|
4
|
+
export declare function SwapInt32(addr: $.VarRef<number> | null, _new: number): number;
|
|
5
|
+
export declare function SwapUint32(addr: $.VarRef<number> | null, _new: number): number;
|
|
6
|
+
export declare function SwapUintptr(addr: $.VarRef<uintptr> | null, _new: uintptr): uintptr;
|
|
7
|
+
export declare function SwapPointer(addr: $.VarRef<Pointer> | null, _new: Pointer): Pointer;
|
|
8
|
+
export declare function CompareAndSwapInt32(addr: $.VarRef<number> | null, old: number, _new: number): boolean;
|
|
9
|
+
export declare function CompareAndSwapUint32(addr: $.VarRef<number> | null, old: number, _new: number): boolean;
|
|
10
|
+
export declare function CompareAndSwapUintptr(addr: $.VarRef<uintptr> | null, old: uintptr, _new: uintptr): boolean;
|
|
11
|
+
export declare function CompareAndSwapPointer(addr: $.VarRef<Pointer> | null, old: Pointer, _new: Pointer): boolean;
|
|
12
|
+
export declare function AddInt32(addr: $.VarRef<number> | null, delta: number): number;
|
|
13
|
+
export declare function AddUint32(addr: $.VarRef<number> | null, delta: number): number;
|
|
14
|
+
export declare function AddUintptr(addr: $.VarRef<uintptr> | null, delta: uintptr): uintptr;
|
|
15
|
+
export declare function AndInt32(addr: $.VarRef<number> | null, mask: number): number;
|
|
16
|
+
export declare function AndUint32(addr: $.VarRef<number> | null, mask: number): number;
|
|
17
|
+
export declare function AndUintptr(addr: $.VarRef<uintptr> | null, mask: uintptr): uintptr;
|
|
18
|
+
export declare function OrInt32(addr: $.VarRef<number> | null, mask: number): number;
|
|
19
|
+
export declare function OrUint32(addr: $.VarRef<number> | null, mask: number): number;
|
|
20
|
+
export declare function OrUintptr(addr: $.VarRef<uintptr> | null, mask: uintptr): uintptr;
|
|
21
|
+
export declare function LoadInt32(addr: $.VarRef<number> | null): number;
|
|
22
|
+
export declare function LoadUint32(addr: $.VarRef<number> | null): number;
|
|
23
|
+
export declare function LoadUintptr(addr: $.VarRef<uintptr> | null): uintptr;
|
|
24
|
+
export declare function LoadPointer(addr: $.VarRef<Pointer> | null): Pointer;
|
|
25
|
+
export declare function StoreInt32(addr: $.VarRef<number> | null, val: number): void;
|
|
26
|
+
export declare function StoreUint32(addr: $.VarRef<number> | null, val: number): void;
|
|
27
|
+
export declare function StoreUintptr(addr: $.VarRef<uintptr> | null, val: uintptr): void;
|
|
28
|
+
export declare function StorePointer(addr: $.VarRef<Pointer> | null, val: Pointer): void;
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
// SwapInt32 atomically stores new into *addr and returns the previous *addr value.
|
|
2
|
+
// Consider using the more ergonomic and less error-prone [Int32.Swap] instead.
|
|
3
|
+
//
|
|
4
|
+
//go:noescape
|
|
5
|
+
export function SwapInt32(addr, _new) {
|
|
6
|
+
if (!addr)
|
|
7
|
+
return 0;
|
|
8
|
+
let old = addr.value;
|
|
9
|
+
addr.value = _new;
|
|
10
|
+
return old;
|
|
11
|
+
}
|
|
12
|
+
// SwapUint32 atomically stores new into *addr and returns the previous *addr value.
|
|
13
|
+
// Consider using the more ergonomic and less error-prone [Uint32.Swap] instead.
|
|
14
|
+
//
|
|
15
|
+
//go:noescape
|
|
16
|
+
export function SwapUint32(addr, _new) {
|
|
17
|
+
if (!addr)
|
|
18
|
+
return 0;
|
|
19
|
+
let old = addr.value;
|
|
20
|
+
addr.value = _new;
|
|
21
|
+
return old;
|
|
22
|
+
}
|
|
23
|
+
// SwapUintptr atomically stores new into *addr and returns the previous *addr value.
|
|
24
|
+
// Consider using the more ergonomic and less error-prone [Uintptr.Swap] instead.
|
|
25
|
+
//
|
|
26
|
+
//go:noescape
|
|
27
|
+
export function SwapUintptr(addr, _new) {
|
|
28
|
+
if (!addr)
|
|
29
|
+
return 0;
|
|
30
|
+
let old = addr.value;
|
|
31
|
+
addr.value = _new;
|
|
32
|
+
return old;
|
|
33
|
+
}
|
|
34
|
+
// SwapPointer atomically stores new into *addr and returns the previous *addr value.
|
|
35
|
+
// Consider using the more ergonomic and less error-prone [Pointer.Swap] instead.
|
|
36
|
+
export function SwapPointer(addr, _new) {
|
|
37
|
+
if (!addr)
|
|
38
|
+
return null;
|
|
39
|
+
let old = addr.value;
|
|
40
|
+
addr.value = _new;
|
|
41
|
+
return old;
|
|
42
|
+
}
|
|
43
|
+
// CompareAndSwapInt32 executes the compare-and-swap operation for an int32 value.
|
|
44
|
+
// Consider using the more ergonomic and less error-prone [Int32.CompareAndSwap] instead.
|
|
45
|
+
//
|
|
46
|
+
//go:noescape
|
|
47
|
+
export function CompareAndSwapInt32(addr, old, _new) {
|
|
48
|
+
if (!addr)
|
|
49
|
+
return false;
|
|
50
|
+
if (addr.value === old) {
|
|
51
|
+
addr.value = _new;
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
// CompareAndSwapUint32 executes the compare-and-swap operation for a uint32 value.
|
|
57
|
+
// Consider using the more ergonomic and less error-prone [Uint32.CompareAndSwap] instead.
|
|
58
|
+
//
|
|
59
|
+
//go:noescape
|
|
60
|
+
export function CompareAndSwapUint32(addr, old, _new) {
|
|
61
|
+
if (!addr)
|
|
62
|
+
return false;
|
|
63
|
+
if (addr.value === old) {
|
|
64
|
+
addr.value = _new;
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
// CompareAndSwapUintptr executes the compare-and-swap operation for a uintptr value.
|
|
70
|
+
// Consider using the more ergonomic and less error-prone [Uintptr.CompareAndSwap] instead.
|
|
71
|
+
//
|
|
72
|
+
//go:noescape
|
|
73
|
+
export function CompareAndSwapUintptr(addr, old, _new) {
|
|
74
|
+
if (!addr)
|
|
75
|
+
return false;
|
|
76
|
+
if (addr.value === old) {
|
|
77
|
+
addr.value = _new;
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
// CompareAndSwapPointer executes the compare-and-swap operation for a unsafe.Pointer value.
|
|
83
|
+
// Consider using the more ergonomic and less error-prone [Pointer.CompareAndSwap] instead.
|
|
84
|
+
export function CompareAndSwapPointer(addr, old, _new) {
|
|
85
|
+
if (!addr)
|
|
86
|
+
return false;
|
|
87
|
+
if (addr.value === old) {
|
|
88
|
+
addr.value = _new;
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
// AddInt32 atomically adds delta to *addr and returns the new value.
|
|
94
|
+
// Consider using the more ergonomic and less error-prone [Int32.Add] instead.
|
|
95
|
+
//
|
|
96
|
+
//go:noescape
|
|
97
|
+
export function AddInt32(addr, delta) {
|
|
98
|
+
if (!addr)
|
|
99
|
+
return 0;
|
|
100
|
+
addr.value = (addr.value + delta) | 0; // Use bitwise OR to ensure 32-bit signed integer
|
|
101
|
+
return addr.value;
|
|
102
|
+
}
|
|
103
|
+
// AddUint32 atomically adds delta to *addr and returns the new value.
|
|
104
|
+
// To subtract a signed positive constant value c from x, do AddUint32(&x, ^uint32(c-1)).
|
|
105
|
+
// In particular, to decrement x, do AddUint32(&x, ^uint32(0)).
|
|
106
|
+
// Consider using the more ergonomic and less error-prone [Uint32.Add] instead.
|
|
107
|
+
//
|
|
108
|
+
//go:noescape
|
|
109
|
+
export function AddUint32(addr, delta) {
|
|
110
|
+
if (!addr)
|
|
111
|
+
return 0;
|
|
112
|
+
addr.value = (addr.value + delta) >>> 0; // Use unsigned right shift to ensure 32-bit unsigned integer
|
|
113
|
+
return addr.value;
|
|
114
|
+
}
|
|
115
|
+
// AddUintptr atomically adds delta to *addr and returns the new value.
|
|
116
|
+
// Consider using the more ergonomic and less error-prone [Uintptr.Add] instead.
|
|
117
|
+
//
|
|
118
|
+
//go:noescape
|
|
119
|
+
export function AddUintptr(addr, delta) {
|
|
120
|
+
if (!addr)
|
|
121
|
+
return 0;
|
|
122
|
+
addr.value = (addr.value + delta) >>> 0; // Use unsigned right shift for uintptr
|
|
123
|
+
return addr.value;
|
|
124
|
+
}
|
|
125
|
+
// AndInt32 atomically performs a bitwise AND operation on *addr using the bitmask provided as mask
|
|
126
|
+
// and returns the old value.
|
|
127
|
+
// Consider using the more ergonomic and less error-prone [Int32.And] instead.
|
|
128
|
+
//
|
|
129
|
+
//go:noescape
|
|
130
|
+
export function AndInt32(addr, mask) {
|
|
131
|
+
if (!addr)
|
|
132
|
+
return 0;
|
|
133
|
+
let old = addr.value;
|
|
134
|
+
addr.value = (addr.value & mask) | 0; // Use bitwise OR to ensure 32-bit signed integer
|
|
135
|
+
return old;
|
|
136
|
+
}
|
|
137
|
+
// AndUint32 atomically performs a bitwise AND operation on *addr using the bitmask provided as mask
|
|
138
|
+
// and returns the old value.
|
|
139
|
+
// Consider using the more ergonomic and less error-prone [Uint32.And] instead.
|
|
140
|
+
//
|
|
141
|
+
//go:noescape
|
|
142
|
+
export function AndUint32(addr, mask) {
|
|
143
|
+
if (!addr)
|
|
144
|
+
return 0;
|
|
145
|
+
let old = addr.value;
|
|
146
|
+
addr.value = (addr.value & mask) >>> 0; // Use unsigned right shift to ensure 32-bit unsigned integer
|
|
147
|
+
return old;
|
|
148
|
+
}
|
|
149
|
+
// AndUintptr atomically performs a bitwise AND operation on *addr using the bitmask provided as mask
|
|
150
|
+
// and returns the old value.
|
|
151
|
+
// Consider using the more ergonomic and less error-prone [Uintptr.And] instead.
|
|
152
|
+
//
|
|
153
|
+
//go:noescape
|
|
154
|
+
export function AndUintptr(addr, mask) {
|
|
155
|
+
if (!addr)
|
|
156
|
+
return 0;
|
|
157
|
+
let old = addr.value;
|
|
158
|
+
addr.value = (addr.value & mask) >>> 0; // Use unsigned right shift for uintptr
|
|
159
|
+
return old;
|
|
160
|
+
}
|
|
161
|
+
// OrInt32 atomically performs a bitwise OR operation on *addr using the bitmask provided as mask
|
|
162
|
+
// and returns the old value.
|
|
163
|
+
// Consider using the more ergonomic and less error-prone [Int32.Or] instead.
|
|
164
|
+
//
|
|
165
|
+
//go:noescape
|
|
166
|
+
export function OrInt32(addr, mask) {
|
|
167
|
+
if (!addr)
|
|
168
|
+
return 0;
|
|
169
|
+
let old = addr.value;
|
|
170
|
+
addr.value = (addr.value | mask) | 0; // Use bitwise OR to ensure 32-bit signed integer
|
|
171
|
+
return old;
|
|
172
|
+
}
|
|
173
|
+
// OrUint32 atomically performs a bitwise OR operation on *addr using the bitmask provided as mask
|
|
174
|
+
// and returns the old value.
|
|
175
|
+
// Consider using the more ergonomic and less error-prone [Uint32.Or] instead.
|
|
176
|
+
//
|
|
177
|
+
//go:noescape
|
|
178
|
+
export function OrUint32(addr, mask) {
|
|
179
|
+
if (!addr)
|
|
180
|
+
return 0;
|
|
181
|
+
let old = addr.value;
|
|
182
|
+
addr.value = (addr.value | mask) >>> 0; // Use unsigned right shift to ensure 32-bit unsigned integer
|
|
183
|
+
return old;
|
|
184
|
+
}
|
|
185
|
+
// OrUintptr atomically performs a bitwise OR operation on *addr using the bitmask provided as mask
|
|
186
|
+
// and returns the old value.
|
|
187
|
+
// Consider using the more ergonomic and less error-prone [Uintptr.Or] instead.
|
|
188
|
+
//
|
|
189
|
+
//go:noescape
|
|
190
|
+
export function OrUintptr(addr, mask) {
|
|
191
|
+
if (!addr)
|
|
192
|
+
return 0;
|
|
193
|
+
let old = addr.value;
|
|
194
|
+
addr.value = (addr.value | mask) >>> 0; // Use unsigned right shift for uintptr
|
|
195
|
+
return old;
|
|
196
|
+
}
|
|
197
|
+
// LoadInt32 atomically loads *addr.
|
|
198
|
+
// Consider using the more ergonomic and less error-prone [Int32.Load] instead.
|
|
199
|
+
//
|
|
200
|
+
//go:noescape
|
|
201
|
+
export function LoadInt32(addr) {
|
|
202
|
+
if (!addr)
|
|
203
|
+
return 0;
|
|
204
|
+
return addr.value;
|
|
205
|
+
}
|
|
206
|
+
// LoadUint32 atomically loads *addr.
|
|
207
|
+
// Consider using the more ergonomic and less error-prone [Uint32.Load] instead.
|
|
208
|
+
//
|
|
209
|
+
//go:noescape
|
|
210
|
+
export function LoadUint32(addr) {
|
|
211
|
+
if (!addr)
|
|
212
|
+
return 0;
|
|
213
|
+
return addr.value;
|
|
214
|
+
}
|
|
215
|
+
// LoadUintptr atomically loads *addr.
|
|
216
|
+
// Consider using the more ergonomic and less error-prone [Uintptr.Load] instead.
|
|
217
|
+
//
|
|
218
|
+
//go:noescape
|
|
219
|
+
export function LoadUintptr(addr) {
|
|
220
|
+
if (!addr)
|
|
221
|
+
return 0;
|
|
222
|
+
return addr.value;
|
|
223
|
+
}
|
|
224
|
+
// LoadPointer atomically loads *addr.
|
|
225
|
+
// Consider using the more ergonomic and less error-prone [Pointer.Load] instead.
|
|
226
|
+
export function LoadPointer(addr) {
|
|
227
|
+
if (!addr)
|
|
228
|
+
return null;
|
|
229
|
+
return addr.value;
|
|
230
|
+
}
|
|
231
|
+
// StoreInt32 atomically stores val into *addr.
|
|
232
|
+
// Consider using the more ergonomic and less error-prone [Int32.Store] instead.
|
|
233
|
+
//
|
|
234
|
+
//go:noescape
|
|
235
|
+
export function StoreInt32(addr, val) {
|
|
236
|
+
if (addr) {
|
|
237
|
+
addr.value = val | 0; // Use bitwise OR to ensure 32-bit signed integer
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
// StoreUint32 atomically stores val into *addr.
|
|
241
|
+
// Consider using the more ergonomic and less error-prone [Uint32.Store] instead.
|
|
242
|
+
//
|
|
243
|
+
//go:noescape
|
|
244
|
+
export function StoreUint32(addr, val) {
|
|
245
|
+
if (addr) {
|
|
246
|
+
addr.value = val >>> 0; // Use unsigned right shift to ensure 32-bit unsigned integer
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
// StoreUintptr atomically stores val into *addr.
|
|
250
|
+
// Consider using the more ergonomic and less error-prone [Uintptr.Store] instead.
|
|
251
|
+
//
|
|
252
|
+
//go:noescape
|
|
253
|
+
export function StoreUintptr(addr, val) {
|
|
254
|
+
if (addr) {
|
|
255
|
+
addr.value = val >>> 0; // Use unsigned right shift for uintptr
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
// StorePointer atomically stores val into *addr.
|
|
259
|
+
// Consider using the more ergonomic and less error-prone [Pointer.Store] instead.
|
|
260
|
+
export function StorePointer(addr, val) {
|
|
261
|
+
if (addr) {
|
|
262
|
+
addr.value = val;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
//# sourceMappingURL=doc.gs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doc.gs.js","sourceRoot":"","sources":["../../../../gs/sync/atomic/doc.gs.ts"],"names":[],"mappings":"AAQA,mFAAmF;AACnF,+EAA+E;AAC/E,EAAE;AACF,aAAa;AACb,MAAM,UAAU,SAAS,CAAC,IAA6B,EAAE,IAAY;IACpE,IAAI,CAAC,IAAI;QAAE,OAAO,CAAC,CAAC;IACpB,IAAI,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC;IACrB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IAClB,OAAO,GAAG,CAAC;AACZ,CAAC;AAED,oFAAoF;AACpF,gFAAgF;AAChF,EAAE;AACF,aAAa;AACb,MAAM,UAAU,UAAU,CAAC,IAA6B,EAAE,IAAY;IACrE,IAAI,CAAC,IAAI;QAAE,OAAO,CAAC,CAAC;IACpB,IAAI,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC;IACrB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IAClB,OAAO,GAAG,CAAC;AACZ,CAAC;AAED,qFAAqF;AACrF,iFAAiF;AACjF,EAAE;AACF,aAAa;AACb,MAAM,UAAU,WAAW,CAAC,IAA8B,EAAE,IAAa;IACxE,IAAI,CAAC,IAAI;QAAE,OAAO,CAAC,CAAC;IACpB,IAAI,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC;IACrB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IAClB,OAAO,GAAG,CAAC;AACZ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15 @@
|
|
|
1
|
+
import * as $ from "@goscript/builtin/builtin.js";
|
|
2
|
+
export declare function SwapInt64(addr: $.VarRef<number> | null, _new: number): number;
|
|
3
|
+
export declare function SwapUint64(addr: $.VarRef<number> | null, _new: number): number;
|
|
4
|
+
export declare function CompareAndSwapInt64(addr: $.VarRef<number> | null, old: number, _new: number): boolean;
|
|
5
|
+
export declare function CompareAndSwapUint64(addr: $.VarRef<number> | null, old: number, _new: number): boolean;
|
|
6
|
+
export declare function AddInt64(addr: $.VarRef<number> | null, delta: number): number;
|
|
7
|
+
export declare function AddUint64(addr: $.VarRef<number> | null, delta: number): number;
|
|
8
|
+
export declare function AndInt64(addr: $.VarRef<number> | null, mask: number): number;
|
|
9
|
+
export declare function AndUint64(addr: $.VarRef<number> | null, mask: number): number;
|
|
10
|
+
export declare function OrInt64(addr: $.VarRef<number> | null, mask: number): number;
|
|
11
|
+
export declare function OrUint64(addr: $.VarRef<number> | null, mask: number): number;
|
|
12
|
+
export declare function LoadInt64(addr: $.VarRef<number> | null): number;
|
|
13
|
+
export declare function LoadUint64(addr: $.VarRef<number> | null): number;
|
|
14
|
+
export declare function StoreInt64(addr: $.VarRef<number> | null, val: number): void;
|
|
15
|
+
export declare function StoreUint64(addr: $.VarRef<number> | null, val: number): void;
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
// SwapInt64 atomically stores new into *addr and returns the previous *addr value.
|
|
2
|
+
// Consider using the more ergonomic and less error-prone [Int64.Swap] instead
|
|
3
|
+
// (particularly if you target 32-bit platforms; see the bugs section).
|
|
4
|
+
//
|
|
5
|
+
//go:noescape
|
|
6
|
+
export function SwapInt64(addr, _new) {
|
|
7
|
+
if (!addr)
|
|
8
|
+
return 0;
|
|
9
|
+
let old = addr.value;
|
|
10
|
+
addr.value = _new;
|
|
11
|
+
return old;
|
|
12
|
+
}
|
|
13
|
+
// SwapUint64 atomically stores new into *addr and returns the previous *addr value.
|
|
14
|
+
// Consider using the more ergonomic and less error-prone [Uint64.Swap] instead
|
|
15
|
+
// (particularly if you target 32-bit platforms; see the bugs section).
|
|
16
|
+
//
|
|
17
|
+
//go:noescape
|
|
18
|
+
export function SwapUint64(addr, _new) {
|
|
19
|
+
if (!addr)
|
|
20
|
+
return 0;
|
|
21
|
+
let old = addr.value;
|
|
22
|
+
addr.value = _new;
|
|
23
|
+
return old;
|
|
24
|
+
}
|
|
25
|
+
// CompareAndSwapInt64 executes the compare-and-swap operation for an int64 value.
|
|
26
|
+
// Consider using the more ergonomic and less error-prone [Int64.CompareAndSwap] instead
|
|
27
|
+
// (particularly if you target 32-bit platforms; see the bugs section).
|
|
28
|
+
//
|
|
29
|
+
//go:noescape
|
|
30
|
+
export function CompareAndSwapInt64(addr, old, _new) {
|
|
31
|
+
if (!addr)
|
|
32
|
+
return false;
|
|
33
|
+
if (addr.value === old) {
|
|
34
|
+
addr.value = _new;
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
// CompareAndSwapUint64 executes the compare-and-swap operation for a uint64 value.
|
|
40
|
+
// Consider using the more ergonomic and less error-prone [Uint64.CompareAndSwap] instead
|
|
41
|
+
// (particularly if you target 32-bit platforms; see the bugs section).
|
|
42
|
+
//
|
|
43
|
+
//go:noescape
|
|
44
|
+
export function CompareAndSwapUint64(addr, old, _new) {
|
|
45
|
+
if (!addr)
|
|
46
|
+
return false;
|
|
47
|
+
if (addr.value === old) {
|
|
48
|
+
addr.value = _new;
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
// AddInt64 atomically adds delta to *addr and returns the new value.
|
|
54
|
+
// Consider using the more ergonomic and less error-prone [Int64.Add] instead
|
|
55
|
+
// (particularly if you target 32-bit platforms; see the bugs section).
|
|
56
|
+
//
|
|
57
|
+
//go:noescape
|
|
58
|
+
export function AddInt64(addr, delta) {
|
|
59
|
+
if (!addr)
|
|
60
|
+
return 0;
|
|
61
|
+
addr.value = addr.value + delta;
|
|
62
|
+
return addr.value;
|
|
63
|
+
}
|
|
64
|
+
// AddUint64 atomically adds delta to *addr and returns the new value.
|
|
65
|
+
// To subtract a signed positive constant value c from x, do AddUint64(&x, ^uint64(c-1)).
|
|
66
|
+
// In particular, to decrement x, do AddUint64(&x, ^uint64(0)).
|
|
67
|
+
// Consider using the more ergonomic and less error-prone [Uint64.Add] instead
|
|
68
|
+
// (particularly if you target 32-bit platforms; see the bugs section).
|
|
69
|
+
//
|
|
70
|
+
//go:noescape
|
|
71
|
+
export function AddUint64(addr, delta) {
|
|
72
|
+
if (!addr)
|
|
73
|
+
return 0;
|
|
74
|
+
addr.value = addr.value + delta;
|
|
75
|
+
return addr.value;
|
|
76
|
+
}
|
|
77
|
+
// AndInt64 atomically performs a bitwise AND operation on *addr using the bitmask provided as mask
|
|
78
|
+
// and returns the old value.
|
|
79
|
+
// Consider using the more ergonomic and less error-prone [Int64.And] instead.
|
|
80
|
+
//
|
|
81
|
+
//go:noescape
|
|
82
|
+
export function AndInt64(addr, mask) {
|
|
83
|
+
if (!addr)
|
|
84
|
+
return 0;
|
|
85
|
+
let old = addr.value;
|
|
86
|
+
addr.value = addr.value & mask;
|
|
87
|
+
return old;
|
|
88
|
+
}
|
|
89
|
+
// AndUint64 atomically performs a bitwise AND operation on *addr using the bitmask provided as mask
|
|
90
|
+
// and returns the old.
|
|
91
|
+
// Consider using the more ergonomic and less error-prone [Uint64.And] instead.
|
|
92
|
+
//
|
|
93
|
+
//go:noescape
|
|
94
|
+
export function AndUint64(addr, mask) {
|
|
95
|
+
if (!addr)
|
|
96
|
+
return 0;
|
|
97
|
+
let old = addr.value;
|
|
98
|
+
addr.value = addr.value & mask;
|
|
99
|
+
return old;
|
|
100
|
+
}
|
|
101
|
+
// OrInt64 atomically performs a bitwise OR operation on *addr using the bitmask provided as mask
|
|
102
|
+
// and returns the old value.
|
|
103
|
+
// Consider using the more ergonomic and less error-prone [Int64.Or] instead.
|
|
104
|
+
//
|
|
105
|
+
//go:noescape
|
|
106
|
+
export function OrInt64(addr, mask) {
|
|
107
|
+
if (!addr)
|
|
108
|
+
return 0;
|
|
109
|
+
let old = addr.value;
|
|
110
|
+
addr.value = addr.value | mask;
|
|
111
|
+
return old;
|
|
112
|
+
}
|
|
113
|
+
// OrUint64 atomically performs a bitwise OR operation on *addr using the bitmask provided as mask
|
|
114
|
+
// and returns the old value.
|
|
115
|
+
// Consider using the more ergonomic and less error-prone [Uint64.Or] instead.
|
|
116
|
+
//
|
|
117
|
+
//go:noescape
|
|
118
|
+
export function OrUint64(addr, mask) {
|
|
119
|
+
if (!addr)
|
|
120
|
+
return 0;
|
|
121
|
+
let old = addr.value;
|
|
122
|
+
addr.value = addr.value | mask;
|
|
123
|
+
return old;
|
|
124
|
+
}
|
|
125
|
+
// LoadInt64 atomically loads *addr.
|
|
126
|
+
// Consider using the more ergonomic and less error-prone [Int64.Load] instead
|
|
127
|
+
// (particularly if you target 32-bit platforms; see the bugs section).
|
|
128
|
+
//
|
|
129
|
+
//go:noescape
|
|
130
|
+
export function LoadInt64(addr) {
|
|
131
|
+
if (!addr)
|
|
132
|
+
return 0;
|
|
133
|
+
return addr.value;
|
|
134
|
+
}
|
|
135
|
+
// LoadUint64 atomically loads *addr.
|
|
136
|
+
// Consider using the more ergonomic and less error-prone [Uint64.Load] instead
|
|
137
|
+
// (particularly if you target 32-bit platforms; see the bugs section).
|
|
138
|
+
//
|
|
139
|
+
//go:noescape
|
|
140
|
+
export function LoadUint64(addr) {
|
|
141
|
+
if (!addr)
|
|
142
|
+
return 0;
|
|
143
|
+
return addr.value;
|
|
144
|
+
}
|
|
145
|
+
// StoreInt64 atomically stores val into *addr.
|
|
146
|
+
// Consider using the more ergonomic and less error-prone [Int64.Store] instead
|
|
147
|
+
// (particularly if you target 32-bit platforms; see the bugs section).
|
|
148
|
+
//
|
|
149
|
+
//go:noescape
|
|
150
|
+
export function StoreInt64(addr, val) {
|
|
151
|
+
if (addr) {
|
|
152
|
+
addr.value = val;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
// StoreUint64 atomically stores val into *addr.
|
|
156
|
+
// Consider using the more ergonomic and less error-prone [Uint64.Store] instead
|
|
157
|
+
// (particularly if you target 32-bit platforms; see the bugs section).
|
|
158
|
+
//
|
|
159
|
+
//go:noescape
|
|
160
|
+
export function StoreUint64(addr, val) {
|
|
161
|
+
if (addr) {
|
|
162
|
+
addr.value = val;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=doc_64.gs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doc_64.gs.js","sourceRoot":"","sources":["../../../../gs/sync/atomic/doc_64.gs.ts"],"names":[],"mappings":"AAEA,mFAAmF;AACnF,8EAA8E;AAC9E,uEAAuE;AACvE,EAAE;AACF,aAAa;AACb,MAAM,UAAU,SAAS,CAAC,IAA6B,EAAE,IAAY;IACpE,IAAI,CAAC,IAAI;QAAE,OAAO,CAAC,CAAC;IACpB,IAAI,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC;IACrB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IAClB,OAAO,GAAG,CAAC;AACZ,CAAC;AAED,oFAAoF;AACpF,+EAA+E;AAC/E,uEAAuE;AACvE,EAAE;AACF,aAAa;AACb,MAAM,UAAU,UAAU,CAAC,IAA6B,EAAE,IAAY;IACrE,IAAI,CAAC,IAAI;QAAE,OAAO,CAAC,CAAC;IACpB,IAAI,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC;IACrB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IAClB,OAAO,GAAG,CAAC;AACZ,CAAC;AAED,kFAAkF;AAClF,wFAAwF;AACxF,uEAAuE;AACvE,EAAE;AACF,aAAa;AACb,MAAM,UAAU,mBAAmB,CAAC,IAA6B,EAAE,GAAW,EAAE,IAAY;IAC3F,IAAI,CAAC,IAAI;QAAE,OAAO,KAAK,CAAC;IACxB,IAAI,IAAI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AAE,OAAO,CAAC,CAAC;IACpB,OAAO,IAAI,CAAC,KAAK,CAAC;AACnB,CAAC;AAED,qCAAqC;AACrC,+EAA+E;AAC/E,uEAAuE;AACvE,EAAE;AACF,aAAa;AACb,MAAM,UAAU,UAAU,CAAC,IAA6B;IACvD,IAAI,CAAC,IAAI;QAAE,OAAO,CAAC,CAAC;IACpB,OAAO,IAAI,CAAC,KAAK,CAAC;AACnB,CAAC;AAED,+CAA+C;AAC/C,+EAA+E;AAC/E,uEAAuE;AACvE,EAAE;AACF,aAAa;AACb,MAAM,UAAU,UAAU,CAAC,IAA6B,EAAE,GAAW;IACpE,IAAI,IAAI,EAAE,CAAC;QACV,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC;IAClB,CAAC;AACF,CAAC;AAED,gDAAgD;AAChD,gFAAgF;AAChF,uEAAuE;AACvE,EAAE;AACF,aAAa;AACb,MAAM,UAAU,WAAW,CAAC,IAA6B,EAAE,GAAW;IACrE,IAAI,IAAI,EAAE,CAAC;QACV,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC;IAClB,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { AddInt32, AddUint32, AddUintptr, AndInt32, AndUint32, AndUintptr, CompareAndSwapInt32, CompareAndSwapPointer, CompareAndSwapUint32, CompareAndSwapUintptr, LoadInt32, LoadPointer, LoadUint32, LoadUintptr, OrInt32, OrUint32, OrUintptr, StoreInt32, StorePointer, StoreUint32, StoreUintptr, SwapInt32, SwapPointer, SwapUint32, SwapUintptr } from "./doc.gs.js";
|
|
2
|
+
export { AddInt64, AddUint64, AndInt64, AndUint64, CompareAndSwapInt64, CompareAndSwapUint64, LoadInt64, LoadUint64, OrInt64, OrUint64, StoreInt64, StoreUint64, SwapInt64, SwapUint64 } from "./doc_64.gs.js";
|
|
3
|
+
export { Bool, Int32, Int64, Pointer, Uint32, Uint64, Uintptr } from "./type.gs.js";
|
|
4
|
+
export { Value } from "./value.gs.js";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { AddInt32, AddUint32, AddUintptr, AndInt32, AndUint32, AndUintptr, CompareAndSwapInt32, CompareAndSwapPointer, CompareAndSwapUint32, CompareAndSwapUintptr, LoadInt32, LoadPointer, LoadUint32, LoadUintptr, OrInt32, OrUint32, OrUintptr, StoreInt32, StorePointer, StoreUint32, StoreUintptr, SwapInt32, SwapPointer, SwapUint32, SwapUintptr } from "./doc.gs.js";
|
|
2
|
+
export { AddInt64, AddUint64, AndInt64, AndUint64, CompareAndSwapInt64, CompareAndSwapUint64, LoadInt64, LoadUint64, OrInt64, OrUint64, StoreInt64, StoreUint64, SwapInt64, SwapUint64 } from "./doc_64.gs.js";
|
|
3
|
+
export { Bool, Int32, Int64, Pointer, Uint32, Uint64, Uintptr } from "./type.gs.js";
|
|
4
|
+
export { Value } from "./value.gs.js";
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../gs/sync/atomic/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC5W,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC9M,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACnF,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA"}
|