Search in sources :

Example 6 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)

Example 7 with ClassMapping

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

the class SystemMappingUpdater method compiledMethodNodesIn_do_.

public SystemMappingUpdater compiledMethodNodesIn_do_(final Reference _superclassReference, final st.gravel.support.jvm.Block1<Object, MethodNode> _aBlock) {
    final ClassMapping[] _superMapping;
    final Class _sc;
    final java.util.Set<st.gravel.core.Symbol>[] _allSelectors;
    _allSelectors = new java.util.Set[1];
    _superMapping = new ClassMapping[1];
    if (_superclassReference == null) {
        return SystemMappingUpdater.this;
    }
    _superMapping[0] = ((ClassMapping) _systemMapping.classMappingAtReference_(_superclassReference));
    _allSelectors[0] = _superMapping[0].allSelectorsIn_(_systemMapping);
    _sc = _superMapping[0].identityClass();
    _compilerTools.methodNamesIn_do_(_sc, 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 (_allSelectors[0].contains(_sel)) {
                final AbstractMethodMapping _methodMapping;
                _methodMapping = _systemMapping.methodMappingFrom_selector_(_superMapping[0], _sel);
                if ((_methodMapping != null) && (_methodMapping.methodNode() != null)) {
                    return _aBlock.value_(_methodMapping.methodNode());
                }
            }
            return SystemMappingUpdater.this;
        }
    });
    return this;
}
Also used : ClassMapping(st.gravel.support.compiler.ast.ClassMapping) AbstractClassMapping(st.gravel.support.compiler.ast.AbstractClassMapping) List(java.util.List) ArrayList(java.util.ArrayList) Set(java.util.Set) HashSet(java.util.HashSet) AbstractMethodMapping(st.gravel.support.compiler.ast.AbstractMethodMapping) BigInteger(java.math.BigInteger) JVMClass(st.gravel.support.compiler.jvm.JVMClass)

Example 8 with ClassMapping

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

the class SystemMappingUpdater method executeUpdateClassDescriptorDiff_reference_.

public SystemMappingUpdater executeUpdateClassDescriptorDiff_reference_(final UpdateClassDescriptorDiff _anUpdateClassDescriptorDiff, final Reference _aReference) {
    final ExtensionClassPartMapping _ecm;
    ClassMapping _cm;
    final ClassDescriptionNode _ncn;
    final MethodNode[] _methods;
    _cm = ((ClassMapping) _systemMapping.classMappingAtReference_(_aReference));
    _cm = ((ClassMapping) st.gravel.support.jvm.ArrayExtensions.inject_into_(_anUpdateClassDescriptorDiff.updatedMethodNodes(), _cm, ((st.gravel.support.jvm.Block2<ClassMapping, ClassMapping, MethodNode>) (new st.gravel.support.jvm.Block2<ClassMapping, ClassMapping, MethodNode>() {

        @Override
        public ClassMapping value_value_(final ClassMapping _classMapping, final MethodNode _methodNode) {
            return (ClassMapping) _classMapping.withoutMethodMapping_(_methodNode.selector());
        }
    }))));
    _cm = ((ClassMapping) st.gravel.support.jvm.ArrayExtensions.inject_into_(_anUpdateClassDescriptorDiff.deletedSelectors(), _cm, ((st.gravel.support.jvm.Block2<ClassMapping, ClassMapping, String>) (new st.gravel.support.jvm.Block2<ClassMapping, ClassMapping, String>() {

        @Override
        public ClassMapping value_value_(final ClassMapping _classMapping, final String _selector) {
            return (ClassMapping) _classMapping.withoutMethodMapping_(_selector);
        }
    }))));
    _ncn = _anUpdateClassDescriptorDiff.applyOnClassNode_(_cm.classNode());
    _methods = st.gravel.support.jvm.ArrayExtensions.copyWithAll_(_anUpdateClassDescriptorDiff.methodNodes(), _anUpdateClassDescriptorDiff.updatedMethodNodes());
    _ecm = this.compileExtensionClassPartMapping_methods_identityClass_instVars_sourceFile_(_ncn, _methods, _cm.identityClass(), _cm.classNode().boundInstVars(), this.findSourceFile_(_anUpdateClassDescriptorDiff.methodNodes()));
    _systemMapping.addClassMapping_(_cm.withClassNode_(_ncn).withExtension_(_ecm));
    return this;
}
Also used : ClassMapping(st.gravel.support.compiler.ast.ClassMapping) AbstractClassMapping(st.gravel.support.compiler.ast.AbstractClassMapping) UnaryMethodNode(st.gravel.support.compiler.ast.UnaryMethodNode) MethodNode(st.gravel.support.compiler.ast.MethodNode) ExtensionClassPartMapping(st.gravel.support.compiler.ast.ExtensionClassPartMapping) ClassDescriptionNode(st.gravel.support.compiler.ast.ClassDescriptionNode)

Example 9 with ClassMapping

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

the class SystemMappingUpdater method link.

public SystemMappingUpdater link() {
    _systemMapping.classMappingsDo_(new st.gravel.support.jvm.Block1<Object, AbstractClassMapping>() {

        @Override
        public Object value_(final AbstractClassMapping _acm) {
            if (_acm.classNode().isMeta()) {
                SystemMappingUpdater.this.initializeClassShareds_(((MetaclassNode) _acm.classNode()));
                return _systemMapping.singletonAtReference_ifAbsentPut_(_acm.reference().nonmeta(), new st.gravel.support.jvm.Block0<Object>() {

                    @Override
                    public Object value() {
                        return _compilerTools.createSingletonForClass_(_acm.identityClass());
                    }
                });
            }
            return SystemMappingUpdater.this;
        }
    });
    _compilerTools.resetCallsites();
    _systemMapping.namespaceGlobalsAndInitializersDo_(new st.gravel.support.jvm.Block2<Object, AbsoluteReference, SharedDeclarationNode>() {

        @Override
        public Object value_value_(final AbsoluteReference _reference, final SharedDeclarationNode _sharedVariable) {
            return _systemMapping.singletonAtReference_initialize_(_reference, _sharedVariable);
        }
    });
    for (final Reference _ref : _toInitialize) {
        _compilerTools.initializeClass_systemMapping_(((ClassMapping) _systemMapping.classMappingAtReference_(_ref)), _systemMapping);
    }
    _toInitialize = new java.util.ArrayList();
    return this;
}
Also used : List(java.util.List) ArrayList(java.util.ArrayList) ClassMapping(st.gravel.support.compiler.ast.ClassMapping) AbstractClassMapping(st.gravel.support.compiler.ast.AbstractClassMapping) AbsoluteReference(st.gravel.support.compiler.ast.AbsoluteReference) Reference(st.gravel.support.compiler.ast.Reference) AbsoluteReference(st.gravel.support.compiler.ast.AbsoluteReference) SharedDeclarationNode(st.gravel.support.compiler.ast.SharedDeclarationNode) ArrayList(java.util.ArrayList) AbstractClassMapping(st.gravel.support.compiler.ast.AbstractClassMapping)

Example 10 with ClassMapping

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

the class SystemMapping method methodHandleFor_methodName_.

public java.lang.invoke.MethodHandle methodHandleFor_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 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