Sha256: cd62331336e4087a1a90b06cf84445b69911a630c81ecf960ee2a4cf03e46446

Contents?: true

Size: 1.4 KB

Versions: 135

Compression:

Stored size: 1.4 KB

Contents

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

package com.xruby.compiler.codegen;

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

public class CgUtil {
	public static Method CONSTRUCTOR = new Method("<init>", Type.VOID_TYPE, Types.NULL_TYPE_ARRAY);
	
	public static String getInternalName(String name) {
		return name.replace(".", "/");
	}
	
	public static Method getMethod(String method, Type returnType) {
		return new Method(method, returnType, Types.NULL_TYPE_ARRAY);
	}
	
	public static Method getMethod(String method, Type returnType, Type... params) {
		return new Method(method, returnType, params);
	}
	
	public static Method getMethod(String method, Class returnType, Class... params) {
		Type[] types = new Type[params.length];
		for (int i = 0; i < params.length; i++) {
			types[i] = Type.getType(params[i]);
		}
		return new Method(method, Type.getType(returnType), types);
	}
	
	public static void createImplicitConstructor(ClassVisitor cv, Type superType) {
		GeneratorAdapter mg = new GeneratorAdapter(Opcodes.ACC_PUBLIC,
                CONSTRUCTOR, null, null, cv);
		mg.visitCode();
        mg.loadThis();
        mg.invokeConstructor(superType, CONSTRUCTOR);
        mg.returnValue();
        mg.endMethod();
    }
	
	private CgUtil() {}
}

Version data entries

135 entries across 135 versions & 2 rubygems

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