package scotch.compiler.syntax.value; import static lombok.AccessLevel.PACKAGE; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.ToString; import scotch.compiler.analyzer.DependencyAccumulator; import scotch.compiler.analyzer.NameAccumulator; import scotch.compiler.analyzer.OperatorAccumulator; import scotch.compiler.analyzer.PrecedenceParser; import scotch.compiler.analyzer.NameQualifier; import scotch.compiler.analyzer.TypeChecker; import scotch.compiler.intermediate.IntermediateGenerator; import scotch.compiler.intermediate.IntermediateValue; import scotch.compiler.intermediate.Intermediates; import scotch.compiler.syntax.pattern.PatternReducer; import scotch.compiler.text.SourceLocation; import scotch.compiler.syntax.type.Type; @AllArgsConstructor(access = PACKAGE) @EqualsAndHashCode(callSuper = false) @ToString(exclude = "sourceLocation") public class Raise extends Value { @Getter private final SourceLocation sourceLocation; private final String message; @Getter private final Type type; @Override public Value accumulateDependencies(DependencyAccumulator state) { return this; } @Override public Value accumulateNames(NameAccumulator state) { throw new UnsupportedOperationException(); // TODO } @Override public Value bindMethods(TypeChecker typeChecker) { return this; } @Override public Value bindTypes(TypeChecker typeChecker) { return withType(typeChecker.generate(type)); } @Override public Value checkTypes(TypeChecker typeChecker) { return this; } @Override public Value defineOperators(OperatorAccumulator state) { throw new UnsupportedOperationException(); // TODO } @Override public IntermediateValue generateIntermediateCode(IntermediateGenerator state) { return Intermediates.raise(message); } @Override public Value parsePrecedence(PrecedenceParser state) { throw new UnsupportedOperationException(); // TODO } @Override public Value qualifyNames(NameQualifier state) { throw new UnsupportedOperationException(); // TODO } @Override public Value reducePatterns(PatternReducer reducer) { throw new UnsupportedOperationException(); // TODO } @Override public Value withType(Type type) { return new Raise(sourceLocation, message, type); } }