Class ProcessSyntheticReturn
java.lang.Object
org.ek9lang.compiler.common.RuleSupport
org.ek9lang.compiler.common.ProcessSyntheticReturn
- All Implemented Interfaces:
BiConsumer<EK9Parser.OperationDetailsContext,
IMayReturnSymbol>
public class ProcessSyntheticReturn
extends RuleSupport
implements BiConsumer<EK9Parser.OperationDetailsContext,IMayReturnSymbol>
Constructs like methods and functions may or may not always return a value.
So when defining these in EK9 the developer can decide not to return any value.
However, within the compiler when resolving expressions and calls, it is important to
fill in the 'Void' definition for the returning type.
That is what this component does. In the case where no return value is defined by the EK9 developer
the compiler creates a dummy '_rtn' variable and gives it the type Void.
So when the compiler comes to check expression use it can see that a function/method does not actually
return anything and, therefore it can emit errors (in the case where the EK9 developer is incorrectly expecting
some form of value).
This won't add a synthetic return it is not needed.
-
Field Summary
Fields inherited from class org.ek9lang.compiler.common.RuleSupport
errorListener, symbolsAndScopes
-
Constructor Summary
ConstructorsConstructorDescriptionProcessSyntheticReturn
(SymbolsAndScopes symbolsAndScopes, SymbolFactory symbolFactory, ErrorListener errorListener) -
Method Summary
Modifier and TypeMethodDescriptionvoid
accept
(EK9Parser.OperationDetailsContext ctx, IMayReturnSymbol symbol) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.function.BiConsumer
andThen
-
Constructor Details
-
ProcessSyntheticReturn
public ProcessSyntheticReturn(SymbolsAndScopes symbolsAndScopes, SymbolFactory symbolFactory, ErrorListener errorListener)
-
-
Method Details
-
accept
- Specified by:
accept
in interfaceBiConsumer<EK9Parser.OperationDetailsContext,
IMayReturnSymbol>
-