use of st.gravel.support.compiler.ast.AbsoluteReference in project gravel by gravel-st.
the class SystemMapping method namespaceGlobalsAndInitializersDo_.
public SystemMapping namespaceGlobalsAndInitializersDo_(final st.gravel.support.jvm.Block2<Object, AbsoluteReference, SharedDeclarationNode> _aBlock) {
for (final Map.Entry<Reference, NamespaceNode> _temp1 : _systemNode.namespaceNodes().entrySet()) {
Reference _reference = _temp1.getKey();
NamespaceNode _namespaceNode = _temp1.getValue();
for (final SharedDeclarationNode _sharedVariable : _namespaceNode.sharedVariables()) {
_aBlock.value_value_(((AbsoluteReference) _reference).$slash$(st.gravel.core.Symbol.value(_sharedVariable.name())), _sharedVariable);
}
}
return this;
}
use of st.gravel.support.compiler.ast.AbsoluteReference in project gravel by gravel-st.
the class SystemMappingUpdater method initializeClassShareds_.
public SystemMappingUpdater initializeClassShareds_(final MetaclassNode _aMetaclassNode) {
for (final SharedDeclarationNode _sharedVariable : _aMetaclassNode.sharedVariables()) {
final AbsoluteReference _reference;
_reference = _aMetaclassNode.reference().nonmeta().$slash$(st.gravel.core.Symbol.value(_sharedVariable.name()));
_systemMapping.singletonAtReference_initialize_(_reference, _sharedVariable);
}
return this;
}
use of st.gravel.support.compiler.ast.AbsoluteReference in project gravel by gravel-st.
the class PackageNodeMerger method load.
public SystemNode load() {
final Map<Reference, ClassNode>[] _classNodes;
final Map<Reference, ClassDescriptionNode>[] _classDescriptionNodes;
final Map<Reference, NamespaceNode>[] _namespaceNodes;
_classDescriptionNodes = new Map[1];
_classNodes = new Map[1];
_namespaceNodes = new Map[1];
_classNodes[0] = new java.util.HashMap<Reference, ClassNode>();
_namespaceNodes[0] = new java.util.HashMap<Reference, NamespaceNode>();
this.packageClassNodesDo_(new st.gravel.support.jvm.Block1<Object, ClassNode>() {
@Override
public Object value_(final ClassNode _classNode) {
if (!_classNode.isExtension()) {
final Reference _reference;
_reference = _classNode.reference();
if (_classNodes[0].containsKey(_reference)) {
throw new RuntimeException("Class " + _reference.toString() + " defined twice");
}
return _classNodes[0].put(_reference, _classNode);
}
return PackageNodeMerger.this;
}
});
this.packageClassNodesDo_(new st.gravel.support.jvm.Block1<Object, ClassNode>() {
@Override
public Object value_(final ClassNode _classNode) {
if (_classNode.isExtension()) {
final Reference _reference;
_reference = _classNode.reference();
if (!_classNodes[0].containsKey(_reference)) {
throw new RuntimeException("Can\'t extend Class " + _reference.toString() + "; not defined yet");
}
return _classNodes[0].put(_reference, _classNodes[0].get(_reference).mergedWithExtension_(_classNode));
}
return PackageNodeMerger.this;
}
});
_classDescriptionNodes[0] = new java.util.HashMap<Reference, ClassDescriptionNode>();
for (final ClassNode _classNode : _classNodes[0].values()) {
_classDescriptionNodes[0].put(_classNode.reference(), _classNode);
_classDescriptionNodes[0].put(_classNode.metaclassNode().reference(), _classNode.metaclassNode());
}
this.packageNamespaceNodesDo_(new st.gravel.support.jvm.Block1<Object, NamespaceNode>() {
@Override
public Object value_(final NamespaceNode _namespaceNode) {
final Reference _reference;
_reference = _namespaceNode.reference();
if (_namespaceNodes[0].containsKey(_reference)) {
return _namespaceNodes[0].put(_reference, _namespaceNode.mergeWith_(_namespaceNodes[0].get(_reference)));
} else {
return _namespaceNodes[0].put(_reference, _namespaceNode);
}
}
});
for (final Reference _ref : _classNodes[0].keySet()) {
final AbsoluteReference _namespace;
_namespace = _ref.namespace();
NamespaceNode _temp1 = _namespaceNodes[0].get(_namespace);
if (_temp1 == null) {
NamespaceNode _temp2 = NamespaceNode.factory.for_(_namespace);
_namespaceNodes[0].put(_namespace, _temp2);
_temp1 = _temp2;
}
}
return SystemNode.factory.classDescriptionNodes_namespaceNodes_(_classDescriptionNodes[0], _namespaceNodes[0]).flattenTraits();
}
use of st.gravel.support.compiler.ast.AbsoluteReference in project gravel by gravel-st.
the class NamespaceNode method mergeWith_.
public NamespaceNode mergeWith_(final NamespaceNode _aNamespaceNode) {
final List<AbsoluteReference>[] _nPublic;
final List<AbsoluteReference>[] _nPrivate;
final Map<String, SharedDeclarationNode>[] _nSharedVariables;
_nSharedVariables = new Map[1];
_nPrivate = new List[1];
_nPublic = new List[1];
_nPublic[0] = new java.util.ArrayList();
_nPrivate[0] = new java.util.ArrayList();
_nSharedVariables[0] = new java.util.HashMap<String, SharedDeclarationNode>();
for (final AbsoluteReference _each : _aNamespaceNode.publicImports()) {
if (!_nPublic[0].contains(_each)) {
_nPublic[0].add(_each);
}
}
for (final AbsoluteReference _each : _publicImports) {
if (!_nPublic[0].contains(_each)) {
_nPublic[0].add(_each);
}
}
for (final AbsoluteReference _each : _aNamespaceNode.privateImports()) {
if (!(_nPublic[0].contains(_each) || _nPrivate[0].contains(_each))) {
_nPrivate[0].add(_each);
}
}
for (final AbsoluteReference _each : _privateImports) {
if (!(_nPublic[0].contains(_each) || _nPrivate[0].contains(_each))) {
_nPrivate[0].add(_each);
}
}
for (final SharedDeclarationNode _each : _sharedVariables) {
_nSharedVariables[0].put(_each.name(), _each);
}
for (final SharedDeclarationNode _each : _aNamespaceNode.sharedVariables()) {
_nSharedVariables[0].put(_each.name(), _each);
}
return this.withPrivateImports_publicImports_sharedVariables_(_nPrivate[0].toArray(new AbsoluteReference[_nPrivate[0].size()]), _nPublic[0].toArray(new AbsoluteReference[_nPublic[0].size()]), _nSharedVariables[0].values().toArray(new SharedDeclarationNode[_nSharedVariables[0].size()]));
}
use of st.gravel.support.compiler.ast.AbsoluteReference in project gravel by gravel-st.
the class NamespaceNode method allImportsIn_do_.
public NamespaceNode allImportsIn_do_(final SystemNode _aSystemNode, final st.gravel.support.jvm.Block1<Object, NamespaceNode> _aBlock) {
final java.util.Set<AbsoluteReference> _aSet;
_aSet = new java.util.HashSet();
_aSet.add(_reference);
_aBlock.value_(this);
this.allImportsIn_private_except_do_(_aSystemNode, true, _aSet, _aBlock);
return this;
}
Aggregations