use of st.gravel.support.compiler.ast.SystemDefinitionNode in project gravel by gravel-st.
the class ClassBuilder method build.
public Class build() {
Map<String, String> _properties = new HashMap<>();
VariableDeclarationNode[] _instVars = instVars.toArray(new VariableDeclarationNode[instVars.size()]);
VariableDeclarationNode[] _classInstVars = new VariableDeclarationNode[0];
MethodNode[] _methods = methods.toArray(new MethodNode[methods.size()]);
MethodNode[] _classMethods = classMethods.toArray(new MethodNode[classMethods.size()]);
Symbol[] _namespace = new Symbol[] { Symbol.value("ClassBuilder") };
ClassNode classNode = ClassNode.factory.name_superclassPath_properties_instVars_classInstVars_sharedVariables_methods_classMethods_namespace_isExtension_isTrait_traitUsage_classTraitUsage_(Symbol.value(name), superclassName, _properties, _instVars, _classInstVars, new SharedDeclarationNode[0], _methods, _classMethods, _namespace, false, false, EmptyTraitUsageNode.factory.basicNew(), EmptyTraitUsageNode.factory.basicNew());
SystemDefinitionNode systemDefinitionNode = ImageBootstrapper.systemMapping.systemDefinitionNode();
ImageBootstrapper.systemMapping.updateTo_(systemDefinitionNode.withPackageNamed_classNode_(Symbol.value(name), classNode));
return ImageBootstrapper.systemMapping.classMappingAtReference_(classNode.reference()).identityClass();
}
use of st.gravel.support.compiler.ast.SystemDefinitionNode 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()));
}
Aggregations