Class: ADSL::Parser::ASTSetTup

Inherits:
ASTNode show all
Defined in:
lib/adsl/parser/ast_nodes.rb

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, #objset_has_side_effects?, #optimize, #preorder_traverse

Methods included from Verification::FormulaGenerators

#[], #and, #binary_op, #binary_op_with_any_number_of_params, #equiv, #exists, #false, #forall, #handle_quantifier, #implies, #in_formula_builder, #not, #or, #true

Methods included from Verification::Utils

#classname_for_classname, #infer_classname_from_varname, #t

Instance Method Details

#to_adslObject



959
960
961
# File 'lib/adsl/parser/ast_nodes.rb', line 959

def to_adsl
  "#{ @objset1.to_adsl }.#{ @rel_name.text } = #{ @objset2.to_adsl }\n"
end

#typecheck_and_resolve(context) ⇒ Object

Raises:



947
948
949
950
951
952
953
954
955
956
957
# File 'lib/adsl/parser/ast_nodes.rb', line 947

def typecheck_and_resolve(context)
  objset1 = @objset1.typecheck_and_resolve context
  objset2 = @objset2.typecheck_and_resolve context
  raise ADSLError, "Ambiguous type on the left hand side on line #{@objset1.lineno}" if objset1.type.nil?
  return [] if objset2.type.nil?
  relation = context.find_relation objset1.type, @rel_name.text, @rel_name.lineno, objset2.type
  return [
    ADSL::DS::DSDeleteTup.new(:objset1 => objset1, :relation => relation, :objset2 => ADSL::DS::DSAllOf.new(:klass => relation.to_class)),
    ADSL::DS::DSCreateTup.new(:objset1 => objset1, :relation => relation, :objset2 => objset2)
  ]
end