use of st.gravel.support.compiler.ast.ClassDescriptionNode 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.ClassDescriptionNode in project gravel by gravel-st.
the class SystemNode method classNodes.
public Map<Reference, ClassNode> classNodes() {
final Map<Reference, ClassNode>[] _dict;
_dict = new Map[1];
_dict[0] = new java.util.HashMap<Reference, ClassNode>();
for (final ClassDescriptionNode _each : _classDescriptionNodes.values()) {
if (_each.isClassNode()) {
final ClassNode _cn;
_cn = ((ClassNode) _each);
_dict[0].put(_each.reference(), _cn);
}
}
return _dict[0];
}
use of st.gravel.support.compiler.ast.ClassDescriptionNode in project gravel by gravel-st.
the class UpdateClassDescriptorDiff method applyOnClassNode_.
public ClassDescriptionNode applyOnClassNode_(final ClassDescriptionNode _startClassNode) {
ClassDescriptionNode _classNode;
_classNode = ((ClassDescriptionNode) st.gravel.support.jvm.ArrayExtensions.inject_into_(_methodNodes, _startClassNode, ((st.gravel.support.jvm.Block2<ClassDescriptionNode, ClassDescriptionNode, MethodNode>) (new st.gravel.support.jvm.Block2<ClassDescriptionNode, ClassDescriptionNode, MethodNode>() {
@Override
public ClassDescriptionNode value_value_(final ClassDescriptionNode _cn, final MethodNode _m) {
return (ClassDescriptionNode) _cn.withMethodNode_(_m);
}
}))));
_classNode = ((ClassDescriptionNode) st.gravel.support.jvm.ArrayExtensions.inject_into_(_updatedMethodNodes, _classNode, ((st.gravel.support.jvm.Block2<ClassDescriptionNode, ClassDescriptionNode, MethodNode>) (new st.gravel.support.jvm.Block2<ClassDescriptionNode, ClassDescriptionNode, MethodNode>() {
@Override
public ClassDescriptionNode value_value_(final ClassDescriptionNode _cn, final MethodNode _m) {
return (ClassDescriptionNode) _cn.copyReplaceMethodNode_(_m);
}
}))));
return ((ClassDescriptionNode) st.gravel.support.jvm.ArrayExtensions.inject_into_(_deletedSelectors, _classNode, ((st.gravel.support.jvm.Block2<ClassDescriptionNode, ClassDescriptionNode, String>) (new st.gravel.support.jvm.Block2<ClassDescriptionNode, ClassDescriptionNode, String>() {
@Override
public ClassDescriptionNode value_value_(final ClassDescriptionNode _cn, final String _sel) {
return (ClassDescriptionNode) _cn.copyRemoveSelector_(_sel);
}
}))));
}
use of st.gravel.support.compiler.ast.ClassDescriptionNode in project gravel by gravel-st.
the class SimpleTraitUsageNode method allMethodsIn_do_.
@Override
public SimpleTraitUsageNode allMethodsIn_do_(final SystemNode _aSystemNode, final st.gravel.support.jvm.Block1<Object, MethodNode> _aBlock) {
final ClassDescriptionNode _trait;
_trait = _aSystemNode.classNodeAt_(_reference);
_trait.allMethodsIn_do_(_aSystemNode, _aBlock);
return this;
}
use of st.gravel.support.compiler.ast.ClassDescriptionNode in project gravel by gravel-st.
the class JVMClassCompiler method compileClassNode.
public JVMClass compileClassNode() {
final MethodNode[] _allMethods;
Reference _superclassReference;
BoundVariableDeclarationNode[] _allInstVars;
final MethodNode[] _localLinkedMethods;
ClassDescriptionNode _scn;
if (_ownerType == null) {
_ownerType = ((JVMDefinedObjectType) _selfType);
}
_allMethods = _classDescriptionNode.methods();
_superclassReference = _classDescriptionNode.superclassReference();
_allInstVars = _classDescriptionNode.boundInstVars();
boolean _temp1 = false;
while (!_temp1) {
_temp1 = _superclassReference == null;
if (!_temp1) {
_scn = _systemNode.classNodeAt_(_superclassReference);
_superclassReference = _scn.superclassReference();
_allInstVars = st.gravel.support.jvm.ArrayExtensions.copyWithAll_(_scn.boundInstVars(), _allInstVars);
}
}
_localLinkedMethods = _systemMappingUpdater.localLinkMethods_instVars_ownerReference_(_allMethods, _allInstVars, _classDescriptionNode.reference());
for (final MethodNode _each : _localLinkedMethods) {
JVMClassCompiler.this.compileMethod_(_each);
}
for (final VariableDeclarationNode _each : _classDescriptionNode.instVars()) {
_fields.add(JVMField.factory.ownerType_varName_type_isStatic_(_ownerType, _each.name(), TypeNodeToJVMTypeConverter.factory.namespace_(JVMClassCompiler.this.namespace()).visit_(_each.type()), false));
}
this.compileBlocks();
return this.createContainerClass();
}
Aggregations