Class: StateMachine::OOStructuredFSM::FunctionState

Inherits:
OOStructuredState show all
Defined in:
lib/kuniri/state_machine/OO_structured_fsm/function_state.rb

Overview

Class responsible for handling function state.

Instance Method Summary collapse

Methods inherited from OOStructuredState

#aggregation_capture, #attribute_capture, #class_capture, #comment_capture, #constructor_capture, #function_capture, #include_capture, #method_capture, #variable_capture

Constructor Details

#initialize(pLanguage) ⇒ FunctionState

Returns a new instance of FunctionState.



14
15
16
# File 'lib/kuniri/state_machine/OO_structured_fsm/function_state.rb', line 14

def initialize(pLanguage)
  @language = pLanguage
end

Instance Method Details

#conditional_captureObject

See Also:



40
41
42
43
# File 'lib/kuniri/state_machine/OO_structured_fsm/function_state.rb', line 40

def conditional_capture
  @language.flagFunctionBehaviour = StateMachine::GLOBAL_FUNCTION_STATE
  @language.set_state(@language.conditionalState)
end

#execute(pElementFile, pLine) ⇒ Object

See Also:



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/kuniri/state_machine/OO_structured_fsm/function_state.rb', line 52

def execute(pElementFile, pLine)
  function = @language.functionHandler.get_function(pLine)

  if function
    function.comments = @language.string_comment_to_transfer
    @language.string_comment_to_transfer = ""
    pElementFile.add_global_function(function)
  end

  if (@language.endBlockHandler.has_end_of_block?(pLine))
    previous = @language.previousState.last

    if (previous.is_a? (StateMachine::OOStructuredFSM::ModuleState))
      module_capture
    elsif (previous.is_a? (StateMachine::OOStructuredFSM::IdleState))
      idle_capture
    end

  end

  return pElementFile
end

#handle_line(pLine) ⇒ Object

See Also:



19
20
21
22
23
24
25
26
27
# File 'lib/kuniri/state_machine/OO_structured_fsm/function_state.rb', line 19

def handle_line(pLine)
  if @language.conditionalHandler.get_conditional(pLine)
    conditional_capture
  elsif @language.repetitionHandler.get_repetition(pLine)
    repetition_capture
  else
    return
  end
end

#idle_captureObject

See Also:



30
31
32
# File 'lib/kuniri/state_machine/OO_structured_fsm/function_state.rb', line 30

def idle_capture
  @language.rewind_state
end

#module_captureObject

See Also:



35
36
37
# File 'lib/kuniri/state_machine/OO_structured_fsm/function_state.rb', line 35

def module_capture
  @language.rewind_state
end

#repetition_captureObject

See Also:



46
47
48
49
# File 'lib/kuniri/state_machine/OO_structured_fsm/function_state.rb', line 46

def repetition_capture
  @language.flagFunctionBehaviour = StateMachine::GLOBAL_FUNCTION_STATE
  @language.set_state(@language.repetitionState)
end