lib/openwfe/expressions/fe_define.rb in openwferu-0.9.8 vs lib/openwfe/expressions/fe_define.rb in openwferu-0.9.9

- old
+ new

@@ -37,69 +37,86 @@ # "made in Japan" # # John Mettraux at openwfe.org # -require 'openwfe/rudefinitions' +#require 'openwfe/rudefinitions' require 'openwfe/expressions/flowexpression' +require 'openwfe/expressions/fe_sequence' module OpenWFE - class DefineExpression < FlowExpression + # + # The <process-definition> expression. + # + class DefineExpression < SequenceExpression + is_definition + names :define, :process_definition, :workflow_definition + + attr_accessor :body_fei, :eval_only + + # + # Evaluates the definition, but doesn't apply its body, will + # simply return the body fei. + # def evaluate (workitem) + @eval_only = true + apply workitem + return @body_fei + end - #ldebug { "evaluate() #{@fei.to_s}" } + # + # Called at the end of the 'evaluation', the 'apply' operation on + # the body of the definition is done here. + # + def reply_to_parent (workitem) - # - # spot the body of this expression - # define each sub-definition + return if @eval_only - body_fei = nil + unless @body_fei + super workitem + return + end - @children.each do |fei| + fei = @body_fei + @body_fei = nil - #ldebug { "evaluate() looking at #{fei.to_debug_s}" } + store_itself() - rawchild, _fei = get_expression_pool().fetch(fei) + get_expression_pool.apply fei, workitem + end - if not rawchild.is_definition? - body_fei = rawchild.fei if not body_fei - next - end + protected - # then it's a definition + def get_to_next_child - get_environment()[rawchild.definition_name()] = fei - end - - # - # store self + next_fei = super - store_itself() + return nil unless next_fei - # - # return the id of the body + rawchild = get_expression_pool.fetch_expression next_fei - return body_fei - end + unless rawchild.is_definition? + @body_fei = next_fei unless @body_fei + return get_to_next_child + end - # - # apply / reply + exp_class = get_expression_map.get_class rawchild - def apply (workitem) - # - # apply the body + if exp_class == DefineExpression + get_environment()[rawchild.definition_name()] = next_fei + return get_to_next_child + end - body_fei = evaluate(workitem) - get_expression_pool().apply(body_fei, workitem) - end + # + # our next child will simply get applied - #def reply (workitem) - #end + next_fei + end end end