@shd101wyy/yo 0.1.5 → 0.1.6

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.
@@ -1,3 +1,4 @@
1
+ import type { Expr } from "../expr";
1
2
  import type { ModuleValue } from "../value";
2
3
  export declare class CodeGeneratorC {
3
4
  private emitter;
@@ -11,6 +12,7 @@ export declare class CodeGeneratorC {
11
12
  debugAsyncAwait?: boolean;
12
13
  allocator?: "mimalloc" | "libc";
13
14
  isLibrary?: boolean;
15
+ allModuleLevelInitExprs?: Expr[];
14
16
  }): void;
15
17
  print(): string;
16
18
  getExportedFunctionNames(): Set<string>;
@@ -107,6 +107,7 @@ export interface FunctionGenerationContext extends CodeGenContext {
107
107
  };
108
108
  smWhileBodyDrops?: Expr[];
109
109
  shortCircuitHandledDropVarNames?: Set<string>;
110
+ declaredTempVars?: Set<string>;
110
111
  effectHandlerParamDrops?: string[];
111
112
  effectSmConsumedArgCNames?: Set<string>;
112
113
  loopBodyDropsBaselineCount?: number;
@@ -4,6 +4,16 @@ import type { FunctionType } from "../../types/definitions";
4
4
  import { type CodeGenContext } from "../utils";
5
5
  import type { FunctionGenerationContext } from "./context";
6
6
  export declare function generateAllFunctions(context: FunctionGenerationContext): void;
7
+ export declare function emitModuleLevelVariableDeclarations(context: FunctionGenerationContext): Array<{
8
+ cVarName: string;
9
+ cTypeStr: string;
10
+ rhs: Expr;
11
+ }>;
12
+ export declare function generateLibraryInitFunction(context: FunctionGenerationContext, moduleLevelVars: Array<{
13
+ cVarName: string;
14
+ cTypeStr: string;
15
+ rhs: Expr;
16
+ }>): void;
7
17
  export declare function generateMainWrapper(context: FunctionGenerationContext): void;
8
18
  export declare function preRegisterEffectfulFunctions(context: FunctionGenerationContext): void;
9
19
  export declare function generateFunction(functionValue: FunctionValue, cFunctionName: string, context: FunctionGenerationContext): void;
@@ -82,6 +82,7 @@ export interface CodeGenContext {
82
82
  typeIdStatics?: Map<string, string>;
83
83
  isLibrary?: boolean;
84
84
  needsIntelAsmSyntax?: boolean;
85
+ moduleLevelInitExprs?: Expr[];
85
86
  currentModuleId?: string;
86
87
  exportedFunctionLabels?: Map<FuncValueId, string>;
87
88
  }
@@ -20,6 +20,7 @@ export interface Variable {
20
20
  isImplicit?: boolean;
21
21
  isFromEffectSpread?: boolean;
22
22
  isEffectParam?: boolean;
23
+ isModuleLevel?: boolean;
23
24
  }
24
25
  export type WhereClauseConstraints = {
25
26
  someType: SomeType;
@@ -109,6 +109,7 @@ export declare class BuildRegistry {
109
109
  findTest(name: string): BuildTestSuite | undefined;
110
110
  findRunStep(name: string): BuildRunStep | undefined;
111
111
  findStep(name: string): BuildStep | undefined;
112
+ private checkDuplicateArtifactName;
112
113
  findDependency(name: string): BuildGitDependency | undefined;
113
114
  findPathDependency(name: string): BuildPathDependency | undefined;
114
115
  findSystemLibrary(name: string): BuildSystemLibrary | undefined;
@@ -36,6 +36,7 @@ export interface EvaluatorContext {
36
36
  env: Environment;
37
37
  };
38
38
  isEvaluatingFunctionBodyOrAsyncBlock?: FunctionEvaluationContext | AsyncBlockEvaluationContext | TestBlockEvaluationContext;
39
+ isInsideImplBlock?: boolean;
39
40
  capturedVariables?: Map<string, CapturedVariableInfo>;
40
41
  isEvaluatingLoopBody?: {
41
42
  kind: "while" | "for";
@@ -195,6 +195,7 @@ export declare const BuiltinFunctions: {
195
195
  __yo_ptr_set: string[];
196
196
  __yo_slice_len: string[];
197
197
  __yo_slice_new: string[];
198
+ __yo_slice_ptr: string[];
198
199
  __yo_as: string[];
199
200
  __yo_expr_is_atom: string[];
200
201
  __yo_expr_is_fn_call: string[];
@@ -565,6 +566,7 @@ export interface ExprToStringConfig {
565
566
  indentLevel?: number;
566
567
  }
567
568
  export declare function exprToString(expr: Expr, config?: ExprToStringConfig): string;
569
+ export declare function consumeCaseBodyTempVar(evaluatedBody: Expr, env: Environment): Environment;
568
570
  export declare function attachTempVariableToExpr(expr: Expr, isOwningTheRcValue: boolean, isOwningTheSameRcValueAs?: Variable): void;
569
571
  export declare function mergeAndCheckEnvs(env: Environment, bodies: Expr[]): Environment;
570
572
  export declare function replaceFuncCallExprWithFuncCallExpr(funcExpr: FnCallExpr, newFuncExpr: FnCallExpr): void;
@@ -28,4 +28,5 @@ export declare function isTargetMSVC(target: TargetInfo): boolean;
28
28
  export declare function isTargetWasm(target: TargetInfo): boolean;
29
29
  export declare function isTargetEmscripten(target: TargetInfo): boolean;
30
30
  export declare function isTargetStandaloneWasi(target: TargetInfo): boolean;
31
+ export declare function isTargetMusl(target: TargetInfo): boolean;
31
32
  export declare function isTargetPosix(target: TargetInfo): boolean;
@@ -41,6 +41,7 @@ export type ModuleValue = {
41
41
  tag: ValueTag.Module;
42
42
  type: ModuleType;
43
43
  fields: (Value | undefined)[];
44
+ moduleLevelInitExprs?: Expr[];
44
45
  };
45
46
  export type TraitValue = {
46
47
  tag: ValueTag.Trait;
@@ -123,7 +124,7 @@ export declare function createUnknownValue(type: Type, { variableName, recursive
123
124
  context: EvaluatorContext;
124
125
  }): UnknownValue | TypeValue;
125
126
  export declare function createStructValue(type: StructType, fields: Value[]): StructValue;
126
- export declare function createModuleValue(type: ModuleType, fields: (Value | undefined)[]): ModuleValue;
127
+ export declare function createModuleValue(type: ModuleType, fields: (Value | undefined)[], moduleLevelInitExprs?: Expr[]): ModuleValue;
127
128
  export declare function createTraitValue(type: TraitType, fields: (Value | undefined)[]): TraitValue;
128
129
  export declare function createTupleValue(type: TupleType, fields: Value[]): TupleValue;
129
130
  export declare function createEnumValue(type: EnumType, variantName: string, fields: Value[]): EnumValue;