OW2 Consortium
Search OW2 Mail Archive: 

Advanced Search - Powered by Google


Mail Archive Home | fractal-commits List | April 2008 Index

<--  Date Index  --> <--  Thread Index  -->

[fractal-commits] [7560] trunk/fractaladl/juliac: Separating the core of Juliac (compiler) from the OO optimization level.


Title: [7560] trunk/fractaladl/juliac: Separating the core of Juliac (compiler) from the OO optimization level.
Revision
7560
Author
seintur
Date
2008-04-30 16:24:27 +0200 (Wed, 30 Apr 2008)

Log Message

Separating the core of Juliac (compiler) from the OO optimization level.
Ignoring some target/ directories.

Modified Paths

Added Paths

Removed Paths

Property Changed

Diff

Property changes: trunk/fractaladl/juliac/examples/advanced/helloworld-bin/assembly


Name: svn:ignore
   + target

Modified: trunk/fractaladl/juliac/examples/advanced/helloworld-bin/assembly/pom.xml (7559 => 7560)


--- trunk/fractaladl/juliac/examples/advanced/helloworld-bin/assembly/pom.xml	2008-04-30 14:15:44 UTC (rev 7559)
+++ trunk/fractaladl/juliac/examples/advanced/helloworld-bin/assembly/pom.xml	2008-04-30 14:24:27 UTC (rev 7560)
@@ -72,6 +72,13 @@
 					<types>example.hw.HelloWorld</types>
 					<!-- debug>true</debug -->
 				</configuration>
+				<dependencies>
+					<dependency>
+						<groupId>org.objectweb.fractal.fractaladl.juliac</groupId>
+						<artifactId>oo</artifactId>
+						<version>${project.version}</version>
+					</dependency>
+				</dependencies>
 			</plugin>
 		</plugins>
     </build>

Property changes: trunk/fractaladl/juliac/examples/advanced/helloworld-bin/code


Name: svn:ignore
   + target

Modified: trunk/fractaladl/juliac/examples/advanced/mix/pom.xml (7559 => 7560)


--- trunk/fractaladl/juliac/examples/advanced/mix/pom.xml	2008-04-30 14:15:44 UTC (rev 7559)
+++ trunk/fractaladl/juliac/examples/advanced/mix/pom.xml	2008-04-30 14:24:27 UTC (rev 7560)
@@ -71,6 +71,13 @@
 					<types>membrane.mix.HelloWorld</types>
 					<!-- debug>true</debug -->
 				</configuration>
+				<dependencies>
+					<dependency>
+						<groupId>org.objectweb.fractal.fractaladl.juliac</groupId>
+						<artifactId>oo</artifactId>
+						<version>${project.version}</version>
+					</dependency>
+				</dependencies>
 			</plugin>
         </plugins>
     </build>

Modified: trunk/fractaladl/juliac/examples/comanche/pom.xml (7559 => 7560)


--- trunk/fractaladl/juliac/examples/comanche/pom.xml	2008-04-30 14:15:44 UTC (rev 7559)
+++ trunk/fractaladl/juliac/examples/comanche/pom.xml	2008-04-30 14:24:27 UTC (rev 7560)
@@ -65,6 +65,13 @@
 					<types>example.comanche.Comanche</types>
 					<!-- debug>true</debug -->
 				</configuration>
+				<dependencies>
+					<dependency>
+						<groupId>org.objectweb.fractal.fractaladl.juliac</groupId>
+						<artifactId>oo</artifactId>
+						<version>${project.version}</version>
+					</dependency>
+				</dependencies>
 			</plugin>
         </plugins>
     </build>

Modified: trunk/fractaladl/juliac/examples/helloworld/pom.xml (7559 => 7560)


--- trunk/fractaladl/juliac/examples/helloworld/pom.xml	2008-04-30 14:15:44 UTC (rev 7559)
+++ trunk/fractaladl/juliac/examples/helloworld/pom.xml	2008-04-30 14:24:27 UTC (rev 7560)
@@ -65,6 +65,13 @@
 					<types>example.hw.HelloWorld</types>
 					<!-- debug>true</debug -->
 				</configuration>
+				<dependencies>
+					<dependency>
+						<groupId>org.objectweb.fractal.fractaladl.juliac</groupId>
+						<artifactId>oo</artifactId>
+						<version>${project.version}</version>
+					</dependency>
+				</dependencies>
 			</plugin>
 		</plugins>
     </build>

Modified: trunk/fractaladl/juliac/julia-mixed/oo/pom.xml (7559 => 7560)


--- trunk/fractaladl/juliac/julia-mixed/oo/pom.xml	2008-04-30 14:15:44 UTC (rev 7559)
+++ trunk/fractaladl/juliac/julia-mixed/oo/pom.xml	2008-04-30 14:24:27 UTC (rev 7560)
@@ -54,6 +54,13 @@
 					<types>primitive parametricPrimitive composite primitiveTemplate compositeTemplate</types>
 					<!-- debug>true</debug -->
 				</configuration>
+				<dependencies>
+					<dependency>
+						<groupId>org.objectweb.fractal.fractaladl.juliac</groupId>
+						<artifactId>oo</artifactId>
+						<version>${project.version}</version>
+					</dependency>
+				</dependencies>
 			</plugin>
 		</plugins>
     </build>

Added: trunk/fractaladl/juliac/opt/oo/.classpath (0 => 7560)


--- trunk/fractaladl/juliac/opt/oo/.classpath	                        (rev 0)
+++ trunk/fractaladl/juliac/opt/oo/.classpath	2008-04-30 14:24:27 UTC (rev 7560)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src/main/java"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/juliac-compiler"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/fractal-api-2.0.2"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/julia-runtime-2.5.2"/>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>

Added: trunk/fractaladl/juliac/opt/oo/.project (0 => 7560)


--- trunk/fractaladl/juliac/opt/oo/.project	                        (rev 0)
+++ trunk/fractaladl/juliac/opt/oo/.project	2008-04-30 14:24:27 UTC (rev 7560)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>juliac-opt-oo</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

Added: trunk/fractaladl/juliac/opt/oo/pom.xml (0 => 7560)


--- trunk/fractaladl/juliac/opt/oo/pom.xml	                        (rev 0)
+++ trunk/fractaladl/juliac/opt/oo/pom.xml	2008-04-30 14:24:27 UTC (rev 7560)
@@ -0,0 +1,24 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.objectweb.fractal.fractaladl.juliac.opt</groupId>
+        <artifactId>parent</artifactId>
+        <version>1.3-SNAPSHOT</version>
+    </parent>
+
+  <groupId>org.objectweb.fractal.fractaladl.juliac</groupId>
+  <artifactId>oo</artifactId>
+  <packaging>jar</packaging>
+  <name>Juliac OO Optimization Level</name>
+ 
+    <dependencies>
+        <dependency>
+            <groupId>org.objectweb.fractal.fractaladl.juliac</groupId>
+            <artifactId>compiler</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>
+
+</project>

Added: trunk/fractaladl/juliac/opt/oo/src/main/java/org/objectweb/fractal/adl/juliac/opt/oo/FCOOCtrlSourceCodeGenerator.java (0 => 7560)


--- trunk/fractaladl/juliac/opt/oo/src/main/java/org/objectweb/fractal/adl/juliac/opt/oo/FCOOCtrlSourceCodeGenerator.java	                        (rev 0)
+++ trunk/fractaladl/juliac/opt/oo/src/main/java/org/objectweb/fractal/adl/juliac/opt/oo/FCOOCtrlSourceCodeGenerator.java	2008-04-30 14:24:27 UTC (rev 7560)
@@ -0,0 +1,225 @@
+/***
+ * Juliac
+ * Copyright (C) 2007 INRIA, France Telecom, USTL
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Contact: Lionel.Seinturier@xxxxxxx
+ *
+ * Author: Lionel Seinturier
+ */
+
+package org.objectweb.fractal.adl.juliac.opt.oo;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.objectweb.fractal.adl.juliac.ControllerDesc;
+import org.objectweb.fractal.adl.juliac.InitializerSourceCodeGenerator;
+import org.objectweb.fractal.adl.juliac.Juliac;
+import org.objectweb.fractal.adl.juliac.JuliacLoader;
+import org.objectweb.fractal.adl.juliac.MembraneDesc;
+import org.objectweb.fractal.adl.juliac.NoSuchControllerDescriptorException;
+import org.objectweb.fractal.adl.juliac.OptLevelDefaultSourceCodeGenerator;
+import org.objectweb.fractal.api.type.ComponentType;
+import org.objectweb.fractal.api.type.InterfaceType;
+import org.objectweb.fractal.julia.loader.BasicLoader;
+import org.objectweb.fractal.julia.loader.Tree;
+
+/**
+ * This class generates the source code associated to Fractal components.
+ * The membrane implementation and the initializer implementation are generated.
+ * 
+ * The content, the interceptors and the controllers are kept in separate
+ * classes and the controllers are implemented with objects.
+ * 
+ * @author Lionel Seinturier <Lionel.Seinturier@xxxxxxx>
+ */
+public class FCOOCtrlSourceCodeGenerator extends OptLevelDefaultSourceCodeGenerator {
+    
+    public FCOOCtrlSourceCodeGenerator() {
+        super();
+    }
+    
+    // -----------------------------------------------------------------------
+    // Implementation of the FCSourceCodeGenerator interface
+    // -----------------------------------------------------------------------
+
+    /**
+     * Initialize this generator.
+     * 
+     * The initialization process is kept separated from the constructor in
+     * order to be able to customize the julia.config system property.
+     */
+    @Override
+    public void init() throws IOException {
+        JuliacLoader loader = Juliac.get().getJuliacLoader();
+        loader.loadConfigFile(BasicLoader.DEFAULT_CONFIGURATION);
+        super.init();
+    }
+
+    /**
+     * Generate the implementation of the membrane associated to a Fractal
+     * component.
+     * 
+     * @param ct                the component type
+     * @param ctrldesc          the component controller descriptor
+     * @param contentClassName  the name of the component content class
+     * @param context           contextual information
+     * @return                  data about the membrane implementation
+     */
+    public MembraneDesc generateMembraneImpl(
+        ComponentType ct, String ctrldesc, String contentClassName, Map<?,?> context )
+    throws IOException, NoSuchControllerDescriptorException {
+        
+        Juliac jc = Juliac.get();
+
+        /*
+         * Generate business and control interface implementations.
+         */
+        InterfaceType[] its = ct.getFcInterfaceTypes();
+        generateInterfaceImpl(its,ctrldesc);
+        InterfaceType[] membraneits = getMembraneType(ctrldesc,context);
+        generateInterfaceImpl(membraneits,ctrldesc);
+        
+        /*
+         * Generate controller implementations.
+         */
+        List<ControllerDesc> ctrlDescs = getCtrlsImplLayers(ctrldesc,context);        
+        for (ControllerDesc ctrlDesc : ctrlDescs) {
+            
+            List<String> ctrlImplLayers = ctrlDesc.getLayerImplNames();
+            String ctrlImplClassName = ctrlDesc.getImplName();
+            
+            if( ctrlImplClassName.startsWith("(") ) {
+                /*
+                 * Skip CloneableAttributeController implementations.
+                 * The controller implementation class name is in this case
+                 * something like:
+                 * 
+                 * ((attribute-controller org.objectweb.fractal.julia.conform.components.CAttributes))
+                 */
+                continue;
+            }
+            
+            if( ctrlImplLayers == null ) {
+                /*
+                 * Skip the case where the controller is a single class
+                 * (not obtained by mixing layers).
+                 */
+                continue;
+            }
+            
+            ctrlImplClassName = jc.getJuliacGeneratedStrongTypeName(ctrlImplClassName);
+            ctrlDesc.setImplName(ctrlImplClassName);
+            
+            // Avoid duplicate generation
+            if( ! jc.hasBeenGenerated(ctrlImplClassName) ) {
+                jc.mixAndGenerate(ctrlImplClassName,ctrlImplLayers);
+            }
+        }
+        
+        /*
+         * Prepare a membrane descriptor.
+         */
+        MembraneDesc md = new MembraneDesc(null,ctrldesc,membraneits,ctrlDescs);
+
+        /*
+         * Generate interceptor implementations.
+         * Interceptors must be generated after controllers as some interceptors
+         * (e.g. the lifecycle interceptor) use controller implementation
+         * class names.
+         */
+        setInterceptorSourceCodeGenerator(context,md);
+        generateInterceptorImpl(its,md);
+        generateInterceptorImpl(membraneits,md);
+        
+        return md;
+    }
+
+
+    // -----------------------------------------------------------------------
+    // Implementation of abstract methods defined in super classes
+    // -----------------------------------------------------------------------
+    
+    /**
+     * Return the source code generators for the initializer classes associated
+     * with this component source code generator.
+     */
+    protected InitializerSourceCodeGenerator[] getInitializerSourceCodeGenerators() {
+        return
+            new InitializerSourceCodeGenerator[]{
+                new InitializerOOCtrlSourceCodeGenerator()
+            };
+    }
+    
+
+    // ------------------------------------------------------------------
+    // Implementation specific
+    // ------------------------------------------------------------------
+    
+    /**
+     * Return the list of controller descriptors associated with the specified
+     * control membrane descriptor.
+     * 
+     * @param ctrldesc  the control membrane descriptor
+     * @param context   the contextual information
+     */
+    private List<ControllerDesc> getCtrlsImplLayers( String ctrldesc, Map<?,?> context )
+    throws NoSuchControllerDescriptorException {
+        
+        Tree[] ctrlTrees = getCtrlImplTrees(ctrldesc, context);
+        List<ControllerDesc> ctrlDescs = new ArrayList<ControllerDesc>();        
+        
+        for (int i = 0; i < ctrlTrees.length; i++) {
+            
+            Tree ctrlTree = ctrlTrees[i];
+            ControllerDesc ctrlDesc = null;
+            
+            if( ctrlTree.getSize() == 0 ) {
+                /*
+                 * Special case where the name of the controller implementation
+                 * is directly specified (not generated with
+                 * MixinClassGenerator).
+                 */
+                String name = ctrlTree.toString();
+                ctrlDesc = new ControllerDesc(name,null,null);
+            }
+            else {
+                Tree t = ctrlTree.getSubTree(0);
+                Tree[] ts = t.getSubTrees();
+                
+                /*
+                 * Skip
+                 * [0]: org.objectweb.fractal.julia.asm.MixinClassGenerator
+                 * [1]: class name (e.g. NameControllerImpl)
+                 */
+                String name = ts[1].toString();
+                List<String> layers = new ArrayList<String>();
+                for (int j = 2; j < ts.length; j++) {
+                    String s = ts[j].toString();
+                    layerInsert(layers,s);
+                }
+                ctrlDesc = new ControllerDesc(name,layers,ctrlTree);
+            }
+            ctrlDescs.add(ctrlDesc);
+        }
+        
+        return ctrlDescs;
+    }
+
+}

Added: trunk/fractaladl/juliac/opt/oo/src/main/java/org/objectweb/fractal/adl/juliac/opt/oo/InitializerOOCtrlSourceCodeGenerator.java (0 => 7560)


--- trunk/fractaladl/juliac/opt/oo/src/main/java/org/objectweb/fractal/adl/juliac/opt/oo/InitializerOOCtrlSourceCodeGenerator.java	                        (rev 0)
+++ trunk/fractaladl/juliac/opt/oo/src/main/java/org/objectweb/fractal/adl/juliac/opt/oo/InitializerOOCtrlSourceCodeGenerator.java	2008-04-30 14:24:27 UTC (rev 7560)
@@ -0,0 +1,315 @@
+/***
+ * Juliac
+ * Copyright (C) 2007 INRIA, France Telecom, USTL
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Contact: Lionel.Seinturier@xxxxxxx
+ *
+ * Author: Lionel Seinturier
+ */
+
+package org.objectweb.fractal.adl.juliac.opt.oo;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import org.objectweb.fractal.adl.juliac.ControllerDesc;
+import org.objectweb.fractal.adl.juliac.InitializerSourceCodeGenerator;
+import org.objectweb.fractal.adl.juliac.Utils;
+import org.objectweb.fractal.adl.juliac.proxy.AttributeSourceCodeGenerator;
+import org.objectweb.fractal.adl.juliac.proxy.ProxySourceCodeGenerator;
+import org.objectweb.fractal.adl.juliac.ucf.UnifiedClass;
+import org.objectweb.fractal.adl.juliac.ucf.UnifiedClassFactory;
+import org.objectweb.fractal.adl.juliac.ucf.UnifiedClassFactoryItf;
+import org.objectweb.fractal.adl.juliac.visit.MethodSourceCodeVisitor;
+import org.objectweb.fractal.api.Component;
+import org.objectweb.fractal.api.Interface;
+import org.objectweb.fractal.api.NoSuchInterfaceException;
+import org.objectweb.fractal.api.factory.InstantiationException;
+import org.objectweb.fractal.api.type.InterfaceType;
+import org.objectweb.fractal.julia.Controller;
+import org.objectweb.fractal.julia.InitializationContext;
+import org.objectweb.fractal.julia.factory.ChainedInstantiationException;
+import org.objectweb.fractal.julia.loader.Initializable;
+import org.objectweb.fractal.julia.loader.Tree;
+import org.objectweb.fractal.julia.type.BasicInterfaceType;
+
+/**
+ * Initializer generator for Fractal components with an object-oriented control
+ * membrane and where the content, the interceptors and the controllers are kept
+ * in separate classes.
+ * 
+ * @author Lionel Seinturier <Lionel.Seinturier@xxxxxxx>
+ */
+public class InitializerOOCtrlSourceCodeGenerator extends InitializerSourceCodeGenerator {
+    
+    public String getTargetClassName() {
+        String ctrlDesc = membraneDesc.getDescriptor();
+        String contentClassName = Utils.getContentClassName(ctrlDesc,contentDesc);
+        String membraneClassName = Utils.getMembraneClassName(ctrlDesc,contentClassName);
+        String initializerClassName = Utils.getInitializerClassName(ct,membraneClassName);
+       return initializerClassName;
+    }
+    
+    @Override
+    protected void generateGetFcControllerDescMethod( MethodSourceCodeVisitor mv ) {
+        mv.visit  ("      return \"");
+        mv.visit  (membraneDesc.getDescriptor());
+        mv.visitln("\";");
+    }
+    
+    @Override
+    protected void generateGetFcContentDescMethod( MethodSourceCodeVisitor mv ) {
+        mv.visit  ("      return ");
+        mv.visit  (Utils.javaifyContentDesc(contentDesc).toString());
+        mv.visitln(";");
+    }
+    
+    @Override
+    protected void generateNewFcContentMethod( MethodSourceCodeVisitor mv ) {        
+        
+        String ctrlDesc = membraneDesc.getDescriptor();
+        String contentClassName = Utils.getContentClassName(ctrlDesc,contentDesc);
+
+        mv.visit("    Object content = ");
+        if( contentClassName == null ) {
+            mv.visitln("null;");
+        }
+        else {
+            mv.visit  ("new ");
+            mv.visit  (contentClassName);
+            mv.visitln("();");
+        }
+        mv.visitln("    return content;");
+    }
+    
+    @Override
+    protected void generateNewFcInstanceMethod( MethodSourceCodeVisitor mv ) {
+        mv.visitln("    Object content = newFcContent();");
+        mv.visitln("    return newFcInstance(content);");
+    }        
+
+    @Override
+    protected void generateNewFcInstanceContentMethod( MethodSourceCodeVisitor mv ) {
+        
+        InterfaceType[] membraneits = membraneDesc.getCtrlItfTypes();
+        List<ControllerDesc> ctrlDescs = membraneDesc.getCtrlDescs();
+        
+        // Check the content
+        generateContentChecks(mv);
+
+        // Prepare an InitializationContext
+        mv.visitln("    "+InitializationContext.class.getName()+" ic = new "+InitializationContext.class.getName()+"();");
+        mv.visitln("    ic.controllers = new "+ArrayList.class.getName()+"();");
+        mv.visitln("    ic.interfaces = new "+HashMap.class.getName()+"();");
+        mv.visitln("    ic.internalInterfaces = new "+HashMap.class.getName()+"();");
+        
+        // Instantiate the content
+        generateInitializationContextForContent(mv);
+        
+        // Instantiate controllers
+        mv.visitln("    Object ctrl = null;");
+        mv.visitln("    "+Component.class.getName()+" compctrl = null;");
+        UnifiedClassFactoryItf ucf = UnifiedClassFactory.get();
+        UnifiedClass ucinitializable = ucf.create(Initializable.class.getName());
+        for (ControllerDesc ctrlDesc : ctrlDescs) {
+            String ctrlImplName = ctrlDesc.getImplName();
+            if( ctrlImplName.charAt(0) == '(' ) {
+                /*
+                 * Skip CloneableAttributeController implementations.
+                 * The controller implementation class name is in this case
+                 * something like:
+                 * 
+                 * ((attribute-controller org.objectweb.fractal.julia.conform.components.CAttributes))
+                 */
+                continue;
+            }
+            mv.visitln("    ic.controllers.add(ctrl = new "+ctrlImplName+"());");
+            UnifiedClass uc = ucf.create(ctrlImplName);
+            if( ucinitializable.isAssignableFrom(uc) ) {
+                Tree tree = ctrlDesc.getTree();
+                if( tree != null ) {
+                    mv.visitln("    "+Tree.class.getName()+" tree = "+Utils.javaify(tree)+';');
+                    mv.visitln("    try {");
+                    mv.visitln("      (("+Initializable.class.getName()+")ctrl).initialize(tree);");
+                    mv.visitln("    }");
+                    mv.visitln("    catch( Exception e ) {");
+                    mv.visitln("      throw new "+ChainedInstantiationException.class.getName()+"(e,null,\"\");");
+                    mv.visitln("    }");
+                }
+            }
+            mv.visitln("    if( ctrl instanceof "+Component.class.getName()+") {compctrl=("+Component.class.getName()+")ctrl;}");
+        }
+
+        InterfaceType compctrlit =
+            new BasicInterfaceType(
+                "component",Component.class.getName(),false,false,false);
+
+        // Interceptor
+        mv.visitln("    Object intercept = null;");
+        if( ! generateInterceptorCreation(mv,compctrlit,"compctrl") ) {
+            mv.visitln("    intercept = compctrl;");
+        }
+
+        // Component controller
+        ProxySourceCodeGenerator itfscg = getInterfaceSourceCodeGenerator(compctrlit);
+        String fcitfClassname = itfscg.getTargetClassName();
+        String itstring = Utils.javaify(compctrlit).toString();
+        mv.visit  ("    "+Interface.class.getName()+" proxy = ");
+        mv.visit  ("new "+fcitfClassname+"(");
+        mv.visitln("compctrl,\"component\","+itstring+",false,intercept);");
+        mv.visit  ("    "+Component.class.getName()+" proxyForCompCtrl = ");
+        mv.visitln("("+Component.class.getName()+") proxy;");
+        mv.visitln("    ic.interfaces.put(\"component\",proxy);");
+        
+        boolean attrimplgenerated = false;
+
+        // Controllers other than the component controller
+        for (int i=1; i < membraneits.length; i++) {
+            
+            String itname = membraneits[i].getFcItfName();
+            itfscg = getInterfaceSourceCodeGenerator(membraneits[i]);
+            fcitfClassname = itfscg.getTargetClassName();
+            itstring = Utils.javaify(membraneits[i]).toString();
+            
+            // Control external interface
+            if( itname.equals("/cloneable-attribute-controller") ) {
+                InterfaceType attrit = null;
+                try {
+                    attrit = ct.getFcInterfaceType("attribute-controller");
+                }
+                catch (NoSuchInterfaceException e) {
+                    throw new RuntimeException(e);
+                }
+                ProxySourceCodeGenerator attrscg =
+                    new AttributeSourceCodeGenerator(attrit,null,false,null);
+                String s = attrscg.getTargetClassName();
+                mv.visitln("    Object attrimpl = new "+s+"();");
+                attrimplgenerated = true;
+                mv.visit  ("    proxy = ");
+                mv.visit  ("new "+fcitfClassname+"(");
+                mv.visit  ("proxyForCompCtrl,\""+itname+"\","+itstring+",false,");
+                mv.visitln("attrimpl);");
+            }
+            else {
+                mv.visitln("    for( int i=0 ; i < ic.controllers.size() ; i++ ) {");
+                mv.visitln("      ctrl = ic.controllers.get(i);");
+                mv.visitln("      if( ctrl instanceof "+membraneits[i].getFcItfSignature()+" ) {");
+                mv.visitln("        break;");
+                mv.visitln("      }");
+                mv.visitln("      ctrl = null;");
+                mv.visitln("    }");
+                mv.visitln("    if( ctrl == null ) {");
+                mv.visitln("      if( content instanceof "+membraneits[i].getFcItfSignature()+") {");
+                mv.visitln("        ctrl = content;");
+                mv.visitln("      }");
+                mv.visitln("      else {");
+                mv.visitln("        throw new "+InstantiationException.class.getName()+"(\"No such controller implementing "+membraneits[i].getFcItfSignature()+"\");");
+                mv.visitln("      }");
+                mv.visitln("    }");                
+
+                // Interceptors
+                if( ! generateInterceptorCreation(mv,membraneits[i],"ctrl") ) {
+                    mv.visitln("    intercept = ctrl;");
+                }
+
+                mv.visit  ("    proxy = new "+fcitfClassname+"(");
+                mv.visit  ("proxyForCompCtrl,\""+itname+"\","+itstring+",false,");
+                mv.visitln("intercept);");
+            }
+            mv.visitln("    ic.interfaces.put(\""+itname+"\",proxy);");
+            
+            // Control internal interface
+            if( itname.equals("factory") ) {
+                InterfaceType intit = Utils.newSymetricInterfaceType(membraneits[i]);
+                itfscg = getInterfaceSourceCodeGenerator(intit);
+                fcitfClassname = itfscg.getTargetClassName();
+                itstring = Utils.javaify(intit).toString();
+                mv.visit  ("    proxy = ");
+                mv.visit  ("new "+fcitfClassname+"(");
+                mv.visit  ("proxyForCompCtrl,\""+itname+"\","+itstring);
+                mv.visitln(",true,intercept);");
+                mv.visitln("    ic.internalInterfaces.put(\""+itname+"\",proxy);");
+            }
+        }
+        
+        // Component type
+        InterfaceType[] its = ct.getFcInterfaceTypes();
+        InterfaceType[] fullits = new InterfaceType[ membraneits.length + its.length ];
+        System.arraycopy(membraneits, 0, fullits, 0, membraneits.length);
+        System.arraycopy(its, 0, fullits, membraneits.length, its.length);
+        mv.visitln("    ic.type = "+Utils.javaify(fullits)+";");
+        
+        // Business interfaces
+        for (int i = 0; i < its.length; i++) {
+            
+            String itname = its[i].getFcItfName();
+            
+            if( its[i].isFcCollectionItf() ) {
+                // Julia naming convention for collection interfaces
+                itname = "/collection/" + itname;
+            }
+
+            // Interceptors
+            if( ! generateInterceptorCreation(mv,its[i],"content") ) {
+                mv.visit("    intercept = ");
+                mv.visit( its[i].isFcClientItf() ? "null" : "content" );
+                mv.visitln(";");
+            }
+
+            // External interface
+            itfscg = getInterfaceSourceCodeGenerator(its[i]);
+            fcitfClassname = itfscg.getTargetClassName();
+            itstring = Utils.javaify(its[i]).toString();
+            mv.visit("    proxy = ");
+            mv.visit("new "+fcitfClassname+"(");
+            mv.visit("proxyForCompCtrl,\""+itname+"\","+itstring+",false,");
+            if( itname.equals("attribute-controller") && attrimplgenerated ) {
+                mv.visit("attrimpl");
+            }
+            else {
+                mv.visit("intercept");  // interceptor or content or null
+            }
+            mv.visitln(");");
+            mv.visitln("    ic.interfaces.put(\""+itname+"\",proxy);");
+            
+            // Internal interface
+            if( ! itname.equals("attribute-controller") ) {
+                InterfaceType intit = Utils.newSymetricInterfaceType(its[i]);
+                itfscg = getInterfaceSourceCodeGenerator(intit);
+                fcitfClassname = itfscg.getTargetClassName();
+                itstring = Utils.javaify(intit).toString();
+                mv.visit("    proxy = ");
+                mv.visit("new "+fcitfClassname+"(");
+                mv.visit("proxyForCompCtrl,\""+itname+"\","+itstring);
+                mv.visit(",true,intercept);");  // interceptor or content or null
+                mv.visitln("    ic.internalInterfaces.put(\""+itname+"\",proxy);");
+            }
+        }
+        
+        // Initialize controllers
+        mv.visitln("    for( int i=0 ; i < ic.controllers.size() ; i++ ) {");
+        mv.visitln("      ctrl = ic.controllers.get(i);");
+        mv.visitln("      if( ctrl instanceof "+Controller.class.getName()+" ) {");
+        mv.visitln("        (("+Controller.class.getName()+")ctrl).initFcController(ic);");
+        mv.visitln("      }");
+        mv.visitln("    }");
+        
+        // Return the fcinterface for the component controller
+        mv.visitln("    return proxyForCompCtrl;");
+    }
+}

Modified: trunk/fractaladl/juliac/opt/pom.xml (7559 => 7560)


--- trunk/fractaladl/juliac/opt/pom.xml	2008-04-30 14:15:44 UTC (rev 7559)
+++ trunk/fractaladl/juliac/opt/pom.xml	2008-04-30 14:24:27 UTC (rev 7560)
@@ -14,6 +14,7 @@
 	<packaging>pom</packaging>
 
 	<modules>
+		<module>oo</module>
 		<module>ultra-merge</module>
 	</modules>
 

Property changes: trunk/fractaladl/juliac/opt/ultra-merge


Name: svn:ignore
   + target

Modified: trunk/fractaladl/juliac/tests-conf/pom.xml (7559 => 7560)


--- trunk/fractaladl/juliac/tests-conf/pom.xml	2008-04-30 14:15:44 UTC (rev 7559)
+++ trunk/fractaladl/juliac/tests-conf/pom.xml	2008-04-30 14:24:27 UTC (rev 7560)
@@ -74,6 +74,13 @@
 							<genclass>target/test-classes</genclass>
 							<!-- debug>true</debug -->
 						</configuration>
+						<dependencies>
+							<dependency>
+								<groupId>org.objectweb.fractal.fractaladl.juliac</groupId>
+								<artifactId>oo</artifactId>
+								<version>${project.version}</version>
+							</dependency>
+						</dependencies>
 					</plugin>
 		
 					<!-- ============= -->


<--  Date Index  --> <--  Thread Index  -->

Reply via email to:

Powered by MHonArc.

Copyright © 2006-2007, OW2 Consortium | contact | webmaster.