Search in sources :

Example 1 with NonLocalReturn

use of st.gravel.support.jvm.NonLocalReturn in project gravel by gravel-st.

the class ClassNode method javaClassPath.

public st.gravel.core.Symbol[] javaClassPath() {
    final Object _temp1 = new Object();
    try {
        final String _javaClass;
        _javaClass = ((String) st.gravel.support.jvm.DictionaryExtensions.at_ifAbsent_(_properties, "javaClass", ((st.gravel.support.jvm.Block0<String>) (new st.gravel.support.jvm.Block0<String>() {

            @Override
            public String value() {
                throw new NonLocalReturn(null, _temp1);
            }
        }))));
        return ((st.gravel.core.Symbol[]) st.gravel.support.jvm.ArrayExtensions.collect_(st.gravel.support.jvm.StringExtensions.tokensBasedOn_(_javaClass, '.'), ((st.gravel.support.jvm.Block1<st.gravel.core.Symbol, String>) (new st.gravel.support.jvm.Block1<st.gravel.core.Symbol, String>() {

            @Override
            public st.gravel.core.Symbol value_(final String _each) {
                return (st.gravel.core.Symbol) st.gravel.core.Symbol.value(_each);
            }
        }))));
    } catch (NonLocalReturn nlr) {
        if (nlr.marker == _temp1) {
            return (st.gravel.core.Symbol[]) nlr.returnValue;
        } else {
            throw nlr;
        }
    }
}
Also used : NonLocalReturn(st.gravel.support.jvm.NonLocalReturn)

Example 2 with NonLocalReturn

use of st.gravel.support.jvm.NonLocalReturn in project gravel by gravel-st.

the class MethodNode method pragmaPropertyAt_ifAbsent_.

public Object pragmaPropertyAt_ifAbsent_(final st.gravel.core.Symbol _aKey, final st.gravel.support.jvm.Block0<Object> _aBlock) {
    final Object _temp1 = new Object();
    try {
        final PragmaNode _pr;
        _pr = ((PragmaNode) st.gravel.support.jvm.ArrayExtensions.detect_ifNone_(_pragmas, new st.gravel.support.jvm.Predicate1<PragmaNode>() {

            @Override
            public boolean value_(final PragmaNode _each) {
                return _each.isPropertyPragmaAt_(_aKey);
            }
        }, ((st.gravel.support.jvm.Block0<PragmaNode>) (new st.gravel.support.jvm.Block0<PragmaNode>() {

            @Override
            public PragmaNode value() {
                throw new NonLocalReturn(_aBlock.value(), _temp1);
            }
        }))));
        return ((LiteralNode) _pr.expression().arguments()[1]).value();
    } catch (NonLocalReturn nlr) {
        if (nlr.marker == _temp1) {
            return (Object) nlr.returnValue;
        } else {
            throw nlr;
        }
    }
}
Also used : NilLiteralNode(st.gravel.support.compiler.ast.NilLiteralNode) LiteralNode(st.gravel.support.compiler.ast.LiteralNode) SymbolLiteralNode(st.gravel.support.compiler.ast.SymbolLiteralNode) StringLiteralNode(st.gravel.support.compiler.ast.StringLiteralNode) ArrayLiteralNode(st.gravel.support.compiler.ast.ArrayLiteralNode) PragmaNode(st.gravel.support.compiler.ast.PragmaNode) NonLocalReturn(st.gravel.support.jvm.NonLocalReturn)

Example 3 with NonLocalReturn

use of st.gravel.support.jvm.NonLocalReturn in project gravel by gravel-st.

the class SystemMapping method namespacedSingletonHolderAtReference_ifAbsent_.

public st.gravel.support.jvm.runtime.AlmostFinalValue namespacedSingletonHolderAtReference_ifAbsent_(final AbsoluteReference _reference, final st.gravel.support.jvm.Block0<st.gravel.support.jvm.runtime.AlmostFinalValue> _aBlock) {
    final Object _temp1 = new Object();
    try {
        final NamespaceNode _nsNode;
        _nsNode = _systemNode.namespaceNodeAt_ifAbsent_(_reference.namespace().namespace(), ((st.gravel.support.jvm.Block0<NamespaceNode>) (new st.gravel.support.jvm.Block0<NamespaceNode>() {

            @Override
            public NamespaceNode value() {
                return (NamespaceNode) null;
            }
        })));
        if (_nsNode != null) {
            _nsNode.allImportsIn_do_(_systemNode, new st.gravel.support.jvm.Block1<Object, NamespaceNode>() {

                @Override
                public Object value_(final NamespaceNode _importNS) {
                    final st.gravel.support.jvm.runtime.AlmostFinalValue _sh;
                    final SharedDeclarationNode _shared;
                    _shared = _importNS.sharedVariableAt_ifAbsent_(_reference.name().asString(), ((st.gravel.support.jvm.Block0<SharedDeclarationNode>) (new st.gravel.support.jvm.Block0<SharedDeclarationNode>() {

                        @Override
                        public SharedDeclarationNode value() {
                            return (SharedDeclarationNode) null;
                        }
                    })));
                    if (_shared != null) {
                        throw new NonLocalReturn(SystemMapping.this.singletonAtReference_initialize_(_importNS.reference().$slash$(_reference.name()), _shared), _temp1);
                    }
                    st.gravel.support.jvm.runtime.AlmostFinalValue _temp2 = _singletonHolders.get(_importNS.reference().$slash$(_reference.name()));
                    _sh = ((st.gravel.support.jvm.runtime.AlmostFinalValue) _temp2);
                    if (_sh != null) {
                        throw new NonLocalReturn(_sh, _temp1);
                    }
                    return SystemMapping.this;
                }
            });
        }
        return _aBlock.value();
    } catch (NonLocalReturn nlr) {
        if (nlr.marker == _temp1) {
            return (st.gravel.support.jvm.runtime.AlmostFinalValue) nlr.returnValue;
        } else {
            throw nlr;
        }
    }
}
Also used : SharedDeclarationNode(st.gravel.support.compiler.ast.SharedDeclarationNode) NamespaceNode(st.gravel.support.compiler.ast.NamespaceNode) NonLocalReturn(st.gravel.support.jvm.NonLocalReturn)

Aggregations

NonLocalReturn (st.gravel.support.jvm.NonLocalReturn)3 ArrayLiteralNode (st.gravel.support.compiler.ast.ArrayLiteralNode)1 LiteralNode (st.gravel.support.compiler.ast.LiteralNode)1 NamespaceNode (st.gravel.support.compiler.ast.NamespaceNode)1 NilLiteralNode (st.gravel.support.compiler.ast.NilLiteralNode)1 PragmaNode (st.gravel.support.compiler.ast.PragmaNode)1 SharedDeclarationNode (st.gravel.support.compiler.ast.SharedDeclarationNode)1 StringLiteralNode (st.gravel.support.compiler.ast.StringLiteralNode)1 SymbolLiteralNode (st.gravel.support.compiler.ast.SymbolLiteralNode)1