make file pretty
This commit is contained in:
@@ -55,17 +55,19 @@ public class ContextAnalysis extends KlangBaseVisitor<Node> {
|
||||
statements[i] = (Statement) currentStatement;
|
||||
actualStatementCount += 1;
|
||||
|
||||
// We use the existance of a type to indicate that this statement returns something
|
||||
// for which the VariableDeclaration is an exception
|
||||
// We use the existance of a type to indicate that this statement returns
|
||||
// something for which the VariableDeclaration is an exception
|
||||
if (currentStatement.type != null && !(currentStatement instanceof VariableDeclaration)) {
|
||||
// check whether the type matches
|
||||
try {
|
||||
this.currentDeclaredReturnType.combine(currentStatement.type);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(Helper.getErrorPrefix(currentStatement.line, currentStatement.col) + e.getMessage());
|
||||
throw new RuntimeException(
|
||||
Helper.getErrorPrefix(currentStatement.line, currentStatement.col) + e.getMessage());
|
||||
}
|
||||
|
||||
// since we have a return guaranteed, every statement after this one is unreachable code
|
||||
// since we have a return guaranteed, every statement
|
||||
// after this one is unreachable code
|
||||
hasReturn = true;
|
||||
break;
|
||||
}
|
||||
@@ -125,8 +127,9 @@ public class ContextAnalysis extends KlangBaseVisitor<Node> {
|
||||
}
|
||||
|
||||
if (thenBlock.type != null && type != null) {
|
||||
// Since a block verifies that it can combine with the return type of the function
|
||||
// it is defined in, we do not have check whether the then and alt block return types match
|
||||
// Since a block verifies that it can combine with the return type of the
|
||||
// function it is defined in, we do not have check whether the then and
|
||||
// alt block return types match
|
||||
result.type = thenBlock.type;
|
||||
}
|
||||
|
||||
@@ -558,7 +561,7 @@ public class ContextAnalysis extends KlangBaseVisitor<Node> {
|
||||
// Visit the block, make sure that a return value is guaranteed
|
||||
Node block = this.visit(ctx.braced_block());
|
||||
if (block.type == null) {
|
||||
String error = "Function " + name +" has to return something of type " + returnType.getName() +".";
|
||||
String error = "Function " + name + " has to return something of type " + returnType.getName() + ".";
|
||||
throw new RuntimeException(Helper.getErrorPrefix(line, col) + error);
|
||||
}
|
||||
|
||||
@@ -608,7 +611,7 @@ public class ContextAnalysis extends KlangBaseVisitor<Node> {
|
||||
try {
|
||||
expression.type.combine(func.signature[i]); // Make sure the types are matching
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(Helper.getErrorPrefix(line, col) + "argument " + i +" " + e.getMessage());
|
||||
throw new RuntimeException(Helper.getErrorPrefix(line, col) + "argument " + i + " " + e.getMessage());
|
||||
}
|
||||
args[i] = expression;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user