@@ -5,8 +5,8 @@ import * as proc from './process.mjs';
55const ProcessID = proc . ProcessID ;
66import { AbstractLevel } from './AbstractLevel.mjs' ;
77import { Level } from './Level.mjs' ;
8- import { Authority } from './Authority.mjs'
9- import * as levels from './Level.mjs' ;
8+ import { Authority } from './Authority.mjs' ;
9+ import * as levels from './Level.mjs' ;
1010import { TroupeType } from './TroupeTypes.mjs' ;
1111const actsFor = levels . actsFor ;
1212
@@ -16,204 +16,204 @@ import { TroupeAggregateRawValue, TroupeRawValue } from './TroupeRawValue.mjs';
1616// import { LVal } from './Lval';
1717
1818function _thread ( ) {
19- return getRuntimeObject ( ) . __sched . __currentThread
19+ return getRuntimeObject ( ) . __sched . __currentThread ;
2020}
2121
2222function __stringRep ( v ) {
2323 if ( v . stringRep ) {
24- return v . stringRep ( )
24+ return v . stringRep ( ) ;
2525 } else {
26- let t = ""
26+ let t = "" ;
2727 if ( typeof v === 'string' ) {
28- t = "\"" + v . toString ( ) + "\""
28+ t = "\"" + v . toString ( ) + "\"" ;
2929 } else {
3030 t = v . toString ( ) ;
3131 }
32- return t
32+ return t ;
3333 }
3434}
3535
36- let err = x => _thread ( ) . threadError ( x )
36+ const err = x => { _thread ( ) . threadError ( x ) ; } ;
3737export function assertIsAtom ( x : any ) {
38- _thread ( ) . raiseBlockingThreadLev ( x . tlev )
38+ _thread ( ) . raiseBlockingThreadLev ( x . tlev ) ;
3939 if ( x . val . _troupeType != TroupeType . ATOM ) {
40- err ( "value " + __stringRep ( x ) + " is not an atom" )
40+ err ( "value " + __stringRep ( x ) + " is not an atom" ) ;
4141 }
4242}
4343
4444export function rawAssertIsNumber ( x ) {
4545 if ( typeof x != 'number' ) {
46- err ( "value " + __stringRep ( x ) + " is not a number" )
46+ err ( "value " + __stringRep ( x ) + " is not a number" ) ;
4747 }
4848}
4949
5050export function assertIsNumber ( x : any ) {
51- _thread ( ) . raiseBlockingThreadLev ( x . tlev )
51+ _thread ( ) . raiseBlockingThreadLev ( x . tlev ) ;
5252 if ( typeof x . val != 'number' ) {
53- err ( "value " + __stringRep ( x ) + " is not a number" )
53+ err ( "value " + __stringRep ( x ) + " is not a number" ) ;
5454 }
5555}
5656
5757export function assertIsBoolean ( x : any ) {
5858 _thread ( ) . raiseBlockingThreadLev ( x . tlev ) ;
5959 if ( typeof x . val != 'boolean' ) {
60- err ( "value " + __stringRep ( x ) + " is not a boolean" )
60+ err ( "value " + __stringRep ( x ) + " is not a boolean" ) ;
6161 }
6262}
6363
6464export function rawAssertIsBoolean ( x :any ) {
6565 if ( typeof x != 'boolean' ) {
66- err ( "value " + __stringRep ( x ) + " is not a boolean" )
66+ err ( "value " + __stringRep ( x ) + " is not a boolean" ) ;
6767 }
6868}
6969
7070export function assertIsFunction ( x : any , internal = false ) {
7171 _thread ( ) . raiseBlockingThreadLev ( x . tlev ) ;
72- rawAssertIsFunction ( x . val , internal )
72+ rawAssertIsFunction ( x . val , internal ) ;
7373}
7474
7575export function rawAssertIsFunction ( x , internal = false ) {
7676 if ( x . _troupeType != TroupeType . CLOSURE ) {
77- _thread ( ) . threadError ( "value " + __stringRep ( x ) + " is not a function" , internal )
77+ _thread ( ) . threadError ( "value " + __stringRep ( x ) + " is not a function" , internal ) ;
7878 }
7979}
8080
8181
8282export function assertIsLocalObject ( x : any ) {
8383 _thread ( ) . raiseBlockingThreadLev ( x . tlev ) ;
8484 if ( x . val . _troupeType != TroupeType . LOCALOBJECT ) {
85- err ( "value " + __stringRep ( x ) + " is not a local object" )
85+ err ( "value " + __stringRep ( x ) + " is not a local object" ) ;
8686 }
8787}
8888
8989export function assertIsHandler ( x : any ) {
9090 _thread ( ) . raiseBlockingThreadLev ( x . tlev ) ;
9191 if ( x . val . _troupeType != TroupeType . CLOSURE ) {
92- err ( "value " + __stringRep ( x ) + " is not a handler" )
92+ err ( "value " + __stringRep ( x ) + " is not a handler" ) ;
9393 }
9494}
9595
9696export function assertIsUnit ( x : any ) {
9797 _thread ( ) . raiseBlockingThreadLev ( x . tlev ) ;
9898 if ( ! x . val . _is_unit ) {
99- err ( "value " + __stringRep ( x ) + " is not unit" )
99+ err ( "value " + __stringRep ( x ) + " is not unit" ) ;
100100 }
101101}
102102
103103
104104export function assertIsListOrTuple ( x : any ) {
105105 _thread ( ) . raiseBlockingThreadLev ( x . lev ) ; ;
106106 if ( ! ( ( isListFlagSet ( x . val ) || isTupleFlagSet ( x . val ) ) ) ) {
107- err ( "value " + __stringRep ( x ) + " is not a list or tuple" )
107+ err ( "value " + __stringRep ( x ) + " is not a list or tuple" ) ;
108108 }
109109}
110110
111111export function assertIsList ( x : any ) {
112112 _thread ( ) . raiseBlockingThreadLev ( x . lev ) ; ;
113- rawAssertIsList ( x . val )
113+ rawAssertIsList ( x . val ) ;
114114}
115115
116116export function rawAssertIsList ( x :any ) {
117117 if ( ! isListFlagSet ( x ) ) {
118- err ( "value " + __stringRep ( x ) + " is not a list" )
118+ err ( "value " + __stringRep ( x ) + " is not a list" ) ;
119119 }
120120}
121121
122122export function assertIsNTuple ( x : any , n : number ) {
123123 _thread ( ) . raiseBlockingThreadLev ( x . lev ) ;
124124 if ( ! ( Array . isArray ( x . val ) && isTupleFlagSet ( x . val ) && x . val . length == n ) ) {
125- err ( "value " + __stringRep ( x ) + " is not a " + n + "-tuple" )
125+ err ( "value " + __stringRep ( x ) + " is not a " + n + "-tuple" ) ;
126126 }
127127}
128128
129129
130130export function assertIsNTupleR3 ( x :TroupeRawValue , lev :Level , tlev :Level , n :number ) {
131131 _thread ( ) . raiseBlockingThreadLev ( lev ) ;
132132 if ( ! ( Array . isArray ( x ) && isTupleFlagSet ( x ) && x . length == n ) ) {
133- err ( "value " + __stringRep ( x ) + " is not a " + n + "-tuple" )
133+ err ( "value " + __stringRep ( x ) + " is not a " + n + "-tuple" ) ;
134134 }
135135}
136136
137137export function rawAssertIsTuple ( x ) {
138138 if ( ! ( Array . isArray ( x ) && isTupleFlagSet ( x ) ) ) {
139- err ( "value " + __stringRep ( x ) + " is not a tuple" )
140- }
139+ err ( "value " + __stringRep ( x ) + " is not a tuple" ) ;
140+ }
141141}
142142
143143/**
144144 * Assumes `x` is a tuple and asserts it has at least length `n`.
145145 */
146146export function rawAssertTupleLengthGreaterThan ( x , n : number ) {
147147 if ( x . length <= n ) {
148- err ( "Index out of bounds: tuple " + __stringRep ( x ) + " does not have length more than " + n )
148+ err ( "Index out of bounds: tuple " + __stringRep ( x ) + " does not have length more than " + n ) ;
149149 }
150150}
151151
152152
153153export function rawAssertRecordHasField ( x , field : string ) {
154154 if ( ! x . hasField ( field ) ) {
155- err ( `record ${ __stringRep ( x ) } does not have field \'${ field } \'` )
155+ err ( `record ${ __stringRep ( x ) } does not have field \'${ field } \'` ) ;
156156 }
157157}
158158
159159
160160export function assertIsRecord ( x : any ) {
161161 _thread ( ) . raiseBlockingThreadLev ( x . lev ) ;
162162 if ( x . val . _troupeType != TroupeType . RECORD ) {
163- err ( `value ${ __stringRep ( x ) } is not a record` )
163+ err ( `value ${ __stringRep ( x ) } is not a record` ) ;
164164 }
165165}
166166
167167export function rawAssertIsRecord ( x : any ) {
168168 if ( x . _troupeType != TroupeType . RECORD ) {
169- err ( `value ${ __stringRep ( x ) } is not a record` )
169+ err ( `value ${ __stringRep ( x ) } is not a record` ) ;
170170 }
171171}
172172
173173export function assertIsString ( x : any ) {
174174 _thread ( ) . raiseBlockingThreadLev ( x . tlev ) ;
175175 if ( typeof x . val != 'string' ) {
176- err ( "value " + __stringRep ( x ) + " is not a string" )
176+ err ( "value " + __stringRep ( x ) + " is not a string" ) ;
177177 }
178178}
179179
180180export function rawAssertIsString ( x :any ) {
181181 if ( typeof x != 'string' ) {
182- err ( "value " + __stringRep ( x ) + " is not a string" )
183- }
182+ err ( "value " + __stringRep ( x ) + " is not a string" ) ;
183+ }
184184}
185185
186186export function rawAssertNotZero ( x :any ) {
187187 if ( x === 0 ) {
188- err ( "Division by zero error" )
188+ err ( "Division by zero error" ) ;
189189 }
190190}
191191
192192
193193export function assertIsNode ( x : any ) {
194194 _thread ( ) . raiseBlockingThreadLev ( x . tlev ) ;
195195 if ( typeof x . val != 'string' ) {
196- err ( "value " + __stringRep ( x ) + " is not a node string" ) // todo: check for it being a proper nodeid format?
196+ err ( "value " + __stringRep ( x ) + " is not a node string" ) ; // todo: check for it being a proper nodeid format?
197197 }
198198 if ( x . val . startsWith ( "@" ) ) {
199199 if ( ! __nodeManager . aliases [ x . val . substring ( 1 ) ] ) {
200- err ( `${ x . val } is not a defined alias` )
200+ err ( `${ x . val } is not a defined alias` ) ;
201201 }
202202 }
203203}
204204
205205export function assertIsProcessId ( x : any ) {
206206 _thread ( ) . raiseBlockingThreadLev ( x . tlev ) ;
207207 if ( ! ( x . val instanceof ProcessID ) ) {
208- err ( "value " + __stringRep ( x ) + " is not a process id" )
208+ err ( "value " + __stringRep ( x ) + " is not a process id" ) ;
209209 }
210210}
211211
212212
213213export function assertIsCapability ( x : any ) {
214214 _thread ( ) . raiseBlockingThreadLev ( x . tlev ) ;
215215 if ( ! ( x . val instanceof Capability ) ) {
216- err ( "value " + __stringRep ( x ) + " is not a capability of lowering the mailbox clearance" )
216+ err ( "value " + __stringRep ( x ) + " is not a capability of lowering the mailbox clearance" ) ;
217217 }
218218}
219219
@@ -230,11 +230,11 @@ export function rawAssertIsLevel (x:any) {
230230 }
231231}
232232export function assertIsRootAuthority ( x : any ) {
233- let isTop = actsFor ( x . val . authorityLevel , levels . ROOT ) ;
233+ const isTop = actsFor ( x . val . authorityLevel , levels . ROOT ) ;
234234 if ( ! isTop ) {
235- let errorMessage =
235+ const errorMessage =
236236 "Provided authority is not TOP\n" +
237- ` | level of the provided authority: ${ x . val . authorityLevel . stringRep ( ) } `
237+ ` | level of the provided authority: ${ x . val . authorityLevel . stringRep ( ) } ` ;
238238 err ( errorMessage ) ;
239239 }
240240}
@@ -262,13 +262,13 @@ export function assertIsEnv(x: any) {
262262
263263export function assertNormalState ( s : string ) {
264264 if ( ! _thread ( ) . handlerState . isNormal ( ) ) {
265- err ( "invalid handler state in " + s + " -- side effects are prohbited in handler pattern matching or sandboxed code" )
265+ err ( "invalid handler state in " + s + " -- side effects are prohbited in handler pattern matching or sandboxed code" ) ;
266266 }
267267}
268268
269269export function assertDeclassificationAllowed ( s : string ) {
270270 if ( ! _thread ( ) . handlerState . declassificationAllowed ( ) ) {
271- err ( "invalid handler state in " + s + ": declassification prohibited in handler pattern matching" )
271+ err ( "invalid handler state in " + s + ": declassification prohibited in handler pattern matching" ) ;
272272 }
273273}
274274
@@ -291,9 +291,9 @@ export function assertPairAreStringsOrNumbers(x: any, y: any) {
291291
292292export function rawAssertPairsAreStringsOrNumbers ( x :any , y :any ) {
293293 switch ( typeof x ) {
294- case 'number' : rawAssertIsNumber ( y ) ; break
295- case 'string' : rawAssertIsString ( y ) ; break
296- default : err ( "value " + __stringRep ( x ) + " is not a number or a string" )
294+ case 'number' : rawAssertIsNumber ( y ) ; break ;
295+ case 'string' : rawAssertIsString ( y ) ; break ;
296+ default : err ( "value " + __stringRep ( x ) + " is not a number or a string" ) ;
297297 // default: err("values " + __stringRep(x) + " and " + __stringRep(y) + " are of different types")
298298 }
299299}
0 commit comments