use of st.gravel.support.compiler.ast.PackageNode in project gravel by gravel-st.
the class SystemDefinitionNode method classNodeAt_ifAbsent_.
public ClassNode classNodeAt_ifAbsent_(final Reference _reference, final st.gravel.support.jvm.Block0<ClassNode> _aBlock) {
final ClassNode[] _cn;
_cn = new ClassNode[1];
for (final PackageNode _each : _packageNodes) {
_cn[0] = _each.classNodeAt_ifAbsent_(_reference, ((st.gravel.support.jvm.Block0<ClassNode>) (new st.gravel.support.jvm.Block0<ClassNode>() {
@Override
public ClassNode value() {
return (ClassNode) null;
}
})));
if (_cn[0] != null) {
return _cn[0];
}
}
return _aBlock.value();
}
use of st.gravel.support.compiler.ast.PackageNode in project gravel by gravel-st.
the class SystemDefinitionNode method copyUpdatePackage_do_.
public SystemDefinitionNode copyUpdatePackage_do_(final st.gravel.core.Symbol _packageName, final st.gravel.support.jvm.Block1<PackageNode, PackageNode> _aBlock) {
final int _idx;
final PackageNode _updatedPackage;
_idx = st.gravel.support.jvm.ArrayExtensions.indexWhere_(_packageNodes, new st.gravel.support.jvm.Predicate1<PackageNode>() {
@Override
public boolean value_(final PackageNode _pkg) {
return st.gravel.support.jvm.ObjectExtensions.equals_(_pkg.name(), _packageName);
}
});
_updatedPackage = _aBlock.value_(_packageNodes[_idx - 1]);
return this.copy().pvtSetPackageNodes_(st.gravel.support.jvm.ArrayExtensions.copyAt_put_(_packageNodes, _idx, _updatedPackage));
}
use of st.gravel.support.compiler.ast.PackageNode in project gravel by gravel-st.
the class ClassDescriptionMirror method compile_classified_.
public Object compile_classified_(String source, String protocol) {
final MethodNode method = Parser.factory.parseMethod_(source).withProtocol_(protocol);
ClassDescriptionNode currentClassNode = definitionClassNode();
final MethodNode current = currentClassNode.methodOrNilAt_(method.selector());
Symbol targetPackageName = current == null ? definitionClassNode().packageName() : current.packageName();
if (targetPackageName == null) {
targetPackageName = definitionClassNode().packageName();
if (targetPackageName == null) {
targetPackageName = current.packageName();
}
}
SystemDefinitionNode newSystem = ImageBootstrapper.systemMapping.systemDefinitionNode().copyUpdatePackage_do_(targetPackageName, new Block1<PackageNode, PackageNode>() {
@Override
public PackageNode value_(PackageNode packageNode) {
return packageNode.copyUpdateClassNode_do_(definitionClassNode().reference(), new Block1<ClassNode, ClassNode>() {
@Override
public ClassNode value_(ClassNode classNode) {
return current == null ? classNode.withMethodNode_(method) : classNode.copyReplaceMethodNode_(method);
}
});
}
});
ImageBootstrapper.systemMapping.updateTo_(newSystem);
return getMethodMirror(Symbol.value(method.selector()));
}
use of st.gravel.support.compiler.ast.PackageNode in project gravel by gravel-st.
the class DiskClassReader method read.
public SystemDefinitionNode read() {
final List<PackageNode>[] _coll;
_coll = new List[1];
_coll[0] = new java.util.ArrayList();
for (final String _packageName : _root.list()) {
_coll[0].add(DiskClassReader.this.readPackage_(_packageName));
}
return SystemDefinitionNode.factory.packageNodes_(_coll[0].toArray(new PackageNode[_coll[0].size()]));
}
Aggregations