module XfOOrth
XfOOrth - the module name space of the fOOrth language system.
-
fOOrth.rb - The root file that gathers up all the system's parts.
-
compiler.rb - The compiler portion of the fOOrth language system.
-
compiler/cast.rb - Support for casting methods to alternate routings.
-
compiler/context.rb - The compile progress context manager of the fOOrth language system.
-
compiler/context/locals.rb - Support local methods in context.
-
compiler/context/map_name.rb - The fOOrth language mapping of names in a context.
-
compiler/context/tags.rb - Support tags in context.
-
compiler/modes.rb - The control of the various compiler modes.
-
compiler/modes/compiled.rb - The compiled system mode.
-
compiler/modes/deferred.rb - The control of the deferred compiler mode.
-
compiler/modes/delayed.rb - The delayed compile system mode.
-
compiler/modes/nested.rb - The control of the nested compiler modes.
-
compiler/modes/suspend.rb - The ability to suspend buffered mode.
-
compiler/parser.rb - Parse source code from a code source.
-
compiler/parser/get_string.rb - Extract string literals from code source.
-
compiler/parser/normal.rb - Parse source code when not in quote mode.
-
compiler/parser/skip.rb - Skip over stuff in the source code.
-
compiler/parser/special.rb - Parse source code in special quoted mode.
-
compiler/process.rb - Process source code from a code source.
-
compiler/process/generate.rb - Generate the Ruby object code.
-
compiler/process/get_token.rb - Get a complete language element.
-
compiler/process/procedure.rb - Get an embedded procedure literal.
-
compiler/process/string.rb - Get an embedded string literal.
-
compiler/source.rb - The abstract source class shared by many code sources.
-
compiler/console.rb - The fOOrth console support file.
-
compiler/file_source.rb - Uses a file as a source of fOOrth source code.
-
compiler/read_point.rb - A module used to read source code text from a buffer.
-
compiler/string_source.rb - Uses a string as a source of fOOrth source code.
-
compiler/token.rb - A little bit of object code compiled from the source.
-
compiler/word_specs.rb - The classes that support the specification of the compile and run-time behaviors of fOOrth definitions of all sorts.
-
core.rb - The fOOrth language OO core.
-
core/virtual_machine.rb - The core connection to the virtual machine.
-
debug.rb - Internal debug support.
-
debug/dbg_puts.rb - Display diagnostic/debug information if enabled.
-
debug/display_abort.rb - Display diagnostic information on an error.
-
initialize.rb - The initialize method for the virtual machine
-
interpreter.rb - The run time interpreter portion of the fOOrth language system.
-
interpreter/add_to_hash.rb - The fOOrth language hash literal support module.
-
interpreter/data_stack.rb - The fOOrth language system data stack.
-
interpreter/do_loop.rb - The fOOrth language do loop support module.
-
interpreter/squash.rb - The fOOrth language array literal support module.
-
library.rb - The word library portion of the fOOrth language system.
-
library/alias_library.rb - Support for method aliasing in fOOrth.
-
library/array_library.rb -
Array
support for the fOOrth library.
-
library/bundle_library.rb - The fOOrth Bundle class library.
-
library/class_library.rb - The fOOrth
Class
class library.
-
library/clone_library.rb - The fOOrth data cloning library.
-
library/command_library.rb - The utility command fOOrth library.
-
library/compile_library.rb - The compile support fOOrth library.
-
library/complex_library.rb -
Numeric
support for the fOOrth library.
-
library/ctrl_struct_library.rb - The control structures fOOrth library.
-
library/data_ref_library.rb - The data references (variables) fOOrth library.
-
library/duration/arithmetic.rb - Arithmetic operator support for durations.
-
library/duration/formatter.rb -
Duration
formatting support library.
-
library/duration/intervals.rb -
Duration
intervals support library.
-
library/duration/make.rb - Support for duration constructor.
-
library/duration_library.rb - The duration support fOOrth library.
-
library/fiber_library.rb - The fOOrth Fiber class library.
-
library/float_library.rb -
Float
specific support for the fOOrth library.
-
library/formatting/bullets.rb - Print out bullet points.
-
library/formatting/bullets.rb - Print out data in neat columns.
-
library/hash_library.rb -
Hash
support for the fOOrth library.
-
library/in_stream_library.rb - The fOOrth InStream class library.
-
library/numeric_library.rb -
Numeric
support for the fOOrth library.
-
library/introspection/context.rb -
Context
support for introspection.
-
library/introspection/symbol_map.rb - Mapping support for introspection.
-
library/introspection/vm.rb - Virtual Machine support for introspection.
-
library/introspection/word_specs.rb - WordSpec support for introspection.
-
library/introspection_library.rb - The fOOrth introspection library.
-
library/mutex_library.rb - The mutex support fOOrth library.
-
library/numeric_library.rb -
Numeric
support for the fOOrth library.
-
library/object_library.rb - The fOOrth
Object
class library.
-
library/other_value_types_library.rb - Support for true, false, and nil in the fOOrth library.
-
library/in_stream_library.rb - The fOOrth InStream class library.
-
library/procedure_library.rb -
Proc
support for the fOOrth library.
-
library/queue_library.rb - The Queue support fOOrth library.
-
library/rational_library.rb -
Numeric
support for the fOOrth library.
-
library/stack_library.rb - The Stack support fOOrth library.
-
library/stdio_library.rb - The standard I/O fOOrth library.
-
library/string_library.rb -
String
support for the fOOrth library.
-
library/stubs.rb - The standard fOOrth library.
-
library/stubs_library.rb - Support for method stubs in fOOrth.
-
library/sync_bundle_library.rb - The fOOrth SyncBundle class library.
-
library/thread_library.rb - The thread support fOOrth library.
-
library/time_library.rb - The time support fOOrth library.
-
library/class_library.rb - The fOOrth
Class
class library.
-
main.rb - The entry point for a stand-alone foorth session.
-
exceptions.rb -
Exception
classes for the fOOrth language interpreter.
-
symbol_map.rb - The name mangler for the foorth Language System.
-
version.rb - The version string for fOOrth.
Constants
- DCC_VAL
The procedure used for dot colon colon instance vals
- DCC_VAR
The procedure used for dot colon colon instance vars
- DC_VAL
The procedure used for dot colon instance vals
- DC_VAR
The procedure used for dot colon instance vars
- DegreesPerRadian
The number of degrees in one radian.
- Local_Val_Action
The lambda used to define local values. fOOrth language definition is:
[n] val: lv [], lv = n
- Local_Var_Action
The lambda used to define local variables. fOOrth language definition is:
[n] var: lv [], lv = [n]
- TimeFormat
The user facing format used for date/time display.
- VERSION
The version string for fOOrth.
Public Class Methods
Set up the common local defns.
Parameters:
-
vm - The current virtual machine instance.
-
ctrl - A list of valid start controls.
Endemic Code Smells
-
:reek:TooManyStatements
# File lib/fOOrth/library/compile_library.rb, line 193 def self.add_common_compiler_locals(vm, ctrl) context = vm.context #Support for local data. context.create_local_method('var:', LocalSpec, [:immediate], &Local_Var_Action) context.create_local_method('val:', LocalSpec, [:immediate], &Local_Val_Action) #Support for super methods. context.create_local_method('super', LocalSpec, [:immediate], &lambda {|vm| vm << 'super(vm); ' }) #The standard end-compile adapter word: ';' semi-colon. context.create_local_method(';', LocalSpec, [:immediate], &lambda {|vm| vm.clear_cast vm.end_compile_mode([ctrl]) }) end
Add locals specific to a dot colon colon methods.
# File lib/fOOrth/library/compile_library.rb, line 180 def self.add_dot_colon_colon_locals(context) context.create_local_method('var@:', LocalSpec, [:immediate], &DCC_VAR) context.create_local_method('val@:', LocalSpec, [:immediate], &DCC_VAL) end
Add locals specific to a dot colon methods.
# File lib/fOOrth/library/compile_library.rb, line 122 def self.add_dot_colon_locals(context) context.create_local_method('var@:', LocalSpec, [:immediate], &DC_VAR) context.create_local_method('val@:', LocalSpec, [:immediate], &DC_VAL) end
Display the start-up messages for the interactive session.
# File lib/fOOrth/main.rb, line 57 def self.announcements puts "Welcome to fOOrth: fO(bject)O(riented)rth." puts "\nfOOrth Reference Implementation Version: #{XfOOrth.version}" puts "\nSession began on: #{Time.now.strftime(TimeFormat)}" end
The starting point for an interactive fOOrth programming session. This method only returns when the session is closed.
Returns:
-
The virtual machine used to run the session.
To launch a fOOrth interactive session, simply use:
XfOOrth::main
Endemic Code Smells
-
:reek:TooManyStatements
# File lib/fOOrth/main.rb, line 19 def self.main vm = VirtualMachine.vm('Console') running = false loop do begin running ||= start_up(vm) vm.process_console rescue Interrupt, ForceExit, SilentExit, MiniReadlineEOI => err puts "\n#{err.foorth_message}" break rescue StandardError => err vm.display_abort(err) rescue Exception => err puts "\n#{err.class.to_s.gsub(/.*::/, '')} detected: #{err}" puts err.backtrace break end break unless running end vm end
Determine the type of method being created. This only applies to non-vm methods as vm methods are all of type VmSpec
.
Parameters *name - The name of the method to be created. <Returns>
-
The class of the spec to be used for this method.
# File lib/fOOrth/library/compile_library.rb, line 217 def self.name_to_type(name, vm) normal_spec = case name[0] when '.' TosSpec when '~' SelfSpec when /[0-9A-Z$@#]/ error "F10: Invalid name for a method: #{name}" else NosSpec end vm.get_cast || normal_spec end
Process the command line arguments. A string is returned containing fOOrth commands to be executed after the dictionary is loaded.
Returns
-
A string of fOOrth commands to be executed after the dictionary is loaded.
Endemic Code Smells
-
:reek:TooManyStatements
# File lib/fOOrth/main.rb, line 69 def self.process_command_line_options begin defer, found = "", false opts = GetoptLong.new( [ "--help", "-h", "-?", GetoptLong::NO_ARGUMENT ], [ "--load", "-l", GetoptLong::REQUIRED_ARGUMENT ], [ "--debug", "-d", GetoptLong::NO_ARGUMENT ], [ "--show", "-s", GetoptLong::NO_ARGUMENT ], [ "--quit", "-q", GetoptLong::NO_ARGUMENT ], [ "--words", "-w", GetoptLong::NO_ARGUMENT ]) # Translate the parsed options into fOOrth. opts.each do |opt, arg| unless found puts found = true end case opt when "--debug" defer << ")debug " when "--show" defer << ")show " when "--load" defer << ")load#{arg.inspect}" when "--quit" defer << ")quit " when "--words" defer << ")words " else fail SilentExit end end puts if found rescue Exception puts puts "fOOrth available options:" puts puts "--help -h -? Display this message and exit." puts "--load -l <filename> Load the specified fOOrth source file." puts "--debug -d Default to debug ON." puts "--quit -q Quit after processing the command line." puts "--show -s Default to show results ON." puts "--words -w List the current vocabulary." puts raise SilentExit end defer end
Perform one time start-up actions.
# File lib/fOOrth/main.rb, line 48 def self.start_up(vm) announcements vm.debug = false vm.show_stack = false vm.process_string(process_command_line_options) true end
Check for the case where a string method is created on another class.
Parameters *type - The class of the method to be created. *target - The object that is to receive this method. *name - The name of the method to be created.
Endemic Code Smells
-
:reek:ControlParameter – false positive
# File lib/fOOrth/library/compile_library.rb, line 260 def self.validate_string_method(type, target, name) if type == TosSpec && name[-1] == '"' && target != String error "F13: Creating a string method #{name} on a #{target.foorth_name}" end end
Compare the new method's spec against the specs of other methods of the same name. If no specs exist, create one on Object
if the new spec is not a virtual machine spec.
Parameters *vm - The current virtual machine. *type - The class of the method to be created. *name - The name of the method to be created.
# File lib/fOOrth/library/compile_library.rb, line 242 def self.validate_type(vm, type, name) if (spec = vm.context.map_without_defaults(name)) if spec.class != type error "F90: Spec type mismatch #{spec.foorth_name} vs #{type.foorth_name}" end else Object.create_shared_method(name, type, [:stub]) unless type == VmSpec end end
The version of this module.
Returns
-
A version string; <major>.<minor>.<step>
# File lib/fOOrth.rb, line 36 def self.version VERSION end