Skip to content

Commit

Permalink
Add expression and bind checks to exception checking, see #14
Browse files Browse the repository at this point in the history
  • Loading branch information
nickbattle committed Jan 6, 2020
1 parent 759f6ff commit 62ab12e
Show file tree
Hide file tree
Showing 57 changed files with 1,106 additions and 575 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["Error 3241: recmodify-11.vdm at 11:3 Body of trap statement does not throw exceptions"]
["recmodify-11.vdmparses and type checks"]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["Error 3241: recordexpr-10.vdm at 15:1 Body of trap statement does not throw exceptions"]
["recordexpr-10.vdmparses and type checks"]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["Error 3241: setcomp-09.vdm at 14:1 Body of trap statement does not throw exceptions"]
["setcomp-09.vdmparses and type checks"]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["Error 3241: typejudgement-03.vdm at 16:4 Body of trap statement does not throw exceptions"]
["typejudgement-03.vdmparses and type checks"]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["Error 3241: exception-08.vdm at 16:3 Body of trap statement does not throw exceptions"]
["exception-08.vdmparses and type checks"]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["Error 3241: exception-09.vdm at 16:3 Body of trap statement does not throw exceptions","Error 3327: exception-09.vdm at 40:8 Value is not of the right type","Error 3027: exception-09.vdm at 35:1 Operation returns unexpected type"]
["Error 3327: exception-09.vdm at 40:8 Value is not of the right type","Error 3027: exception-09.vdm at 35:1 Operation returns unexpected type"]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["Error 3241: blockstmt-07.vdm at 10:1 Body of trap statement does not throw exceptions"]
["blockstmt-07.vdmparses and type checks"]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["Error 3241: trapstmt.vpp at 15:3 Body of trap statement does not throw exceptions","Error 3328: trapstmt.vpp at 33:5 Statement may return void value","Error 3241: trapstmt.vpp at 26:3 Body of trap statement does not throw exceptions","Error 3327: trapstmt.vpp at 27:33 Value is not of the right type","Error 3129: trapstmt.vpp at 27:26 Constructor field 2 is of wrong type","Error 3313: trapstmt.vpp at 24:3 Operation returns void value"]
["Error 3328: trapstmt.vpp at 33:5 Statement may return void value","Error 3241: trapstmt.vpp at 26:3 Body of trap statement does not throw exceptions","Error 3327: trapstmt.vpp at 27:33 Value is not of the right type","Error 3129: trapstmt.vpp at 27:26 Constructor field 2 is of wrong type","Error 3313: trapstmt.vpp at 24:3 Operation returns void value"]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["Error 3327: casesstmt-17.vdm at 15:17 Value is not of the right type","Error 3327: casesstmt-17.vdm at 19:17 Value is not of the right type","Error 3241: casesstmt-17.vdm at 18:15 Body of trap statement does not throw exceptions","Error 3213: casesstmt-17.vdm at 18:29 Operation ErrorAction is not in scope"]
["Error 3327: casesstmt-17.vdm at 15:17 Value is not of the right type","Error 3327: casesstmt-17.vdm at 19:17 Value is not of the right type","Error 3213: casesstmt-17.vdm at 18:29 Operation ErrorAction is not in scope"]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["Error 3327: if-18.vdm at 15:17 Value is not of the right type","Error 3327: if-18.vdm at 18:17 Value is not of the right type","Error 3241: if-18.vdm at 17:10 Body of trap statement does not throw exceptions","Error 3213: if-18.vdm at 17:24 Operation ErrorAction is not in scope"]
["Error 3327: if-18.vdm at 15:17 Value is not of the right type","Error 3327: if-18.vdm at 18:17 Value is not of the right type","Error 3213: if-18.vdm at 17:24 Operation ErrorAction is not in scope"]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["Error 3241: trapstmt.vdm at 18:3 Body of trap statement does not throw exceptions","Error 3328: trapstmt.vdm at 36:5 Statement may return void value","Error 3241: trapstmt.vdm at 29:3 Body of trap statement does not throw exceptions","Error 3327: trapstmt.vdm at 30:33 Value is not of the right type","Error 3129: trapstmt.vdm at 30:26 Constructor field 2 is of wrong type","Error 3313: trapstmt.vdm at 27:3 Operation returns void value"]
["Error 3328: trapstmt.vdm at 36:5 Statement may return void value","Error 3241: trapstmt.vdm at 29:3 Body of trap statement does not throw exceptions","Error 3327: trapstmt.vdm at 30:33 Value is not of the right type","Error 3129: trapstmt.vdm at 30:26 Constructor field 2 is of wrong type","Error 3313: trapstmt.vdm at 27:3 Operation returns void value"]
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
import org.overture.typechecker.assistant.definition.PDefinitionSet;
import org.overture.typechecker.assistant.definition.SClassDefinitionAssistantTC;
import org.overture.typechecker.assistant.definition.SFunctionDefinitionAssistantTC;
import org.overture.typechecker.assistant.expression.PExpAssistantTC;
import org.overture.typechecker.assistant.module.AModuleExportsAssistantTC;
import org.overture.typechecker.assistant.module.AModuleImportsAssistantTC;
import org.overture.typechecker.assistant.module.AModuleModulesAssistantTC;
Expand Down Expand Up @@ -147,7 +148,7 @@ public interface ITypeCheckerAssistantFactory extends IAstAssistantFactory

//ACaseAlternativeAssistantTC createACaseAlternativeAssistant();

//PExpAssistantTC createPExpAssistant();
PExpAssistantTC createPExpAssistant(ITypeCheckerAssistantFactory af);

// SBinaryExpAssistantTC createSBinaryExpAssistant();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
import org.overture.typechecker.assistant.definition.PDefinitionSet;
import org.overture.typechecker.assistant.definition.SClassDefinitionAssistantTC;
import org.overture.typechecker.assistant.definition.SFunctionDefinitionAssistantTC;
import org.overture.typechecker.assistant.expression.PExpAssistantTC;
import org.overture.typechecker.assistant.module.AModuleExportsAssistantTC;
import org.overture.typechecker.assistant.module.AModuleImportsAssistantTC;
import org.overture.typechecker.assistant.module.AModuleModulesAssistantTC;
Expand Down Expand Up @@ -1045,4 +1046,10 @@ public IAnswer<String> getDetailedTypeDisplayer()
{
return new DetailedTypeDisplayer(this);
}

@Override
public PExpAssistantTC createPExpAssistant(ITypeCheckerAssistantFactory af)
{
return new PExpAssistantTC(af);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
*
*/
package org.overture.typechecker.assistant.expression;

import java.util.List;

import org.overture.ast.analysis.AnalysisException;
import org.overture.ast.analysis.intf.IQuestionAnswer;
import org.overture.ast.assistant.IAstAssistant;
import org.overture.ast.expressions.PExp;
import org.overture.ast.patterns.PMultipleBind;
import org.overture.ast.util.PTypeSet;
import org.overture.typechecker.Environment;
import org.overture.typechecker.assistant.ITypeCheckerAssistantFactory;

public class PExpAssistantTC implements IAstAssistant
{
protected final ITypeCheckerAssistantFactory af;

public PExpAssistantTC(ITypeCheckerAssistantFactory af)
{
this.af = af;
}

public PTypeSet exitCheck(List<PExp> args, Environment env) throws AnalysisException
{
PTypeSet result = new PTypeSet(af);
IQuestionAnswer<Environment, PTypeSet> checker = af.getExitTypeCollector();

for (PExp exp: args)
{
result.addAll(exp.apply(checker, env));
}

return result;
}

public PTypeSet exitCheckMultipleBindList(List<PMultipleBind> bindList, Environment env) throws AnalysisException
{
PTypeSet result = new PTypeSet(af);
IQuestionAnswer<Environment, PTypeSet> checker = af.getExitTypeCollector();

for (PMultipleBind mbind: bindList)
{
result.addAll(mbind.apply(checker, env));
}

return result;
}
}
Loading

0 comments on commit 62ab12e

Please sign in to comment.