Class: Y2R::AST::YCP::Break
Instance Method Summary collapse
Methods inherited from Node
#always_returns?, #compile_as_copy_if_needed, #compile_statements, #compile_statements_inside_block, #compile_statements_with_whitespace, #creates_local_scope?, #needs_copy?, #never_nil?, #optimize_last_statement, #optimize_next, #optimize_return, #remove_duplicate_imports, transfers_comments
Instance Method Details
#compile(context) ⇒ Object
865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 |
# File 'lib/y2r/ast/ycp.rb', line 865 def compile(context) case context.innermost(While, Do, Repeat, UnspecBlock, Case, Default) when While, Do, Repeat Ruby::Break.new when UnspecBlock Ruby::MethodCall.new( :receiver => nil, :name => "raise", :args => [Ruby::Variable.new(:name => "Break")], :block => nil, :parens => false ) when Case raise NotImplementedError, "Case with a break in the middle encountered. These are not supported." when Default raise NotImplementedError, "Default with a break in the middle encountered. These are not supported." else raise "Misplaced \"break\" statement." end end |