Search in sources :

Example 11 with MethodNode

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

the class UpdateClassDescriptorDiff method applyOnClassNode_.

public ClassDescriptionNode applyOnClassNode_(final ClassDescriptionNode _startClassNode) {
    ClassDescriptionNode _classNode;
    _classNode = ((ClassDescriptionNode) st.gravel.support.jvm.ArrayExtensions.inject_into_(_methodNodes, _startClassNode, ((st.gravel.support.jvm.Block2<ClassDescriptionNode, ClassDescriptionNode, MethodNode>) (new st.gravel.support.jvm.Block2<ClassDescriptionNode, ClassDescriptionNode, MethodNode>() {

        @Override
        public ClassDescriptionNode value_value_(final ClassDescriptionNode _cn, final MethodNode _m) {
            return (ClassDescriptionNode) _cn.withMethodNode_(_m);
        }
    }))));
    _classNode = ((ClassDescriptionNode) st.gravel.support.jvm.ArrayExtensions.inject_into_(_updatedMethodNodes, _classNode, ((st.gravel.support.jvm.Block2<ClassDescriptionNode, ClassDescriptionNode, MethodNode>) (new st.gravel.support.jvm.Block2<ClassDescriptionNode, ClassDescriptionNode, MethodNode>() {

        @Override
        public ClassDescriptionNode value_value_(final ClassDescriptionNode _cn, final MethodNode _m) {
            return (ClassDescriptionNode) _cn.copyReplaceMethodNode_(_m);
        }
    }))));
    return ((ClassDescriptionNode) st.gravel.support.jvm.ArrayExtensions.inject_into_(_deletedSelectors, _classNode, ((st.gravel.support.jvm.Block2<ClassDescriptionNode, ClassDescriptionNode, String>) (new st.gravel.support.jvm.Block2<ClassDescriptionNode, ClassDescriptionNode, String>() {

        @Override
        public ClassDescriptionNode value_value_(final ClassDescriptionNode _cn, final String _sel) {
            return (ClassDescriptionNode) _cn.copyRemoveSelector_(_sel);
        }
    }))));
}
Also used : MethodNode(st.gravel.support.compiler.ast.MethodNode) ClassDescriptionNode(st.gravel.support.compiler.ast.ClassDescriptionNode)

Example 12 with MethodNode

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

the class MetaclassNode method withMethodNode_.

@Override
public MetaclassNode withMethodNode_(final MethodNode _aMethodNode) {
    final MethodNode _current;
    _current = this.methodOrNilAt_(_aMethodNode.selector());
    if (_current != null) {
        throw new RuntimeException("Duplicate selector: " + _aMethodNode.selector());
    }
    return this.copy().pvtSetMethods_(st.gravel.support.jvm.ArrayExtensions.copyWith_(_methods, _aMethodNode));
}
Also used : MethodNode(st.gravel.support.compiler.ast.MethodNode)

Example 13 with MethodNode

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

the class SystemMappingUpdater method compileClassDescriptionNodeNonStatic_.

public SystemMappingUpdater compileClassDescriptionNodeNonStatic_(final ClassDescriptionNode _aClassDescriptionNode) {
    final Class _identityClass;
    final IdentityClassPartMapping _identityMapping;
    final MethodNode[] _allMethods;
    final MethodNode[] _extraMethods;
    final ClassDescriptionNode _ecdn;
    _extraMethods = this.extraMethodsFor_(_aClassDescriptionNode);
    _ecdn = _aClassDescriptionNode.withExtraMethods_(_extraMethods);
    _identityClass = this.compileClass_isStatic_(_ecdn, false);
    _allMethods = this.methods_withExtraMethods_(_aClassDescriptionNode.methods(), _extraMethods);
    _identityMapping = ((IdentityClassPartMapping) this.linkMethods_in_identityClass_to_isStatic_(_allMethods, _identityClass, _identityClass, IdentityClassPartMapping.factory.javaClass_isGenerated_(_identityClass, true), false));
    _systemMapping.addClassMapping_(ClassMapping.factory.identityMapping_extensions_instVarMappings_classNode_(_identityMapping, new ExtensionClassPartMapping[] {}, new java.util.HashMap<String, InstVarMapping>(), _aClassDescriptionNode));
    return this;
}
Also used : UnaryMethodNode(st.gravel.support.compiler.ast.UnaryMethodNode) MethodNode(st.gravel.support.compiler.ast.MethodNode) HashMap(java.util.HashMap) ExtensionClassPartMapping(st.gravel.support.compiler.ast.ExtensionClassPartMapping) JVMClass(st.gravel.support.compiler.jvm.JVMClass) IdentityClassPartMapping(st.gravel.support.compiler.ast.IdentityClassPartMapping) ClassDescriptionNode(st.gravel.support.compiler.ast.ClassDescriptionNode)

Example 14 with MethodNode

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

the class SystemMappingUpdater method methods_withExtraMethods_.

public MethodNode[] methods_withExtraMethods_(final MethodNode[] _methods, final MethodNode[] _extraMethods) {
    final java.util.Set<String>[] _selectors;
    final List<MethodNode>[] _n;
    _n = new List[1];
    _selectors = new java.util.Set[1];
    _selectors[0] = new java.util.HashSet();
    _n[0] = new java.util.ArrayList();
    for (final MethodNode _each : _methods) {
        if (!_selectors[0].contains(_each.selector())) {
            _selectors[0].add(_each.selector());
            _n[0].add(_each);
        }
    }
    for (final MethodNode _each : _extraMethods) {
        if (!_selectors[0].contains(_each.selector())) {
            _selectors[0].add(_each.selector());
            _n[0].add(_each);
        }
    }
    return _n[0].toArray(new MethodNode[_n[0].size()]);
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashSet(java.util.HashSet) UnaryMethodNode(st.gravel.support.compiler.ast.UnaryMethodNode) MethodNode(st.gravel.support.compiler.ast.MethodNode) List(java.util.List) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList)

Example 15 with MethodNode

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

Aggregations

MethodNode (st.gravel.support.compiler.ast.MethodNode)28 ClassDescriptionNode (st.gravel.support.compiler.ast.ClassDescriptionNode)10 UnaryMethodNode (st.gravel.support.compiler.ast.UnaryMethodNode)9 HashMap (java.util.HashMap)7 VariableDeclarationNode (st.gravel.support.compiler.ast.VariableDeclarationNode)6 ArrayList (java.util.ArrayList)5 List (java.util.List)5 ExtensionClassPartMapping (st.gravel.support.compiler.ast.ExtensionClassPartMapping)5 HashSet (java.util.HashSet)4 Set (java.util.Set)4 BoundVariableDeclarationNode (st.gravel.support.compiler.ast.BoundVariableDeclarationNode)4 ClassNode (st.gravel.support.compiler.ast.ClassNode)4 IdentityClassPartMapping (st.gravel.support.compiler.ast.IdentityClassPartMapping)4 Map (java.util.Map)3 Symbol (st.gravel.core.Symbol)3 AbstractClassMapping (st.gravel.support.compiler.ast.AbstractClassMapping)2 ClassMapping (st.gravel.support.compiler.ast.ClassMapping)2 KeywordMethodNode (st.gravel.support.compiler.ast.KeywordMethodNode)2 MethodMapping (st.gravel.support.compiler.ast.MethodMapping)2 PackageNode (st.gravel.support.compiler.ast.PackageNode)2