Package org.openquark.cal.compiler

Examples of org.openquark.cal.compiler.ForeignFunctionInfo


        int nArguments = appChain.length - 1;
        Expression.Var var = appChain[0].asVar();
          
        // Check that the full number of arguments are supplied.
        ForeignFunctionInfo foreignFunctionInfo = var.getForeignFunctionInfo();
        PrimOps.PrimOpInfo info = null;
        info = PrimOps.fetchInfo (var.getName());
        int nExpectedArguments;
       
        if (info == null && foreignFunctionInfo == null) {
            //not a built-in primitive or a foreign function call
            return null;
        }
       
       
        if (info != null) { 
            nExpectedArguments = info.getArity ();
        } else
        if (foreignFunctionInfo != null) {
            try {
                nExpectedArguments = foreignFunctionInfo.getNArguments();
            } catch (UnableToResolveForeignEntityException ex) {
                throw new CodeGenerationException("Failed to resolve foreign method, field, or constructor.", ex);
            }
        } else {
            //not a built-in primitive or a foreign function call
View Full Code Here


            case T_ForeignFunctionCall:
            {
                // The ForeignFunctionInfo instance is saved as a qualified name
                // which can be used for a lookup into the ModuleTypeInfo at
                // load time.
                ForeignFunctionInfo ffi = (ForeignFunctionInfo)info;
                // CAL name of the foreign function
                s.writeQualifiedName(ffi.getCalName());
            }
            break;
               
            case T_Instrument:
            {
View Full Code Here

        }

        // Unpack the basic op into subexpressions
        final BasicOpTuple basicOpExpressions = BasicOpTuple.isBasicOp(e);

        final ForeignFunctionInfo foreignFunctionInfo = basicOpExpressions.getForeignFunctionInfo();
        final ForeignFunctionInfo.JavaKind kind = foreignFunctionInfo.getJavaKind();

        JavaExpression returnExpression = null;
        Block returnContext = new Block();

        if (kind.isMethod()) {
View Full Code Here

                    // We know that this is an unboxed argument to a CAL function.
                    // The unboxed value cannot be void.  If we are calling a foreign
                    // function with return type of void we can't do a direct call.  We
                    // need to call the CAL wrapper function which will return the CAL
                    // equivalent to void. i.e. Unit
                    ForeignFunctionInfo ffi = bot.getForeignFunctionInfo();
                    Class<?> foreignReturnType = SCJavaDefn.getJavaReturnType(ffi);

                    verifyUnboxType(unboxType, JavaTypeName.make(foreignReturnType));

View Full Code Here

                // Finally we need to be sure that the primitiveness of the operation/foreign function and the
                // desired unbox type match.  For example an operation that produces an int can either unbox to
                // an int or an Object.
                if (bot.getPrimitiveOp() == PrimOps.PRIMOP_FOREIGN_FUNCTION) {
                    // If this foreign SC is of type internal value we can't just get the unboxed value and pass
                    final ForeignFunctionInfo ffi = bot.getForeignFunctionInfo();
                    final Class<?> foreignReturnType = SCJavaDefn.getJavaReturnType(ffi);

                    // If this foreign SC is of type Prelude.CalValue we can't just get the unboxed value and pass
                    final boolean hasCalValueReturnType = isCalValueClass(foreignReturnType);
                    if (hasCalValueReturnType){
View Full Code Here

TOP

Related Classes of org.openquark.cal.compiler.ForeignFunctionInfo

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.