Package bm.vm

Examples of bm.vm.Instance


    protected Instance doMath( final Object val1, final Object val2 )
            throws VirtualMachineException
    {
        if( val1 instanceof FixedPoint )
        {
            final Instance instance =
                    getVirtualMachine().newInstance( "double" );
            instance.set(
                    "value",
                    ((FixedPoint) val1).sub( (FixedPoint) val2 )
            );
            return instance;
        }
        else if( val1 instanceof Long )
        {
            final Instance instance =
                    getVirtualMachine().newInstance( "long" );
            instance.set(
                    "value",
                    new Long(
                            ((Long) val1).longValue() -
                            ( (Long) val2 ).longValue()
                    )
            );
            return instance;
        }
        else if( val1 instanceof Integer )
        {
            final Instance instance =
                    getVirtualMachine().newInstance( "int" );
            instance.set(
                    "value",
                    new Integer(
                            ((Integer) val1).intValue() -
                            ( (Integer) val2 ).intValue()
                    )
            );
            return instance;
        }
        else if( val1 instanceof Short )
        {
            final Instance instance =
                    getVirtualMachine().newInstance( "short" );
            instance.set(
                    "value",
                    new Short( (short)
                            (((Short) val1).shortValue() -
                             ( (Short) val2 ).shortValue() )
                    )
            );
            return instance;
        }
        else
        {
            final Instance instance =
                    getVirtualMachine().newInstance( "byte" );
            instance.set(
                    "value",
                    new Byte( (byte)
                            (((Byte) val1).byteValue() -
                             ( (Byte) val2 ).byteValue() )
                    )
View Full Code Here


                terminated = true;
                return child.run();
            }
            else
            {
                final Instance retval = child.run();
                if( child.isTerminated() )
                {
                    terminated = true;
                    return retval;
                }
View Full Code Here

    public Instance run()
            throws VirtualMachineException
    {
        final Context context = getContext();
        condition.setContext( context );
        final Instance cond = condition.run();
        Instance retval = null;
        if( cond != null && Conversor.toBoolean( cond ) )
        {
            ifBranch.setContext( context );
            retval = ifBranch.run();
            terminated = ifBranch.isTerminated();
View Full Code Here

        else
        {
            final Context context = getContext();
            operand1.setContext( context );
            operand2.setContext( context );
            Instance value1 = operand1.run();
            Instance value2 = operand2.run();

            Object val1 = parseValue( value1 );
            Object val2 = parseValue( value2 );

            final int precission1 = ((Byte)
View Full Code Here

            {
                throw new VirtualMachineException( 0, "Division by zero" );
            }
            else
            {
                final Instance instance =
                        getVirtualMachine().newInstance( "double" );
                instance.set(
                        "value",
                        ((FixedPoint) val1).div( (FixedPoint) val2 )
                );
                return instance;
            }
        }
        else if( val1 instanceof Long )
        {
            if( ((Long) val2).longValue() == 0 )
            {
                throw new VirtualMachineException( 0, "Division by zero" );
            }
            else
            {
                final Instance instance =
                        getVirtualMachine().newInstance( "long" );
                instance.set(
                        "value",
                        new Long(
                                ((Long) val1).longValue() /
                                ( (Long) val2 ).longValue()
                        )
                );
                return instance;
            }
        }
        else if( val1 instanceof Integer )
        {
            if( ((Integer) val2).intValue() == 0 )
            {
                throw new VirtualMachineException( 0, "Division by zero" );
            }
            else
            {
                final Instance instance =
                        getVirtualMachine().newInstance( "int" );
                instance.set(
                        "value",
                        new Integer(
                                ((Integer) val1).intValue() /
                                ( (Integer) val2 ).intValue()
                        )
                );
                return instance;
            }
        }
        else if( val1 instanceof Short )
        {
            if( ((Short) val2).shortValue() == 0 )
            {
                throw new VirtualMachineException( 0, "Division by zero" );
            }
            else
            {
                final Instance instance =
                        getVirtualMachine().newInstance( "short" );
                instance.set(
                        "value",
                        new Short( (short)
                                (((Short) val1).shortValue() /
                                 ( (Short) val2 ).shortValue() )
                        )
                );
                return instance;
            }
        }
        else
        {
            if( ((Byte) val2).byteValue() == 0 )
            {
                throw new VirtualMachineException( 0, "Division by zero" );
            }
            else
            {
                final Instance instance =
                        getVirtualMachine().newInstance( "byte" );
                instance.set(
                        "value",
                        new Byte( (byte)
                                (((Byte) val1).byteValue() /
                                 ( (Byte) val2 ).byteValue() )
                        )
View Full Code Here

     */
    public Instance run()
            throws VirtualMachineException
    {
        target.setContext( getContext() );
        final Instance instance = target.run();
        if( instance == null )
        {
            throw new NullPointerException( "Instance is null" );
        }
        final Instance[] arguments = args != null ?
                                     new Instance[ args.size() ] :
                                     null;
        if( args != null )
        {
            final int length = args.size();
            for( int i = 0; i < length; i++ )
            {
                arguments[i] = ((Expression) args.elementAt( i )).run();
            }
        }
        return targetClass != null ?
               instance.invoke( targetClass, methodName, arguments ) :
               instance.invoke( methodName, arguments );
    }
View Full Code Here

    protected Instance doMath( final Object val1, final Object val2 )
            throws VirtualMachineException
    {
        if( val1 instanceof FixedPoint )
        {
            final Instance instance =
                    getVirtualMachine().newInstance( "double" );
            instance.set(
                    "value",
                    ((FixedPoint) val1).mult( (FixedPoint) val2 )
            );
            return instance;
        }
        else if( val1 instanceof Long )
        {
            final Instance instance =
                    getVirtualMachine().newInstance( "long" );
            instance.set(
                    "value",
                    new Long(
                            ((Long) val1).longValue() *
                            ( (Long) val2 ).longValue()
                    )
            );
            return instance;
        }
        else if( val1 instanceof Integer )
        {
            final Instance instance =
                    getVirtualMachine().newInstance( "int" );
            instance.set(
                    "value",
                    new Integer(
                            ((Integer) val1).intValue() *
                            ( (Integer) val2 ).intValue()
                    )
            );
            return instance;
        }
        else if( val1 instanceof Short )
        {
            final Instance instance =
                    getVirtualMachine().newInstance( "short" );
            instance.set(
                    "value",
                    new Short( (short)
                            (((Short) val1).shortValue() *
                             ( (Short) val2 ).shortValue() )
                    )
            );
            return instance;
        }
        else
        {
            final Instance instance =
                    getVirtualMachine().newInstance( "byte" );
            instance.set(
                    "value",
                    new Byte( (byte)
                            (((Byte) val1).byteValue() *
                             ( (Byte) val2 ).byteValue() )
                    )
View Full Code Here

    public Instance run()
            throws VirtualMachineException
    {
        final Context context = getContext();
        target.setContext( context );
        final Instance instance = target.run();
        return Conversor.toInstance( context, instance.get( propertyName ) );
    }
View Full Code Here

            operand2.setContext( context );
            final Boolean value = Conversor.toBoolean( operand1.run() ) &&
                   Conversor.toBoolean( operand2.run() ) ?
                         CoreConstants.TRUE :
                         CoreConstants.FALSE;
            Instance instance = null;
            try
            {
                instance = getVirtualMachine().newInstance( "boolean" );
                instance.set( "value", value );
            }
            catch( ScriptingClassNotFoundException e )
            {
            }
            return instance;
View Full Code Here

        {
            return null;
        }
        else if( item.equals( "true" ) )
        {
            final Instance instance =
                    getVirtualMachine().newInstance( "boolean" );
            instance.set( "value", CoreConstants.TRUE );
            return instance;
        }
        else if( item.equals( "false" ) )
        {
            final Instance instance =
                    getVirtualMachine().newInstance( "boolean" );
            instance.set( "value", CoreConstants.FALSE );
            return instance;
        }
        else
        {
            final Context context = getContext();
            if( context.contains( item ) )
            {
                return Conversor.toInstance( context, context.get( item ) );
            }
            else
            {
                final Instance thisInstance = (Instance) context.get( "this" );
                if( thisInstance.getScriptingClass().hasProperty( item ) )
                {
                    return Conversor.toInstance(
                            context,
                            thisInstance.get( item )
                    );
                }
                else
                {
                    throw new InvocationException(
View Full Code Here

TOP

Related Classes of bm.vm.Instance

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.