Module: Carbon::Compiler::Visitor::Generation::Asserts
- Included in:
- Carbon::Compiler::Visitor::Generation
- Defined in:
- lib/carbon/compiler/visitor/generation/asserts.rb
Instance Method Summary collapse
- #assert_nolocal(name, context, location: Location.default) ⇒ Object
- #assert_type_boolean(found, location: Location.default) ⇒ Object
- #assert_type_equal(found, expected, location: Location.default) ⇒ Object
- #assert_type_void(found, location: Location.default) ⇒ Object
Instance Method Details
#assert_nolocal(name, context, location: Location.default) ⇒ Object
22 23 24 25 |
# File 'lib/carbon/compiler/visitor/generation/asserts.rb', line 22 def assert_nolocal(name, context, location: Location.default) return unless context.key?(name) @file.emit("Statement/Let/Redefine", location, [name]) end |
#assert_type_boolean(found, location: Location.default) ⇒ Object
18 19 20 |
# File 'lib/carbon/compiler/visitor/generation/asserts.rb', line 18 def assert_type_boolean(found, location: Location.default) assert_type_equal(found, Carbon::Boolean, location: location) end |
#assert_type_equal(found, expected, location: Location.default) ⇒ Object
9 10 11 12 |
# File 'lib/carbon/compiler/visitor/generation/asserts.rb', line 9 def assert_type_equal(found, expected, location: Location.default) return unless found != expected @file.emit("Expression/Type/Mismatch", location, [found, expected]) end |
#assert_type_void(found, location: Location.default) ⇒ Object
14 15 16 |
# File 'lib/carbon/compiler/visitor/generation/asserts.rb', line 14 def assert_type_void(found, location: Location.default) assert_type_equal(found, Carbon::Void, location: location) end |