Search in sources :

Example 1 with BoundVariableDeclarationNode

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

the class JVMClassCompiler method compileClassNode.

public JVMClass compileClassNode() {
    final MethodNode[] _allMethods;
    Reference _superclassReference;
    BoundVariableDeclarationNode[] _allInstVars;
    final MethodNode[] _localLinkedMethods;
    ClassDescriptionNode _scn;
    if (_ownerType == null) {
        _ownerType = ((JVMDefinedObjectType) _selfType);
    }
    _allMethods = _classDescriptionNode.methods();
    _superclassReference = _classDescriptionNode.superclassReference();
    _allInstVars = _classDescriptionNode.boundInstVars();
    boolean _temp1 = false;
    while (!_temp1) {
        _temp1 = _superclassReference == null;
        if (!_temp1) {
            _scn = _systemNode.classNodeAt_(_superclassReference);
            _superclassReference = _scn.superclassReference();
            _allInstVars = st.gravel.support.jvm.ArrayExtensions.copyWithAll_(_scn.boundInstVars(), _allInstVars);
        }
    }
    _localLinkedMethods = _systemMappingUpdater.localLinkMethods_instVars_ownerReference_(_allMethods, _allInstVars, _classDescriptionNode.reference());
    for (final MethodNode _each : _localLinkedMethods) {
        JVMClassCompiler.this.compileMethod_(_each);
    }
    for (final VariableDeclarationNode _each : _classDescriptionNode.instVars()) {
        _fields.add(JVMField.factory.ownerType_varName_type_isStatic_(_ownerType, _each.name(), TypeNodeToJVMTypeConverter.factory.namespace_(JVMClassCompiler.this.namespace()).visit_(_each.type()), false));
    }
    this.compileBlocks();
    return this.createContainerClass();
}
Also used : MethodNode(st.gravel.support.compiler.ast.MethodNode) VariableDeclarationNode(st.gravel.support.compiler.ast.VariableDeclarationNode) BoundVariableDeclarationNode(st.gravel.support.compiler.ast.BoundVariableDeclarationNode) Reference(st.gravel.support.compiler.ast.Reference) JVMDefinedObjectType(st.gravel.support.compiler.jvm.JVMDefinedObjectType) BoundVariableDeclarationNode(st.gravel.support.compiler.ast.BoundVariableDeclarationNode) ClassDescriptionNode(st.gravel.support.compiler.ast.ClassDescriptionNode)

Example 2 with BoundVariableDeclarationNode

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

the class BlockInliner method link_.

public MethodNode link_(final MethodNode _aMethodNode) {
    final SelfNode _owner;
    final SystemMappingUpdater _updater;
    final BoundVariableDeclarationNode[] _instVars;
    _owner = SelfNode.factory.basicNew();
    _updater = _systemMapping.newSystemMappingUpdater();
    _instVars = _updater.allInstVarsForReference_(_receiverReference);
    return ((MethodNode) _updater.localLink_instVars_ownerReference_owner_(_aMethodNode, _instVars, _receiverReference, _owner));
}
Also used : SystemMappingUpdater(st.gravel.support.compiler.ast.SystemMappingUpdater) SelfNode(st.gravel.support.compiler.ast.SelfNode) BoundVariableDeclarationNode(st.gravel.support.compiler.ast.BoundVariableDeclarationNode)

Example 3 with BoundVariableDeclarationNode

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

the class ClassMapping method allInstVarsIn_.

@Override
public BoundVariableDeclarationNode[] allInstVarsIn_(final SystemMapping _aSystemMapping) {
    final BoundVariableDeclarationNode[] _arr;
    final ClassMapping _scm;
    _arr = this.boundInstVars();
    _scm = ((ClassMapping) this.superclassMappingIn_(_aSystemMapping));
    if (_scm != null) {
        return st.gravel.support.jvm.ArrayExtensions.copyWithAll_(_arr, _scm.allInstVarsIn_(_aSystemMapping));
    }
    return _arr;
}
Also used : AbstractClassMapping(st.gravel.support.compiler.ast.AbstractClassMapping) BoundVariableDeclarationNode(st.gravel.support.compiler.ast.BoundVariableDeclarationNode)

Example 4 with BoundVariableDeclarationNode

use of st.gravel.support.compiler.ast.BoundVariableDeclarationNode 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 5 with BoundVariableDeclarationNode

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

the class SystemMappingUpdater method localLink_instVars_ownerReference_owner_.

public Node localLink_instVars_ownerReference_owner_(final Node _node, final BoundVariableDeclarationNode[] _instVars, final Reference _ownerReference, final Expression _owner) {
    final Node _intermediate;
    final Node _nonLocal;
    final Node _holderized;
    final Node _fieldAccessed;
    _intermediate = IntermediateNodeRewriter.factory.visit_(_node);
    _nonLocal = NonLocalReturnRewriter.factory.nlrMarker_(_compilerTools.nextNlrMarker()).visit_(_intermediate);
    _holderized = NonLocalTempWritesToHolderConverter.factory.visit_(_nonLocal);
    _fieldAccessed = VariableAccessToFieldAccessConverter.factory.instVars_owner_ownerReference_(_instVars, _owner, _ownerReference).visit_(_holderized);
    return _fieldAccessed;
}
Also used : InstanceCreationNode(st.gravel.support.compiler.ast.InstanceCreationNode) ReturnNode(st.gravel.support.compiler.ast.ReturnNode) UnaryMethodNode(st.gravel.support.compiler.ast.UnaryMethodNode) MethodNode(st.gravel.support.compiler.ast.MethodNode) PragmaNode(st.gravel.support.compiler.ast.PragmaNode) VariableNode(st.gravel.support.compiler.ast.VariableNode) MetaclassNode(st.gravel.support.compiler.ast.MetaclassNode) Node(st.gravel.support.compiler.ast.Node) SharedDeclarationNode(st.gravel.support.compiler.ast.SharedDeclarationNode) SequenceNode(st.gravel.support.compiler.ast.SequenceNode) ClassDescriptionNode(st.gravel.support.compiler.ast.ClassDescriptionNode) SelfNode(st.gravel.support.compiler.ast.SelfNode) NamespaceNode(st.gravel.support.compiler.ast.NamespaceNode) ClassNode(st.gravel.support.compiler.ast.ClassNode) BoundVariableDeclarationNode(st.gravel.support.compiler.ast.BoundVariableDeclarationNode)

Aggregations

BoundVariableDeclarationNode (st.gravel.support.compiler.ast.BoundVariableDeclarationNode)5 ClassDescriptionNode (st.gravel.support.compiler.ast.ClassDescriptionNode)3 MethodNode (st.gravel.support.compiler.ast.MethodNode)3 SelfNode (st.gravel.support.compiler.ast.SelfNode)2 UnaryMethodNode (st.gravel.support.compiler.ast.UnaryMethodNode)2 HashMap (java.util.HashMap)1 AbstractClassMapping (st.gravel.support.compiler.ast.AbstractClassMapping)1 ClassNode (st.gravel.support.compiler.ast.ClassNode)1 ExtensionClassPartMapping (st.gravel.support.compiler.ast.ExtensionClassPartMapping)1 IdentityClassPartMapping (st.gravel.support.compiler.ast.IdentityClassPartMapping)1 InstanceCreationNode (st.gravel.support.compiler.ast.InstanceCreationNode)1 MetaclassNode (st.gravel.support.compiler.ast.MetaclassNode)1 NamespaceNode (st.gravel.support.compiler.ast.NamespaceNode)1 Node (st.gravel.support.compiler.ast.Node)1 PragmaNode (st.gravel.support.compiler.ast.PragmaNode)1 Reference (st.gravel.support.compiler.ast.Reference)1 ReturnNode (st.gravel.support.compiler.ast.ReturnNode)1 SequenceNode (st.gravel.support.compiler.ast.SequenceNode)1 SharedDeclarationNode (st.gravel.support.compiler.ast.SharedDeclarationNode)1 SystemMappingUpdater (st.gravel.support.compiler.ast.SystemMappingUpdater)1