Class: Idl::ReturnStatementAst
- Includes:
- Returns
- Defined in:
- lib/idl/ast.rb
Overview
represents a function return statement
for example:
return 5;
return X[rs1] + 1;
Instance Method Summary collapse
- #enclosing_function ⇒ Object
-
#expected_return_type(symtab) ⇒ Type
The expected return type (as defined by the encolsing function).
-
#initialize(input, interval, return_expression) ⇒ ReturnStatementAst
constructor
A new instance of ReturnStatementAst.
- #return_expression ⇒ Object
-
#return_type(symtab) ⇒ Type
The actual return type.
-
#return_types(symtab) ⇒ Array<Type>
List of actual return types.
-
#return_value(symtab) ⇒ Integer, ...
Evaluate the compile-time return value of this node, or, if the node does not return (e.g., because it is an IfAst but there is no return on the taken path), execute the node and update the symtab.
-
#return_value_nodes ⇒ Array<AstNode>
List of return value nodes.
-
#return_values(symtab) ⇒ Array<Integer>, Array<Boolean>
Evaluate all possible compile-time return values of this node, or, if the node does not return (e.g., because it is an IfAst but there is no return on a possible path), execute the node and update the symtab.
- #to_idl ⇒ Object
-
#type_check(symtab) ⇒ void
type check this node and all children.
Constructor Details
#initialize(input, interval, return_expression) ⇒ ReturnStatementAst
Returns a new instance of ReturnStatementAst.
3928 3929 3930 |
# File 'lib/idl/ast.rb', line 3928 def initialize(input, interval, return_expression) super(input, interval, [return_expression]) end |
Instance Method Details
#enclosing_function ⇒ Object
3957 3958 3959 |
# File 'lib/idl/ast.rb', line 3957 def enclosing_function return_expression.enclosing_function end |
#expected_return_type(symtab) ⇒ Type
Returns The expected return type (as defined by the encolsing function).
3943 3944 3945 |
# File 'lib/idl/ast.rb', line 3943 def expected_return_type(symtab) return_expression.expected_return_type(symtab) end |
#return_expression ⇒ Object
3924 3925 3926 |
# File 'lib/idl/ast.rb', line 3924 def return_expression @children[0] end |
#return_type(symtab) ⇒ Type
Returns The actual return type.
3938 3939 3940 |
# File 'lib/idl/ast.rb', line 3938 def return_type(symtab) return_expression.retrun_type(symtab) end |
#return_types(symtab) ⇒ Array<Type>
Returns List of actual return types.
3933 3934 3935 |
# File 'lib/idl/ast.rb', line 3933 def return_types(symtab) return_expression.return_types(symtab) end |
#return_value(symtab) ⇒ Integer, ...
Evaluate the compile-time return value of this node, or, if the node does not return (e.g., because it is an IfAst but there is no return on the taken path), execute the node and update the symtab
3962 3963 3964 |
# File 'lib/idl/ast.rb', line 3962 def return_value(symtab) return_expression.return_value(symtab) end |
#return_value_nodes ⇒ Array<AstNode>
Returns List of return value nodes.
3953 3954 3955 |
# File 'lib/idl/ast.rb', line 3953 def return_value_nodes return_expression.return_value_nodes end |
#return_values(symtab) ⇒ Array<Integer>, Array<Boolean>
Evaluate all possible compile-time return values of this node, or, if the node does not return (e.g., because it is an IfAst but there is no return on a possible path), execute the node and update the symtab
3967 3968 3969 |
# File 'lib/idl/ast.rb', line 3967 def return_values(symtab) return_expression.return_values(symtab) end |
#to_idl ⇒ Object
3971 |
# File 'lib/idl/ast.rb', line 3971 def to_idl = "#{return_expression.to_idl};" |
#type_check(symtab) ⇒ void
This method returns an undefined value.
type check this node and all children
Calls to #type and/or #value may depend on type_check being called first with the same symtab. If not, those functions may raise an AstNode::InternalError
3948 3949 3950 |
# File 'lib/idl/ast.rb', line 3948 def type_check(symtab) return_expression.type_check(symtab) end |