Search in sources :

Example 1 with PackageNode

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

the class SystemDefinitionNode method classNodeAt_ifAbsent_.

public ClassNode classNodeAt_ifAbsent_(final Reference _reference, final st.gravel.support.jvm.Block0<ClassNode> _aBlock) {
    final ClassNode[] _cn;
    _cn = new ClassNode[1];
    for (final PackageNode _each : _packageNodes) {
        _cn[0] = _each.classNodeAt_ifAbsent_(_reference, ((st.gravel.support.jvm.Block0<ClassNode>) (new st.gravel.support.jvm.Block0<ClassNode>() {

            @Override
            public ClassNode value() {
                return (ClassNode) null;
            }
        })));
        if (_cn[0] != null) {
            return _cn[0];
        }
    }
    return _aBlock.value();
}
Also used : ClassNode(st.gravel.support.compiler.ast.ClassNode) PackageNode(st.gravel.support.compiler.ast.PackageNode)

Example 2 with PackageNode

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

the class SystemDefinitionNode method copyUpdatePackage_do_.

public SystemDefinitionNode copyUpdatePackage_do_(final st.gravel.core.Symbol _packageName, final st.gravel.support.jvm.Block1<PackageNode, PackageNode> _aBlock) {
    final int _idx;
    final PackageNode _updatedPackage;
    _idx = st.gravel.support.jvm.ArrayExtensions.indexWhere_(_packageNodes, new st.gravel.support.jvm.Predicate1<PackageNode>() {

        @Override
        public boolean value_(final PackageNode _pkg) {
            return st.gravel.support.jvm.ObjectExtensions.equals_(_pkg.name(), _packageName);
        }
    });
    _updatedPackage = _aBlock.value_(_packageNodes[_idx - 1]);
    return this.copy().pvtSetPackageNodes_(st.gravel.support.jvm.ArrayExtensions.copyAt_put_(_packageNodes, _idx, _updatedPackage));
}
Also used : PackageNode(st.gravel.support.compiler.ast.PackageNode)

Example 3 with PackageNode

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

Example 4 with PackageNode

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

the class DiskClassReader method read.

public SystemDefinitionNode read() {
    final List<PackageNode>[] _coll;
    _coll = new List[1];
    _coll[0] = new java.util.ArrayList();
    for (final String _packageName : _root.list()) {
        _coll[0].add(DiskClassReader.this.readPackage_(_packageName));
    }
    return SystemDefinitionNode.factory.packageNodes_(_coll[0].toArray(new PackageNode[_coll[0].size()]));
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) PackageNode(st.gravel.support.compiler.ast.PackageNode) ArrayList(java.util.ArrayList)

Aggregations

PackageNode (st.gravel.support.compiler.ast.PackageNode)4 ClassNode (st.gravel.support.compiler.ast.ClassNode)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Symbol (st.gravel.core.Symbol)1 ClassDescriptionNode (st.gravel.support.compiler.ast.ClassDescriptionNode)1 MethodNode (st.gravel.support.compiler.ast.MethodNode)1 SystemDefinitionNode (st.gravel.support.compiler.ast.SystemDefinitionNode)1