Class: MessagePack::IDL::Evaluator::Template

Inherits:
Object
  • Object
show all
Defined in:
lib/msgpack/idl/evaluator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(generic_type, nullable = false) ⇒ Template

Returns a new instance of Template.



26
27
28
29
30
31
# File 'lib/msgpack/idl/evaluator.rb', line 26

def initialize(generic_type, nullable=false)
	@name = generic_type.name
	@params = generic_type.type_params
	@generic_type = generic_type
	@nullable = nullable
end

Instance Attribute Details

#generic_typeObject (readonly)

Returns the value of attribute generic_type.



32
33
34
# File 'lib/msgpack/idl/evaluator.rb', line 32

def generic_type
  @generic_type
end

#nullableObject (readonly)

Returns the value of attribute nullable.



32
33
34
# File 'lib/msgpack/idl/evaluator.rb', line 32

def nullable
  @nullable
end

Instance Method Details

#match_all(name, array) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/msgpack/idl/evaluator.rb', line 38

def match_all(name, array)
	if @name != name
		return nil
	end
	if array.size != @params.size
		return nil
	end
	resolved_params = @params.zip(array).map {|a,b|
		if b.class == IR::TypeParameterSymbol
			return nil
		end
		if a.class != IR::TypeParameterSymbol && a != b
			return nil
		end
		b
	}
	resolved_params
end

#nullable?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/msgpack/idl/evaluator.rb', line 34

def nullable?
	@nullable
end