Sha256: 83011a9034d902e81142ec3df3e81993d0f908dd226a4b27c223fef2361b8419

Contents?: true

Size: 1.68 KB

Versions: 135

Compression:

Stored size: 1.68 KB

Contents

/**
 * Copyright 2007 Ye Zheng
 * Distributed under the BSD License
 */

package com.xruby.runtime.lang.util;

import java.lang.annotation.Annotation;

import org.objectweb.asm.Type;
import org.objectweb.asm.commons.GeneratorAdapter;
import org.objectweb.asm.commons.Method;

import com.xruby.compiler.codegen.CgUtil;
import com.xruby.compiler.codegen.Types;
import com.xruby.runtime.lang.annotation.RubyLevelModule;

class RubyModuleFactory extends RubyTypeFactory {
	private static final Method RubyModuleBuilderCreateRubyModuleMethod = 
		CgUtil.getMethod("createRubyModule", Types.RUBY_MODULE_TYPE);
	private static final Method RubyAPIDefineModuleMethod = 
		CgUtil.getMethod("defineModule", Types.RUBY_MODULE_TYPE, Type.getType(String.class));
	private static final Type BuilderInterface = Type.getType(RubyModuleBuilder.class);
	
	RubyModuleFactory(Class klass) {
		super(klass);
	}
	
	protected boolean isModule() {
		return true;
	}
	
	protected Class getTypeAnnotationClass() {
		return RubyLevelModule.class;
	}
	
	protected String getBuilderName(Class klass) {
		return CgUtil.getInternalName(klass.getName() + "$ModuleBuilder");
	}

	protected Type getInterface() {
		return BuilderInterface;
	}
	
	protected Method getBuilderMethod() {
		return RubyModuleBuilderCreateRubyModuleMethod;
	}
	
	protected int createRubyType(GeneratorAdapter mg, Annotation annotation) {
		RubyLevelModule moduleAnnotation = (RubyLevelModule)annotation;
		mg.push(moduleAnnotation.name());
		mg.invokeStatic(Types.RUBY_API_TYPE, RubyAPIDefineModuleMethod);
		int rubyTypeIdx = mg.newLocal(Types.RUBY_MODULE_TYPE);
		mg.storeLocal(rubyTypeIdx);
		
		return rubyTypeIdx;
	}
}

Version data entries

135 entries across 135 versions & 2 rubygems

Version Path
rhodes-7.6.0 platform/shared/xruby/src/com/xruby/runtime/lang/util/RubyModuleFactory.java
rhodes-7.5.1 platform/shared/xruby/src/com/xruby/runtime/lang/util/RubyModuleFactory.java
rhodes-7.4.1 platform/shared/xruby/src/com/xruby/runtime/lang/util/RubyModuleFactory.java
rhodes-7.1.17 platform/shared/xruby/src/com/xruby/runtime/lang/util/RubyModuleFactory.java
rhodes-6.2.0 platform/shared/xruby/src/com/xruby/runtime/lang/util/RubyModuleFactory.java
rhodes-6.0.11 platform/shared/xruby/src/com/xruby/runtime/lang/util/RubyModuleFactory.java
rhodes-5.5.18 platform/shared/xruby/src/com/xruby/runtime/lang/util/RubyModuleFactory.java
rhodes-5.5.17 platform/shared/xruby/src/com/xruby/runtime/lang/util/RubyModuleFactory.java
rhodes-5.5.15 platform/shared/xruby/src/com/xruby/runtime/lang/util/RubyModuleFactory.java
rhodes-5.5.0.22 platform/shared/xruby/src/com/xruby/runtime/lang/util/RubyModuleFactory.java
rhodes-5.5.2 platform/shared/xruby/src/com/xruby/runtime/lang/util/RubyModuleFactory.java
rhodes-5.5.0.7 platform/shared/xruby/src/com/xruby/runtime/lang/util/RubyModuleFactory.java
rhodes-5.5.0.3 platform/shared/xruby/src/com/xruby/runtime/lang/util/RubyModuleFactory.java
rhodes-5.5.0 platform/shared/xruby/src/com/xruby/runtime/lang/util/RubyModuleFactory.java
tauplatform-1.0.3 platform/shared/xruby/src/com/xruby/runtime/lang/util/RubyModuleFactory.java
tauplatform-1.0.2 platform/shared/xruby/src/com/xruby/runtime/lang/util/RubyModuleFactory.java
tauplatform-1.0.1 platform/shared/xruby/src/com/xruby/runtime/lang/util/RubyModuleFactory.java
rhodes-3.5.1.12 platform/shared/xruby/src/com/xruby/runtime/lang/util/RubyModuleFactory.java
rhodes-3.3.5 platform/shared/xruby/src/com/xruby/runtime/lang/util/RubyModuleFactory.java
rhodes-3.4.2 platform/shared/xruby/src/com/xruby/runtime/lang/util/RubyModuleFactory.java