Search in sources :

Example 1 with InstVarMapping

use of st.gravel.support.compiler.ast.InstVarMapping in project gravel by gravel-st.

the class SystemMapping method newClassMappingForJavaClass_.

public ClassMapping newClassMappingForJavaClass_(final Class _receiverClass) {
    final Map<st.gravel.core.Symbol, AbstractMethodMapping>[] _methodMappings;
    final ClassNode _classNode;
    final ClassMapping _superMapping;
    final java.util.Set<st.gravel.core.Symbol>[] _allSelectors;
    _allSelectors = new java.util.Set[1];
    _methodMappings = new Map[1];
    _superMapping = this.bestClassMappingFor_(_receiverClass);
    _allSelectors[0] = _superMapping.allSelectorsIn_(this);
    _methodMappings[0] = new java.util.HashMap<st.gravel.core.Symbol, AbstractMethodMapping>();
    _compilerTools.methodNamesIn_do_(_receiverClass, new st.gravel.support.jvm.Block2<Object, String, Integer>() {

        @Override
        public Object value_value_(final String _methodName, final Integer _numArgs) {
            final st.gravel.core.Symbol _sel;
            _sel = _selectorConverter.functionNameAsSelector_(_methodName);
            if (st.gravel.support.jvm.IntegerExtensions.equals_(_sel.numArgs(), _numArgs) && _allSelectors[0].contains(_sel)) {
                final java.lang.invoke.MethodHandle _methodHandle;
                _methodHandle = _compilerTools.methodHandleAt_numArgs_in_identityClass_isStatic_(_methodName, _sel.numArgs(), _receiverClass, _receiverClass, false);
                if (_methodHandle != null) {
                    return _methodMappings[0].put(_sel, AnonymousMethodMapping.factory.methodHandle_definingClass_(_methodHandle, _receiverClass));
                }
            }
            return SystemMapping.this;
        }
    });
    _classNode = ClassNode.factory.name_superclassPath_properties_instVars_classInstVars_sharedVariables_methods_classMethods_namespace_isExtension_isTrait_traitUsage_classTraitUsage_(_superMapping.classNode().name(), _superMapping.reference().toString(), new java.util.HashMap<String, String>(), new VariableDeclarationNode[] {}, new VariableDeclarationNode[] {}, new SharedDeclarationNode[] {}, new MethodNode[] {}, new MethodNode[] {}, _superMapping.classNode().namespace(), false, false, EmptyTraitUsageNode.factory.basicNew(), EmptyTraitUsageNode.factory.basicNew());
    return ClassMapping.factory.identityMapping_extensions_instVarMappings_classNode_(IdentityClassPartMapping.factory.javaClass_isGenerated_(_receiverClass, false).withMethodMappings_(_methodMappings[0]), new ExtensionClassPartMapping[] {}, new java.util.HashMap<String, InstVarMapping>(), _classNode);
}
Also used : ClassMapping(st.gravel.support.compiler.ast.ClassMapping) AbstractClassMapping(st.gravel.support.compiler.ast.AbstractClassMapping) HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) SharedDeclarationNode(st.gravel.support.compiler.ast.SharedDeclarationNode) InstVarMapping(st.gravel.support.compiler.ast.InstVarMapping) MethodNode(st.gravel.support.compiler.ast.MethodNode) VariableDeclarationNode(st.gravel.support.compiler.ast.VariableDeclarationNode) ClassNode(st.gravel.support.compiler.ast.ClassNode) AbstractMethodMapping(st.gravel.support.compiler.ast.AbstractMethodMapping) BigInteger(java.math.BigInteger) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

BigInteger (java.math.BigInteger)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Set (java.util.Set)1 AbstractClassMapping (st.gravel.support.compiler.ast.AbstractClassMapping)1 AbstractMethodMapping (st.gravel.support.compiler.ast.AbstractMethodMapping)1 ClassMapping (st.gravel.support.compiler.ast.ClassMapping)1 ClassNode (st.gravel.support.compiler.ast.ClassNode)1 InstVarMapping (st.gravel.support.compiler.ast.InstVarMapping)1 MethodNode (st.gravel.support.compiler.ast.MethodNode)1 SharedDeclarationNode (st.gravel.support.compiler.ast.SharedDeclarationNode)1 VariableDeclarationNode (st.gravel.support.compiler.ast.VariableDeclarationNode)1