rpl.rb/lib/core.rb

70 lines
1.4 KiB
Ruby
Raw Normal View History

2021-12-07 16:09:17 +01:00
# frozen_string_literal: true
require 'bigdecimal/math'
require_relative './core/branch'
require_relative './core/general'
require_relative './core/mode'
require_relative './core/operations'
require_relative './core/program'
require_relative './core/stack'
require_relative './core/store'
require_relative './core/string'
require_relative './core/test'
require_relative './core/time-date'
require_relative './core/trig'
require_relative './core/logs'
2021-12-15 13:33:52 +01:00
require_relative './core/filesystem'
require_relative './core/list'
module Rpl
2021-12-07 15:50:58 +01:00
module Lang
module Core
module_function
2021-12-07 15:50:58 +01:00
include BigMath
2021-12-07 15:50:58 +01:00
def precision
@precision or 12
end
2021-12-07 15:50:58 +01:00
def precision=( value )
@precision = value
end
2021-12-07 15:50:58 +01:00
def stack_extract( stack, needs )
2021-12-08 13:45:29 +01:00
raise ArgumentError, 'Not enough elements' if stack.size < needs.size
2021-12-07 15:50:58 +01:00
args = []
needs.each do |need|
elt = stack.pop
2021-12-15 13:33:40 +01:00
raise ArgumentError, "Type Error, needed #{need} got #{elt[:type]}" unless need == :any || need.include?( elt[:type] )
2021-12-07 15:50:58 +01:00
args << elt
end
2021-12-07 15:50:58 +01:00
[stack, args]
end
def infer_resulting_base( numerics )
10 if numerics.length.zero?
numerics.last[:base]
end
2021-12-16 15:22:14 +01:00
def __todo( stack, dictionary )
2021-12-07 15:50:58 +01:00
puts '__NOT IMPLEMENTED__'
2021-12-16 15:22:14 +01:00
[stack, dictionary]
end
def __pp_stack( stack, dictionary )
pp stack
[stack, dictionary]
2021-12-07 15:50:58 +01:00
end
end
end
end