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));
}
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()]));
}
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;
}
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());
}
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;
}
Aggregations