Skip to content

Commit

Permalink
Merge 1a983fa into 1921816
Browse files Browse the repository at this point in the history
  • Loading branch information
fdodino committed May 1, 2020
2 parents 1921816 + 1a983fa commit b4ad994
Show file tree
Hide file tree
Showing 32 changed files with 78 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,17 @@ class XDebugStackFrame implements Serializable {

def static toVariable(WVariable variable, EvaluationContext<WollokObject> context) {
if (allVariables.contains(variable)) {
return new XDebugStackFrameVariable(variable, null) // Evita que el listener entre en loop infinito por referencias circulares. Luego el diagrama de objetos enlaza los objetos por id interno.
// Evita que el listener entre en loop infinito por referencias circulares. (parte 1)
// Luego el diagrama de objetos enlaza los objetos por id interno.
return new XDebugStackFrameVariable(variable, null)
}
val value = allValues.get(variable)
if (value !== null) {
return new XDebugStackFrameVariable(variable, value)
}
allVariables.add(variable)
val newValue = context.resolve(variable.name)
allValues.put(variable, newValue)
new XDebugStackFrameVariable(variable, newValue)
val result = new XDebugStackFrameVariable(variable, newValue)
result
}

def static initAllVariables() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import org.eclipse.xtend.lib.annotations.Accessors
import org.uqbar.project.wollok.interpreter.context.WVariable
import org.uqbar.project.wollok.interpreter.core.WollokObject

import static org.uqbar.project.wollok.debugger.server.rmi.XDebugStackFrame.*
import static org.uqbar.project.wollok.sdk.WollokSDK.*

/**
Expand All @@ -20,7 +21,19 @@ class XDebugStackFrameVariable implements Serializable {

new(WVariable variable, WollokObject value) {
this.variable = variable
this.value = if (value === null) null else value.asRemoteValue
if (value === null) {
this.value = null
return
}
val valueIdentifier = value.call("identity").toString
val allVariableIds = XDebugStackFrame.allVariables.map [ id.toString ]
if (allVariableIds.contains(valueIdentifier)) {
this.value = null
} else {
allVariables.add(variable)
allValues.put(variable, value)
this.value = value.asRemoteValue
}
}

def asRemoteValue(WollokObject object) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@ abstract class XWollokCollectionDebugValue extends XDebugValue {
new(WollokObject collection, String concreteNativeType, String collectionType) {
super(collectionType, System.identityHashCode(collection))
this.concreteNativeType = concreteNativeType
var i = 0
val result = newArrayList
val elements = collection.getElements(concreteNativeType)
for (e : elements) {
result.add(new XDebugStackFrameVariable(new WVariable(i.getVariableName(collection, concreteNativeType), System.identityHashCode(e), false), e))
i++
}
elements.forEach [ element, i |
result.add(new XDebugStackFrameVariable(new WVariable(i.getVariableName(collection, concreteNativeType), System.identityHashCode(element), false), element))
]
variables = newArrayList(result)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import static extension org.uqbar.project.wollok.interpreter.core.ToStringBuilde
import static extension org.uqbar.project.wollok.model.WollokModelExtensions.*
import static extension org.uqbar.project.wollok.utils.WollokObjectUtils.*
import static extension org.uqbar.project.wollok.sdk.WollokSDK.*
import static org.uqbar.project.wollok.WollokConstants.*

/**
* A stack frame variable's value that holds a wollok object.
Expand All @@ -29,11 +30,11 @@ class XWollokObjectDebugValue extends XDebugValue {

def static description(WollokObject obj) {
if (obj.isBasicType) {
obj.asString("toSmartString",obj)
obj.asString(TO_STRING_PRINTABLE)
}
else {
if (obj.hasShortDescription)
obj.asString("shortDescription")
obj.asString(TO_STRING_SHORT)
else obj.shortLabel
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ import org.uqbar.project.wollok.launch.WollokLauncher
import org.uqbar.project.wollok.wollokDsl.WFile

import static org.uqbar.project.wollok.launch.Messages.*
import static org.uqbar.project.wollok.sdk.WollokSDK.*

import static extension org.uqbar.project.wollok.errorHandling.WollokExceptionExtensions.*
import static extension org.uqbar.project.wollok.model.WollokModelExtensions.*
import static org.uqbar.project.wollok.WollokConstants.*

/**
*
Expand Down Expand Up @@ -144,12 +146,8 @@ class WollokRepl {
}

def dispatch doPrintReturnValue(WollokObject wo) {
println(wo?.call("printString").toString.returnStyle)
}

// Unused
def dispatch doPrintReturnValue(String obj) {
println(('"' + obj + '"').returnStyle)
val toStringMethod = if (wo.kind.fqn.equals(STRING)) TO_STRING_PRINTABLE else TO_STRING
println(wo?.call(toStringMethod).toString.returnStyle)
}

def parseRepl(CharSequence content, File mainFile) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class WBoolean extends AbstractJavaWrapper<Boolean> {

@NativeMessage("toString")
def wollokToString() { wrapped.toString }
def toSmartString(Object alreadyShown) { wollokToString }

@NativeMessage("==")
def wollokEquals(WollokObject other) {
Expand Down
25 changes: 12 additions & 13 deletions org.uqbar.project.wollok.lib/src/wollok/lang/WString.xtend
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ class WString extends AbstractJavaWrapper<String> {
def dispatch WollokObject doConcatWith(WString o) { newInstanceWithWrapped(this.wrapped + o.wrapped) }
def dispatch WollokObject doConcatWith(WollokObject it) { convertToWString.asWString.doConcatWith }

def startsWith(String other) {
other.checkNotNull("startsWith")
wrapped.startsWith(other)
def startsWith(String prefix) {
prefix.checkNotNull("startsWith")
wrapped.startsWith(prefix)
}

def endsWith(String other) {
other.checkNotNull("endsWith")
wrapped.endsWith(other)
def endsWith(String suffix) {
suffix.checkNotNull("endsWith")
wrapped.endsWith(suffix)
}

def indexOf(String other) {
Expand All @@ -54,9 +54,9 @@ class WString extends AbstractJavaWrapper<String> {
result
}

def contains(String other) {
other.checkNotNull("contains")
wrapped.contains(other)
def contains(String element) {
element.checkNotNull("contains")
wrapped.contains(element)
}

def toLowerCase() { wrapped.toLowerCase }
Expand All @@ -69,15 +69,14 @@ class WString extends AbstractJavaWrapper<String> {
wrapped.substring(index.coerceToPositiveInteger)
}

def substring(BigDecimal startIndex, BigDecimal length) {
def substring(BigDecimal startIndex, BigDecimal endIndex) {
startIndex.checkNotNull("substring")
length.checkNotNull("substring")
wrapped.substring(startIndex.coerceToPositiveInteger, length.coerceToPositiveInteger)
endIndex.checkNotNull("substring")
wrapped.substring(startIndex.coerceToPositiveInteger, endIndex.coerceToPositiveInteger)
}

@NativeMessage("toString")
def wollokToString() { wrapped.toString }
def toSmartString(Object alreadyShown) { '"' + wollokToString + '"' }

@NativeMessage("<")
def lessThan(WollokObject other) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ class WollokObjectComparator implements Comparator<WollokObject> {
}

static def defaultOrderingKey(WollokObject object) {
object.kind.fqn + object.toString + object.hashCode
}
object.kind.fqn + object.hashCode
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@
<repository location="http://dl.bintray.com/wollok/sgit-update-site/"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
<repository location="https://ci.eclipse.org/xpect/job/Xpect/job/master/lastSuccessfulBuild/artifact/org.eclipse.xpect.releng/p2-repository/target/repository/"/>
<unit id="org.eclipse.xpect.sdk.feature.group" version="0.2.0.201907311039"/>
<unit id="org.eclipse.xpect.xtext.lib.feature.feature.group" version="0.2.0.201907311039"/>
<unit id="org.eclipse.xpect.xtext.xbase.lib.feature.feature.group" version="0.2.0.201907311039"/>
<repository location="https://ci.eclipse.org/xpect/job/Xpect/job/release_0.2.0/lastBuild/artifact/org.eclipse.xpect.releng/p2-repository/target/repository/"/>
<unit id="org.eclipse.xpect.sdk.feature.group" version="0.2.0.v20190619"/>
<unit id="org.eclipse.xpect.xtext.lib.feature.feature.group" version="0.2.0.v20190619"/>
<unit id="org.eclipse.xpect.xtext.xbase.lib.feature.feature.group" version="0.2.0.v20190619"/>
</location>
</locations>
<targetJRE path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class RecursiveToStringTestCase extends AbstractWollokInterpreterTestCase {
obj2.setY(obj1)
obj1.addX(new Prb())
assert.equals('obj2[y=obj1[x=[obj2, a Prb[]]]]', obj2.toString())
assert.equals('obj2', obj2.toString())
}
'''.interpretPropagatingErrors
}
Expand Down Expand Up @@ -70,7 +70,7 @@ class RecursiveToStringTestCase extends AbstractWollokInterpreterTestCase {
cuenta.duenios().add(duenio)
cuenta.metodoInexistente()
} catch e {
assert.equals("a Cuenta[duenios=[a Duenio[cuentas=[a Cuenta]]]] does not understand metodoInexistente()", e.message())
assert.equals("a Cuenta does not understand metodoInexistente()", e.message())
}
}
'''.interpretPropagatingErrors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,23 @@ class MixinsTestCase extends AbstractWollokInterpreterTestCase {
}

@Test
def void toString1() {
def void toStringMixedMethodContainer1Mixin() {
'''
«toStringFixture»
test "toString de un mixed method container con 1 mixin" {
const pm = new Persona() with EnvejeceDoble
assert.equals(pm.toString(), "Persona with EnvejeceDoble[edad=10]")
assert.equals(pm.toString(), "Persona with EnvejeceDoble")
}
'''.interpretPropagatingErrors
}

@Test
def void toString2() {
def void toStringMixedContainerWith2Mixins() {
'''
«toStringFixture»
test "toString de un mixed method container con 2 mixins" {
const pm = new Persona() with EnvejeceDoble with EnvejeceTriple
assert.equals(pm.toString(), "Persona with EnvejeceDoble with EnvejeceTriple[edad=10]")
assert.equals(pm.toString(), "Persona with EnvejeceDoble with EnvejeceTriple")
}
'''.interpretPropagatingErrors
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ class WollokLibraryHealthyTest extends AbstractWollokInterpreterTestCase {
.filter[severity == Severity.ERROR && code != 'OBJECT_NAME_MUST_START_LOWERCASE']
.forEach[ sb.append(severity).append(":").append(message).append(" ").append(uri).append(":").append(lineNumber).append(System.lineSeparator) ]
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ program natives {
assert.equals(1, true)
} catch e {
assert.equals(e.getStackTraceAsString(),
"wollok.lib.AssertionException: Expected [1] but found [true]
"wollok.lib.AssertionException: Expected <1> but found <true>
at wollok.lib.assert.equals(expected,actual) [/lib.wlk:72]
at [/assertTest.wpgm:3]
"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ class ObjectTest extends AbstractWollokInterpreterTestCase {
program p {
const perro = new Perro()
assert.equals('a Perro[nombre="Colita", edad=7]', perro.toString())
assert.equals('casa[ambientes=3, direccion="San Juan 1234"]', casa.toString())
assert.equals('a Perro', perro.toString())
assert.equals('casa', casa.toString())
const anonymousObject = object {
var edad = 23
var altura = 2
}
assert.equals("an Object[altura=2, edad=23]", anonymousObject.toString())
assert.equals("an Object", anonymousObject.toString())
}
'''.interpretPropagatingErrors
}
Expand All @@ -48,7 +48,7 @@ class ObjectTest extends AbstractWollokInterpreterTestCase {
}
program p {
assert.equals("persona[altura=1.7, edad=23]", persona.toString())
assert.equals("persona", persona.toString())
}
'''.interpretPropagatingErrors
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ object dateTests {
// XPECT methodType at m18 --> (Date, Date) => Boolean
method m18(_date, _date1) = _date.between(_date1, new Date())

// XPECT methodType at m19 --> (List<Object>) => String
method m19(b) = new Date().toSmartString(b)

// XPECT methodType at m20 --> (Date) => Number
method m20(_date) = _date.day() + _date.internalDayOfWeek() + _date.month() + _date.year()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,6 @@ object numberTest {
return a.isPrime()
}

// XPECT methodType at m28 --> (Number, List<Object>) => String
method m28(n, b) = n.coerceToInteger().internalToSmartString(b)

// XPECT methodType at m29 --> () => String
method m29() = 4.4.simplifiedToSmartString()

// XPECT methodType at m30 --> (Number) => String
method m30(n) = n.stringValue()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,6 @@ object objectTests {
// XPECT methodType at errorObject --> (Object, String) => Void
method errorObject(o, message) = o.error(message)


// XPECT methodType at toSmartString --> (Object, List<Object>) => String
method toSmartString(o, alreadyShown) = o.toSmartString(alreadyShown)

// XPECT methodType at internalToSmartStringObject --> (Object, List<Object>) => String
method internalToSmartStringObject(o, alreadyShown) = o.internalToSmartString(alreadyShown)

// XPECT methodType at simplifiedToSmartString --> (Object) => String
method simplifiedToSmartString(o) = o.simplifiedToSmartString()

// XPECT methodType at messageNotUnderstood --> (Object, String, List<Object>) => Void
method messageNotUnderstood(o, name, parameters) = o.messageNotUnderstood(name, parameters)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ object instanceVariableMirrorTest {
// XPECT methodType at value --> () => Any
method value() = self.construction(null, null).value()

// XPECT methodType at valueToSmartString --> (InstanceVariableMirror, List<Object>) => String
method valueToSmartString(mirror, alreadyShown) = mirror.valueToSmartString(alreadyShown)
// XPECT methodType at valueToString --> (InstanceVariableMirror) => String
method valueToString(mirror) = mirror.valueToString()
}

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@ class DateTypeDeclarations extends TypeDeclarations {
Date >> "between" === #[Date, Date] => Boolean
// Private
Date >> "initialize" === #[] => Void;
Date >> "toSmartString" === #[Boolean] => String;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ class WollokCoreTypeDeclarations extends TypeDeclarations {
O >> "className" === #[] => String;
O >> "error" === #[String] => Void;
/* privates */
O >> "toSmartString" === #[List.of(Object)] => String
O >> "internalToSmartString" === #[List.of(Object)] => String
O >> "simplifiedToSmartString" === #[] => String
O >> "messageNotUnderstood" === #[String, List.of(Object)] => Void
O >> "generateDoesNotUnderstandMessage" === #[String, String, Number] => String
/* introspection */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class WollokLibTypeDeclarations extends TypeDeclarations {
InstanceVariableMirror.variable("target", Object)
InstanceVariableMirror.variable("name", String)
InstanceVariableMirror >> "value" === #[] => T //TODO: should return variable type
InstanceVariableMirror >> "valueToSmartString" === #[List.of(Object)] => String
InstanceVariableMirror >> "valueToString" === #[] => String

StringPrinter >> "println" === #[T] => Void
StringPrinter >> "getBuffer" === #[] => String
Expand Down
Loading

0 comments on commit b4ad994

Please sign in to comment.