Skip to content

Commit

Permalink
actually use bootclasspath in the generator
Browse files Browse the repository at this point in the history
  • Loading branch information
baroquebobcat committed May 6, 2012
1 parent 16647d4 commit 65520ec
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
5 changes: 5 additions & 0 deletions lib/mirah/generator.rb
Expand Up @@ -26,7 +26,12 @@ class Generator
def initialize(state, compiler_class, logging, verbose)
@state = state
@scoper = SimpleScoper.new {|scoper, node| Mirah::AST::StaticScope.new(node, scoper)}

# TODO untie this from the jvm backend (nh)
type_system = Mirah::JVM::Types::TypeFactory.new
type_system.classpath = state.classpath
type_system.bootclasspath = state.bootclasspath

@typer = Mirah::Typer::Typer.new(type_system, @scoper, self)
@parser = Mirah::Parser.new(state, @typer, logging)
@compiler = Mirah::Compiler::ASTCompiler.new(compiler_class, logging)
Expand Down
8 changes: 1 addition & 7 deletions lib/mirah/util/compilation_state.rb
Expand Up @@ -33,13 +33,7 @@ def initialize
attr_accessor :command
attr_accessor :loggers

def classpath=(classpath)
Mirah::AST.type_factory.classpath = classpath
end

def bootclasspath=(classpath)
Mirah::AST.type_factory.bootclasspath = classpath
end
attr_accessor :classpath, :bootclasspath

def set_jvm_version(ver_str)
case ver_str
Expand Down
26 changes: 26 additions & 0 deletions test/core/generator_test.rb
@@ -0,0 +1,26 @@
# Copyright (c) 2010 The Mirah project authors. All Rights Reserved.
# All contributing project authors may be found in the NOTICE file.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require 'test_helper'


class GeneratorTest < Test::Unit::TestCase
def test_generator_sets_classpath_bootclasspath_on_type_system

state = Mirah::Util::CompilationState.new
state.bootclasspath = "a:b"
generator = Mirah::Generator.new(state, Mirah::JVM::Compiler::JVMBytecode, false, false)
assert state.bootclasspath == generator.typer.type_system.bootclasspath
end
end

0 comments on commit 65520ec

Please sign in to comment.