Search in sources :

Example 6 with AbsoluteReference

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

the class MetaclassNode method superclassReference.

@Override
public Reference superclassReference() {
    final Reference _csr;
    _csr = _classNode.superclassReference();
    if (_csr == null) {
        return null;
    }
    return ClassReference.factory.reference_(((AbsoluteReference) _csr));
}
Also used : Reference(st.gravel.support.compiler.ast.Reference) AbsoluteReference(st.gravel.support.compiler.ast.AbsoluteReference) ClassReference(st.gravel.support.compiler.ast.ClassReference) AbsoluteReference(st.gravel.support.compiler.ast.AbsoluteReference)

Example 7 with AbsoluteReference

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

the class DiskClassReader method readNamespace_namespace_.

public NamespaceNode readNamespace_namespace_(final java.io.File _aFilename, final String[] _namespaceStrings) {
    final Map<String, Object> _dict;
    final AbsoluteReference[] _publicImports;
    final AbsoluteReference[] _privateImports;
    final Object[] _publicImportStrings;
    final Object[] _privateImportStrings;
    final Map<String, String> _sharedVariableStrings;
    final List<SharedDeclarationNode>[] _sharedVariables;
    _sharedVariables = new List[1];
    _dict = this.readPropertiesFile_(_aFilename);
    Object _temp1 = _dict.get("publicImports");
    if (_temp1 == null) {
        _temp1 = new Object[] {};
    }
    _publicImportStrings = ((Object[]) _temp1);
    Object _temp2 = _dict.get("privateImports");
    if (_temp2 == null) {
        _temp2 = new Object[] {};
    }
    _privateImportStrings = ((Object[]) _temp2);
    Object _temp3 = _dict.get("sharedVariables");
    if (_temp3 == null) {
        _temp3 = new java.util.HashMap<String, String>();
    }
    _sharedVariableStrings = ((Map<String, String>) _temp3);
    _publicImports = st.gravel.support.jvm.ArrayExtensions.collect_(_publicImportStrings, ((st.gravel.support.jvm.Block1<AbsoluteReference, Object>) (new st.gravel.support.jvm.Block1<AbsoluteReference, Object>() {

        @Override
        public AbsoluteReference value_(final Object _obj) {
            final String _str;
            _str = ((String) _obj);
            return (AbsoluteReference) Reference.factory.value_(_str);
        }
    })));
    _privateImports = st.gravel.support.jvm.ArrayExtensions.collect_(_privateImportStrings, ((st.gravel.support.jvm.Block1<AbsoluteReference, Object>) (new st.gravel.support.jvm.Block1<AbsoluteReference, Object>() {

        @Override
        public AbsoluteReference value_(final Object _obj) {
            final String _str;
            _str = ((String) _obj);
            return (AbsoluteReference) Reference.factory.value_(_str);
        }
    })));
    _sharedVariables[0] = new java.util.ArrayList();
    for (final Map.Entry<String, String> _temp4 : _sharedVariableStrings.entrySet()) {
        String _name = _temp4.getKey();
        String _initializerString = _temp4.getValue();
        _sharedVariables[0].add(SharedDeclarationNode.factory.name_initializer_(_name, DiskClassReader.this.parseInitializerSource_(_initializerString)));
    }
    return NamespaceNode.factory.reference_publicImports_privateImports_sharedVariables_(AbsoluteReference.factory.path_(st.gravel.support.jvm.ArrayExtensions.collect_(_namespaceStrings, ((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);
        }
    })))), _publicImports, _privateImports, _sharedVariables[0].toArray(new SharedDeclarationNode[_sharedVariables[0].size()]));
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) AbsoluteReference(st.gravel.support.compiler.ast.AbsoluteReference) SharedDeclarationNode(st.gravel.support.compiler.ast.SharedDeclarationNode) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Example 8 with AbsoluteReference

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

the class DiskClassWriter method writeNamespace_in_.

public DiskClassWriter writeNamespace_in_(final NamespaceNode _aNamespaceNode, final java.io.File _aFilename) {
    final java.io.File _nsFn;
    final String _json;
    final Map<String, Object> _dict;
    final String[] _privateImports;
    final String[] _publicImports;
    final Map<String, String>[] _sharedVariables;
    _sharedVariables = new Map[1];
    _nsFn = ((java.io.File) st.gravel.support.jvm.ArrayExtensions.inject_into_(_aNamespaceNode.reference().path(), _aFilename, ((st.gravel.support.jvm.Block2<java.io.File, java.io.File, st.gravel.core.Symbol>) (new st.gravel.support.jvm.Block2<java.io.File, java.io.File, st.gravel.core.Symbol>() {

        @Override
        public java.io.File value_value_(final java.io.File _fn, final st.gravel.core.Symbol _each) {
            return (java.io.File) new java.io.File(_fn, _each.asString());
        }
    }))));
    _nsFn.mkdirs();
    _dict = new java.util.HashMap<String, Object>();
    _privateImports = st.gravel.support.jvm.ArrayExtensions.collect_(_aNamespaceNode.privateImports(), ((st.gravel.support.jvm.Block1<String, AbsoluteReference>) (new st.gravel.support.jvm.Block1<String, AbsoluteReference>() {

        @Override
        public String value_(final AbsoluteReference _each) {
            return (String) _each.toString();
        }
    })));
    _dict.put("privateImports", _privateImports);
    _publicImports = st.gravel.support.jvm.ArrayExtensions.collect_(_aNamespaceNode.publicImports(), ((st.gravel.support.jvm.Block1<String, AbsoluteReference>) (new st.gravel.support.jvm.Block1<String, AbsoluteReference>() {

        @Override
        public String value_(final AbsoluteReference _each) {
            return (String) _each.toString();
        }
    })));
    _dict.put("publicImports", _publicImports);
    _sharedVariables[0] = new java.util.HashMap<String, String>();
    for (final SharedDeclarationNode _each : _aNamespaceNode.sharedVariables()) {
        _sharedVariables[0].put(_each.name(), _each.initializer() == null ? null : _each.initializer().sourceString());
    }
    _dict.put("sharedVariables", _sharedVariables[0]);
    _json = st.gravel.support.jvm.DictionaryExtensions.asJSON(_dict);
    st.gravel.support.jvm.StringExtensions.writeToFile_(_json, new java.io.File(_nsFn, "properties.json"));
    return this;
}
Also used : AbsoluteReference(st.gravel.support.compiler.ast.AbsoluteReference) SharedDeclarationNode(st.gravel.support.compiler.ast.SharedDeclarationNode) HashMap(java.util.HashMap) Map(java.util.Map)

Example 9 with AbsoluteReference

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

the class MethodLinker method globalReadBootstrap.

public static CallSite globalReadBootstrap(Lookup lookup, String selector, MethodType type, String namespaceString) throws Throwable {
    AbsoluteReference namespace = (AbsoluteReference) Reference.factory.value_(namespaceString);
    AbsoluteReference fullReference = namespace.$slash$(Symbol.value(selector));
    final AlmostFinalValue singletonHolder = ImageBootstrapper.systemMapping.resolveSingletonHolder_(fullReference);
    return new ConstantCallSite(singletonHolder.createGetter());
}
Also used : AbsoluteReference(st.gravel.support.compiler.ast.AbsoluteReference) ConstantCallSite(java.lang.invoke.ConstantCallSite)

Example 10 with AbsoluteReference

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

the class SystemMappingUpdater method link.

public SystemMappingUpdater link() {
    _systemMapping.classMappingsDo_(new st.gravel.support.jvm.Block1<Object, AbstractClassMapping>() {

        @Override
        public Object value_(final AbstractClassMapping _acm) {
            if (_acm.classNode().isMeta()) {
                SystemMappingUpdater.this.initializeClassShareds_(((MetaclassNode) _acm.classNode()));
                return _systemMapping.singletonAtReference_ifAbsentPut_(_acm.reference().nonmeta(), new st.gravel.support.jvm.Block0<Object>() {

                    @Override
                    public Object value() {
                        return _compilerTools.createSingletonForClass_(_acm.identityClass());
                    }
                });
            }
            return SystemMappingUpdater.this;
        }
    });
    _compilerTools.resetCallsites();
    _systemMapping.namespaceGlobalsAndInitializersDo_(new st.gravel.support.jvm.Block2<Object, AbsoluteReference, SharedDeclarationNode>() {

        @Override
        public Object value_value_(final AbsoluteReference _reference, final SharedDeclarationNode _sharedVariable) {
            return _systemMapping.singletonAtReference_initialize_(_reference, _sharedVariable);
        }
    });
    for (final Reference _ref : _toInitialize) {
        _compilerTools.initializeClass_systemMapping_(((ClassMapping) _systemMapping.classMappingAtReference_(_ref)), _systemMapping);
    }
    _toInitialize = new java.util.ArrayList();
    return this;
}
Also used : List(java.util.List) ArrayList(java.util.ArrayList) ClassMapping(st.gravel.support.compiler.ast.ClassMapping) AbstractClassMapping(st.gravel.support.compiler.ast.AbstractClassMapping) AbsoluteReference(st.gravel.support.compiler.ast.AbsoluteReference) Reference(st.gravel.support.compiler.ast.Reference) AbsoluteReference(st.gravel.support.compiler.ast.AbsoluteReference) SharedDeclarationNode(st.gravel.support.compiler.ast.SharedDeclarationNode) ArrayList(java.util.ArrayList) AbstractClassMapping(st.gravel.support.compiler.ast.AbstractClassMapping)

Aggregations

AbsoluteReference (st.gravel.support.compiler.ast.AbsoluteReference)12 SharedDeclarationNode (st.gravel.support.compiler.ast.SharedDeclarationNode)6 HashMap (java.util.HashMap)5 Map (java.util.Map)5 Reference (st.gravel.support.compiler.ast.Reference)5 ArrayList (java.util.ArrayList)3 List (java.util.List)3 ConstantCallSite (java.lang.invoke.ConstantCallSite)2 ClassReference (st.gravel.support.compiler.ast.ClassReference)2 NamespaceNode (st.gravel.support.compiler.ast.NamespaceNode)2 MethodHandle (java.lang.invoke.MethodHandle)1 HashSet (java.util.HashSet)1 AbstractClassMapping (st.gravel.support.compiler.ast.AbstractClassMapping)1 ClassDescriptionNode (st.gravel.support.compiler.ast.ClassDescriptionNode)1 ClassMapping (st.gravel.support.compiler.ast.ClassMapping)1 ClassNode (st.gravel.support.compiler.ast.ClassNode)1