Class: ADSL::Parser::ASTUnion
Instance Method Summary
collapse
Methods inherited from ASTNode
#==, #adsl_ast, #adsl_ast_size, #block_replace, #dup, #hash, is_formula?, is_objset?, is_statement?, node_type, #preorder_traverse
#[], #and, #binary_op, #binary_op_with_any_number_of_params, #equiv, #exists, #false, #forall, #handle_quantifier, #implies, #in_formula_builder, #not, #or, #true
#classname_for_classname, #infer_classname_from_varname, #t
Instance Method Details
#objset_has_side_effects? ⇒ Boolean
1033
1034
1035
|
# File 'lib/adsl/parser/ast_nodes.rb', line 1033
def objset_has_side_effects?
@objsets.nil? ? false : @objsets.map{ |o| o.objset_has_side_effects? }.include?(true)
end
|
1051
1052
1053
1054
1055
1056
1057
1058
1059
|
# File 'lib/adsl/parser/ast_nodes.rb', line 1051
def optimize
until_no_change super do |union|
next ASTEmptyObjset.new if union.objsets.empty?
next union.objsets.first if union.objsets.length == 1
ASTUnion.new(:objsets => union.objsets.map{ |objset|
objset.is_a?(ASTUnion) ? objset.objsets : [objset]
}.flatten(1).reject{ |o| o.is_a? ASTEmptyObjset })
end
end
|
1061
1062
1063
|
# File 'lib/adsl/parser/ast_nodes.rb', line 1061
def to_adsl
"union(#{ @objsets.map(&:to_adsl).join(', ') })"
end
|
#typecheck_and_resolve(context) ⇒ Object
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
|
# File 'lib/adsl/parser/ast_nodes.rb', line 1037
def typecheck_and_resolve(context)
objsets = @objsets.map{ |o| o.typecheck_and_resolve context }
objsets.reject!{ |o| o.type.nil? }
return ADSL::DS::DSEmptyObjset.new if objsets.length == 0
return objsets.first if objsets.length == 1
types = objsets.map{ |o| o.type }
ADSL::DS::DSClass.common_supertype(types)
return ADSL::DS::DSUnion.new :objsets => objsets
end
|