Search in sources :

Example 1 with ClassMapping

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

the class SystemMapping method methodMappingFor_methodName_.

public MethodMapping methodMappingFor_methodName_(final Class _receiverClass, final String _methodName) {
    final st.gravel.core.Symbol _sel;
    final ClassMapping _classMapping;
    _classMapping = this.classMappingForJavaClass_(_receiverClass);
    _sel = _selectorConverter.functionNameAsSelector_(_methodName);
    return ((MethodMapping) this.methodMappingFrom_selector_(_classMapping, _sel));
}
Also used : ClassMapping(st.gravel.support.compiler.ast.ClassMapping) AbstractClassMapping(st.gravel.support.compiler.ast.AbstractClassMapping)

Example 2 with ClassMapping

use of st.gravel.support.compiler.ast.ClassMapping 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)

Example 3 with ClassMapping

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

the class SystemMapping method classMappingForJavaClass_.

public ClassMapping classMappingForJavaClass_(final Class _receiverClass) {
    return this.classMappingAtJavaClass_ifAbsent_(_receiverClass, ((st.gravel.support.jvm.Block0<ClassMapping>) (new st.gravel.support.jvm.Block0<ClassMapping>() {

        @Override
        public ClassMapping value() {
            final ClassMapping _newClassMapping;
            _newClassMapping = SystemMapping.this.newClassMappingForJavaClass_(_receiverClass);
            _classMappingsByJavaClass.put(_receiverClass, _newClassMapping);
            return (ClassMapping) _newClassMapping;
        }
    })));
}
Also used : ClassMapping(st.gravel.support.compiler.ast.ClassMapping) AbstractClassMapping(st.gravel.support.compiler.ast.AbstractClassMapping)

Example 4 with ClassMapping

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

the class SystemMapping method methodMappingForNil_.

public MethodMapping methodMappingForNil_(final String _methodName) {
    final st.gravel.core.Symbol _sel;
    final ClassMapping _classMapping;
    _classMapping = this.nilClassMapping();
    _sel = _selectorConverter.functionNameAsSelector_(_methodName);
    return ((MethodMapping) this.methodMappingFrom_selector_(_classMapping, _sel));
}
Also used : ClassMapping(st.gravel.support.compiler.ast.ClassMapping) AbstractClassMapping(st.gravel.support.compiler.ast.AbstractClassMapping)

Example 5 with ClassMapping

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

the class SystemMapping method methodHandleForNil_.

public java.lang.invoke.MethodHandle methodHandleForNil_(final String _methodName) {
    final st.gravel.core.Symbol _sel;
    final ClassMapping _classMapping;
    _classMapping = this.nilClassMapping();
    _sel = _selectorConverter.functionNameAsSelector_(_methodName);
    return this.methodHandleFrom_selector_(_classMapping, _sel);
}
Also used : ClassMapping(st.gravel.support.compiler.ast.ClassMapping) AbstractClassMapping(st.gravel.support.compiler.ast.AbstractClassMapping)

Aggregations

AbstractClassMapping (st.gravel.support.compiler.ast.AbstractClassMapping)11 ClassMapping (st.gravel.support.compiler.ast.ClassMapping)11 BigInteger (java.math.BigInteger)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Set (java.util.Set)2 AbsoluteReference (st.gravel.support.compiler.ast.AbsoluteReference)2 AbstractMethodMapping (st.gravel.support.compiler.ast.AbstractMethodMapping)2 MethodNode (st.gravel.support.compiler.ast.MethodNode)2 Reference (st.gravel.support.compiler.ast.Reference)2 SharedDeclarationNode (st.gravel.support.compiler.ast.SharedDeclarationNode)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ClassDescriptionNode (st.gravel.support.compiler.ast.ClassDescriptionNode)1 ClassNode (st.gravel.support.compiler.ast.ClassNode)1 ExtensionClassPartMapping (st.gravel.support.compiler.ast.ExtensionClassPartMapping)1 InstVarMapping (st.gravel.support.compiler.ast.InstVarMapping)1 UnaryMethodNode (st.gravel.support.compiler.ast.UnaryMethodNode)1 VariableDeclarationNode (st.gravel.support.compiler.ast.VariableDeclarationNode)1