| 1096 | } |
| 1097 | |
| 1098 | void ScriptValidator::CheckCommand(const Command* command) { |
| 1099 | switch (command->type) { |
| 1100 | case CommandType::Module: { |
| 1101 | Validator module_validator(errors_, &cast<ModuleCommand>(command)->module, |
| 1102 | options_); |
| 1103 | module_validator.CheckModule(); |
| 1104 | break; |
| 1105 | } |
| 1106 | |
| 1107 | case CommandType::ScriptModule: { |
| 1108 | Validator module_validator( |
| 1109 | errors_, &cast<ScriptModuleCommand>(command)->module, options_); |
| 1110 | module_validator.CheckModule(); |
| 1111 | break; |
| 1112 | } |
| 1113 | |
| 1114 | case CommandType::Action: |
| 1115 | // Ignore result type. |
| 1116 | CheckAction(cast<ActionCommand>(command)->action.get()); |
| 1117 | break; |
| 1118 | |
| 1119 | case CommandType::Register: |
| 1120 | case CommandType::AssertMalformed: |
| 1121 | case CommandType::AssertInvalid: |
| 1122 | case CommandType::AssertUnlinkable: |
| 1123 | case CommandType::AssertUninstantiable: |
| 1124 | // Ignore. |
| 1125 | break; |
| 1126 | |
| 1127 | case CommandType::AssertReturn: { |
| 1128 | auto* assert_return_command = cast<AssertReturnCommand>(command); |
| 1129 | const Action* action = assert_return_command->action.get(); |
| 1130 | ActionResult result = CheckAction(action); |
| 1131 | const Expectation* expected = assert_return_command->expected.get(); |
| 1132 | switch (result.kind) { |
| 1133 | case ActionResult::Kind::Types: |
| 1134 | CheckExpectationTypes(&action->loc, *result.types, expected, |
| 1135 | "action"); |
| 1136 | break; |
| 1137 | |
| 1138 | case ActionResult::Kind::Type: |
| 1139 | CheckExpectationTypes(&action->loc, {result.type}, expected, |
| 1140 | "action"); |
| 1141 | break; |
| 1142 | |
| 1143 | case ActionResult::Kind::Error: |
| 1144 | // Error occurred, don't do any further checks. |
| 1145 | break; |
| 1146 | } |
| 1147 | break; |
| 1148 | } |
| 1149 | |
| 1150 | case CommandType::AssertTrap: |
| 1151 | // ignore result type. |
| 1152 | CheckAction(cast<AssertTrapCommand>(command)->action.get()); |
| 1153 | break; |
| 1154 | case CommandType::AssertExhaustion: |
| 1155 | // ignore result type. |
nothing calls this directly
no test coverage detected