Sha256: 1c63e1badef83411767900302be54b6b9d0e59543c8e693b668e189a2bd3bf15
Contents?: true
Size: 1.99 KB
Versions: 23
Compression:
Stored size: 1.99 KB
Contents
# Author:: Eric Crane (mailto:eric.crane@mac.com) # Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved. # # A String. # module GlooLang module Objs class Alias < GlooLang::Core::Obj KEYWORD = 'alias'.freeze KEYWORD_SHORT = 'ln'.freeze ALIAS_REFERENCE = '*'.freeze # # The name of the object type. # def self.typename return KEYWORD end # # The short name of the object type. # def self.short_typename return KEYWORD_SHORT end # # Set the value with any necessary type conversions. # def set_value( new_value ) self.value = new_value.to_s end # --------------------------------------------------------------------- # Messages # --------------------------------------------------------------------- # # Get a list of message names that this object receives. # def self.messages return super + %w[resolve] end # # Check to see if the referenced object exists. # def msg_resolve pn = GlooLang::Core::Pn.new( @engine, self.value ) s = pn.exists? @engine.heap.it.set_to s return s end # --------------------------------------------------------------------- # Resolve # --------------------------------------------------------------------- # # Is the object an alias If so, then resolve it. # The ref_name is the name used to refer to the object. # If it ends with the * then we won't resolve the alias since # we are trying to refer to the alias itself. # def self.resolve_alias( engine, obj, ref_name = nil ) return nil unless obj return obj unless obj.type_display == GlooLang::Objs::Alias.typename return obj if ref_name&.end_with?( ALIAS_REFERENCE ) ln = GlooLang::Core::Pn.new( engine, obj.value ) return ln.resolve end end end end
Version data entries
23 entries across 23 versions & 1 rubygems