Skip to content

Commit

Permalink
remove formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
0xNeshi committed Feb 21, 2025
1 parent ddf4f47 commit 5c62450
Showing 1 changed file with 6 additions and 29 deletions.
35 changes: 6 additions & 29 deletions packages/core/stylus/src/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,23 +100,14 @@ export class ContractBuilder implements Contract {
return [...this.constantsMap.values()];
}

addUseClause(
containerPath: string,
name: string,
options?: { groupable?: boolean; alias?: string }
): void {
addUseClause(containerPath: string, name: string, options?: { groupable?: boolean; alias?: string }): void {
// groupable defaults to true
const groupable = options?.groupable ?? true;
const alias = options?.alias ?? '';
const uniqueName = alias.length > 0 ? alias : name;
const present = this.useClausesMap.has(uniqueName);
if (!present) {
this.useClausesMap.set(uniqueName, {
containerPath,
name,
groupable,
alias,
});
this.useClausesMap.set(uniqueName, { containerPath, name, groupable, alias });
}
}

Expand Down Expand Up @@ -152,21 +143,15 @@ export class ContractBuilder implements Contract {
return this.implementedTraitsMap.has(name);
}

addFunction(
baseTrait: BaseImplementedTrait,
fn: BaseFunction
): ContractFunction {
addFunction(baseTrait: BaseImplementedTrait, fn: BaseFunction): ContractFunction {
const t = this.addImplementedTrait(baseTrait);

const signature = this.getFunctionSignature(fn);

// Look for the existing function with the same signature and return it if found
for (let i = 0; i < t.functions.length; i++) {
const existingFn = t.functions[i];
if (
existingFn !== undefined &&
this.getFunctionSignature(existingFn) === signature
) {
if (existingFn !== undefined && this.getFunctionSignature(existingFn) === signature) {
return existingFn;
}
}
Expand All @@ -184,21 +169,13 @@ export class ContractBuilder implements Contract {
return [fn.name, '(', ...fn.args.map(a => a.name), ')'].join('');
}

addFunctionCodeBefore(
baseTrait: BaseImplementedTrait,
fn: BaseFunction,
codeBefore: string[]
): void {
addFunctionCodeBefore(baseTrait: BaseImplementedTrait, fn: BaseFunction, codeBefore: string[]): void {
this.addImplementedTrait(baseTrait);
const existingFn = this.addFunction(baseTrait, fn);
existingFn.codeBefore = [...(existingFn.codeBefore ?? []), ...codeBefore];
}

addFunctionTag(
baseTrait: BaseImplementedTrait,
fn: BaseFunction,
tag: string
): void {
addFunctionTag(baseTrait: BaseImplementedTrait, fn: BaseFunction, tag: string): void {
this.addImplementedTrait(baseTrait);
const existingFn = this.addFunction(baseTrait, fn);
existingFn.tag = tag;
Expand Down

0 comments on commit 5c62450

Please sign in to comment.