remove NYI errors, check if a struct is defined if the declared type is not primitive
This commit is contained in:
@@ -195,8 +195,8 @@ public class ContextAnalysis extends KlangBaseVisitor<Node> {
|
|||||||
int col = ctx.start.getCharPositionInLine();
|
int col = ctx.start.getCharPositionInLine();
|
||||||
Type declaredType = Type.getByName(ctx.type_annotation().type().getText());
|
Type declaredType = Type.getByName(ctx.type_annotation().type().getText());
|
||||||
|
|
||||||
if (!declaredType.isPrimitiveType()) {
|
if (!declaredType.isPrimitiveType() && !this.structs.contains(declaredType.getName())) {
|
||||||
String error = "Using a struct as a type for a variable is not yet implemented";
|
String error = "Type " + declaredType.getName() + " not defined.";
|
||||||
throw new RuntimeException(Helper.getErrorPrefix(line, col) + error);
|
throw new RuntimeException(Helper.getErrorPrefix(line, col) + error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -682,8 +682,8 @@ public class ContextAnalysis extends KlangBaseVisitor<Node> {
|
|||||||
Type returnType = Type.getByName(ctx.returnType.type().getText());
|
Type returnType = Type.getByName(ctx.returnType.type().getText());
|
||||||
this.currentDeclaredReturnType = returnType;
|
this.currentDeclaredReturnType = returnType;
|
||||||
|
|
||||||
if (!returnType.isPrimitiveType()) {
|
if (!returnType.isPrimitiveType() && !this.structs.contains(returnType.getName())) {
|
||||||
String error = "Using a struct as the return type of a function is not yet implemented";
|
String error = "Type " + returnType.getName() + " not defined.";
|
||||||
throw new RuntimeException(Helper.getErrorPrefix(line, col) + error);
|
throw new RuntimeException(Helper.getErrorPrefix(line, col) + error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -726,11 +726,10 @@ public class ContextAnalysis extends KlangBaseVisitor<Node> {
|
|||||||
String name = ctx.IDENT().getText();
|
String name = ctx.IDENT().getText();
|
||||||
int line = ctx.start.getLine();
|
int line = ctx.start.getLine();
|
||||||
int col = ctx.start.getCharPositionInLine();
|
int col = ctx.start.getCharPositionInLine();
|
||||||
|
|
||||||
Type type = Type.getByName(ctx.type_annotation().type().getText());
|
Type type = Type.getByName(ctx.type_annotation().type().getText());
|
||||||
|
|
||||||
if (!type.isPrimitiveType()) {
|
if (!type.isPrimitiveType() && !this.structs.contains(type.getName())) {
|
||||||
String error = "Using a struct as a parameter is not yet implemented";
|
String error = "Type " + type.getName() + " not defined.";
|
||||||
throw new RuntimeException(Helper.getErrorPrefix(line, col) + error);
|
throw new RuntimeException(Helper.getErrorPrefix(line, col) + error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user