summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorahaase2008-01-23 13:49:59 (EST)
committer ahaase2008-01-23 13:49:59 (EST)
commitfcad1d53d87a88a3b43ae2260600bbc958e921cc (patch)
tree31acfaa7b298d86371cb3c07d6b4a12b2831fcdf
parentbfd6799a8781e32fe02e56ed9e5ff6656271ad8b (diff)
downloadorg.eclipse.xpand-fcad1d53d87a88a3b43ae2260600bbc958e921cc.zip
org.eclipse.xpand-fcad1d53d87a88a3b43ae2260600bbc958e921cc.tar.gz
org.eclipse.xpand-fcad1d53d87a88a3b43ae2260600bbc958e921cc.tar.bz2
implemented isDeleteLine
-rw-r--r--plugins/org.eclipse.xtend.backend/todo.txt9
-rw-r--r--plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/OldDefinitionConverter.java38
-rw-r--r--plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/OldXpandRegistry.java3
3 files changed, 33 insertions, 17 deletions
diff --git a/plugins/org.eclipse.xtend.backend/todo.txt b/plugins/org.eclipse.xtend.backend/todo.txt
index c5c90f8..5c0d333 100644
--- a/plugins/org.eclipse.xtend.backend/todo.txt
+++ b/plugins/org.eclipse.xtend.backend/todo.txt
@@ -2,12 +2,13 @@ todo
----
Adapter für Xpand und Xtend
-BackendType.getStaticProperty???
+potential bug - EfficientLazyString is mutable || return value from cached function
UML typesystem
-make classes final where meaningful
Check: SourcePos-Infos in Fehlern, Exceptions in ExpressionBase ordentlich gewrappt
+logNullDeRef: log call stack including call parameters
+
Outlets: Funktionen "registerOutlet" parallel zu "file" --> Outlets registrieren (inkl. Default-Outlet),
Convenience mit Primitives und "richtige" Outlets. Outlet: Liefert Writer für identifizierenden
String (d.h. Filenamen)
@@ -20,7 +21,7 @@ Marker-Interface / Annotation "FunctionDefs" o.ä. --> generische Unterscheidung
JavaBeansType: Interfaces als Supertypen
-syslib
+syslib vervollständigen
testen, insbes. syslib
DefinitionType in FunctionType mergen
@@ -57,7 +58,6 @@ globale Type-Registry für alle zurückgegebenen Objekte --> nach beliebigem Rumre
Konzept für stufenweises Überschreiben - syslib --> built-in operation --> Extension (oder so)
-toString() überschreibbar, trotz lazy evaluation
Debugger: ein Source-Primitive kann aus mehreren Runtime-Primitives bestehen - in der RT
markieren, wo neuer Source-Primitive beginnt? Oder einfach Mapping in Rückrichtung
und vergleichen?
@@ -100,4 +100,5 @@ Konzept für FunctionType - braucht der Parametertypen!?
metaType etc.
EMF-Typesystem
setExecutionContext bei ExecutionContextAware nicht als exportierte Funktion behandeln
+toString() überschreibbar, trotz lazy evaluation
diff --git a/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/OldDefinitionConverter.java b/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/OldDefinitionConverter.java
index 2e5defb..c48c092 100644
--- a/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/OldDefinitionConverter.java
+++ b/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/OldDefinitionConverter.java
@@ -12,6 +12,7 @@ package org.eclipse.xtend.middleend.old;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -48,12 +49,14 @@ import org.eclipse.xtend.backend.expr.InvocationOnObjectExpression;
import org.eclipse.xtend.backend.expr.LiteralExpression;
import org.eclipse.xtend.backend.expr.LocalVarEvalExpression;
import org.eclipse.xtend.backend.expr.NewLocalVarDefExpression;
+import org.eclipse.xtend.backend.expr.SequenceExpression;
import org.eclipse.xtend.backend.functions.FunctionDefContextImpl;
import org.eclipse.xtend.backend.functions.SourceDefinedFunction;
import org.eclipse.xtend.backend.syslib.FileIoOperations;
import org.eclipse.xtend.backend.syslib.SysLibNames;
import org.eclipse.xtend.backend.types.builtin.ObjectType;
import org.eclipse.xtend.backend.util.SyntaxConstants;
+import org.eclipse.xtend.backend.xtendlib.XpandIsDeleteLine;
import org.eclipse.xtend.backend.xtendlib.XtendIterator;
import org.eclipse.xtend.backend.xtendlib.XtendLibNames;
import org.eclipse.xtend.expression.AnalysationIssue;
@@ -122,21 +125,22 @@ final class OldDefinitionConverter {
paramTypes.add (_typeConverter.convertToBackendType (pt));
}
- return new SourceDefinedFunction (def.getName(), paramNames, paramTypes, fdc, convertStatmentSequence (def.getBody(), def, referencedDefinitions), false, null);
+ return new SourceDefinedFunction (def.getName(), paramNames, paramTypes, fdc, convertStatementSequence (def.getBody(), def, referencedDefinitions), false, null);
}
finally {
_ctx = oldCtx;
}
}
-
- private ExpressionBase convertStatmentSequence (Statement[] statements, SyntaxElement oldPos, Set<XpandDefinitionName> referencedDefinitions) {
+
+ private ExpressionBase convertStatementSequence (Statement[] statements, SyntaxElement oldPos, Set<XpandDefinitionName> referencedDefinitions) {
final List<ExpressionBase> parts = new ArrayList<ExpressionBase> ();
-
+
for (Statement stmt: statements)
parts.add (convertStatement (stmt, referencedDefinitions));
-
+
return new ConcatExpression (parts, getSourcePos(oldPos));
}
+
private ExpressionBase convertStatement (Statement stmt, Set<XpandDefinitionName> referencedDefinitions) {
if (stmt instanceof ErrorStatement)
@@ -245,7 +249,7 @@ final class OldDefinitionConverter {
// forEach without an iterator
_ctx = (XpandExecutionContext) _ctx.cloneWithVariable (new Variable (varName, eleType));
try {
- body = convertStatmentSequence (stmt.getBody(), stmt, referencedDefinitions);
+ body = convertStatementSequence (stmt.getBody(), stmt, referencedDefinitions);
}
finally {
_ctx = oldContext;
@@ -262,7 +266,7 @@ final class OldDefinitionConverter {
_ctx = (XpandExecutionContext) _ctx.cloneWithVariable (new Variable (varName, eleType));
_ctx = (XpandExecutionContext) _ctx.cloneWithVariable (new Variable (stmt.getIteratorName().getValue(), _ctx.getTypeForName (IteratorType.TYPE_NAME)));
try {
- body = convertStatmentSequence (stmt.getBody(), stmt, referencedDefinitions);
+ body = convertStatementSequence (stmt.getBody(), stmt, referencedDefinitions);
}
finally {
_ctx = oldContext;
@@ -290,7 +294,7 @@ final class OldDefinitionConverter {
}
else {
// the else part is an IfStatement with null condition
- return convertStatmentSequence (stmt.getBody(), stmt, referencedDefinitions);
+ return convertStatementSequence (stmt.getBody(), stmt, referencedDefinitions);
}
}
@@ -304,7 +308,7 @@ final class OldDefinitionConverter {
try {
final ExpressionBase def = convertExpression (stmt.getVarValue());
- final ExpressionBase body = convertStatmentSequence (stmt.getBody(), stmt, referencedDefinitions);
+ final ExpressionBase body = convertStatementSequence (stmt.getBody(), stmt, referencedDefinitions);
if (oldContext.getVisibleVariables().containsKey (varName))
return new HidingLocalVarDefExpression (varName, def, body, getSourcePos (stmt));
@@ -317,7 +321,7 @@ final class OldDefinitionConverter {
}
private ExpressionBase convertFileStatement (FileStatement stmt, Set<XpandDefinitionName> referencedDefinitions) {
- final ExpressionBase body = convertStatmentSequence (stmt.getBody(), stmt, referencedDefinitions);
+ final ExpressionBase body = convertStatementSequence (stmt.getBody(), stmt, referencedDefinitions);
final ExpressionBase filename = convertExpression (stmt.getTargetFileName());
final Outlet outlet = _ctx.getOutput().getOutlet (stmt.getOutletName());
@@ -340,8 +344,18 @@ final class OldDefinitionConverter {
}
private ExpressionBase convertTextStatement (TextStatement stmt) {
- //TODO isDeleteLine
- return new LiteralExpression (stmt.getValue(), getSourcePos(stmt));
+ if (stmt.isDeleteLine()) {
+ final List<ExpressionBase> emptyParamList = Collections.emptyList();
+ final ExpressionBase registerExpression = new InvocationOnObjectExpression (XtendLibNames.DELETE_LINE_REGISTER, emptyParamList, getSourcePos(stmt));
+
+ final ExpressionBase markerExpression = new LiteralExpression (XpandIsDeleteLine.MARKER_FOR_IS_DELETE_LINE, getSourcePos(stmt));
+ final ExpressionBase contentExpression = new LiteralExpression (stmt.getValue(), getSourcePos (stmt));
+ final ExpressionBase concatExpression = new ConcatExpression (Arrays.asList(markerExpression, contentExpression), getSourcePos (stmt));
+
+ return new SequenceExpression (Arrays.asList(registerExpression, concatExpression), getSourcePos (stmt));
+ }
+ else
+ return new LiteralExpression (stmt.getValue(), getSourcePos(stmt));
}
diff --git a/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/OldXpandRegistry.java b/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/OldXpandRegistry.java
index 65ef7f7..b42623f 100644
--- a/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/OldXpandRegistry.java
+++ b/plugins/org.eclipse.xtend.middleend.old/src/org/eclipse/xtend/middleend/old/OldXpandRegistry.java
@@ -118,7 +118,8 @@ final class OldXpandRegistry {
for (String xpandFileName: xpandFileNames)
registerXpandFile (xpandFileName);
- // ... and register all registered extensions in this fdc
+ // ... and register all template definitions from these files. It is necessary to have them all registered to enable
+ // polymorphism - static type analysis does not find all potential matches.
for (String xpandFileName: xpandFileNames)
for (NamedFunction f: _functionsByResource.get (xpandFileName))
fdc.register(f);