<commit_before>package som.interpreter.nodes.dispatch;

import static som.interpreter.TruffleCompiler.transferToInterpreterAndInvalidate;
import som.interpreter.SArguments;
import som.interpreter.Types;
import som.interpreter.nodes.MessageSendNode.GenericMessageSendNode;
import som.vm.Universe;
import som.vmobjects.SClass;
import som.vmobjects.SMethod;
import som.vmobjects.SSymbol;

import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.Node;


public class UninitializedDispatchNode extends AbstractDispatchWithLookupNode {

  public UninitializedDispatchNode(final SSymbol selector, final Universe universe) {
    super(selector, universe);
  }

  @Override
  public Object executeDispatch(final VirtualFrame frame,
      final SArguments arguments) {
    transferToInterpreterAndInvalidate("Initialize a dispatch node.");

    // Determine position in dispatch node chain, i.e., size of inline cache
    Node i = this;
    int chainDepth = 0;
    while (i.getParent() instanceof AbstractDispatchNode) {
      i = i.getParent();
      chainDepth++;
    }
    GenericMessageSendNode sendNode = (GenericMessageSendNode) i.getParent();


    if (chainDepth < INLINE_CACHE_SIZE) {
      SClass rcvrClass = Types.getClassOf(arguments.getReceiver(), universe);
      SMethod method   = rcvrClass.lookupInvokable(selector);

      if (method != null) {
        UninitializedDispatchNode newChainEnd = new UninitializedDispatchNode(selector, universe);

        AbstractDispatchNode initializedReplacement = new CachedDispatchNode(
            rcvrClass, method, newChainEnd, universe);
        return replace(initializedReplacement).executeDispatch(frame, arguments);
      }
      // if method == null: fall through and use generic node
    }
<commit_msg>Proper type for result variable<commit_after>package som.interpreter.nodes.dispatch;

import static som.interpreter.TruffleCompiler.transferToInterpreterAndInvalidate;
import som.interpreter.SArguments;
import som.interpreter.Types;
import som.interpreter.nodes.MessageSendNode.GenericMessageSendNode;
import som.vm.Universe;
import som.vmobjects.SClass;
import som.vmobjects.SMethod;
import som.vmobjects.SSymbol;

import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.Node;


public class UninitializedDispatchNode extends AbstractDispatchWithLookupNode {

  public UninitializedDispatchNode(final SSymbol selector, final Universe universe) {
    super(selector, universe);
  }

  @Override
  public Object executeDispatch(final VirtualFrame frame,
      final SArguments arguments) {
    transferToInterpreterAndInvalidate("Initialize a dispatch node.");

    // Determine position in dispatch node chain, i.e., size of inline cache
    Node i = this;
    int chainDepth = 0;
    while (i.getParent() instanceof AbstractDispatchNode) {
      i = i.getParent();
      chainDepth++;
    }
    GenericMessageSendNode sendNode = (GenericMessageSendNode) i.getParent();


    if (chainDepth < INLINE_CACHE_SIZE) {
      SClass rcvrClass = Types.getClassOf(arguments.getReceiver(), universe);
      SMethod method   = rcvrClass.lookupInvokable(selector);

      if (method != null) {
        UninitializedDispatchNode newChainEnd = new UninitializedDispatchNode(selector, universe);

        CachedDispatchNode initializedReplacement = new CachedDispatchNode(
            rcvrClass, method, newChainEnd, universe);
        return replace(initializedReplacement).executeDispatch(frame, arguments);
      }
      // if method == null: fall through and use generic node
    }

{'fraction_non_alphanumeric': 0.08249721293199554, 'fraction_numerical': 0.0005574136008918618, 'mean_word_length': 4.396992481203007, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3834925', 'n_tokens_mistral': 961, 'n_tokens_neox': 970, 'n_words': 236}