Module: Idl::Returns

Extended by:
T::Helpers, T::Sig
Included in:
ConditionalReturnStatementAst, ElseIfAst, ForLoopAst, FunctionBodyAst, IfAst, IfBodyAst, ReturnExpressionAst, ReturnStatementAst
Defined in:
lib/idlc/ast.rb

Overview

interface for nodes that might return a value in a function body

Instance Method Summary collapse

Instance Method Details

#expected_return_type(symtab) ⇒ Object



803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
# File 'lib/idlc/ast.rb', line 803

def expected_return_type(symtab)
  T.bind(self, AstNode) # let Sorbet know this is always executed by an AstNode

  func_def = T.cast(find_ancestor(FunctionDefAst), T.nilable(FunctionDefAst))
  if func_def.nil?
    if symtab.get("__expected_return_type").nil?
      internal_error "Forgot to set __expected_return_type in the symbol table"
    end

    symtab.get("__expected_return_type")
  else
    global_symtab = symtab.global_clone
    global_symtab.push(nil)
    rtype = func_def.return_type(global_symtab)
    global_symtab.release
    rtype
  end
end

#return_type(symtab) ⇒ Object



780
# File 'lib/idlc/ast.rb', line 780

def return_type(symtab); end

#return_value(symtab) ⇒ Object



785
# File 'lib/idlc/ast.rb', line 785

def return_value(symtab); end

#return_values(symtab) ⇒ Object



799
# File 'lib/idlc/ast.rb', line 799

def return_values(symtab); end