Class: RedParse::UnOpNode
- Defined in:
- lib/redparse/node.rb
Direct Known Subclasses
Constant Summary
Constants included from FlattenedIvars
FlattenedIvars::EXCLUDED_IVARS
Instance Attribute Summary collapse
Attributes inherited from Node
#endline, #errors, #offset, #parent, #startline
Attributes included from Stackable::Meta
#boolean_identity_params, #identity_params
Instance Method Summary collapse
- #image ⇒ Object
-
#initialize(op, val) ⇒ UnOpNode
constructor
A new instance of UnOpNode.
- #lvalue_parsetree(o) ⇒ Object
- #parsetree(o) ⇒ Object
- #to_lisp ⇒ Object
- #unparse(o = default_unparse_options) ⇒ Object
Methods inherited from Node
#+, #+@, #==, [], #[]=, #add_parent_links!, #begin_parsetree, create, #data, #deep_copy, #delete_extraneous_ivars!, #delete_linenums!, #depthwalk, #depthwalk_nodes, #error?, #evalable_inspect, #fixup_multiple_assignments!, #fixup_rescue_assignments!, #initialize_ivars, inline_symbols, #inspect, #lhs_unparse, #linerange, #lvars_defined_in, #merge_replacement_session, namelist, #negate, #original_brackets_assign, param_names, #parsetrees, #pretty_print, #prohibit_fixup, #replace_ivars_and_self, #replace_value, #rescue_parsetree, #to_parsetree, #to_parsetree_and_warnings, #unary, #walk, #xform_tree!
Methods included from Stackable::Meta
#build_exemplars, #enumerate_exemplars, #identity_param
Methods included from FlattenedIvars
#flattened_ivars, #flattened_ivars_equal?
Methods included from Stackable
Constructor Details
#initialize(op, val) ⇒ UnOpNode
Returns a new instance of UnOpNode.
1654 1655 1656 1657 1658 1659 1660 1661 1662 |
# File 'lib/redparse/node.rb', line 1654 def initialize(op,val) @offset||=op.offset rescue val.offset op=op.ident if op.respond_to? :ident /([&*])$/===op and op=$1+"@" /^(?:!|not)$/===op and val.respond_to? :special_conditions! and val.special_conditions! super(op,val) end |
Instance Attribute Details
#lvalue ⇒ Object
1668 1669 1670 1671 1672 1673 |
# File 'lib/redparse/node.rb', line 1668 def lvalue # return nil unless op=="*@" return @lvalue if defined? @lvalue @lvalue=true end |
Instance Method Details
#image ⇒ Object
1666 |
# File 'lib/redparse/node.rb', line 1666 def image; "(#{op})" end |
#lvalue_parsetree(o) ⇒ Object
1695 1696 1697 |
# File 'lib/redparse/node.rb', line 1695 def lvalue_parsetree(o) parsetree(o) end |
#parsetree(o) ⇒ Object
1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 |
# File 'lib/redparse/node.rb', line 1680 def parsetree(o) node=self node=node.val while UnOpNode===node and node.op=="+@" return node.parsetree(o) if LiteralNode&-{:val=>Integer|Float|Symbol}===node return node.parsetree(o) if StringNode&-{:char=>'/', :size=>1}===node case op when /^&/; [:block_arg, val.ident.to_sym] when "!","not"; [:not, val.rescue_parsetree(o)] when "defined?"; [:defined, val.parsetree(o)] else [:call, val.rescue_parsetree(o), op.to_sym] end end |
#to_lisp ⇒ Object
1676 1677 1678 |
# File 'lib/redparse/node.rb', line 1676 def to_lisp "(#{op} #{val.to_lisp})" end |
#unparse(o = default_unparse_options) ⇒ Object
1699 1700 1701 1702 1703 1704 1705 |
# File 'lib/redparse/node.rb', line 1699 def unparse o= op=op() op=op.chomp "@" result=op result+=" " if /#{LETTER}/o===op or /^[+-]/===op && LiteralNode===val result+=val.unparse(o) end |