@shd101wyy/yo 0.0.25 → 0.0.27

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 (47) hide show
  1. package/README.md +9 -9
  2. package/out/cjs/index.cjs +568 -563
  3. package/out/cjs/yo-cli.cjs +569 -564
  4. package/out/esm/index.mjs +487 -482
  5. package/out/types/src/codegen/async/state-machine.d.ts +1 -1
  6. package/out/types/src/codegen/exprs/await.d.ts +1 -0
  7. package/out/types/src/codegen/exprs/downcast.d.ts +3 -0
  8. package/out/types/src/codegen/exprs/return.d.ts +1 -0
  9. package/out/types/src/codegen/exprs/typeid.d.ts +3 -0
  10. package/out/types/src/codegen/exprs/while.d.ts +1 -1
  11. package/out/types/src/codegen/functions/context.d.ts +6 -18
  12. package/out/types/src/codegen/functions/declarations.d.ts +10 -2
  13. package/out/types/src/codegen/types/dyn.d.ts +1 -0
  14. package/out/types/src/codegen/types/generation.d.ts +1 -1
  15. package/out/types/src/codegen/utils/index.d.ts +1 -0
  16. package/out/types/src/evaluator/async/await-analysis.d.ts +1 -0
  17. package/out/types/src/evaluator/builtins/downcast.d.ts +8 -0
  18. package/out/types/src/evaluator/builtins/rc-fns.d.ts +5 -0
  19. package/out/types/src/evaluator/builtins/typeid.d.ts +8 -0
  20. package/out/types/src/evaluator/context.d.ts +2 -0
  21. package/out/types/src/expr.d.ts +3 -0
  22. package/out/types/src/function-value.d.ts +1 -0
  23. package/out/types/src/types/creators.d.ts +3 -1
  24. package/out/types/src/types/definitions.d.ts +3 -1
  25. package/out/types/tsconfig.tsbuildinfo +1 -1
  26. package/package.json +1 -1
  27. package/std/crypto/random.yo +25 -13
  28. package/std/encoding/base64.yo +24 -49
  29. package/std/encoding/hex.yo +25 -22
  30. package/std/encoding/json.yo +25 -3
  31. package/std/encoding/utf16.yo +6 -5
  32. package/std/error.yo +39 -23
  33. package/std/fs/dir.yo +106 -103
  34. package/std/fs/file.yo +122 -158
  35. package/std/fs/metadata.yo +23 -22
  36. package/std/fs/temp.yo +41 -47
  37. package/std/fs/walker.yo +48 -55
  38. package/std/net/addr.yo +8 -7
  39. package/std/net/dns.yo +27 -33
  40. package/std/net/errors.yo +13 -8
  41. package/std/net/tcp.yo +92 -113
  42. package/std/net/udp.yo +50 -54
  43. package/std/os/signal.yo +13 -8
  44. package/std/prelude.yo +21 -16
  45. package/std/sys/errors.yo +45 -33
  46. package/std/url/url.yo +19 -32
  47. package/out/types/src/codegen/effects/effect-state-machine.d.ts +0 -34
@@ -11,4 +11,4 @@ export interface StateMachineInfo {
11
11
  }
12
12
  export declare function generateResumeFunctionDeclaration(info: StateMachineInfo, context: FunctionGenerationContext): void;
13
13
  export declare function getStateMachineFieldName(variableId: string, kind?: "outer" | "local"): string;
14
- export declare function generateAsyncBlockResumeFunction(bodyExpr: Expr, asyncBlockId: string, structName: string, resumeFunctionName: string, analysis: AwaitAnalysisResult, futureType: SomeType | DynType, captureType: StructType | undefined, context: FunctionGenerationContext): void;
14
+ export declare function generateAsyncBlockResumeFunction(bodyExpr: Expr, asyncBlockId: string, structName: string, resumeFunctionName: string, analysis: AwaitAnalysisResult, futureType: SomeType | DynType, captureType: StructType | undefined, context: FunctionGenerationContext): string[];
@@ -2,3 +2,4 @@ import { type FnCallExpr } from "../../expr";
2
2
  import { type CodeGenContext } from "../utils";
3
3
  export declare function generateAwait(expr: FnCallExpr, indent: string, context: CodeGenContext): string;
4
4
  export declare function generateState(expr: FnCallExpr, indent: string, context: CodeGenContext): string;
5
+ export declare function generateJoinHandleAwait(expr: FnCallExpr, indent: string, context: CodeGenContext): string;
@@ -0,0 +1,3 @@
1
+ import type { FnCallExpr } from "../../expr";
2
+ import type { CodeGenContext } from "../utils";
3
+ export declare function generateDowncast(expr: FnCallExpr, indent: string, context: CodeGenContext): string;
@@ -2,5 +2,6 @@ import { type Expr, type FnCallExpr } from "../../expr";
2
2
  import type { FunctionGenerationContext } from "../functions/context";
3
3
  import { type CodeGenContext } from "../utils";
4
4
  export declare function generatePendingDeferredDrops(indent: string, context: FunctionGenerationContext, expr: Expr, isCompletion?: boolean, skipAlreadyDroppedCheck?: boolean, skipEnvCheck?: boolean): void;
5
+ export declare function generateConsumedVarDropsForEscape(indent: string, context: FunctionGenerationContext, expr: Expr, skipEnvCheck?: boolean): void;
5
6
  export declare function generateReturn(expr: FnCallExpr, indent: string, context: CodeGenContext): string;
6
7
  export declare function generateImplicitReturnStatement(expr: Expr, indent: string, context: CodeGenContext): void;
@@ -0,0 +1,3 @@
1
+ import type { FnCallExpr } from "../../expr";
2
+ import type { CodeGenContext } from "../utils";
3
+ export declare function generateTypeId(expr: FnCallExpr, indent: string, context: CodeGenContext): string;
@@ -1,3 +1,3 @@
1
1
  import { type FnCallExpr } from "../../expr";
2
- import type { CodeGenContext } from "../utils";
2
+ import { type CodeGenContext } from "../utils";
3
3
  export declare function generateWhileLoop(expr: FnCallExpr, indent: string, context: CodeGenContext): string;
@@ -2,8 +2,8 @@ import type { AwaitAnalysisResult, CapturedVariable } from "../../evaluator/asyn
2
2
  import type { Expr } from "../../expr";
3
3
  import type { FunctionValue, FuncValueId } from "../../function-value";
4
4
  import type { DynType, FunctionType, FutureTraitType, SomeType, StructType, Type, TypeId } from "../../types/definitions";
5
- import type { EffectStateMachineInfo } from "../effects/effect-state-machine";
6
5
  import type { CodeGenContext } from "../utils";
6
+ import type { EvidenceParameter } from "./declarations";
7
7
  export interface FunctionGenerationContext extends CodeGenContext {
8
8
  functions: Record<FuncValueId, {
9
9
  value: FunctionValue;
@@ -25,23 +25,17 @@ export interface FunctionGenerationContext extends CodeGenContext {
25
25
  futureType: SomeType | DynType;
26
26
  };
27
27
  stateMachineVariables?: Map<string, CapturedVariable>;
28
- inEffectStateMachine?: EffectStateMachineInfo;
29
- deferredEffectfulFunctions?: Array<{
30
- functionValue: FunctionValue;
31
- cFunctionName: string;
32
- info: EffectStateMachineInfo;
33
- }>;
28
+ inEffectStateMachine?: unknown;
29
+ isModuleEffectMemberFunction?: boolean;
30
+ currentEvidenceParams?: Map<string, EvidenceParameter>;
34
31
  continuationVariables?: Map<string, {
35
- smVar: string;
36
- smInfo: EffectStateMachineInfo;
37
- effectIndex?: number;
38
- } | {
39
32
  directReturnVar: string;
40
33
  directExitLabel?: string;
41
34
  isUnitReturn?: boolean;
42
35
  }>;
43
36
  variableIdRemapping?: Map<string, string>;
44
37
  pendingDeferredDrops?: Expr[];
38
+ consumedVarPendingDrops?: Expr[];
45
39
  deferredAsyncBlocks?: Array<{
46
40
  bodyExpr: Expr;
47
41
  asyncBlockId: string;
@@ -112,12 +106,6 @@ export interface FunctionGenerationContext extends CodeGenContext {
112
106
  shortCircuitHandledDropVarNames?: Set<string>;
113
107
  effectHandlerParamDrops?: string[];
114
108
  effectSmConsumedArgCNames?: Set<string>;
115
- effectWhileLoopContinuation?: {
116
- label: string;
117
- stepExpr: Expr | undefined;
118
- whileDoneLabel: string;
119
- remainingExprs: Expr[];
120
- bodyDropExprs: Expr[];
121
- };
122
109
  loopBodyDropsBaselineCount?: number;
110
+ overrideReturnTypeStr?: string;
123
111
  }
@@ -3,8 +3,16 @@ import type { FunctionType } from "../../types/definitions";
3
3
  import { type CodeGenContext } from "../utils";
4
4
  import type { FunctionGenerationContext } from "./context";
5
5
  export declare function generateFunctionDeclarations(context: FunctionGenerationContext): void;
6
- export declare function generateFunctionPrototype(functionType: FunctionType, cFunctionName: string, context: CodeGenContext, overrideReturnType?: string): string;
7
- export declare function generateFunctionDeclaration(functionType: FunctionType, cFunctionName: string, isExtern: boolean, context: CodeGenContext, functionBody?: Expr): void;
6
+ export interface EvidenceParameter {
7
+ implicitLabel: string;
8
+ fieldLabel: string;
9
+ fieldPath: string[];
10
+ fieldFunctionType: FunctionType;
11
+ cParamName: string;
12
+ }
13
+ export declare function getEvidenceParameters(functionType: FunctionType): EvidenceParameter[];
14
+ export declare function generateFunctionPrototype(functionType: FunctionType, cFunctionName: string, context: CodeGenContext, overrideReturnType?: string, originalFunctionType?: FunctionType): string;
15
+ export declare function generateFunctionDeclaration(functionType: FunctionType, cFunctionName: string, isExtern: boolean, context: CodeGenContext, functionBody?: Expr, originalFunctionType?: FunctionType): void;
8
16
  export declare function generateObjectConstructorDeclarations(context: FunctionGenerationContext): void;
9
17
  export declare function generateClosureConstructorDeclarations(context: FunctionGenerationContext): void;
10
18
  export declare function generateCaptureDisposeFunctionDeclarations(context: FunctionGenerationContext): void;
@@ -1,4 +1,5 @@
1
1
  import type { DynType } from "../../types/definitions";
2
2
  import { type CodeGenContext } from "../utils";
3
+ export declare function generateDynForwardDeclarations(context: CodeGenContext): void;
3
4
  export declare function generateDynDeclaration(dynType: DynType, cName: string, context: CodeGenContext): void;
4
5
  export declare function generateDynBoxTypes(context: CodeGenContext): void;
@@ -11,4 +11,4 @@ export declare function generateStructDeclaration(structType: StructType, cName:
11
11
  export declare function generateTupleDeclaration(tupleType: TupleType, cName: string, context: CodeGenContext): void;
12
12
  export declare function generateUnionDeclaration(unionType: UnionType, cName: string, context: CodeGenContext): void;
13
13
  export declare function generateEnumDeclaration(enumType: EnumType, cName: string, context: CodeGenContext): void;
14
- export { generateDynBoxTypes, generateDynDeclaration } from "./dyn";
14
+ export { generateDynBoxTypes, generateDynDeclaration, generateDynForwardDeclarations, } from "./dyn";
@@ -76,6 +76,7 @@ export interface CodeGenContext {
76
76
  currentLoopLabel?: string;
77
77
  currentContinueLabel?: string;
78
78
  insideMatch?: boolean;
79
+ typeIdStatics?: Map<string, string>;
79
80
  }
80
81
  export declare function sanitizeForCIdentifier(str: string, isExternC?: boolean): string;
81
82
  export declare function shouldAvoidConst(type: Type): boolean;
@@ -6,4 +6,5 @@ export declare function isIoAsyncCall(expr: Expr): boolean;
6
6
  export declare function isIoAwaitCall(expr: Expr): boolean;
7
7
  export declare function isIoStateCall(expr: Expr): boolean;
8
8
  export declare function isIoSpawnCall(expr: Expr): boolean;
9
+ export declare function isJoinHandleAwaitCall(expr: Expr): boolean;
9
10
  export declare function getLocalVariablesFromBody(body: Expr): CapturedVariable[];
@@ -0,0 +1,8 @@
1
+ import type { Environment } from "../../env";
2
+ import { type FnCallExpr } from "../../expr";
3
+ import type { EvaluatorContext } from "../context";
4
+ export declare function evaluateDowncast({ expr, env, context, }: {
5
+ expr: FnCallExpr;
6
+ env: Environment;
7
+ context: EvaluatorContext;
8
+ }): FnCallExpr;
@@ -1,6 +1,11 @@
1
1
  import { type Environment } from "../../env";
2
2
  import { type Expr, type FnCallExpr } from "../../expr";
3
+ import type { EnumType, Type } from "../../types/definitions";
3
4
  import type { EvaluatorContext } from "../context";
5
+ export declare function createOptionType(innerType: Type, env: Environment, context: EvaluatorContext): {
6
+ optionType: EnumType;
7
+ env: Environment;
8
+ };
4
9
  export declare function evaluateYoDecrRc({ expr, env, context, }: {
5
10
  expr: FnCallExpr;
6
11
  env: Environment;
@@ -0,0 +1,8 @@
1
+ import type { Environment } from "../../env";
2
+ import { type FnCallExpr } from "../../expr";
3
+ import type { EvaluatorContext } from "../context";
4
+ export declare function evaluateTypeId({ expr, env, context, }: {
5
+ expr: FnCallExpr;
6
+ env: Environment;
7
+ context: EvaluatorContext;
8
+ }): FnCallExpr;
@@ -42,6 +42,8 @@ export interface EvaluatorContext {
42
42
  env: Environment;
43
43
  };
44
44
  SelfType?: Type;
45
+ SelfTraitType?: Type;
46
+ SelfModuleType?: Type;
45
47
  ReceiverType?: Type;
46
48
  isEvaluatingFunctionType?: boolean;
47
49
  loadModule?: (modulePath: string) => {
@@ -50,6 +50,7 @@ export interface EvaluatedExprData {
50
50
  comment?: string;
51
51
  deferredDupExpressions?: Expr[];
52
52
  deferredDropExpressions?: Expr[];
53
+ consumedVariableDropExpressions?: Expr[];
53
54
  asyncStackSize?: Expr;
54
55
  asyncStateMachineStructName?: string;
55
56
  captureType?: StructType;
@@ -171,6 +172,8 @@ export declare const BuiltinFunctions: {
171
172
  typeof: string[];
172
173
  sizeof: string[];
173
174
  alignof: string[];
175
+ typeid: string[];
176
+ downcast: string[];
174
177
  consume: string[];
175
178
  macro_expand: string[];
176
179
  as: string[];
@@ -33,6 +33,7 @@ export type FunctionValue = {
33
33
  isControlFunction?: boolean;
34
34
  definitionSiteEnclosingFunctionType?: FunctionType;
35
35
  closureInfo?: ClosureInfo;
36
+ isModuleEffectMember?: boolean;
36
37
  isIoAsyncStateMachineClosure?: boolean;
37
38
  };
38
39
  export interface FunctionCapturedVariableInfo extends CapturedVariableInfo {
@@ -45,7 +45,7 @@ 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;
47
47
  export declare function createUnionType(env: Environment): UnionType;
48
- export declare function createFunctionType({ parameters, forallParameters, implicitParameters, variadicParameter, whereClauseExprs, return_, env, parametersFrame, SelfType, isClosure, }: {
48
+ export declare function createFunctionType({ parameters, forallParameters, implicitParameters, variadicParameter, whereClauseExprs, return_, env, parametersFrame, SelfType, SelfTraitType, SelfModuleType, isClosure, }: {
49
49
  parameters: FunctionParameter[];
50
50
  forallParameters: FunctionForallParameter[];
51
51
  implicitParameters?: FunctionImplicitParameter[];
@@ -55,6 +55,8 @@ export declare function createFunctionType({ parameters, forallParameters, impli
55
55
  env: Environment;
56
56
  parametersFrame: Frame;
57
57
  SelfType?: Type;
58
+ SelfTraitType?: Type;
59
+ SelfModuleType?: Type;
58
60
  isClosure?: boolean;
59
61
  }): FunctionType;
60
62
  export declare function createPtrType(childType: Type): PtrType;
@@ -14,7 +14,7 @@ export interface Type {
14
14
  cInclude?: string;
15
15
  trait?: TraitType;
16
16
  definedInModulePath?: string;
17
- ioBuiltin?: "io_async" | "io_await" | "io_state" | "io_spawn";
17
+ ioBuiltin?: "io_async" | "io_await" | "io_state" | "io_spawn" | "join_handle_await";
18
18
  }
19
19
  export interface ExprType extends Type {
20
20
  tag: TypeTag.Expr;
@@ -229,6 +229,8 @@ export interface FunctionType extends Type {
229
229
  env: Environment;
230
230
  parametersFrame: Frame;
231
231
  SelfType?: Type;
232
+ SelfTraitType?: Type;
233
+ SelfModuleType?: Type;
232
234
  trait: TraitType;
233
235
  isClosure?: boolean;
234
236
  }