Skip to content

Commit

Permalink
minor (#663): fixed type semantics, used type specifier as template
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzholzbauer committed Jul 23, 2024
1 parent 13faeb7 commit ecce17a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,4 @@ import type { ProcessedType } from "../../../../../semantics";
* @since 0.8.0
*/
export interface TypeofTypeSpecifierExpressionSemantics extends TypeSpecifierExpressionSemantics {
/**
* The checked type for this typeof expression.
* @since 0.12.0
*/
evaluatedType: ProcessedType;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { CompilableASTNode } from "../../../../compilable-ast-node";
import { TypeSpecifierExpression } from "../type-specifier-expression";
import type { TypeofTypeSpecifierExpressionContext } from "../../../../../lexer-parser";
import { KindParseRuleMapping, ParseRuleKindMapping } from "../../../../../lexer-parser";
import { RawType } from "../../../../../semantics";
import { BuiltInType, BuiltInTypes, RawType } from "../../../../../semantics";

/**
* Typeof type specifier expression, which represents a runtime typeof expression evaluating the type of a value.
Expand Down Expand Up @@ -81,13 +81,8 @@ export class TypeofTypeSpecifierExpression extends TypeSpecifierExpression<
* the children has already failed and as such no parent node should run type checking.
*/
public async primarySemanticAnalysis(): Promise<void> {
const expression = this.children[0];

this.programCtx.semanticCheck(this);

this.semanticData = {
evaluatedType: expression.getTypeSemanticData().evaluatedType,
rawType: new RawType(expression.sourceCode)
rawType: new RawType(this.sourceCode)
};
}

Expand All @@ -99,11 +94,11 @@ export class TypeofTypeSpecifierExpression extends TypeSpecifierExpression<
public async primarySemanticTypeChecking(): Promise<void> {
const semanticData = this.getSemanticData();

this.programCtx.semanticCheck(this);
const valueType = this.programCtx.typeCheck(this).getCheckedType(semanticData.rawType, this.scope);

this.typeSemantics = {
storedType: semanticData.object.g,
evaluatedType: semanticData.object.getTypeSemanticData().evaluatedType,
evaluatedType: BuiltInTypes.type,
storedType: valueType,
};
}

Expand Down

0 comments on commit ecce17a

Please sign in to comment.