945470cdc38e3c6a1d3b48c5c4c196b0012651c6 — Tim Morgan 1 year, 7 months ago e3ea9b9
Use dot to separate library name parts
2 files changed, 23 insertions(+), 22 deletions(-)

M compiler/libraries.rb
M spec/compiler_spec.rb
M compiler/libraries.rb => compiler/libraries.rb +4 -3
@@ 77,7 77,7 @@ end
  
      def import_set_all(set, relative_to, _options)
-       name = set.join('/')
+       name = set.join('.')
        isolated_options = { locals: {}, syntax: {} }
        include = include_library_if_needed(name, relative_to, isolated_options)
        [


@@ 95,11 95,12 @@       def include_library_if_needed(name, relative_to, options)
        return [] if @libs.key?(name)
-       do_include(["\"#{name}.scm\""], relative_to, options)
+       filename = name.tr('.', '/')
+       do_include(["\"#{filename}.scm\""], relative_to, options)
      end
  
      def do_define_library((name, *declarations), options)
-       name_as_string = name.join('/')
+       name_as_string = name.join('.')
        exports = @libs[name_as_string] = {
          syntax: {},
          bindings: {}

M spec/compiler_spec.rb => spec/compiler_spec.rb +19 -19
@@ 1140,7 1140,7 @@           it 'includes the code' do
            expected = [
-             'VM::IMPORT_LIB', 'scheme/base', 'write-string', 'write-string',
+             'VM::IMPORT_LIB', 'scheme.base', 'write-string', 'write-string',
              'VM::PUSH_STR', 'hello from include-test',
              'VM::PUSH_NUM', 1,
              'VM::SET_ARGS',


@@ 1293,25 1293,25 @@ end
  
        it 'records export names for the libraries' do
-         expect(subject.libs['my-lib/1'][:syntax]['macro1']).to include(
+         expect(subject.libs['my-lib.1'][:syntax]['macro1']).to include(
            locals: Array,
            transformer: [
              'syntax-rules', [],
              [['macro1'], '1']
            ]
          )
-         expect(subject.libs['my-lib/1'][:bindings]).to eq(
+         expect(subject.libs['my-lib.1'][:bindings]).to eq(
            'foo'    => 'foo',
            'macro1' => 'macro1'
          )
-         expect(subject.libs['my-lib/2'][:syntax]['macro2']).to include(
+         expect(subject.libs['my-lib.2'][:syntax]['macro2']).to include(
            locals: Array,
            transformer: [
              'syntax-rules', [],
              [['macro2'], 'macro1']
            ]
          )
-         expect(subject.libs['my-lib/2'][:bindings]).to eq(
+         expect(subject.libs['my-lib.2'][:bindings]).to eq(
            'foo'    => 'foo',
            'baz'    => 'baz',
            'bar'    => 'foo',


@@ 1321,28 1321,28 @@         it 'compiles into vm instructions' do
          expected = [
-           'VM::SET_LIB', 'my-lib/1',
+           'VM::SET_LIB', 'my-lib.1',
            'VM::PUSH_STR', 'foo',
            'VM::DEFINE_VAR', 'foo',
            'VM::ENDL',
  
-           'VM::SET_LIB', 'my-lib/2',
-           'VM::IMPORT_LIB', 'my-lib/1', 'foo', 'foo',
+           'VM::SET_LIB', 'my-lib.2',
+           'VM::IMPORT_LIB', 'my-lib.1', 'foo', 'foo',
            'VM::PUSH_STR', 'baz',
            'VM::DEFINE_VAR', 'baz',
            'VM::ENDL',
  
-           'VM::IMPORT_LIB', 'my-lib/1', 'foo', 'foo',
-           'VM::IMPORT_LIB', 'my-lib/2', 'foo', 'foo',
-           'VM::IMPORT_LIB', 'my-lib/2', 'baz', 'baz',
-           'VM::IMPORT_LIB', 'my-lib/2', 'foo', 'bar',
-           'VM::IMPORT_LIB', 'my-lib/1', 'foo', 'foo',
-           'VM::IMPORT_LIB', 'my-lib/1', 'foo', 'my-foo',
-           'VM::IMPORT_LIB', 'my-lib/1', 'foo', 'baz',
-           'VM::IMPORT_LIB', 'my-lib/2', 'foo', 'foo',
-           'VM::IMPORT_LIB', 'my-lib/2', 'baz', 'baz',
-           'VM::IMPORT_LIB', 'my-lib/2', 'foo', 'my-baz',
-           'VM::IMPORT_LIB', 'my-lib/2', 'baz', 'my-baz',
+           'VM::IMPORT_LIB', 'my-lib.1', 'foo', 'foo',
+           'VM::IMPORT_LIB', 'my-lib.2', 'foo', 'foo',
+           'VM::IMPORT_LIB', 'my-lib.2', 'baz', 'baz',
+           'VM::IMPORT_LIB', 'my-lib.2', 'foo', 'bar',
+           'VM::IMPORT_LIB', 'my-lib.1', 'foo', 'foo',
+           'VM::IMPORT_LIB', 'my-lib.1', 'foo', 'my-foo',
+           'VM::IMPORT_LIB', 'my-lib.1', 'foo', 'baz',
+           'VM::IMPORT_LIB', 'my-lib.2', 'foo', 'foo',
+           'VM::IMPORT_LIB', 'my-lib.2', 'baz', 'baz',
+           'VM::IMPORT_LIB', 'my-lib.2', 'foo', 'my-baz',
+           'VM::IMPORT_LIB', 'my-lib.2', 'baz', 'my-baz',
  
            'VM::HALT'
          ]