lib/rubinius/compiler/compiled_file.rb
##
# For object +val+, return a String represetation.
For object +val+, return a String represetation.
For object + val + return a String represetation .
def marshal(val)
        case val
        when TrueClass
          "t\n"
        when FalseClass
          "f\n"
        when NilClass
          "n\n"
        when Fixnum, Bignum
          b "I\n#{val.to_s(16)}\n"
        when String
          name = val.encoding.name
          enc_name = "E\n#{name.bytesize}\n#{name}\n"
          b "s\n#{enc_name}#{val.bytesize}\n#{val}\n"
        when Symbol
          s = val.to_s
          name = s.encoding.name
          enc_name = "E\n#{name.bytesize}\n#{name}\n"
          b "x\n#{enc_name}#{s.bytesize}\n#{s}\n"
        when Rubinius::Tuple
          str = "p\n#{val.size}\n"
          val.each do |ele|
            str.append marshal(ele)
          end
          str
        when Float
          str = "d\n"
          if val.infinite?
            str.append "-" if val < 0.0
            str.append "Infinity"
          elsif val.nan?
            str.append "NaN"
          else
            str.append " %+.54f %5d" % Math.frexp(val)
          end
          str.append "\n"
        when Rational
          str = "R\n"
          str.append marshal(val.numerator)
          str.append marshal(val.denominator)
          str
        when Complex
          str = "C\n"
          str.append marshal(val.real)
          str.append marshal(val.imaginary)
          str
        when Rubinius::InstructionSequence
          str = "i\n#{val.size}\n"
          val.opcodes.each do |op|
            unless op.kind_of?(Fixnum)
              raise TypeError, "InstructionSequence contains non Fixnum: #{op.inspect}"
            end
            str.append "#{op}\n"
          end
          str
        when Rubinius::CompiledCode
          str = "M\n1\n"
          str.append marshal(val.metadata)
          str.append marshal(val.primitive)
          str.append marshal(val.name)
          str.append marshal(val.iseq)
          str.append marshal(val.stack_size)
          str.append marshal(val.local_count)
          str.append marshal(val.required_args)
          str.append marshal(val.post_args)
          str.append marshal(val.total_args)
          str.append marshal(val.splat)
          str.append marshal(val.keywords)
          str.append marshal(val.arity)
          str.append marshal(val.literals)
          str.append marshal(val.lines)
          str.append marshal(val.file)
          str.append marshal(val.local_names)
          str
        else
          if val.respond_to? :rbx_marshal_constant
            name = StringValue(val.rbx_marshal_constant)
            "c\n#{name.size}\n#{name}\n"
          else
            raise ArgumentError, "Unknown type #{val.class}: #{val.inspect}"
          end
        end
      end
def marshal ( val ) case val when TrueClass "t\n" when FalseClass "f\n" when NilClass "n\n" when Fixnum , Bignum b "I\n#{val.to_s(16)}\n" when String name = val . encoding . name enc_name = "E\n#{name.bytesize}\n#{name}\n" b "s\n#{enc_name}#{val.bytesize}\n#{val}\n" when Symbol s = val . to_s name = s . encoding . name enc_name = "E\n#{name.bytesize}\n#{name}\n" b "x\n#{enc_name}#{s.bytesize}\n#{s}\n" when Rubinius :: Tuple str = "p\n#{val.size}\n" val . each do | ele | str . append marshal ( ele ) end str when Float str = "d\n" if val . infinite? str . append "-" if val < 0.0 str . append "Infinity" elsif val . nan? str . append "NaN" else str . append " %+.54f %5d" % Math . frexp ( val ) end str . append "\n" when Rational str = "R\n" str . append marshal ( val . numerator ) str . append marshal ( val . denominator ) str when Complex str = "C\n" str . append marshal ( val . real ) str . append marshal ( val . imaginary ) str when Rubinius :: InstructionSequence str = "i\n#{val.size}\n" val . opcodes . each do | op | unless op . kind_of? ( Fixnum ) raise TypeError , "InstructionSequence contains non Fixnum: #{op.inspect}" end str . append "#{op}\n" end str when Rubinius :: CompiledCode str = "M\n1\n" str . append marshal ( val . metadata ) str . append marshal ( val . primitive ) str . append marshal ( val . name ) str . append marshal ( val . iseq ) str . append marshal ( val . stack_size ) str . append marshal ( val . local_count ) str . append marshal ( val . required_args ) str . append marshal ( val . post_args ) str . append marshal ( val . total_args ) str . append marshal ( val . splat ) str . append marshal ( val . keywords ) str . append marshal ( val . arity ) str . append marshal ( val . literals ) str . append marshal ( val . lines ) str . append marshal ( val . file ) str . append marshal ( val . local_names ) str else if val . respond_to? :rbx_marshal_constant name = StringValue ( val . rbx_marshal_constant ) "c\n#{name.size}\n#{name}\n" else raise ArgumentError , "Unknown type #{val.class}: #{val.inspect}" end end end
For object +val+, return a String represetation.
For object + val + return a String represetation .
val
<not_specific>