started on type checker
This commit is contained in:
@@ -50,7 +50,7 @@ semantics.addOperation<any>("toAST", {
|
||||
value: this.sourceString,
|
||||
type: {
|
||||
typeUsage: "NamedTypeUsage",
|
||||
name: { name: "i64", spanStart: 0, spanEnd: 0 },
|
||||
name: { text: "i64", spanStart: 0, spanEnd: 0 },
|
||||
},
|
||||
};
|
||||
},
|
||||
@@ -60,7 +60,7 @@ semantics.addOperation<any>("toAST", {
|
||||
value: this.sourceString,
|
||||
type: {
|
||||
typeUsage: "NamedTypeUsage",
|
||||
name: { name: "f64", spanStart: 0, spanEnd: 0 },
|
||||
name: { text: "f64", spanStart: 0, spanEnd: 0 },
|
||||
},
|
||||
};
|
||||
},
|
||||
@@ -70,7 +70,7 @@ semantics.addOperation<any>("toAST", {
|
||||
value: this.sourceString,
|
||||
type: {
|
||||
typeUsage: "NamedTypeUsage",
|
||||
name: { name: "bool", spanStart: 0, spanEnd: 0 },
|
||||
name: { text: "bool", spanStart: 0, spanEnd: 0 },
|
||||
},
|
||||
};
|
||||
},
|
||||
@@ -80,7 +80,7 @@ semantics.addOperation<any>("toAST", {
|
||||
value: text.sourceString,
|
||||
type: {
|
||||
typeUsage: "NamedTypeUsage",
|
||||
name: { name: "String", spanStart: 0, spanEnd: 0 },
|
||||
name: { text: "String", spanStart: 0, spanEnd: 0 },
|
||||
},
|
||||
};
|
||||
},
|
||||
@@ -100,7 +100,7 @@ semantics.addOperation<any>("toAST", {
|
||||
},
|
||||
identifier(_1, _2): Identifier {
|
||||
return {
|
||||
name: this.sourceString,
|
||||
text: this.sourceString,
|
||||
spanStart: this.source.startIdx,
|
||||
spanEnd: this.source.endIdx,
|
||||
};
|
||||
@@ -197,10 +197,7 @@ semantics.addOperation<any>("toAST", {
|
||||
statementType: "LetStatement",
|
||||
variableName: ident.toAST(),
|
||||
expression: expression.toAST(),
|
||||
type:
|
||||
tu.length > 0
|
||||
? tu[0]
|
||||
: { typeUsage: "UnknownTypeUsage", name: nextUnknown() },
|
||||
type: tu.length > 0 ? tu[0] : { typeUsage: "UnknownTypeUsage", name: nextUnknown() },
|
||||
};
|
||||
},
|
||||
AssignmentStatement(variable, _2, expression, _4): AssignmentStatement {
|
||||
@@ -248,15 +245,7 @@ semantics.addOperation<any>("toAST", {
|
||||
type: typeUsage.toAST(),
|
||||
};
|
||||
},
|
||||
FunctionDeclaration(
|
||||
_1,
|
||||
identifier,
|
||||
_3,
|
||||
args,
|
||||
_4,
|
||||
_5,
|
||||
returnType,
|
||||
): FunctionDeclaration {
|
||||
FunctionDeclaration(_1, identifier, _3, args, _4, _5, returnType): FunctionDeclaration {
|
||||
return {
|
||||
name: identifier.toAST(),
|
||||
arguments: args.asIteration().children.map((c) => c.toAST()),
|
||||
@@ -276,14 +265,7 @@ semantics.addOperation<any>("toAST", {
|
||||
type: typeUsage.toAST(),
|
||||
};
|
||||
},
|
||||
StructTypeDeclaration(
|
||||
_1,
|
||||
identifier,
|
||||
_3,
|
||||
_4,
|
||||
fields,
|
||||
_6,
|
||||
): StructTypeDeclaration {
|
||||
StructTypeDeclaration(_1, identifier, _3, _4, fields, _6): StructTypeDeclaration {
|
||||
return {
|
||||
moduleItem: "StructTypeDeclaration",
|
||||
typeDeclaration: "StructTypeDeclaration",
|
||||
@@ -294,14 +276,7 @@ semantics.addOperation<any>("toAST", {
|
||||
TraitMethod(declaration, _2): FunctionDeclaration {
|
||||
return declaration.toAST();
|
||||
},
|
||||
TraitTypeDeclaration(
|
||||
_1,
|
||||
identifier,
|
||||
_3,
|
||||
_4,
|
||||
methods,
|
||||
_5,
|
||||
): TraitTypeDeclaration {
|
||||
TraitTypeDeclaration(_1, identifier, _3, _4, methods, _5): TraitTypeDeclaration {
|
||||
return {
|
||||
moduleItem: "TraitTypeDeclaration",
|
||||
typeDeclaration: "TraitTypeDeclaration",
|
||||
|
||||
Reference in New Issue
Block a user