class
Crystal::ToSVisitor
Defined in:
compiler/crystal/semantic/to_s.crcompiler/crystal/syntax/to_s.cr
Constant Summary
-
UNARY_OPERATORS =
{"+", "-", "~", "&+", "&-"} -
Related:
Token::Kind#unary_operator?
Constructors
Instance Method Summary
- #accept_with_indent(node : Expressions)
- #accept_with_indent(node : Nop)
- #accept_with_indent(node : ASTNode)
- #append_indent
- #drop_parens_for_proc_notation(drop : Bool = true, &)
- #drop_parens_for_proc_notation(node : ASTNode, &)
-
#drop_parens_for_proc_notation? : Bool
Inside a comma-separated list of parameters or args, this becomes true and the outermost pair of parentheses are removed from type restrictions that are
ProcNotationnodes, sofoo(x : (T, U -> V), W)becomesfoo(x : T, U -> V, W). - #in_parenthesis(need_parens, is_multiline = false, &)
- #in_parenthesis(need_parens, node, is_multiline = false)
- #indent_string
- #inside_macro(&)
- #needs_suffix?(node : NumberLiteral)
- #newline
- #outside_macro(&)
-
#to_s(io : IO) : Nil
Appends a short String representation of this object which includes its class name and its object address.
-
#to_s : String
Returns a nicely readable and concise string representation of this object, typically intended for users.
- #to_s_binary(node, op)
- #visit(node : Nop)
- #visit(node : BoolLiteral)
- #visit(node : NumberLiteral)
- #visit(node : CharLiteral)
- #visit(node : SymbolLiteral)
- #visit(node : StringLiteral)
- #visit(node : StringInterpolation)
- #visit(node : ArrayLiteral)
- #visit(node : HashLiteral)
- #visit(node : NamedTupleLiteral)
- #visit(node : NilLiteral)
- #visit(node : Expressions)
- #visit(node : If)
- #visit(node : Unless)
- #visit(node : ClassDef)
- #visit(node : ModuleDef)
- #visit(node : AnnotationDef)
- #visit(node : Call)
- #visit(node : NamedArgument)
- #visit(node : Assign)
- #visit(node : OpAssign)
- #visit(node : MultiAssign)
- #visit(node : While)
- #visit(node : Until)
- #visit(node : Out)
- #visit(node : Var)
- #visit(node : ProcLiteral)
- #visit(node : ProcPointer)
- #visit(node : External)
- #visit(node : Def)
- #visit(node : Macro)
- #visit(node : MacroExpression)
- #visit(node : MacroIf)
- #visit(node : MacroFor)
- #visit(node : MacroVar)
- #visit(node : MacroLiteral)
- #visit(node : MacroVerbatim)
- #visit(node : ExternalVar)
- #visit(node : Arg)
- #visit(node : ProcNotation)
- #visit(node : Self)
- #visit(node : Path)
- #visit(node : Generic)
- #visit(node : Underscore)
- #visit(node : Splat)
- #visit(node : DoubleSplat)
- #visit(node : Union)
- #visit(node : Metaclass)
- #visit(node : InstanceVar)
- #visit(node : ReadInstanceVar)
- #visit(node : ClassVar)
- #visit(node : Yield)
- #visit(node : Return)
- #visit(node : Break)
- #visit(node : Next)
- #visit(node : RegexLiteral)
- #visit(node : TupleLiteral)
- #visit(node : TypeDeclaration)
- #visit(node : UninitializedVar)
- #visit(node : Block)
- #visit(node : Include)
- #visit(node : Extend)
- #visit(node : And)
- #visit(node : Or)
- #visit(node : Not)
- #visit(node : VisibilityModifier)
- #visit(node : Global)
- #visit(node : LibDef)
- #visit(node : FunDef)
- #visit(node : TypeDef)
- #visit(node : CStructOrUnionDef)
- #visit(node : EnumDef)
- #visit(node : RangeLiteral)
- #visit(node : PointerOf)
- #visit(node : SizeOf)
- #visit(node : InstanceSizeOf)
- #visit(node : AlignOf)
- #visit(node : InstanceAlignOf)
- #visit(node : OffsetOf)
- #visit(node : IsA)
- #visit(node : Cast)
- #visit(node : NilableCast)
- #visit(node : RespondsTo)
- #visit(node : Require)
- #visit(node : Case)
- #visit(node : When)
- #visit(node : Select)
- #visit(node : ImplicitObj)
- #visit(node : ExceptionHandler)
- #visit(node : Rescue)
- #visit(node : Alias)
- #visit(node : TypeOf)
- #visit(node : Annotation)
- #visit(node : MagicConstant)
- #visit(node : Asm)
- #visit(node : AsmOperand)
- #visit(node : Primitive)
- #visit(node : MetaVar)
- #visit(node : MetaMacroVar)
- #visit(node : TypeFilteredNode)
- #visit(node : TypeNode)
- #visit(node : AssignWithRestriction)
- #visit(node : YieldBlockBinder)
- #visit(node : FileNode)
- #visit(node : MacroId)
- #visit(node : Unreachable)
- #visit_any(node)
- #visit_backtick(exp)
- #visit_call(node, ignore_obj = false)
- #visit_cast(node, keyword)
- #visit_control(node, keyword)
- #visit_interpolation(node, &)
- #visit_named_arg_name(name)
- #visit_symbol_literal_value(value : String)
- #visit_unpack(node)
- #visit_while_or_until(node, name)
- #with_indent(&)
Instance methods inherited from class Crystal::Visitor
accept(node)
accept,
end_visit(node)
end_visit,
end_visit_any(node)
end_visit_any,
visit_any(node)
visit_any
Instance methods inherited from class Reference
==(other : self)==(other : JSON::Any)
==(other : YAML::Any)
==(other) ==, dup dup, hash(hasher) hash, initialize initialize, inspect(io : IO) : Nil inspect, object_id : UInt64 object_id, pretty_print(pp) : Nil pretty_print, same?(other : Reference) : Bool
same?(other : Nil) same?, to_s(io : IO) : Nil to_s
Constructor methods inherited from class Reference
new
new,
unsafe_construct(address : Pointer, *args, **opts) : self
unsafe_construct
Class methods inherited from class Reference
pre_initialize(address : Pointer)
pre_initialize
Instance methods inherited from class Object
! : Bool
!,
!=(other)
!=,
!~(other)
!~,
==(other)
==,
===(other : JSON::Any)===(other : YAML::Any)
===(other) ===, =~(other) =~, as(type : Class) as, as?(type : Class) as?, class class, dup dup, hash(hasher)
hash hash, in?(collection : Object) : Bool
in?(*values : Object) : Bool in?, inspect(io : IO) : Nil
inspect : String inspect, is_a?(type : Class) : Bool is_a?, itself itself, nil? : Bool nil?, not_nil!(message)
not_nil! not_nil!, pretty_inspect(width = 79, newline = "\n", indent = 0) : String pretty_inspect, pretty_print(pp : PrettyPrint) : Nil pretty_print, responds_to?(name : Symbol) : Bool responds_to?, tap(&) tap, to_json(io : IO) : Nil
to_json : String to_json, to_pretty_json(indent : String = " ") : String
to_pretty_json(io : IO, indent : String = " ") : Nil to_pretty_json, to_s(io : IO) : Nil
to_s : String to_s, to_yaml(io : IO) : Nil
to_yaml : String to_yaml, try(&) try, unsafe_as(type : T.class) forall T unsafe_as
Class methods inherited from class Object
from_json(string_or_io : String | IO, root : String)from_json(string_or_io : String | IO) from_json, from_yaml(string_or_io : String | IO) from_yaml
Macros inherited from class Object
class_getter(*names, &block)
class_getter,
class_getter!(*names)
class_getter!,
class_getter?(*names, &block)
class_getter?,
class_property(*names, &block)
class_property,
class_property!(*names)
class_property!,
class_property?(*names, &block)
class_property?,
class_setter(*names)
class_setter,
def_clone
def_clone,
def_equals(*fields)
def_equals,
def_equals_and_hash(*fields)
def_equals_and_hash,
def_hash(*fields)
def_hash,
delegate(*methods, to object)
delegate,
forward_missing_to(delegate)
forward_missing_to,
getter(*names, &block)
getter,
getter!(*names)
getter!,
getter?(*names, &block)
getter?,
property(*names, &block)
property,
property!(*names)
property!,
property?(*names, &block)
property?,
setter(*names)
setter
Constructor Detail
Instance Method Detail
Inside a comma-separated list of parameters or args, this becomes true and
the outermost pair of parentheses are removed from type restrictions that
are ProcNotation nodes, so foo(x : (T, U -> V), W) becomes
foo(x : T, U -> V, W). This is used by defs, lib funs, and calls to deal
with the parsing rules for ->. See #11966 and #14216 for more details.
Appends a short String representation of this object which includes its class name and its object address.
class Person
def initialize(@name : String, @age : Int32)
end
end
Person.new("John", 32).to_s # => #<Person:0x10a199f20>