@shd101wyy/yo 0.0.23 → 0.0.25

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.
Files changed (97) hide show
  1. package/out/cjs/index.cjs +560 -520
  2. package/out/cjs/yo-cli.cjs +598 -558
  3. package/out/esm/index.mjs +551 -511
  4. package/out/types/src/codegen/exprs/arc.d.ts +5 -0
  5. package/out/types/src/codegen/types/generation.d.ts +2 -0
  6. package/out/types/src/codegen/utils/index.d.ts +8 -1
  7. package/out/types/src/evaluator/builtins/rc-fns.d.ts +5 -0
  8. package/out/types/src/evaluator/calls/arc.d.ts +15 -0
  9. package/out/types/src/evaluator/calls/trait-type.d.ts +8 -1
  10. package/out/types/src/evaluator/context.d.ts +11 -1
  11. package/out/types/src/evaluator/types/utils.d.ts +8 -3
  12. package/out/types/src/evaluator/utils/closure.d.ts +7 -1
  13. package/out/types/src/evaluator/values/impl.d.ts +8 -0
  14. package/out/types/src/expr.d.ts +6 -0
  15. package/out/types/src/test-runner.d.ts +2 -0
  16. package/out/types/src/types/creators.d.ts +2 -1
  17. package/out/types/src/types/definitions.d.ts +10 -0
  18. package/out/types/src/types/guards.d.ts +2 -1
  19. package/out/types/src/types/tags.d.ts +1 -0
  20. package/out/types/tsconfig.tsbuildinfo +1 -1
  21. package/package.json +1 -1
  22. package/std/collections/array_list.yo +80 -10
  23. package/std/collections/btree_map.yo +120 -2
  24. package/std/collections/deque.yo +98 -6
  25. package/std/collections/hash_map.yo +137 -1
  26. package/std/collections/hash_set.yo +85 -1
  27. package/std/collections/linked_list.yo +61 -1
  28. package/std/collections/priority_queue.yo +70 -1
  29. package/std/crypto/md5.yo +4 -4
  30. package/std/crypto/random.yo +3 -3
  31. package/std/crypto/sha256.yo +8 -7
  32. package/std/encoding/base64.yo +6 -6
  33. package/std/encoding/hex.yo +27 -22
  34. package/std/encoding/json.yo +185 -186
  35. package/std/encoding/utf16.yo +2 -2
  36. package/std/fmt/display.yo +1 -1
  37. package/std/fmt/writer.yo +2 -4
  38. package/std/fs/dir.yo +5 -5
  39. package/std/fs/file.yo +21 -13
  40. package/std/fs/metadata.yo +4 -4
  41. package/std/fs/temp.yo +3 -3
  42. package/std/fs/types.yo +1 -1
  43. package/std/fs/walker.yo +1 -1
  44. package/std/net/addr.yo +2 -2
  45. package/std/net/dns.yo +21 -20
  46. package/std/net/errors.yo +1 -1
  47. package/std/net/tcp.yo +134 -100
  48. package/std/net/udp.yo +51 -42
  49. package/std/os/env.yo +21 -23
  50. package/std/os/signal.yo +10 -9
  51. package/std/prelude.yo +158 -22
  52. package/std/string/string.yo +99 -1
  53. package/std/sync/once.yo +1 -1
  54. package/std/{io → sys}/advise.yo +1 -1
  55. package/std/sys/bufio/buf_reader.yo +300 -0
  56. package/std/sys/bufio/buf_writer.yo +168 -0
  57. package/std/{io → sys}/clock.yo +1 -1
  58. package/std/{io → sys}/constants.yo +1 -1
  59. package/std/{io → sys}/copy.yo +1 -1
  60. package/std/{io → sys}/dir.yo +6 -6
  61. package/std/{io → sys}/dns.yo +3 -3
  62. package/std/{io → sys}/errors.yo +1 -1
  63. package/std/{io → sys}/events.yo +1 -1
  64. package/std/{io → sys}/externs.yo +1 -1
  65. package/std/{io → sys}/fallocate.yo +1 -1
  66. package/std/{io → sys}/fcntl.yo +1 -1
  67. package/std/{io → sys}/file.yo +1 -1
  68. package/std/{io → sys}/future.yo +1 -1
  69. package/std/{io → sys}/iov.yo +1 -1
  70. package/std/{io → sys}/lock.yo +1 -1
  71. package/std/{io → sys}/mmap.yo +1 -1
  72. package/std/{io → sys}/path.yo +1 -1
  73. package/std/{io → sys}/perm.yo +3 -3
  74. package/std/{io → sys}/pipe.yo +1 -1
  75. package/std/{io → sys}/process.yo +1 -1
  76. package/std/{io → sys}/seek.yo +1 -1
  77. package/std/{io → sys}/signal.yo +1 -1
  78. package/std/{io → sys}/signals.yo +1 -1
  79. package/std/{io → sys}/socket.yo +1 -1
  80. package/std/{io → sys}/socketpair.yo +1 -1
  81. package/std/{io → sys}/sockinfo.yo +1 -1
  82. package/std/{io → sys}/statfs.yo +2 -2
  83. package/std/{io → sys}/statx.yo +1 -1
  84. package/std/{io → sys}/sysinfo.yo +1 -1
  85. package/std/{io → sys}/tcp.yo +3 -3
  86. package/std/{io → sys}/temp.yo +1 -1
  87. package/std/{io → sys}/time.yo +2 -2
  88. package/std/{io → sys}/timer.yo +1 -1
  89. package/std/{io → sys}/tty.yo +1 -1
  90. package/std/{io → sys}/udp.yo +4 -4
  91. package/std/{io → sys}/umask.yo +1 -1
  92. package/std/{io → sys}/unix.yo +1 -1
  93. package/std/time/datetime.yo +18 -23
  94. package/std/time/instant.yo +13 -11
  95. package/std/url/url.yo +533 -0
  96. package/std/math/functions.yo +0 -74
  97. package/std/math/random.yo +0 -94
@@ -0,0 +1,5 @@
1
+ import type { FnCallExpr } from "../../expr";
2
+ import { type CodeGenContext } from "../utils";
3
+ export declare function generateYoArcDispose(expr: FnCallExpr, indent: string, context: CodeGenContext): string;
4
+ export declare function isArcTypeCall(expr: FnCallExpr): boolean;
5
+ export declare function generateArcTypeCall(expr: FnCallExpr, indent: string, context: CodeGenContext): string;
@@ -4,6 +4,8 @@ export declare function generateTypeDeclarations(context: CodeGenContext): void;
4
4
  export declare function generateArrayStructDeclarations(context: CodeGenContext): void;
5
5
  export declare function generateSliceStructDeclarations(context: CodeGenContext): void;
6
6
  export declare function generateIsoTypeDeclarations(context: CodeGenContext): void;
7
+ export declare function generateArcTypeForwardDeclarations(context: CodeGenContext): void;
8
+ export declare function generateArcTypeDefinitions(context: CodeGenContext): void;
7
9
  export declare function generateClosureDeclaration(functionType: FunctionType, cName: string, captureType: StructType | undefined, context: CodeGenContext): void;
8
10
  export declare function generateStructDeclaration(structType: StructType, cName: string, context: CodeGenContext): void;
9
11
  export declare function generateTupleDeclaration(tupleType: TupleType, cName: string, context: CodeGenContext): void;
@@ -2,7 +2,7 @@ import { Emitter } from "../../emitter";
2
2
  import { type Environment } from "../../env";
3
3
  import { type Expr } from "../../expr";
4
4
  import type { FunctionValue, FuncValueId } from "../../function-value";
5
- import type { DynType, EnumType, FunctionType, IsoType, StructType, Type, TypeId } from "../../types/definitions";
5
+ import type { ArcType, DynType, EnumType, FunctionType, IsoType, StructType, Type, TypeId } from "../../types/definitions";
6
6
  import { type TraitValue } from "../../value";
7
7
  export interface CodeGenContext {
8
8
  types: Record<TypeId, {
@@ -35,6 +35,13 @@ export interface CodeGenContext {
35
35
  extractGenerated?: boolean;
36
36
  disposeGenerated?: boolean;
37
37
  }>;
38
+ arcTypes?: Map<string, {
39
+ childTypeCName: string;
40
+ arcType: ArcType;
41
+ structGenerated?: boolean;
42
+ createGenerated?: boolean;
43
+ disposeGenerated?: boolean;
44
+ }>;
38
45
  spawnedFunctionSignatures: Map<string, {
39
46
  parameterTypes: Type[];
40
47
  returnType: Type;
@@ -56,6 +56,11 @@ export declare function evaluateYoIsoDispose({ expr, env, context, }: {
56
56
  env: Environment;
57
57
  context: EvaluatorContext;
58
58
  }): Expr;
59
+ export declare function evaluateYoArcDispose({ expr, env, context, }: {
60
+ expr: FnCallExpr;
61
+ env: Environment;
62
+ context: EvaluatorContext;
63
+ }): Expr;
59
64
  export declare function evaluateYoDropArrayElement({ expr, env, context, }: {
60
65
  expr: FnCallExpr;
61
66
  env: Environment;
@@ -0,0 +1,15 @@
1
+ import { type Environment } from "../../env";
2
+ import { type FnCallExpr } from "../../expr";
3
+ import type { ArcType } from "../../types/definitions";
4
+ import type { EvaluatorContext } from "../context";
5
+ export declare function evaluateArcTypeCall({ expr, env, context, }: {
6
+ expr: FnCallExpr;
7
+ env: Environment;
8
+ context: EvaluatorContext;
9
+ }): FnCallExpr;
10
+ export declare function evaluateArcValueCall({ expr, env, context, arcType, }: {
11
+ expr: FnCallExpr;
12
+ env: Environment;
13
+ context: EvaluatorContext;
14
+ arcType: ArcType;
15
+ }): FnCallExpr;
@@ -1,7 +1,14 @@
1
1
  import { type Environment } from "../../env";
2
2
  import { type Expr } from "../../expr";
3
3
  import type { TraitType } from "../../types/definitions";
4
- import type { EvaluatorContext, TraitTypeCallResult } from "../context";
4
+ import type { EvaluatorContext, TraitSpecializationResult, TraitTypeCallResult } from "../context";
5
+ export declare function tryToSpecializeTraitType({ traitType, argExprs, callerEnv, context, }: {
6
+ traitExpr: Expr;
7
+ traitType: TraitType;
8
+ argExprs: Expr[];
9
+ callerEnv: Environment;
10
+ context: EvaluatorContext;
11
+ }): TraitSpecializationResult;
5
12
  export declare function tryToImplementTraitWithArgumentsByTraitType({ traitExpr, traitType, argExprs, callerEnv, context, }: {
6
13
  traitExpr: Expr;
7
14
  traitType: TraitType;
@@ -3,7 +3,7 @@ import { YoError } from "../error";
3
3
  import type { Expr, FnCallExpr, PathCollection } from "../expr";
4
4
  import type { FunctionValue } from "../function-value";
5
5
  import type { Token } from "../token";
6
- import type { FunctionType, Type } from "../types/definitions";
6
+ import type { FunctionType, TraitType, Type } from "../types/definitions";
7
7
  import type { ArrayValue, ModuleValue, TraitValue, Value } from "../value";
8
8
  export interface FunctionEvaluationContext {
9
9
  kind: "function-body";
@@ -112,6 +112,10 @@ export interface TraitTypeCallResult {
112
112
  traitValue: TraitValue;
113
113
  callerEnv: Environment;
114
114
  }
115
+ export interface TraitSpecializationResult {
116
+ specializedTraitType: TraitType;
117
+ callerEnv: Environment;
118
+ }
115
119
  export interface ArrayCallResult {
116
120
  value: Value | undefined;
117
121
  index?: number;
@@ -157,6 +161,9 @@ export interface FunctionToCall {
157
161
  } | {
158
162
  kind: "trait-type";
159
163
  result: TraitTypeCallResult;
164
+ } | {
165
+ kind: "trait-specialization";
166
+ result: TraitSpecializationResult;
160
167
  } | {
161
168
  kind: "array";
162
169
  result: ArrayCallResult;
@@ -169,6 +176,9 @@ export interface FunctionToCall {
169
176
  } | {
170
177
  kind: "iso-value";
171
178
  result: FnCallExpr;
179
+ } | {
180
+ kind: "arc-value";
181
+ result: FnCallExpr;
172
182
  } | {
173
183
  kind: "error";
174
184
  error: Error | YoError;
@@ -1,18 +1,18 @@
1
1
  import type { Environment } from "../../env";
2
2
  import type { Token } from "../../token";
3
- import type { DynType, EnumType, IsoType, SomeType, StructType, TupleType, UnionType } from "../../types/definitions";
3
+ import type { ArcType, DynType, EnumType, IsoType, SomeType, StructType, TupleType, UnionType } from "../../types/definitions";
4
4
  import type { EvaluatorContext } from "../context";
5
5
  export declare function addFunctionSignatureToSelfTypeModule({ label, functionSignature, SelfType, env, context, }: {
6
6
  label: string;
7
7
  functionSignature: string;
8
- SelfType: StructType | EnumType | DynType | SomeType | IsoType;
8
+ SelfType: StructType | EnumType | DynType | SomeType | IsoType | ArcType;
9
9
  env: Environment;
10
10
  context: EvaluatorContext;
11
11
  }): Environment;
12
12
  export declare function addFunctionCodeToSelfTypeModule({ label, functionCode, SelfType, env, context, }: {
13
13
  label: string;
14
14
  functionCode: string;
15
- SelfType: StructType | EnumType | DynType | SomeType | IsoType;
15
+ SelfType: StructType | EnumType | DynType | SomeType | IsoType | ArcType;
16
16
  env: Environment;
17
17
  context: EvaluatorContext;
18
18
  }): Environment;
@@ -54,6 +54,11 @@ export declare function addRcFunctionsToIsoType({ isoType, env, context, }: {
54
54
  env: Environment;
55
55
  context: EvaluatorContext;
56
56
  }): Environment;
57
+ export declare function addRcFunctionsToArcType({ arcType, env, context, }: {
58
+ arcType: ArcType;
59
+ env: Environment;
60
+ context: EvaluatorContext;
61
+ }): Environment;
57
62
  export declare function attachTraitToReceiverType(moduleName: string, receiverType: StructType | EnumType | UnionType | TupleType | SomeType, env: Environment, context: EvaluatorContext): Environment;
58
63
  export declare function autoDeriveSendForStructType({ structType, env, context, }: {
59
64
  structType: StructType;
@@ -2,7 +2,7 @@ import { type Environment } from "../../env";
2
2
  import { type Expr } from "../../expr";
3
3
  import type { FunctionCapturedVariableInfo } from "../../function-value";
4
4
  import type { Token } from "../../token";
5
- import type { StructType } from "../../types/definitions";
5
+ import type { SomeType, StructType } from "../../types/definitions";
6
6
  import { type StructValue, type UnknownValue } from "../../value";
7
7
  import type { CapturedVariableInfo, EvaluatorContext } from "../context";
8
8
  export declare function consumeCapturedVariables({ capturedVariables, env, closureToken, }: {
@@ -11,6 +11,12 @@ export declare function consumeCapturedVariables({ capturedVariables, env, closu
11
11
  closureToken: Token;
12
12
  }): Environment;
13
13
  export declare function buildPathCollectionFromCapturedVariables(capturedVariables: Map<string, CapturedVariableInfo>): string[][];
14
+ export declare function validateCaptureTraitRequirements({ wrapperType, captureType, env, errorToken, }: {
15
+ wrapperType: SomeType;
16
+ captureType: StructType;
17
+ env: Environment;
18
+ errorToken: Token;
19
+ }): void;
14
20
  export declare function createCaptureTypeAndValue({ expectedCaptureType, capturedVariablesWithValues, env, closureToken, context, }: {
15
21
  expectedCaptureType: StructType | undefined;
16
22
  capturedVariablesWithValues: Map<string, FunctionCapturedVariableInfo> | undefined;
@@ -44,6 +44,14 @@ export declare function findMethodsFromGenericImpls({ concreteType, methodName,
44
44
  type: FunctionType;
45
45
  value: Value | undefined;
46
46
  }[];
47
+ export declare function findAssociatedTypeFromGenericImpls({ concreteType, propertyName, env, }: {
48
+ concreteType: Type;
49
+ propertyName: string;
50
+ env: Environment;
51
+ }): {
52
+ type: Type;
53
+ value: Value;
54
+ } | undefined;
47
55
  export declare function findMethodFromGenericImplForTrait({ concreteType, traitType, methodName, env, }: {
48
56
  concreteType: Type;
49
57
  traitType: TraitType;
@@ -147,6 +147,7 @@ export declare const BuiltinKeywords: {
147
147
  unique: string[];
148
148
  Ptr: string[];
149
149
  Iso: string[];
150
+ Arc: string[];
150
151
  Tuple: string[];
151
152
  Array: string[];
152
153
  Slice: string[];
@@ -190,6 +191,7 @@ export declare const BuiltinFunctions: {
190
191
  __yo_ptr_deref: string[];
191
192
  __yo_ptr_set: string[];
192
193
  __yo_slice_len: string[];
194
+ __yo_slice_new: string[];
193
195
  __yo_as: string[];
194
196
  __yo_expr_is_atom: string[];
195
197
  __yo_expr_is_fn_call: string[];
@@ -501,6 +503,7 @@ export declare const BuiltinFunctions: {
501
503
  __yo_rc_own: string[];
502
504
  __yo_iso_extract: string[];
503
505
  __yo_iso_dispose: string[];
506
+ __yo_arc_dispose: string[];
504
507
  __yo_gc_collect: string[];
505
508
  __yo_dyn_drop: string[];
506
509
  __yo_dyn_dup: string[];
@@ -517,6 +520,9 @@ export declare const BuiltinFunctions: {
517
520
  __yo_noop: string[];
518
521
  __yo_return_self: string[];
519
522
  __yo_ms_sleep: string[];
523
+ __yo_getrandom: string[];
524
+ __yo_arc4random_buf: string[];
525
+ __yo_bcrypt_gen_random: string[];
520
526
  __yo_maybe_uninit_new: string[];
521
527
  __yo_maybe_uninit_as_ptr: string[];
522
528
  __yo_maybe_uninit_assume_init: string[];
@@ -16,6 +16,7 @@ export interface TestResult {
16
16
  passed: boolean;
17
17
  errorMessage?: string;
18
18
  duration: number;
19
+ profileInfo?: string;
19
20
  }
20
21
  export interface TestRunSummary {
21
22
  totalTests: number;
@@ -33,4 +34,5 @@ export declare function runTests(testFiles: string[], options?: {
33
34
  testNamePattern?: string;
34
35
  parallel?: number;
35
36
  keepGeneratedFiles?: boolean;
37
+ profile?: boolean;
36
38
  }): Promise<TestRunSummary>;
@@ -3,7 +3,7 @@ import type { EvaluatorContext } from "../evaluator/context";
3
3
  import type { Expr } from "../expr";
4
4
  import type { FunctionValue } from "../function-value";
5
5
  import { type Value } from "../value";
6
- import type { ArrayType, ComptimeListType, DynType, EffectsRowType, EnumType, FnTraitType, FunctionForallParameter, FunctionImplicitParameter, FunctionParameter, FunctionParameterExprs, FunctionReturn, FunctionType, FutureTraitType, IsoType, ModuleType, PtrType, SliceType, SomeType, StructType, TraitType, TupleType, Type, TypeField, TypeHierarchyType, UnionType, VoidType } from "./definitions";
6
+ import type { ArcType, ArrayType, ComptimeListType, DynType, EffectsRowType, EnumType, FnTraitType, FunctionForallParameter, FunctionImplicitParameter, FunctionParameter, FunctionParameterExprs, FunctionReturn, FunctionType, FutureTraitType, IsoType, ModuleType, PtrType, SliceType, SomeType, StructType, TraitType, TupleType, Type, TypeField, TypeHierarchyType, UnionType, VoidType } from "./definitions";
7
7
  export declare function createComptimeIntType(): Type;
8
8
  export declare function createComptimeFloatType(): Type;
9
9
  export declare function createComptimeStringType(): Type;
@@ -59,6 +59,7 @@ export declare function createFunctionType({ parameters, forallParameters, impli
59
59
  }): FunctionType;
60
60
  export declare function createPtrType(childType: Type): PtrType;
61
61
  export declare function createIsoType(childType: Type, env: Environment): IsoType;
62
+ export declare function createArcType(childType: Type, env: Environment): ArcType;
62
63
  export declare function createSomeType(type: TypeHierarchyType, variableName: string, { id, requiredTraits, negativeTraits, recursiveTypeRef, env, context, }: {
63
64
  id?: string;
64
65
  requiredTraits?: TraitType[];
@@ -169,6 +169,10 @@ export interface TraitType extends Type {
169
169
  concreteType: Type;
170
170
  };
171
171
  definedInModulePath?: string;
172
+ associatedTypeConstraints?: {
173
+ label: string;
174
+ constraintType: Type;
175
+ }[];
172
176
  }
173
177
  export type FnTraitType = TraitType & {
174
178
  isFn: {
@@ -239,6 +243,12 @@ export interface IsoType extends Type {
239
243
  trait: TraitType;
240
244
  env: Environment;
241
245
  }
246
+ export interface ArcType extends Type {
247
+ tag: TypeTag.Arc;
248
+ childType: Type;
249
+ trait: TraitType;
250
+ env: Environment;
251
+ }
242
252
  export interface DynType extends Type {
243
253
  tag: TypeTag.Dyn;
244
254
  requiredTraits: {
@@ -1,5 +1,5 @@
1
1
  import { FunctionValue } from "../function-value";
2
- import type { ArrayType, ComptimeListType, ConcreteModuleType, DynType, EffectsRowType, EnumType, FnTraitType, FunctionType, FutureTraitType, IsoType, ModuleType, PtrType, SliceType, SomeType, StructType, TraitType, TupleType, Type, TypeHierarchyType, UnionType, VoidType } from "./definitions";
2
+ import type { ArcType, ArrayType, ComptimeListType, ConcreteModuleType, DynType, EffectsRowType, EnumType, FnTraitType, FunctionType, FutureTraitType, IsoType, ModuleType, PtrType, SliceType, SomeType, StructType, TraitType, TupleType, Type, TypeHierarchyType, UnionType, VoidType } from "./definitions";
3
3
  export declare function isPrimitiveType(type: Type): boolean;
4
4
  export declare function isUnitType(type?: Type): boolean;
5
5
  export declare function isComptimeIntType(type?: Type): boolean;
@@ -45,6 +45,7 @@ export declare function isType0(type?: Type): boolean;
45
45
  export declare function isSomeType(type?: Type): type is SomeType;
46
46
  export declare function isPtrType(type?: Type): type is PtrType;
47
47
  export declare function isIsoType(type?: Type): type is IsoType;
48
+ export declare function isArcType(type?: Type): type is ArcType;
48
49
  export declare function isDynType(type?: Type): type is DynType;
49
50
  export declare function isRcType(type?: Type): boolean;
50
51
  export declare function isIntegerType(type?: Type): boolean;
@@ -40,6 +40,7 @@ export declare enum TypeTag {
40
40
  Trait = "Trait",
41
41
  Ptr = "Ptr",
42
42
  Iso = "Iso",
43
+ Arc = "Arc",
43
44
  Dyn = "Dyn",
44
45
  Expr = "Expr",
45
46
  ComptimeList = "ComptimeList",