@shd101wyy/yo 0.1.15 → 0.1.16

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 (38) hide show
  1. package/README.md +3 -0
  2. package/out/cjs/index.cjs +541 -561
  3. package/out/cjs/yo-cli.cjs +644 -664
  4. package/out/cjs/yo-lsp.cjs +585 -605
  5. package/out/esm/index.mjs +527 -547
  6. package/out/types/src/codegen/exprs/return.d.ts +1 -1
  7. package/out/types/src/codegen/types/generation.d.ts +0 -2
  8. package/out/types/src/codegen/utils/index.d.ts +2 -8
  9. package/out/types/src/evaluator/builtins/rc-fns.d.ts +0 -5
  10. package/out/types/src/evaluator/context.d.ts +7 -3
  11. package/out/types/src/evaluator/trait-checking.d.ts +2 -0
  12. package/out/types/src/evaluator/types/object.d.ts +2 -1
  13. package/out/types/src/evaluator/types/struct.d.ts +2 -1
  14. package/out/types/src/evaluator/types/utils.d.ts +3 -8
  15. package/out/types/src/expr.d.ts +1 -2
  16. package/out/types/src/function-value.d.ts +1 -0
  17. package/out/types/src/types/creators.d.ts +2 -3
  18. package/out/types/src/types/definitions.d.ts +1 -6
  19. package/out/types/src/types/guards.d.ts +5 -2
  20. package/out/types/src/types/tags.d.ts +0 -1
  21. package/out/types/tsconfig.tsbuildinfo +1 -1
  22. package/package.json +1 -1
  23. package/std/imm/list.yo +254 -0
  24. package/std/imm/map.yo +917 -0
  25. package/std/imm/set.yo +179 -0
  26. package/std/imm/sorted_map.yo +595 -0
  27. package/std/imm/sorted_set.yo +202 -0
  28. package/std/imm/string.yo +667 -0
  29. package/std/imm/vec.yo +456 -0
  30. package/std/prelude.yo +22 -5
  31. package/std/sync/channel.yo +92 -44
  32. package/std/sync/cond.yo +5 -1
  33. package/std/sync/mutex.yo +5 -1
  34. package/std/sync/once.yo +2 -1
  35. package/std/sync/rwlock.yo +2 -1
  36. package/std/sync/waitgroup.yo +2 -1
  37. package/out/types/src/codegen/exprs/arc.d.ts +0 -5
  38. package/out/types/src/evaluator/calls/arc.d.ts +0 -15
@@ -1,7 +1,7 @@
1
1
  import { type Expr, type FnCallExpr } from "../../expr";
2
2
  import type { FunctionGenerationContext } from "../functions/context";
3
3
  import { type CodeGenContext } from "../utils";
4
- export declare function generatePendingDeferredDrops(indent: string, context: FunctionGenerationContext, expr: Expr, isCompletion?: boolean, skipAlreadyDroppedCheck?: boolean, skipEnvCheck?: boolean): void;
4
+ export declare function generatePendingDeferredDrops(indent: string, context: FunctionGenerationContext, expr: Expr, isCompletion?: boolean, skipAlreadyDroppedCheck?: boolean, skipEnvCheck?: boolean, additionalSkipVarNames?: Set<string>): void;
5
5
  export declare function generateConsumedVarDropsForEscape(indent: string, context: FunctionGenerationContext, expr: Expr, skipEnvCheck?: boolean): void;
6
6
  export declare function generateReturn(expr: FnCallExpr, indent: string, context: CodeGenContext): string;
7
7
  export declare function generateImplicitReturnStatement(expr: Expr, indent: string, context: CodeGenContext): void;
@@ -4,8 +4,6 @@ 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;
9
7
  export declare function generateClosureDeclaration(functionType: FunctionType, cName: string, captureType: StructType | undefined, context: CodeGenContext): void;
10
8
  export declare function generateStructDeclaration(structType: StructType, cName: string, context: CodeGenContext): void;
11
9
  export declare function generateTupleDeclaration(tupleType: TupleType, cName: string, context: CodeGenContext): void;
@@ -3,7 +3,7 @@ import { type Environment } from "../../env";
3
3
  import { type Expr } from "../../expr";
4
4
  import type { FunctionValue, FuncValueId } from "../../function-value";
5
5
  import type { TargetInfo } from "../../target";
6
- import type { ArcType, DynType, EnumType, FunctionType, IsoType, StructType, Type, TypeId } from "../../types/definitions";
6
+ import type { DynType, EnumType, FunctionType, IsoType, StructType, Type, TypeId } from "../../types/definitions";
7
7
  import { type TraitValue } from "../../value";
8
8
  export interface CodeGenContext {
9
9
  types: Record<TypeId, {
@@ -36,13 +36,6 @@ export interface CodeGenContext {
36
36
  extractGenerated?: boolean;
37
37
  disposeGenerated?: boolean;
38
38
  }>;
39
- arcTypes?: Map<string, {
40
- childTypeCName: string;
41
- arcType: ArcType;
42
- structGenerated?: boolean;
43
- createGenerated?: boolean;
44
- disposeGenerated?: boolean;
45
- }>;
46
39
  spawnedFunctionSignatures: Map<string, {
47
40
  parameterTypes: Type[];
48
41
  returnType: Type;
@@ -61,6 +54,7 @@ export interface CodeGenContext {
61
54
  functionCName: string;
62
55
  callTypeId: TypeId;
63
56
  callType?: FunctionType;
57
+ consumedCaptures?: string[];
64
58
  }>;
65
59
  currentFunctionName: string;
66
60
  cIncludes: Set<string>;
@@ -61,11 +61,6 @@ export declare function evaluateYoIsoDispose({ expr, env, context, }: {
61
61
  env: Environment;
62
62
  context: EvaluatorContext;
63
63
  }): Expr;
64
- export declare function evaluateYoArcDispose({ expr, env, context, }: {
65
- expr: FnCallExpr;
66
- env: Environment;
67
- context: EvaluatorContext;
68
- }): Expr;
69
64
  export declare function evaluateYoDropArrayElement({ expr, env, context, }: {
70
65
  expr: FnCallExpr;
71
66
  env: Environment;
@@ -38,6 +38,7 @@ export interface EvaluatorContext {
38
38
  isEvaluatingFunctionBodyOrAsyncBlock?: FunctionEvaluationContext | AsyncBlockEvaluationContext | TestBlockEvaluationContext;
39
39
  isInsideImplBlock?: boolean;
40
40
  capturedVariables?: Map<string, CapturedVariableInfo>;
41
+ ownConsumedCaptures?: Set<string>;
41
42
  isEvaluatingLoopBody?: {
42
43
  kind: "while" | "for";
43
44
  env: Environment;
@@ -69,6 +70,12 @@ export interface EvaluatorContext {
69
70
  isInsideIoAsyncCall?: boolean;
70
71
  isInsideGivenHandler?: boolean;
71
72
  isEvaluatingGenericImplSpecialization?: boolean;
73
+ currentlySpecializingFunction?: {
74
+ originalFuncId: string;
75
+ specializedFuncId: string;
76
+ specializedReturnType: Type;
77
+ originalFunction: FunctionValue;
78
+ };
72
79
  docCommentLookup?: Map<string, string>;
73
80
  }
74
81
  export interface ArgValues {
@@ -178,9 +185,6 @@ export interface FunctionToCall {
178
185
  } | {
179
186
  kind: "iso-value";
180
187
  result: FnCallExpr;
181
- } | {
182
- kind: "arc-value";
183
- result: FnCallExpr;
184
188
  } | {
185
189
  kind: "index";
186
190
  result: IndexCallResult;
@@ -16,6 +16,8 @@ export declare function checkTypeImplementsSelfConstraints({ targetType, traitTy
16
16
  export declare function typeImplementsComptime(type: Type, env: Environment): boolean;
17
17
  export declare function findSomeTypeMissingComptimeConstraint(type: Type, env: Environment): SomeType | undefined;
18
18
  export declare function typeImplementsRuntime(type: Type, env: Environment): boolean;
19
+ export declare function beginSendDerivation(typeId: string): void;
20
+ export declare function endSendDerivation(typeId: string): void;
19
21
  export declare function typeImplementsSend(type: Type | undefined, env: Environment): boolean;
20
22
  export declare function typeImplementsDispose(type: Type | undefined, env: Environment): boolean;
21
23
  export declare function typeImplementsAcyclic(type: Type | undefined, env: Environment): boolean;
@@ -1,8 +1,9 @@
1
1
  import type { Environment } from "../../env";
2
2
  import { type FnCallExpr } from "../../expr";
3
3
  import type { EvaluatorContext } from "../context";
4
- export declare function evaluateObjectType({ expr, env, context, }: {
4
+ export declare function evaluateObjectType({ expr, env, context, isAtomicRc, }: {
5
5
  expr: FnCallExpr;
6
6
  env: Environment;
7
7
  context: EvaluatorContext;
8
+ isAtomicRc?: boolean;
8
9
  }): FnCallExpr;
@@ -1,8 +1,9 @@
1
1
  import type { Environment } from "../../env";
2
2
  import { type FnCallExpr } from "../../expr";
3
3
  import type { EvaluatorContext } from "../context";
4
- export declare function evaluateStructType({ expr, env, context, }: {
4
+ export declare function evaluateStructType({ expr, env, context, isAtomicRc, }: {
5
5
  expr: FnCallExpr;
6
6
  env: Environment;
7
7
  context: EvaluatorContext;
8
+ isAtomicRc?: boolean;
8
9
  }): FnCallExpr;
@@ -1,18 +1,18 @@
1
1
  import type { Environment } from "../../env";
2
2
  import type { Token } from "../../token";
3
- import type { ArcType, DynType, EnumType, IsoType, SomeType, StructType, TupleType, UnionType } from "../../types/definitions";
3
+ import type { 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 | ArcType;
8
+ SelfType: StructType | EnumType | DynType | SomeType | IsoType;
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 | ArcType;
15
+ SelfType: StructType | EnumType | DynType | SomeType | IsoType;
16
16
  env: Environment;
17
17
  context: EvaluatorContext;
18
18
  }): Environment;
@@ -54,11 +54,6 @@ 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;
62
57
  export declare function attachTraitToReceiverType(moduleName: string, receiverType: StructType | EnumType | UnionType | TupleType | SomeType, env: Environment, context: EvaluatorContext): Environment;
63
58
  export declare function autoDeriveSendForStructType({ structType, env, context, }: {
64
59
  structType: StructType;
@@ -133,6 +133,7 @@ export declare const BuiltinKeywords: {
133
133
  type: string[];
134
134
  match: string[];
135
135
  test: string[];
136
+ atomic: string[];
136
137
  struct: string[];
137
138
  object: string[];
138
139
  newtype: string[];
@@ -166,7 +167,6 @@ export declare const BuiltinKeywords: {
166
167
  unique: string[];
167
168
  Ptr: string[];
168
169
  Iso: string[];
169
- Arc: string[];
170
170
  Tuple: string[];
171
171
  Array: string[];
172
172
  Slice: string[];
@@ -552,7 +552,6 @@ export declare const BuiltinFunctions: {
552
552
  __yo_rc_own: string[];
553
553
  __yo_iso_extract: string[];
554
554
  __yo_iso_dispose: string[];
555
- __yo_arc_dispose: string[];
556
555
  __yo_gc_collect: string[];
557
556
  __yo_dyn_drop: string[];
558
557
  __yo_dyn_dup: string[];
@@ -46,4 +46,5 @@ export interface ClosureInfo {
46
46
  closureType: FnTraitType;
47
47
  captureType: Type | undefined;
48
48
  effectParamNames?: string[];
49
+ consumedCaptures?: string[];
49
50
  }
@@ -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 { ArcType, ArrayType, ComptimeListType, DynType, EffectsRowType, EnumType, FnTraitType, FunctionForallParameter, FunctionImplicitParameter, FunctionParameter, FunctionParameterExprs, FunctionReturn, FunctionType, FutureTraitType, IsoType, ModuleType, PtrType, SliceType, SomeType, StructType, TraitType, TupleType, Type, TypeApplicationType, TypeField, TypeHierarchyType, UnionType, VoidType } from "./definitions";
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, TypeApplicationType, 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;
@@ -40,7 +40,7 @@ export declare function createSliceType(childType: Type): SliceType;
40
40
  export declare function createStrType(env: Environment): Type;
41
41
  export declare function createVoidType(): VoidType;
42
42
  export declare function createTupleType(fields: TypeField[]): TupleType;
43
- export declare function createStructType(env: Environment, isReferenceSemantics?: boolean, isNewtype?: boolean): StructType;
43
+ export declare function createStructType(env: Environment, isReferenceSemantics?: boolean, isNewtype?: boolean, isAtomicRc?: boolean): StructType;
44
44
  export declare function createModuleType(env: Environment): ModuleType;
45
45
  export declare function createTraitType(env: Environment): TraitType;
46
46
  export declare function createEnumType(env: Environment): EnumType;
@@ -61,7 +61,6 @@ export declare function createFunctionType({ parameters, forallParameters, impli
61
61
  }): FunctionType;
62
62
  export declare function createPtrType(childType: Type): PtrType;
63
63
  export declare function createIsoType(childType: Type, env: Environment): IsoType;
64
- export declare function createArcType(childType: Type, env: Environment): ArcType;
65
64
  export declare function createSomeType(type: TypeHierarchyType, variableName: string, { id, requiredTraits, negativeTraits, recursiveTypeRef, env, context, }: {
66
65
  id?: string;
67
66
  requiredTraits?: TraitType[];
@@ -133,6 +133,7 @@ export type FunctionImplicitParameter = FunctionParameter & {
133
133
  export interface StructType extends Type {
134
134
  tag: TypeTag.Struct;
135
135
  isReferenceSemantics: boolean;
136
+ isAtomicRc?: boolean;
136
137
  isNewtype: boolean;
137
138
  functionValue?: FunctionValue;
138
139
  fields: TypeField[];
@@ -259,12 +260,6 @@ export interface IsoType extends Type {
259
260
  trait: TraitType;
260
261
  env: Environment;
261
262
  }
262
- export interface ArcType extends Type {
263
- tag: TypeTag.Arc;
264
- childType: Type;
265
- trait: TraitType;
266
- env: Environment;
267
- }
268
263
  export interface DynType extends Type {
269
264
  tag: TypeTag.Dyn;
270
265
  requiredTraits: {
@@ -1,5 +1,5 @@
1
1
  import { FunctionValue } from "../function-value";
2
- import type { ArcType, ArrayType, ComptimeListType, ConcreteModuleType, DynType, EffectsRowType, EnumType, FnTraitType, FunctionType, FutureTraitType, IsoType, ModuleType, PtrType, SliceType, SomeType, StructType, TraitType, TupleType, Type, TypeApplicationType, TypeHierarchyType, UnionType, VoidType } from "./definitions";
2
+ import type { ArrayType, ComptimeListType, ConcreteModuleType, DynType, EffectsRowType, EnumType, FnTraitType, FunctionType, FutureTraitType, IsoType, ModuleType, PtrType, SliceType, SomeType, StructType, TraitType, TupleType, Type, TypeApplicationType, 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;
@@ -30,6 +30,10 @@ export declare function isStructType(type?: Type): type is StructType;
30
30
  export declare function isObjectType(type?: Type): type is StructType & {
31
31
  isReferenceSemantics: true;
32
32
  };
33
+ export declare function isAtomicObjectType(type?: Type): type is StructType & {
34
+ isReferenceSemantics: true;
35
+ isAtomicRc: true;
36
+ };
33
37
  export declare function isNewtypeType(type?: Type): type is StructType & {
34
38
  isNewtype: true;
35
39
  };
@@ -45,7 +49,6 @@ export declare function isType0(type?: Type): boolean;
45
49
  export declare function isSomeType(type?: Type): type is SomeType;
46
50
  export declare function isPtrType(type?: Type): type is PtrType;
47
51
  export declare function isIsoType(type?: Type): type is IsoType;
48
- export declare function isArcType(type?: Type): type is ArcType;
49
52
  export declare function isDynType(type?: Type): type is DynType;
50
53
  export declare function isTypeApplicationType(type?: Type): type is TypeApplicationType;
51
54
  export declare function isRcType(type?: Type): boolean;
@@ -40,7 +40,6 @@ export declare enum TypeTag {
40
40
  Trait = "Trait",
41
41
  Ptr = "Ptr",
42
42
  Iso = "Iso",
43
- Arc = "Arc",
44
43
  Dyn = "Dyn",
45
44
  Expr = "Expr",
46
45
  ComptimeList = "ComptimeList",