Skip to content

Commit

Permalink
GH-548 Remove unnecessary exception signatures and get rid of the Int…
Browse files Browse the repository at this point in the history
…erpretation process and application parser
  • Loading branch information
dzikoysk committed Aug 19, 2020
1 parent a8a87c7 commit 2448e51
Show file tree
Hide file tree
Showing 35 changed files with 122 additions and 370 deletions.
2 changes: 2 additions & 0 deletions examples/tests/current_test.panda
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ main {
// Test implementation of Java class
CustomThread thread = new CustomThread()
thread.start()

// Runnable runnable = { log 'x' }
}

// simple interface
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.panda_lang.language.architecture.Application;
import org.panda_lang.language.architecture.Environment;
import org.panda_lang.language.interpreter.source.Source;
import org.panda_lang.utilities.commons.function.ThrowingConsumer;

/**
* Translate source code into efficient intermediate representation and build an application
Expand All @@ -28,16 +27,10 @@ public interface Interpreter {

/**
* Starts the process of interpretation
*/
Application interpret(Source source);

/**
* Starts the process of interpretation and gives access to the interpretation process
*
* @param interpretationConsumer the interpretation process consumer
* @return interpreted application
*/
Application interpret(Source source, ThrowingConsumer<Interpretation, ?> interpretationConsumer);
Application interpret(Source source);

/**
* Get associated environment
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.panda_lang.language.architecture.module.Imports;
import org.panda_lang.language.architecture.statement.Scope;
import org.panda_lang.language.architecture.module.TypeLoader;
import org.panda_lang.language.interpreter.Interpretation;
import org.panda_lang.language.interpreter.parser.expression.ExpressionParser;
import org.panda_lang.language.interpreter.parser.stage.StageController;
import org.panda_lang.language.interpreter.parser.pipeline.PipelinePath;
Expand All @@ -41,11 +40,6 @@ public final class Components {
*/
public static final ContextComponent<FrameworkController> CONTROLLER = ContextComponent.of("controller", FrameworkController.class);

/**
* Represents the interpretation process
*/
public static final ContextComponent<Interpretation> INTERPRETATION = ContextComponent.of("interpretation", Interpretation.class);

/**
* Represents the application environment
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ public interface ContextParser<T> extends Parser {
*
* @param context set of information about source and interpretation process
*/
T parse(Context context) throws Exception;
T parse(Context context);

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package org.panda_lang.language.interpreter.parser.pipeline;

import org.panda_lang.language.interpreter.Interpretation;
import org.panda_lang.language.interpreter.parser.Components;
import org.panda_lang.language.interpreter.parser.Context;
import org.panda_lang.language.interpreter.parser.ContextParser;
Expand All @@ -41,13 +40,11 @@ public PipelineParser(PipelineComponent<T> component) {
* @param context the context to use
* @param stream the stream to parse
* @return returns always null
* @throws Exception if something happen in subparser
*/
public boolean parse(Context context, SourceStream stream) throws Exception {
Interpretation interpretation = context.getComponent(Components.INTERPRETATION);
public boolean parse(Context context, SourceStream stream) {
Pipeline<T> pipeline = context.getComponent(Components.PIPELINE).getPipeline(pipelineComponent);

while (stream.hasUnreadSource() && interpretation.isHealthy()) {
while (stream.hasUnreadSource()) {
LocalChannel channel = new PandaLocalChannel();
Snippet source = stream.toSnippet();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public PandaStage(StageController controller, String name) {
}

@Override
public boolean execute() throws Exception {
public boolean execute() {
while (true) {
currentPhase.callTasks();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ public PandaStageController initialize(List<? extends StageType> types) {
}

@Override
public void launch() throws Exception {
public void launch() {
while (countTasks(null) > 0) {
executeOnce();
}
}

private void executeOnce() throws Exception {
private void executeOnce() {
for (Stage cycle : cycles.values()) {
currentCycle = cycle;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public PandaStagePhase(Stage cycle) {
}

@Override
public void callTasks() throws Exception {
public void callTasks() {
Map<StageOrder, List<DelegatedTask>> unitsMap = new TreeMap<>(tasks);
tasks.clear();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ public interface Stage {
* Launch cycle
*
* @return true if all tasks was called
* @throws Exception allows you to handle exception that may occur in tasks
*/
boolean execute() throws Exception;
boolean execute();

/**
* @return amount of tasks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ public interface StageController {

/**
* Launch cycles
*
* @throws Exception if {@link StagePhase} throws an exception, you should catch it and handle
*/
void launch() throws Exception;
void launch();

/**
* Get amount of tasks before the specified cycle.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ public interface StagePhase {

/**
* Call all tasks delegated to the phase
*
* @throws Exception allows you to handle exception that may occur in tasks
*/
void callTasks() throws Exception;
void callTasks();

/**
* Delegate task
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ public interface StageTask<T> {
* @param cycle current cycle
* @param context data assigned to task
* @return task value
* @throws Exception allows you to handle exception that may occur
*/
@Nullable T call(Stage cycle, Context context) throws Exception;
@Nullable T call(Stage cycle, Context context);

}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static void createPipelines() {
}

@Test
public void testPipelineGeneration() throws Throwable {
public void testPipelineGeneration() {
StringBuilder outputBuilder = new StringBuilder();

generation.getCycle("b").nextPhase().delegate((pipeline, context) -> outputBuilder.append("b "), null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public final class UnsafeUtils {
private UnsafeUtils() { }

@SuppressWarnings("unchecked")
public static <E extends Exception> void throwException(Exception e) throws E {
public static <E extends Throwable> void throwException(Throwable e) throws E {
throw (E) e;
}

Expand Down
Loading

0 comments on commit 2448e51

Please sign in to comment.