Class: ADSL::Parser::ASTDereferenceCreate

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, #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

#objset_has_side_effects?Boolean

Returns:

  • (Boolean)


1141
# File 'lib/adsl/parser/ast_nodes.rb', line 1141

def objset_has_side_effects?; true; end

#to_adslObject



1163
1164
1165
# File 'lib/adsl/parser/ast_nodes.rb', line 1163

def to_adsl
  "derefcreate(#{@objset.to_adsl}.#{@rel_name.text})"
end

#typecheck_and_resolve(context) ⇒ Object

Raises:



1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
# File 'lib/adsl/parser/ast_nodes.rb', line 1143

def typecheck_and_resolve(context)
  objset = @objset.typecheck_and_resolve context
  klass = objset.type
  raise ADSLError, 'Cannot create an object on an empty objset' if klass.nil?
  relation = context.find_relation klass, @rel_name.text, @rel_name.lineno
 
  create_objset = ASTCreateObjset.new(
    :class_name => ASTIdent.new(:text => relation.to_class.name)
  )
  
  assoc_builder = (@empty_first ? ASTSetTup : ASTCreateTup).new(
    :objset1 => @objset,
    :rel_name => @rel_name,
    :objset2 => create_objset
  )
  context.pre_stmts << assoc_builder.typecheck_and_resolve(context)

  create_objset.typecheck_and_resolve(context)
end