failure on XVariableDeclaration resolution in XBaseInterpreter [message #858788] |
Fri, 27 April 2012 05:48  |
Eclipse User |
|
|
|
On a simple language which extends from XBase.
Module:
{Module}
'module' canonicalName=QualifiedName
(elements += XExpressionInsideBlock|elements+=Import)*
;
I wrote the following test which fails in the evaluation of s3:
IllegalStateException: Could not access field:test.s1
def void testParsingAndLinkingWithVars() {
val dsl = "
module test
val s1 = 'foo'
val s2 = 'bar'
val s3 = s1 + s2
"
parser.parse(dsl).assertNoErrors
val module = parser.parse(dsl)
val s1 = module.elements.get(0) as XVariableDeclaration
val s2 = module.elements.get(1) as XVariableDeclaration
val s3 = module.elements.get(2) as XVariableDeclaration
val evaluationContext = contextProvider.get()
evaluationContext.newValue(XbaseScopeProvider::THIS, module)
interpreter.evaluate(s1, evaluationContext, CancelIndicator::NullImpl)
interpreter.evaluate(s2, evaluationContext, CancelIndicator::NullImpl)
val s1val = evaluationContext.getValue(QualifiedName::create(s1.name))
val s2val = evaluationContext.getValue(QualifiedName::create(s2.name))
Assert::assertEquals(s1val, "foo")
Assert::assertEquals(s2val, "bar")
=>here=>interpreter.evaluate(s3, evaluationContext, CancelIndicator::NullImpl)
val s3val = evaluationContext.getValue(QualifiedName::create(s3.name))
Assert::assertEquals(s3val, "foobar")
}
I have an Inferer for Module:
acceptor.accept(module.toClass(module.fullyQualifiedName) [
for (element : module.elements) {
switch element {
XVariableDeclaration: {
members +=element.toField(element.name, element.getExpressionType)
}
}}])
As well as a simpleName provider:
def dispatch getSimpleName(JvmType element) {
return "this";
}
def dispatch getSimpleName(JvmIdentifiableElement element) {
return super.getSimpleName(element);
}
Still when it is trying to resolve s1, it wants to find it under name test.s1 not this.s1 or simply s1...
Perhaps it is to do with me test setup.. What am I missing?
[Updated on: Fri, 27 April 2012 05:57] by Moderator
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02967 seconds