Search in sources :

Example 16 with MethodNode

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

the class SystemMappingUpdater method compileClassDescriptionNodeStatic_.

public SystemMappingUpdater compileClassDescriptionNodeStatic_(final ClassDescriptionNode _aClassDescriptionNode) {
    final Class _extensionClass;
    IdentityClassPartMapping _identityMapping;
    final MethodNode[] _allMethods;
    final MethodNode[] _extraMethods;
    final ClassDescriptionNode _ecdn;
    _extraMethods = this.extraMethodsFor_(_aClassDescriptionNode);
    _allMethods = this.methods_withExtraMethods_(_aClassDescriptionNode.methods(), _extraMethods);
    _ecdn = _aClassDescriptionNode.withExtraMethods_(_extraMethods);
    _extensionClass = this.compileClass_isStatic_(_ecdn, true);
    _identityMapping = IdentityClassPartMapping.factory.javaClass_isGenerated_(_aClassDescriptionNode.isNilClass() ? null : _extensionClass, true);
    _identityMapping = ((IdentityClassPartMapping) this.linkMethods_in_identityClass_to_isStatic_(_allMethods, _extensionClass, _extensionClass, _identityMapping, true));
    _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 17 with MethodNode

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

the class SystemMappingUpdater method visitWrapJavaclassDiff_.

@Override
public SystemMappingUpdater visitWrapJavaclassDiff_(final WrapJavaclassDiff _aWrapJavaclassDiff) {
    final IdentityClassPartMapping _identityMapping;
    final ExtensionClassPartMapping _ecm;
    final MethodNode[] _allMethods;
    final MethodNode[] _extraMethods;
    final ClassDescriptionNode _ecdn;
    _identityMapping = IdentityClassPartMapping.factory.javaClass_isGenerated_(_compilerTools.findJavaClass_(_aWrapJavaclassDiff.classNode().javaClassPath()), false);
    _extraMethods = this.extraMethodsFor_(_aWrapJavaclassDiff.classNode());
    _ecdn = _aWrapJavaclassDiff.classNode().withExtraMethods_(_extraMethods);
    _allMethods = this.methods_withExtraMethods_(_aWrapJavaclassDiff.classNode().methods(), _extraMethods);
    _ecm = this.compileExtensionClassPartMapping_methods_identityClass_instVars_sourceFile_(_ecdn, _allMethods, _identityMapping.javaClass(), new BoundVariableDeclarationNode[] {}, _aWrapJavaclassDiff.classNode().findSourceFile());
    _systemMapping.addClassMapping_(ClassMapping.factory.identityMapping_extensions_instVarMappings_classNode_(_identityMapping, st.gravel.support.jvm.ArrayFactory.with_(_ecm), new java.util.HashMap<String, InstVarMapping>(), _aWrapJavaclassDiff.classNode()));
    this.compileClassDescriptionNode_(_aWrapJavaclassDiff.classNode().metaclassNode());
    _toInitialize.add(_aWrapJavaclassDiff.classNode().metaclassNode().reference());
    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) IdentityClassPartMapping(st.gravel.support.compiler.ast.IdentityClassPartMapping) ClassDescriptionNode(st.gravel.support.compiler.ast.ClassDescriptionNode) BoundVariableDeclarationNode(st.gravel.support.compiler.ast.BoundVariableDeclarationNode)

Example 18 with MethodNode

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

the class SystemMappingUpdater method localLinkMethods_instVars_ownerReference_.

public MethodNode[] localLinkMethods_instVars_ownerReference_(final MethodNode[] _methods, final BoundVariableDeclarationNode[] _instVars, final Reference _ownerReference) {
    final SelfNode[] _owner;
    _owner = new SelfNode[1];
    _owner[0] = SelfNode.factory.basicNew();
    return st.gravel.support.jvm.ArrayExtensions.collect_(_methods, ((st.gravel.support.jvm.Block1<MethodNode, MethodNode>) (new st.gravel.support.jvm.Block1<MethodNode, MethodNode>() {

        @Override
        public MethodNode value_(final MethodNode _m) {
            final MethodNode _fieldAccessed;
            _fieldAccessed = ((MethodNode) SystemMappingUpdater.this.localLink_instVars_ownerReference_owner_(_m, _instVars, _ownerReference, _owner[0]));
            return (MethodNode) _fieldAccessed;
        }
    })));
}
Also used : List(java.util.List) ArrayList(java.util.ArrayList) UnaryMethodNode(st.gravel.support.compiler.ast.UnaryMethodNode) MethodNode(st.gravel.support.compiler.ast.MethodNode) SelfNode(st.gravel.support.compiler.ast.SelfNode)

Example 19 with MethodNode

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

the class LiteralBlockSendCallSite method findMethodForNil.

@Override
protected MethodHandle findMethodForNil() {
    MethodMapping methodMapping = ImageBootstrapper.systemMapping.methodMappingForNil_(selector);
    if (methodMapping == null) {
        return createDNUHandleForNil();
    }
    MethodNode methodNode = methodMapping.methodNode();
    return inlineBlocks(methodNode, ImageBootstrapper.systemMapping.nilClassMapping().reference(), JVMDefinedObjectType.factory.object());
}
Also used : MethodMapping(st.gravel.support.compiler.ast.MethodMapping) MethodNode(st.gravel.support.compiler.ast.MethodNode)

Example 20 with MethodNode

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

the class ClassDescriptionMirror method compile_classified_.

public Object compile_classified_(String source, String protocol) {
    final MethodNode method = Parser.factory.parseMethod_(source).withProtocol_(protocol);
    ClassDescriptionNode currentClassNode = definitionClassNode();
    final MethodNode current = currentClassNode.methodOrNilAt_(method.selector());
    Symbol targetPackageName = current == null ? definitionClassNode().packageName() : current.packageName();
    if (targetPackageName == null) {
        targetPackageName = definitionClassNode().packageName();
        if (targetPackageName == null) {
            targetPackageName = current.packageName();
        }
    }
    SystemDefinitionNode newSystem = ImageBootstrapper.systemMapping.systemDefinitionNode().copyUpdatePackage_do_(targetPackageName, new Block1<PackageNode, PackageNode>() {

        @Override
        public PackageNode value_(PackageNode packageNode) {
            return packageNode.copyUpdateClassNode_do_(definitionClassNode().reference(), new Block1<ClassNode, ClassNode>() {

                @Override
                public ClassNode value_(ClassNode classNode) {
                    return current == null ? classNode.withMethodNode_(method) : classNode.copyReplaceMethodNode_(method);
                }
            });
        }
    });
    ImageBootstrapper.systemMapping.updateTo_(newSystem);
    return getMethodMirror(Symbol.value(method.selector()));
}
Also used : ClassNode(st.gravel.support.compiler.ast.ClassNode) MethodNode(st.gravel.support.compiler.ast.MethodNode) Symbol(st.gravel.core.Symbol) SystemDefinitionNode(st.gravel.support.compiler.ast.SystemDefinitionNode) PackageNode(st.gravel.support.compiler.ast.PackageNode) 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