Package org.openquark.cal.runtime

Examples of org.openquark.cal.runtime.ErrorInfo


        Expression[] argumentExpressions = new Expression [nArguments];
        for (int i = 0; i < nArguments; ++i) {
            argumentExpressions[i] = appChain[i+1];
        }
       
        ErrorInfo errorInfo = null;
        if (var.getErrorInfo() != null){
            Expression.ErrorInfo ei = var.getErrorInfo();
            errorInfo = new ErrorInfo(ei.getTopLevelFunctionName(), ei.getLine(), ei.getColumn());
        }
        return new BasicOpTuple (info == null ? PrimOps.PRIMOP_FOREIGN_FUNCTION : info.getCode(), foreignFunctionInfo, errorInfo, argumentExpressions, var.getName());                    
    }   
View Full Code Here


        try{       
            CALServicesTestUtilities.runNamedFunction(QualifiedName.make(CALPlatformTestModuleNames.ErrorTest, "k1"), calServices);
            fail( "This should have failed" );
        }
        catch(CALExecutorException.ExternalException.ErrorFunctionException e){
            ErrorInfo errorInfo = e.getErrorInfo();
            assertNotNull(errorInfo);
            // The compiler seems to mess up source positions so I can use the exact position
            assertEquals(QualifiedName.make(CALPlatformTestModuleNames.ErrorTest, "k1"), errorInfo.getTopLevelFunctionName());
            assertEquals(81, errorInfo.getLine());
            assertEquals(5, errorInfo.getColumn());
        }
       
        try{       
            CALServicesTestUtilities.runNamedFunction(QualifiedName.make(CALPlatformTestModuleNames.ErrorTest, "k2"), calServices);
            fail( "This should have failed" );
        }
        catch(CALExecutorException.ExternalException.ErrorFunctionException e){
            // The compiler seems to mess up source positions so I can use the exact position
            ErrorInfo errorInfo = e.getErrorInfo();
            assertNotNull(errorInfo);
            // The compiler seems to mess up source positions so I can use the exact position
            assertEquals(QualifiedName.make(CALPlatformTestModuleNames.ErrorTest, "k2"), errorInfo.getTopLevelFunctionName());
            assertEquals(86, errorInfo.getLine());
            assertEquals(5, errorInfo.getColumn());
        }
       
        try{       
            CALServicesTestUtilities.runNamedFunction(QualifiedName.make(CALPlatformTestModuleNames.ErrorTest, "k3"), calServices);
            fail( "This should have failed" );
        }
        catch(CALExecutorException.ExternalException.ErrorFunctionException e){
            // The compiler seems to mess up source positions so I can use the exact position
            ErrorInfo errorInfo = e.getErrorInfo();
            assertNotNull(errorInfo);
            // The compiler seems to mess up source positions so I can use the exact position
            assertEquals(QualifiedName.make(CALPlatformTestModuleNames.ErrorTest, "k3"), errorInfo.getTopLevelFunctionName());
            assertEquals(96, errorInfo.getLine());
            assertEquals(5, errorInfo.getColumn());
        }
       
        try{       
            CALServicesTestUtilities.runNamedFunction(QualifiedName.make(CALPlatformTestModuleNames.ErrorTest, "j"), calServices);
            fail( "This should have failed" );
        }
        catch(CALExecutorException.ExternalException.ErrorFunctionException e){
            ErrorInfo errorInfo = e.getErrorInfo();
            assertNotNull(errorInfo);
            // The compiler seems to mess up source positions so I can use the exact position
            assertEquals(QualifiedName.make(CALPlatformTestModuleNames.ErrorTest, "j"), errorInfo.getTopLevelFunctionName());
            assertEquals(105, errorInfo.getLine());
            assertEquals(12, errorInfo.getColumn());
        }
               
        try{       
            CALServicesTestUtilities.runNamedFunction(QualifiedName.make(CALPlatformTestModuleNames.ErrorTest, "m"), calServices);
            fail( "This should have failed" );
        }
        catch(CALExecutorException.ExternalException.ErrorFunctionException e){
            // This does not have position information because the call is evaluated lazily.
            ErrorInfo errorInfo = e.getErrorInfo();
            assertNotNull(errorInfo);
            // The compiler seems to mess up source positions so I can use the exact position
            assertEquals(QualifiedName.make(CALPlatformTestModuleNames.ErrorTest, "m"), errorInfo.getTopLevelFunctionName());
            assertEquals(118, errorInfo.getLine());
            assertEquals(9, errorInfo.getColumn());
        }

        try{       
            CALServicesTestUtilities.runNamedFunction(QualifiedName.make(CALPlatformTestModuleNames.ErrorTest, "n"), calServices);
            fail( "This should have failed" );
        }
        catch(CALExecutorException.ExternalException.ErrorFunctionException e){
            // This does not have position information because the call is evaluated lazily.
            ErrorInfo errorInfo = e.getErrorInfo();
            assertNotNull(errorInfo);
            // The compiler seems to mess up source positions so I can use the exact position
            assertEquals(QualifiedName.make(CALPlatformTestModuleNames.ErrorTest, "n"), errorInfo.getTopLevelFunctionName());
            assertEquals(122, errorInfo.getLine());
            assertEquals(8, errorInfo.getColumn());
        }

        try{       
            CALServicesTestUtilities.runNamedFunction(QualifiedName.make(CALPlatformTestModuleNames.ErrorTest, "o"), calServices);
            fail( "This should have failed" );
        }
        catch(CALExecutorException.ExternalException.ErrorFunctionException e){
            // This does not have position information because the call is evaluated lazily.
            ErrorInfo errorInfo = e.getErrorInfo();
            assertNotNull(errorInfo);
            // The compiler seems to mess up source positions so I can use the exact position
            assertEquals(QualifiedName.make(CALPlatformTestModuleNames.ErrorTest, "o"), errorInfo.getTopLevelFunctionName());
            assertEquals(132, errorInfo.getLine());
            assertEquals(9, errorInfo.getColumn());
        }

        try{       
            CALServicesTestUtilities.runNamedFunction(QualifiedName.make(CALPlatformTestModuleNames.ErrorTest, "p"), calServices);
            fail( "This should have failed" );
        }
        catch(CALExecutorException.ExternalException.ErrorFunctionException e){
            // This does not have position information because the call is evaluated lazily.
            ErrorInfo errorInfo = e.getErrorInfo();
            assertNotNull(errorInfo);
            // The compiler seems to mess up source positions so I can use the exact position
            assertEquals(QualifiedName.make(CALPlatformTestModuleNames.ErrorTest, "p"), errorInfo.getTopLevelFunctionName());
            assertEquals(136, errorInfo.getLine());
            assertEquals(10, errorInfo.getColumn());
        }

        try{       
            CALServicesTestUtilities.runNamedFunction(QualifiedName.make(CALPlatformTestModuleNames.ErrorTest, "q"), calServices);
            fail( "This should have failed" );
        }
        catch(CALExecutorException.ExternalException.ErrorFunctionException e){
            // This does not have position information because the call is evaluated lazily.
            ErrorInfo errorInfo = e.getErrorInfo();
            assertNotNull(errorInfo);
            // The compiler seems to mess up source positions so I can use the exact position
            assertEquals(QualifiedName.make(CALPlatformTestModuleNames.ErrorTest, "q"), errorInfo.getTopLevelFunctionName());
            assertEquals(143, errorInfo.getLine());
            assertEquals(10, errorInfo.getColumn());
        }

        try{       
            CALServicesTestUtilities.runNamedFunction(QualifiedName.make(CALPlatformTestModuleNames.ErrorTest, "r"), calServices);
            fail( "This should have failed" );
        }
        catch(CALExecutorException.ExternalException.ErrorFunctionException e){
            // This does not have position information because the call is evaluated lazily.
            ErrorInfo errorInfo = e.getErrorInfo();
            assertNotNull(errorInfo);
            // The compiler seems to mess up source positions so I can use the exact position
            assertEquals(QualifiedName.make(CALPlatformTestModuleNames.ErrorTest, "r"), errorInfo.getTopLevelFunctionName());
            assertEquals(149, errorInfo.getLine());
            assertEquals(13, errorInfo.getColumn());
        }

        try{       
            CALServicesTestUtilities.runNamedFunction(QualifiedName.make(CALPlatformTestModuleNames.ErrorTest, "s"), calServices);
            fail( "This should have failed" );
        }
        catch(CALExecutorException.ExternalException.ErrorFunctionException e){
            ErrorInfo errorInfo = e.getErrorInfo();
            assertNotNull(errorInfo);
            // The compiler seems to mess up source positions so I can use the exact position
            assertEquals(QualifiedName.make(CALPlatformTestModuleNames.ErrorTest, "s"), errorInfo.getTopLevelFunctionName());
            assertEquals(156, errorInfo.getLine());
            assertEquals(9, errorInfo.getColumn());
        }

        try{       
            CALServicesTestUtilities.runNamedFunction(QualifiedName.make(CALPlatformTestModuleNames.ErrorTest, "t"), calServices);
            fail( "This should have failed" );
        }
        catch(CALExecutorException.ExternalException.ErrorFunctionException e){
            // This does not have position information because the call is evaluated lazily.
            ErrorInfo errorInfo = e.getErrorInfo();
            assertNotNull(errorInfo);
            // The compiler seems to mess up source positions so I can use the exact position
            assertEquals(QualifiedName.make(CALPlatformTestModuleNames.ErrorTest, "t"), errorInfo.getTopLevelFunctionName());
            assertEquals(165, errorInfo.getLine());
            assertEquals(8, errorInfo.getColumn());
        }

        try{       
            CALServicesTestUtilities.runNamedFunction(QualifiedName.make(CALPlatformTestModuleNames.ErrorTest, "testCases"), calServices);
            fail( "This should have failed" );
        }
        catch(CALExecutorException e){
            // This does not have position information because the call is evaluated lazily.
            ErrorInfo errorInfo = e.getErrorInfo();
            assertNotNull(errorInfo);
            // The compiler seems to mess up source positions so I can use the exact position
            assertEquals(QualifiedName.make(CALPlatformTestModuleNames.ErrorTest, "testCases"), errorInfo.getTopLevelFunctionName());
            assertEquals(178, errorInfo.getLine());
            assertEquals(17, errorInfo.getColumn());
        }

        try{       
            CALServicesTestUtilities.runNamedFunction(QualifiedName.make(CALPlatformTestModuleNames.ErrorTest, "testCasesRecord"), calServices);
            fail( "This should have failed" );
        }
        catch(CALExecutorException e){
            // This does not have position information because the call is evaluated lazily.
            ErrorInfo errorInfo = e.getErrorInfo();
            assertNotNull(errorInfo);
            // The compiler seems to mess up source positions so I can use the exact position
            assertEquals(QualifiedName.make(CALPlatformTestModuleNames.ErrorTest, "testCasesRecord"), errorInfo.getTopLevelFunctionName());
            assertEquals(187, errorInfo.getLine());
            assertEquals(9, errorInfo.getColumn());
        }
       
        try{       
            CALServicesTestUtilities.runNamedFunction(QualifiedName.make(CALPlatformTestModuleNames.ErrorTest, "f"), calServices);
            fail( "This should have failed" );
        }
        catch(CALExecutorException.ExternalException.ErrorFunctionException e){
            // This does not have position information because the call is evaluated lazily.
            assertTrue( -1 != e.toString().indexOf("hi") );
        }
       
        try{       
            CALServicesTestUtilities.runNamedFunction(QualifiedName.make(ModuleName.make("MyFunModule"), "myFunFunction"), calServices);
            fail( "This should have failed" );
        }
        catch(CALExecutorException.ExternalException.ErrorFunctionException e){
            // This does not have position information because the call is evaluated lazily.
            ErrorInfo errorInfo = e.getErrorInfo();
            assertNotNull(errorInfo);
            // The compiler seems to mess up source positions so I can use the exact position
            assertEquals(QualifiedName.make(ModuleName.make("MyFunModule"), "myFunFunction"), errorInfo.getTopLevelFunctionName());
//                assertEquals(72, errorInfo.getLine());
//                assertEquals(5, errorInfo.getColumn());
        }               
    }
View Full Code Here

    @Override
    public Node doEvaluation (Node[] arguments, Executor executor)
            throws CALExecutorException {

        // Evaluate the two arguments.
        ErrorInfo errorInfo = (ErrorInfo) executor.internalEvaluate(arguments[0]).getValue();
        String errorMessage = (String) executor.internalEvaluate(arguments[1]).getValue();
       
        throw new CALExecutorException.ExternalException.ErrorFunctionException(errorInfo, errorMessage);
    }
View Full Code Here

                    Code code = new Code(altGP);
                    altTagToCodeMap.put(altTag, code);
                }
            }

            ErrorInfo errorInfo = sw.getErrorInfo() == null ? null : toRuntimeErrorInfo(sw.getErrorInfo());
            gp.code (new Instruction.I_Switch (altTagToCodeMap, errorInfo));

            return gp;
        }
View Full Code Here

                    Code code = new Code(altGP);
                    altTagToCodeMap.put(altTag, code);
                }
            }

            ErrorInfo errorInfo = sw.getErrorInfo() == null ? null : toRuntimeErrorInfo(sw.getErrorInfo());
            gp.code (new Instruction.I_Switch (altTagToCodeMap, errorInfo));

            return gp;
        }
View Full Code Here

            return gp;
       

        Expression.ErrorInfo errorInfo = e.asErrorInfo();
        if (errorInfo != null){
            gp.code(Instruction.I_PushVVal.makePushVVal(new ErrorInfo(errorInfo.getTopLevelFunctionName(), errorInfo.getLine(), errorInfo.getColumn())));
            return gp;
        }

        // e is a record case
        Expression.RecordCase recordCase = e.asRecordCase();
View Full Code Here

            return record.getMessage() + "\n";
        }
    }
   
    private static ErrorInfo toRuntimeErrorInfo(final Expression.ErrorInfo errorInfo) {       
        return new ErrorInfo(errorInfo.getTopLevelFunctionName(), errorInfo.getLine(), errorInfo.getColumn());        
    }
View Full Code Here

TOP

Related Classes of org.openquark.cal.runtime.ErrorInfo

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.