use of st.gravel.support.compiler.ast.Reference in project gravel by gravel-st.
the class ImageBootstrapperTest method testLookupClass.
@Test
public void testLookupClass() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
ImageBootstrapper.bootstrap();
systemMapping = ImageBootstrapper.systemMapping;
Reference ref = Reference.factory.value_("st.gravel.lang.Message class");
AbstractClassMapping meta = systemMapping.classMappingAtReference_(ref);
Object cl = systemMapping.singletonAtReference_(ref.nonmeta());
Method basicNew = cl.getClass().getMethod("basicNew");
Object instance = basicNew.invoke(cl);
Method r_class = instance.getClass().getMethod("r_class");
Object instanceClass = r_class.invoke(instance);
assertEquals(meta.identityClass(), instanceClass.getClass());
}
use of st.gravel.support.compiler.ast.Reference in project gravel by gravel-st.
the class MetaclassNode method superclassReferenceForMethodLookup.
@Override
public Reference superclassReferenceForMethodLookup() {
final Reference _csr;
_csr = _classNode.superclassReference();
if (_csr == null) {
return AbsoluteReference.factory.path_(new st.gravel.core.Symbol[] { st.gravel.core.Symbol.value("st"), st.gravel.core.Symbol.value("gravel"), st.gravel.core.Symbol.value("lang"), st.gravel.core.Symbol.value("Class") });
}
return ClassReference.factory.reference_(((AbsoluteReference) _csr));
}
use of st.gravel.support.compiler.ast.Reference in project gravel by gravel-st.
the class AbstractClassMapping method superclassMappingIn_.
public AbstractClassMapping superclassMappingIn_(final SystemMapping _aSystemMapping) {
final Reference _superclassReference;
_superclassReference = this.superclassReference();
if (_superclassReference == null) {
return null;
}
return _aSystemMapping.classMappingAtReference_(_superclassReference);
}
use of st.gravel.support.compiler.ast.Reference in project gravel by gravel-st.
the class SystemMapping method methodMappingFrom_selector_.
public AbstractMethodMapping methodMappingFrom_selector_(final ClassMapping _classMapping, final st.gravel.core.Symbol _sel) {
return _classMapping.methodMappingAt_ifAbsent_(_sel, ((st.gravel.support.jvm.Block0<AbstractMethodMapping>) (new st.gravel.support.jvm.Block0<AbstractMethodMapping>() {
@Override
public AbstractMethodMapping value() {
final Reference _superclassReference;
AbstractMethodMapping _mapping;
_superclassReference = _classMapping.superclassReferenceForMethodLookup();
if (_superclassReference == null) {
_mapping = null;
} else {
_mapping = SystemMapping.this.methodMappingFrom_selector_(((ClassMapping) SystemMapping.this.classMappingAtReference_(_superclassReference)), _sel);
}
return (AbstractMethodMapping) _mapping;
}
})));
}
use of st.gravel.support.compiler.ast.Reference 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