Package nexj.core.scripting

Examples of nexj.core.scripting.Function


                     bMissing = true;

                     break;
                  }

                  Function fun = arg.getDefaultValueFunction();

                  if (fun == null)
                  {
                     bMissing = true;
View Full Code Here


      if (m_annotationMap != null)
      {
         for (Lookup2D.Iterator itr = m_annotationMap.valueIterator(); itr.hasNext();)
         {
            Function fun = (Function)itr.next();
            Instance instance = (Instance)itr.getKey1();

            instance.setAnnotation((String)itr.getKey2(),
               instance.getContext().getMachine().invoke(fun, instance, (Pair)null));
         }
View Full Code Here

    * @return The rules engine instance.
    */
   protected Instance getRulesEngine(Metaclass metaclass, Instance instance, String sName)
   {
      Object key = m_context.getPartitionedKey(createRuleSetKey(metaclass, sName));
      Function constructor = (Function)m_context.getGlobalCache().get(key);

      if (constructor == null)
      {
         boolean bSecureSaved = m_context.isSecure();

View Full Code Here

         {
            ThreadContextHolder.setContext(m_context);

            for (Lookup.Iterator iter = m_compensatorMap.valueIterator(); iter.hasNext();)
            {
               Function function = (Function)iter.next();

               try
               {
                  m_context.getMachine().invoke(function, Primitive.createInteger(nTxStatus), (Object[])null);
               }
View Full Code Here

         if (getValue(nOffset, machine) == null)
         {
            AttributeObject attribute = m_class.resolveAttribute(nOffset);
            Object value = machine.invoke(attribute.getInitializerFunction(), this, (Object[])null);
            Function setter = attribute.getSetterFunction();

            if (setter != null)
            {
               value = machine.invoke(setter, this, value, null);
            }
View Full Code Here

      if (selector instanceof Symbol)
      {
         machine.setArg(0, nArgCount, this);

         Function fun = machine.getGlobalEnvironment().findFunction(m_class, (Symbol)selector, nArgCount - 1);

         if (fun != null)
         {
            return fun.invoke(nArgCount, machine);
         }

         fun = m_class.resolveFunction((Symbol)selector, nArgCount - 1);

         if (fun != null)
         {
            return fun.invoke(nArgCount, machine);
         }

         throw new InvocationException("err.scripting.methodLookup",
            new Object[]{selector.toString(), Primitive.createInteger(nArgCount - 1), m_class.getName()});
      }

      if (selector instanceof ClassObject && nArgCount >= 1)
      {
         ClassObject classObject = (ClassObject)selector;

         selector = machine.getArg(1, nArgCount);

         if (selector instanceof Symbol)
         {
            machine.shiftArgs(1, nArgCount--);
            machine.setArg(0, nArgCount, this);

            Function fun = machine.getGlobalEnvironment().findFunction(classObject, (Symbol)selector, -nArgCount);

            if (fun != null)
            {
               return fun.invoke(nArgCount, machine);
            }

            fun = classObject.resolveBaseFunction((Symbol)selector, nArgCount - 1);

            if (fun != null)
            {
               return fun.invoke(nArgCount, machine);
            }

            throw new InvocationException("err.scripting.baseMethodLookup",
               new Object[]{selector.toString(), Primitive.createInteger(nArgCount - 1), classObject.getName()});
         }
View Full Code Here

    * Exposes members from ObjectOriented on a class object.
    * @param classObject The destination class object.
    */
   public static void addMembers(ClassObject classObject)
   {
      classObject.addMethod(":class", 0, false, new Function()
      {
         public boolean invoke(int nArgCount, Machine machine)
         {
            machine.returnValue(((ObjectOriented)machine.getArg(0, nArgCount)).getClassObject(), nArgCount);

            return false;
         }
      });

      classObject.addMethod(":understands?", 2, false, new Function()
      {
         public boolean invoke(int nArgCount, Machine machine)
         {
            int nMemberArgCount = ((Number)machine.getArg(2, nArgCount)).intValue();

            machine.returnValue(Boolean.valueOf(nMemberArgCount >= 0 &&
               ((ObjectOriented)machine.getArg(0, nArgCount)).getClassObject()
               .resolveFunction((Symbol)machine.getArg(1, nArgCount), nMemberArgCount) != null),
               nArgCount);

            return false;
         }
      });

      classObject.addMethod("initialize", 0, false, new Function()
      {
         public boolean invoke(int nArgCount, Machine machine)
         {
            ((ObjectOriented)machine.getArg(0, nArgCount)).initialize(machine);
            machine.returnValue(null, nArgCount);
View Full Code Here

    */
   public static void addMembers(ClassObject classObject)
   {
      MemberObject.addMembers(classObject);

      classObject.addMethod(":arg-count", 0, false, new Function()
      {
         public boolean invoke(int nArgCount, Machine machine)
         {
            machine.returnValue(Primitive.createInteger(((MethodObject)machine.getArg(0, nArgCount))
               .getArgCount()), nArgCount);

            return false;
         }
      });

      classObject.addMethod(":var-arg?", 0, false, new Function()
      {
         public boolean invoke(int nArgCount, Machine machine)
         {
            machine.returnValue(Boolean.valueOf(((MethodObject)machine.getArg(0, nArgCount)).isVarArg()), nArgCount);

            return false;
         }
      });

      classObject.addMethod(":function", 0, false, new Function()
      {
         public boolean invoke(int nArgCount, Machine machine)
         {
            machine.returnValue(((MethodObject)machine.getArg(0, nArgCount)).getFunction(), nArgCount);

View Full Code Here

    * Exposes members from NamedObject.
    * @param classObject The destination class object.
    */
   public static void addMembers(ClassObject classObject)
   {
      classObject.addMethod(":name", 0, false, new Function()
      {
         public boolean invoke(int nArgCount, Machine machine)
         {
            machine.returnValue(((NamedObject)machine.getArg(0, nArgCount)).getName(), nArgCount);

            return false;
         }
      });

      classObject.addMethod(":symbol", 0, false, new Function()
      {
         public boolean invoke(int nArgCount, Machine machine)
         {
            machine.returnValue(((NamedObject)machine.getArg(0, nArgCount)).getSymbol(), nArgCount);

View Full Code Here

      {
         body = new Pair(new Pair(Symbol.LAMBDA, new Pair(null, m_initializer)), body);
         setPosURLs(m_initializer, "initializer");
      }

      Function func = null;
      Compiler compiler = new Compiler();

      if (m_nLoopCount > 0)
      {
         Pair argTail = null;
View Full Code Here

TOP

Related Classes of nexj.core.scripting.Function

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.