Module: RplLang::Words::Mode

Includes:
Types
Included in:
Rpl
Defined in:
lib/rpl/words/mode.rb

Instance Method Summary collapse

Methods included from Types

new_object

Instance Method Details

#populate_dictionaryObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/rpl/words/mode.rb', line 8

def populate_dictionary
  super

  category = 'Mode'

  @dictionary.add_word!( ['prec'],
                         category,
                         '( a -- ) set precision to a',
                         proc do
                           args = stack_extract( [[RplNumeric]] )

                           RplNumeric.precision = args[0].value
                         end )
  @dictionary.add_word!( ['default'],
                         category,
                         '( -- ) set default precision',
                         proc do
                           RplNumeric.default_precision
                         end )
  @dictionary.add_word!( ['type'],
                         category,
                         '( a -- s ) type of a as a string',
                         proc do
                           args = stack_extract( [:any] )

                           @stack << Types.new_object( RplString, "\"#{args[0].class.to_s[10..]}\"" )
                         end )

  # @dictionary.add_word!( ['std'],
  #                  proc { __todo } ) # standard floating numbers representation. ex: std
  # @dictionary.add_word!( ['fix'],
  #                  proc { __todo } ) # fixed point representation. ex: 6 fix
  # @dictionary.add_word!( ['sci'],
  #                  proc { __todo } ) # scientific floating point representation. ex: 20 sci
  # @dictionary.add_word!( ['round'],
  #                  proc { __todo } ) # set float rounding mode. ex: ["nearest", "toward zero", "toward +inf", "toward -inf", "away from zero"] round
end