You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ra...@apache.org on 2018/06/18 13:39:40 UTC

[sling-org-apache-sling-scripting-sightly-compiler-java] branch master updated (d664e69 -> e55b821)

This is an automated email from the ASF dual-hosted git repository.

radu pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-sightly-compiler-java.git.


    from d664e69  SLING-7701 - [HTL] Add support for negative numbers
     new 4a6ed26  SLING-7688 - [HTL] Add support for the in relational operator
     new e55b821  SLING-7682 - Add support for data-sly-list and data-sly-repeat iteration control

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 pom.xml                                            |  7 +--
 .../java/compiler/impl/GlobalShadowChecker.java    |  3 ++
 .../sightly/java/compiler/impl/JavaSource.java     |  4 ++
 .../java/compiler/impl/operator/InOpGen.java       | 50 ++++++++++++++++++++++
 .../java/compiler/impl/operator/Operators.java     |  1 +
 5 files changed, 62 insertions(+), 3 deletions(-)
 create mode 100644 src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/InOpGen.java

-- 
To stop receiving notification emails like this one, please contact
radu@apache.org.

[sling-org-apache-sling-scripting-sightly-compiler-java] 01/02: SLING-7688 - [HTL] Add support for the in relational operator

Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

radu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-sightly-compiler-java.git

commit 4a6ed26f84545f218133063d7f843282b613c2cb
Author: Radu Cotescu <ra...@apache.org>
AuthorDate: Tue May 29 15:16:48 2018 +0200

    SLING-7688 - [HTL] Add support for the in relational operator
---
 .../sightly/java/compiler/impl/JavaSource.java     |  4 ++
 .../java/compiler/impl/operator/InOpGen.java       | 50 ++++++++++++++++++++++
 .../java/compiler/impl/operator/Operators.java     |  1 +
 3 files changed, 55 insertions(+)

diff --git a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/JavaSource.java b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/JavaSource.java
index 680e340..cebb2ae 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/JavaSource.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/JavaSource.java
@@ -252,6 +252,10 @@ public class JavaSource {
         return property(className, "class").startCall("getName", true).endCall();
     }
 
+    public JavaSource instanceOf(String className) {
+        return append(" instanceof ").append(className);
+    }
+
     private StringBuilder indent() {
         for (int i = 0; i < indentLevel; i++) {
             builder.append(INDENT);
diff --git a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/InOpGen.java b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/InOpGen.java
new file mode 100644
index 0000000..c73c839
--- /dev/null
+++ b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/InOpGen.java
@@ -0,0 +1,50 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements.  See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership.  The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License.  You may obtain a copy of the License at
+ ~
+ ~   http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied.  See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+package org.apache.sling.scripting.sightly.java.compiler.impl.operator;
+
+import org.apache.sling.scripting.sightly.compiler.expression.nodes.BinaryOperator;
+import org.apache.sling.scripting.sightly.java.compiler.impl.ExpressionTranslator;
+import org.apache.sling.scripting.sightly.java.compiler.impl.JavaSource;
+import org.apache.sling.scripting.sightly.java.compiler.impl.SourceGenConstants;
+import org.apache.sling.scripting.sightly.java.compiler.impl.Type;
+
+/**
+ * Operator generator for {@link BinaryOperator#IN}.
+ */
+public class InOpGen implements BinaryOpGen {
+
+    @Override
+    public Type returnType(Type leftType, Type rightType) {
+        return Type.BOOLEAN;
+    }
+
+    @Override
+    public void generate(JavaSource source, ExpressionTranslator visitor, TypedNode left, TypedNode right) {
+        source.startMethodCall(BinaryOperator.class.getName(), "inOp");
+        left.getNode().accept(visitor);
+        source.separateArgument();
+        right.getNode().accept(visitor);
+        source.instanceOf("String").conditional();
+        right.getNode().accept(visitor);
+        source.conditionalBranchSep().objectModel().startCall(SourceGenConstants.ROM_TO_COLLECTION, true);
+        right.getNode().accept(visitor);
+        source.endCall();
+        source.endCall();
+    }
+}
diff --git a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/Operators.java b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/Operators.java
index a90e332..c445b29 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/Operators.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/operator/Operators.java
@@ -51,6 +51,7 @@ public class Operators {
         representationMap.put(BinaryOperator.GEQ, new ComparisonOpGen(BinaryOperator.GEQ));
         representationMap.put(BinaryOperator.STRICT_EQ, new StrictEqGenOp(false));
         representationMap.put(BinaryOperator.STRICT_NEQ, new StrictEqGenOp(true));
+        representationMap.put(BinaryOperator.IN, new InOpGen());
 
         unaryMapping.put(UnaryOperator.LENGTH, LengthOpGen.INSTANCE);
         unaryMapping.put(UnaryOperator.IS_WHITESPACE, IsWhiteSpaceGen.INSTANCE);

-- 
To stop receiving notification emails like this one, please contact
radu@apache.org.

[sling-org-apache-sling-scripting-sightly-compiler-java] 02/02: SLING-7682 - Add support for data-sly-list and data-sly-repeat iteration control

Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

radu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-sightly-compiler-java.git

commit e55b821e7e4fdd4e7efc3be51fd42be75ea30019
Author: Radu Cotescu <ra...@apache.org>
AuthorDate: Fri May 25 13:27:44 2018 +0200

    SLING-7682 - Add support for data-sly-list and data-sly-repeat iteration control
    
    * implemented code changes
    * updated HTL TCK module to current snapshot
---
 pom.xml                                                            | 7 ++++---
 .../scripting/sightly/java/compiler/impl/GlobalShadowChecker.java  | 3 +++
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/pom.xml b/pom.xml
index 9cc3684..1a46e5d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -35,7 +35,7 @@
         The versioning scheme defined here corresponds to SLING-7406 (<module_version>-<htl_specification_version>). Take care when
         releasing to only increase the first part, unless the module provides support for a newer version of the HTL specification.
     -->
-    <version>1.0.23-1.3.1-SNAPSHOT</version>
+    <version>1.0.23-1.4.0-SNAPSHOT</version>
     <packaging>bundle</packaging>
 
     <name>Apache Sling Scripting HTL Java Compiler</name>
@@ -82,7 +82,8 @@
                             io.sightly.compiler.java; version:Version=1.1,
                             io.sightly.compiler.java; version:Version=1.2,
                             io.sightly.compiler.java; version:Version=1.3,
-                            io.sightly.compiler.java; version:Version=1.3.1
+                            io.sightly.compiler.java; version:Version=1.3.1,
+                            io.sightly.compiler.java; version:Version=1.4.0
                         </Provide-Capability>
                     </instructions>
                 </configuration>
@@ -163,7 +164,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.scripting.sightly.compiler</artifactId>
-            <version>1.0.20-1.3.1</version>
+            <version>1.0.21-1.4.0-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
 
diff --git a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/GlobalShadowChecker.java b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/GlobalShadowChecker.java
index f3b8fd0..8e4b286 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/GlobalShadowChecker.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/impl/GlobalShadowChecker.java
@@ -57,6 +57,9 @@ public class GlobalShadowChecker extends AbstractCommandVisitor {
     public void visit(Loop.Start loopStart) {
         checkVariable(loopStart.getItemVariable());
         checkVariable(loopStart.getIndexVariable());
+        checkVariable(loopStart.getBeginVariable());
+        checkVariable(loopStart.getStepVariable());
+        checkVariable(loopStart.getEndVariable());
     }
 
     @Override

-- 
To stop receiving notification emails like this one, please contact
radu@apache.org.