idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
38,400 | public Context locate ( ILexNameToken name ) { Value v = get ( name ) ; if ( v == null ) { if ( outer != null ) { return outer . locate ( name ) ; } else { return null ; } } else { return this ; } } | Locate the Context in a chain that contains a name if any . |
38,401 | private synchronized void writeObject ( java . io . ObjectOutputStream stream ) throws java . io . IOException { ThreadState tmp = this . threadState ; this . threadStateSerilizationHashedId = serilizationCache . store ( this . threadState ) ; this . threadState = null ; stream . defaultWriteObject ( ) ; this . threadState = tmp ; } | Custom serialization method handling the transient values |
38,402 | private synchronized void readObject ( java . io . ObjectInputStream stream ) throws java . io . IOException , ClassNotFoundException { stream . defaultReadObject ( ) ; this . threadState = ( ThreadState ) serilizationCache . load ( this . threadStateSerilizationHashedId ) ; this . threadStateSerilizationHashedId = null ; } | Custom de - serialization method handling the transient values |
38,403 | public String getMeasureApply ( AApplyExp node , ILexNameToken measure , boolean close ) { String start = null ; PExp root = node . getRoot ( ) ; if ( root instanceof AApplyExp ) { AApplyExp aexp = ( AApplyExp ) root ; start = getMeasureApply ( aexp , measure , false ) ; } else if ( root instanceof AVariableExp ) { start = measure . getFullName ( ) + "(" ; } else if ( root instanceof AFuncInstatiationExp ) { AFuncInstatiationExp fie = ( AFuncInstatiationExp ) root ; start = measure . getFullName ( ) + "[" + Utils . listToString ( fie . getActualTypes ( ) ) + "](" ; } else { start = root . toString ( ) + "(" ; } return start + Utils . listToString ( node . getArgs ( ) ) + ( close ? ")" : ", " ) ; } | Create a measure application string from this apply turning the root function name into the measure name passed and collapsing curried argument sets into one . |
38,404 | public Value check ( ILexNameToken name ) { Value v = get ( name ) ; if ( v != null ) { return v ; } if ( freeVariables != null ) { v = freeVariables . get ( name ) ; if ( v != null ) { return v ; } } if ( v == null ) { if ( stateCtxt != null ) { v = stateCtxt . check ( name ) ; if ( v != null ) { return v ; } } Context g = getGlobal ( ) ; if ( g != this ) { return g . check ( name ) ; } } return v ; } | Check for the name in the current context and state and if not present search the global context . Note that the context chain is not followed . |
38,405 | public ValueList getValues ( PExp exp , ObjectContext ctxt ) { try { return exp . apply ( af . getExpressionValueCollector ( ) , ctxt ) ; } catch ( AnalysisException e ) { return null ; } } | Return a list of all the updatable values read by the expression . This is used to add listeners to values that affect permission guards so that the guard may be efficiently re - evaluated when the values change . |
38,406 | public PExp findExpression ( PExp exp , int lineno ) { try { return exp . apply ( af . getExpExpressionFinder ( ) , lineno ) ; } catch ( AnalysisException e ) { return null ; } } | Find an expression starting on the given line . Single expressions just compare their location to lineno but expressions with sub - expressions iterate over their branches . |
38,407 | public List < INextGenEvent > getEvents ( Long startTime ) { ArrayList < INextGenEvent > eventList = null ; Long eventKey = events . ceilingKey ( startTime ) ; if ( eventKey != null ) { eventList = events . get ( eventKey ) ; currentEventTime = eventKey ; } return eventList ; } | Get events from a specified start time . If no events at specified time the next series of events is returned |
38,408 | private static int discardWhitespace ( byte [ ] data ) { final int length = data . length ; int i = 0 ; while ( i < length ) { byte c = data [ i ++ ] ; if ( c == ( byte ) ' ' || c == ( byte ) '\n' || c == ( byte ) '\r' || c == ( byte ) '\t' ) { int count = i - 1 ; while ( i < length ) { c = data [ i ++ ] ; if ( c != ( byte ) ' ' && c != ( byte ) '\n' && c != ( byte ) '\r' && c != ( byte ) '\t' ) { data [ count ++ ] = c ; } } return count ; } } return length ; } | Discards any whitespace from a base - 64 encoded block . The base64 data in responses could be chunked in the multiple lines so we need to remove extra whitespaces . The bytes are copied in - place and the length of the actual data bytes is returned . |
38,409 | private void setBreakpoint ( File file , int line , String condition ) throws Exception { if ( file == null ) { file = interpreter . getDefaultFile ( ) ; } if ( file == null || file . getPath ( ) . equals ( "?" ) ) { Set < File > files = interpreter . getSourceFiles ( ) ; if ( files . size ( ) > 1 ) { println ( "Assuming file " + file . getPath ( ) ) ; } else if ( files . isEmpty ( ) ) { println ( "No files defined" ) ; return ; } file = files . iterator ( ) . next ( ) ; } PStm stmt = interpreter . findStatement ( file , line ) ; if ( stmt == null ) { PExp exp = interpreter . findExpression ( file , line ) ; if ( exp == null ) { println ( "No breakable expressions or statements at " + file + ":" + line ) ; } else { interpreter . clearBreakpoint ( BreakpointManager . getBreakpoint ( exp ) . number ) ; Breakpoint bp = interpreter . setBreakpoint ( exp , condition ) ; println ( "Created " + bp ) ; println ( interpreter . getSourceLine ( bp . location ) ) ; } } else { interpreter . clearBreakpoint ( BreakpointManager . getBreakpoint ( stmt ) . number ) ; Breakpoint bp = interpreter . setBreakpoint ( stmt , condition ) ; println ( "Created " + bp ) ; println ( interpreter . getSourceLine ( bp . location ) ) ; } } | Set a breakpoint at the given file and line with a condition . |
38,410 | private void setBreakpoint ( String name , String condition ) throws Exception { LexTokenReader ltr = new LexTokenReader ( name , Dialect . VDM_SL ) ; LexToken token = ltr . nextToken ( ) ; ltr . close ( ) ; Value v = null ; if ( token . is ( VDMToken . IDENTIFIER ) ) { LexIdentifierToken id = ( LexIdentifierToken ) token ; LexNameToken lnt = new LexNameToken ( interpreter . getDefaultName ( ) , id ) ; v = interpreter . findGlobal ( lnt ) ; } else if ( token . is ( VDMToken . NAME ) ) { v = interpreter . findGlobal ( ( LexNameToken ) token ) ; } if ( v instanceof FunctionValue ) { FunctionValue fv = ( FunctionValue ) v ; PExp exp = fv . body ; interpreter . clearBreakpoint ( BreakpointManager . getBreakpoint ( exp ) . number ) ; Breakpoint bp = interpreter . setBreakpoint ( exp , condition ) ; println ( "Created " + bp ) ; println ( interpreter . getSourceLine ( bp . location ) ) ; } else if ( v instanceof OperationValue ) { OperationValue ov = ( OperationValue ) v ; PStm stmt = ov . body ; interpreter . clearBreakpoint ( BreakpointManager . getBreakpoint ( stmt ) . number ) ; Breakpoint bp = interpreter . setBreakpoint ( stmt , condition ) ; println ( "Created " + bp ) ; println ( interpreter . getSourceLine ( bp . location ) ) ; } else if ( v == null ) { println ( name + " is not visible or not found" ) ; } else { println ( name + " is not a function or operation" ) ; } } | Set a breakpoint at the given function or operation name with a condition . |
38,411 | private char rdCh ( ) { char c = super . readCh ( ) ; if ( c == '\n' ) { linecount ++ ; charpos = 0 ; } else if ( c == '\t' ) { charpos += Properties . parser_tabstop - charpos % Properties . parser_tabstop ; } else if ( c != ( char ) - 1 ) { charpos ++ ; } ch = c ; charsread ++ ; offset = getCurrentRawReadOffset ( ) ; return ch ; } | Read the next character from the stream . The position details are updated accounting for newlines and tab stops . The next character is set in the ch field as well as being returned for convenience . |
38,412 | private char rdQuotedCh ( ) throws LexException { quotedQuote = false ; char c = rdCh ( ) ; if ( c == '\\' ) { rdCh ( ) ; switch ( ch ) { case 'r' : ch = '\r' ; break ; case 'n' : ch = '\n' ; break ; case 't' : ch = '\t' ; break ; case 'f' : ch = '\f' ; break ; case 'e' : ch = '\033' ; break ; case 'a' : ch = '\007' ; break ; case '\'' : ch = '\'' ; break ; case '\"' : ch = '\"' ; quotedQuote = true ; break ; case '\\' : ch = '\\' ; break ; case 'x' : ch = ( char ) ( value ( rdCh ( ) ) * 16 + value ( rdCh ( ) ) ) ; break ; case 'c' : ch = ( char ) ( rdCh ( ) - 'A' + 1 ) ; break ; case 'u' : ch = ( char ) ( value ( rdCh ( ) ) * 4096 + value ( rdCh ( ) ) * 256 + value ( rdCh ( ) ) * 16 + value ( rdCh ( ) ) ) ; break ; case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : ch = ( char ) ( value ( ch ) * 64 + value ( rdCh ( ) ) * 8 + value ( rdCh ( ) ) ) ; break ; default : throwMessage ( 1000 , "Malformed quoted character" ) ; } } return ch ; } | Read a backslash quoted character from the stream . This method is used when parsing strings and individual quoted characters which may include things like \ n . |
38,413 | private String rdNumber ( int base ) throws LexException { StringBuilder v = new StringBuilder ( ) ; int n = value ( ch ) ; v . append ( ch ) ; if ( n < 0 || n >= base ) { throwMessage ( 1001 , "Invalid char [" + ch + "] in base " + base + " number" ) ; } while ( true ) { rdCh ( ) ; n = value ( ch ) ; if ( n < 0 || n >= base ) { return v . toString ( ) ; } v . append ( ch ) ; } } | Read a number of the given base . Parsing terminates when a character not within the number base is read . |
38,414 | private LexToken rdReal ( int tokline , int tokpos , int tokOffset ) throws LexException { String floatSyntax = "Expecting <digits>[.<digits>][e<+-><digits>]" ; String value = rdNumber ( 10 ) ; String fraction = null ; String exponent = null ; boolean negative = false ; push ( ) ; if ( ch == '.' ) { rdCh ( ) ; if ( ch >= '0' && ch <= '9' ) { fraction = rdNumber ( 10 ) ; exponent = "0" ; } else { pop ( ) ; return new LexIntegerToken ( value , location ( tokline , tokpos , tokOffset , offset ) ) ; } } unpush ( ) ; if ( ch == 'e' || ch == 'E' ) { if ( fraction == null ) { fraction = "0" ; } switch ( rdCh ( ) ) { case '+' : { rdCh ( ) ; exponent = rdNumber ( 10 ) ; break ; } case '-' : { rdCh ( ) ; exponent = rdNumber ( 10 ) ; negative = true ; break ; } case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : { exponent = rdNumber ( 10 ) ; break ; } default : throwMessage ( 1010 , floatSyntax ) ; } } if ( fraction != null ) { String real = "+" + value + "." + fraction + "e" + ( negative ? "-" : "+" ) + exponent ; return new LexRealToken ( real , location ( tokline , tokpos , tokOffset , offset ) ) ; } return new LexIntegerToken ( value , location ( tokline , tokpos , tokOffset , offset ) ) ; } | Read a decimal floating point number . |
38,415 | private List < String > rdName ( ) { List < String > names = new Vector < String > ( ) ; names . add ( rdIdentifier ( ) ) ; if ( ch == '`' ) { if ( startOfName ( rdCh ( ) ) ) { names . add ( rdIdentifier ( ) ) ; } } if ( names . size ( ) == 2 ) { String first = names . get ( 0 ) ; if ( first . startsWith ( "mk_" ) || first . startsWith ( "is_" ) ) { List < String > one = new Vector < String > ( ) ; one . add ( first + "`" + names . get ( 1 ) ) ; names = one ; } } return names ; } | Read a fully qualified module name . |
38,416 | private String rdIdentifier ( ) { StringBuilder id = new StringBuilder ( ) ; id . append ( ch ) ; while ( restOfName ( rdCh ( ) ) ) { id . append ( ch ) ; } return id . toString ( ) ; } | Read a simple identifier without a module name prefix . |
38,417 | public List < PDefinition > getDefinitions ( PPattern rp , PType ptype , NameScope scope ) { PDefinitionSet set = af . createPDefinitionSet ( ) ; set . addAll ( af . createPPatternAssistant ( ) . getAllDefinitions ( rp , ptype , scope ) ) ; List < PDefinition > result = new Vector < PDefinition > ( set ) ; return result ; } | Get a set of definitions for the pattern s variables . Note that if the pattern includes duplicate variable names these are collapse into one . |
38,418 | private List < PDefinition > getAllDefinitions ( PPattern pattern , PType ptype , NameScope scope ) { try { return pattern . apply ( af . getAllDefinitionLocator ( ) , new AllDefinitionLocator . NewQuestion ( ptype , scope ) ) ; } catch ( AnalysisException e ) { return null ; } } | Get a complete list of all definitions including duplicates . This method should only be used only by PP |
38,419 | protected void waitDebuggerConnected ( ILaunch launch , DebugSessionAcceptor acceptor ) throws CoreException { int timeout = VdmDebugPlugin . getDefault ( ) . getConnectionTimeout ( ) ; if ( ! acceptor . waitConnection ( timeout ) ) { launch . terminate ( ) ; return ; } if ( ! acceptor . waitInitialized ( 60 * 60 * 1000 ) ) { launch . terminate ( ) ; abort ( "errDebuggingEngineNotInitialized" , null ) ; } } | Waiting debugging process to connect to current launch |
38,420 | public static File prepareCustomOvertureProperties ( IVdmProject project , ILaunchConfiguration configuration ) throws CoreException { List < String > properties = new Vector < String > ( ) ; if ( VdmDebugPlugin . getDefault ( ) . getPreferenceStore ( ) . getBoolean ( IDebugPreferenceConstants . PREF_DBGP_ENABLE_EXPERIMENTAL_MODELCHECKER ) ) { properties . add ( getProbHomeProperty ( ) ) ; } return writePropertyFile ( project , "overture.properties" , properties ) ; } | Create the custom overture . properties file loaded by the debugger |
38,421 | public static String getProbHomeProperty ( ) { final Bundle bundle = Platform . getBundle ( ORG_OVERTURE_IDE_PLUGINS_PROBRUNTIME ) ; if ( bundle != null ) { URL buildInfoUrl = FileLocator . find ( bundle , new Path ( "prob/build_info.txt" ) , null ) ; try { if ( buildInfoUrl != null ) { URL buildInfofileUrl = FileLocator . toFileURL ( buildInfoUrl ) ; if ( buildInfofileUrl != null ) { File file = new File ( buildInfofileUrl . getFile ( ) ) ; return "system." + "prob.home=" + file . getParentFile ( ) . getPath ( ) . replace ( '\\' , '/' ) ; } } } catch ( IOException e ) { } } return "" ; } | Obtains the prob bundled executable and returns the prob . home property set to that location |
38,422 | protected Collection < ? extends String > getExtendedCommands ( IVdmProject project , ILaunchConfiguration configuration ) throws CoreException { return new Vector < String > ( ) ; } | Intended to be used when sub classing the delegate to add additional parameters to the launch of VDMJ |
38,423 | private static void abort ( String message , Throwable e ) throws CoreException { throw new CoreException ( ( IStatus ) new Status ( IStatus . ERROR , IDebugConstants . PLUGIN_ID , 0 , message , e ) ) ; } | Throws an exception with a new status containing the given message and optional exception . |
38,424 | public void register ( boolean register ) throws CoreException { DebugPlugin plugin = DebugPlugin . getDefault ( ) ; if ( plugin != null && register ) { plugin . getBreakpointManager ( ) . addBreakpoint ( this ) ; } else { setRegistered ( false ) ; } } | Add this breakpoint to the breakpoint manager or sets it as unregistered . |
38,425 | public static File getBundleFile ( Bundle bundle ) throws IOException { URL rootEntry = bundle . getEntry ( "/" ) ; rootEntry = FileLocator . resolve ( rootEntry ) ; if ( "file" . equals ( rootEntry . getProtocol ( ) ) ) return new File ( rootEntry . getPath ( ) ) ; if ( "jar" . equals ( rootEntry . getProtocol ( ) ) ) { String path = rootEntry . getPath ( ) ; if ( path . startsWith ( "file:" ) ) { path = path . substring ( 5 , path . length ( ) - 2 ) ; return new File ( path ) ; } } throw new IOException ( "Unknown protocol" ) ; } | Returns a file for the contents of the specified bundle . Depending on how the bundle is installed the returned file may be a directory or a jar file containing the bundle content . |
38,426 | public IDbgpFeature getFeature ( String name ) throws DbgpException { IDbgpCoreCommands core = session . getCoreCommands ( ) ; return core . getFeature ( name ) ; } | Feature helper methods |
38,427 | public TemplateCallable [ ] addDefaults ( TemplateCallable [ ] userCallables ) { TemplateCallable strFunctionality = new TemplateCallable ( String . class . getSimpleName ( ) , String . class ) ; for ( TemplateCallable u : userCallables ) { if ( u . equals ( strFunctionality ) ) { return userCallables ; } } return GeneralUtils . concat ( userCallables , new TemplateCallable [ ] { strFunctionality } ) ; } | Enables the static methods of the java . lang . String class to be called from the templates . If the key String is already reserved by the user this method simply returns the input parameter . |
38,428 | public boolean performOk ( ) { IWorkspaceRunnable wr = new IWorkspaceRunnable ( ) { public void run ( IProgressMonitor monitor ) throws CoreException { IVdmBreakpoint breakpoint = getBreakpoint ( ) ; boolean delOnCancel = breakpoint . getMarker ( ) . getAttribute ( ATTR_DELETE_ON_CANCEL ) != null ; if ( delOnCancel ) { breakpoint . getMarker ( ) . setAttribute ( ATTR_DELETE_ON_CANCEL , ( String ) null ) ; breakpoint . setRegistered ( true ) ; } doStore ( ) ; } } ; try { ResourcesPlugin . getWorkspace ( ) . run ( wr , null , 0 , null ) ; } catch ( CoreException e ) { } return super . performOk ( ) ; } | Store the breakpoint properties . |
38,429 | private void storeHitCount ( IVdmBreakpoint breakpoint ) throws CoreException { int hitCount = - 1 ; try { hitCount = Integer . parseInt ( fHitValueText . getText ( ) ) ; } catch ( NumberFormatException e ) { } breakpoint . setHitValue ( hitCount ) ; breakpoint . setHitCondition ( fHitValueButton . getSelection ( ) ? IVdmBreakpoint . HIT_CONDITION_GREATER_OR_EQUAL : - 1 ) ; } | Stores the value of the hit count in the breakpoint . |
38,430 | protected Control createContents ( Composite parent ) { setTitle ( "TODO: property title (VdmBreakpointPropertyPage)" ) ; noDefaultAndApplyButton ( ) ; Composite mainComposite = createComposite ( parent , 1 ) ; createLabels ( mainComposite ) ; try { createEnabledButton ( mainComposite ) ; createHitValueEditor ( mainComposite ) ; createTypeSpecificEditors ( mainComposite ) ; } catch ( CoreException e ) { ; } setValid ( true ) ; try { if ( getBreakpoint ( ) . getMarker ( ) . getAttribute ( ATTR_DELETE_ON_CANCEL ) != null ) { getShell ( ) . addShellListener ( new ShellListener ( ) { public void shellActivated ( ShellEvent e ) { Shell shell = ( Shell ) e . getSource ( ) ; shell . setText ( "TEXT HERE (VdmBreakpointPropertyPage)" ) ; shell . removeShellListener ( this ) ; } public void shellClosed ( ShellEvent e ) { } public void shellDeactivated ( ShellEvent e ) { } public void shellDeiconified ( ShellEvent e ) { } public void shellIconified ( ShellEvent e ) { } } ) ; } } catch ( CoreException e ) { } return mainComposite ; } | Creates the labels and editors displayed for the breakpoint . |
38,431 | protected void createLabels ( Composite parent ) { Composite labelComposite = createComposite ( parent , 2 ) ; try { String typeName = ( ( IVdmBreakpoint ) getElement ( ) ) . getMessage ( ) ; if ( typeName != null ) { String s = getTypeName ( typeName ) ; createLabel ( labelComposite , "Filename:" ) ; Text text = SWTFactory . createText ( labelComposite , SWT . READ_ONLY , 1 , 1 ) ; text . setText ( s ) ; text . setBackground ( parent . getBackground ( ) ) ; } createTypeSpecificLabels ( labelComposite ) ; } catch ( CoreException ce ) { } } | Creates the labels displayed for the breakpoint . |
38,432 | private void hitCountChanged ( ) { if ( ! fHitValueButton . getSelection ( ) ) { removeErrorMessage ( fgHitCountErrorMessage ) ; return ; } String hitCountText = fHitValueText . getText ( ) ; int hitCount = - 1 ; try { hitCount = Integer . parseInt ( hitCountText ) ; } catch ( NumberFormatException e1 ) { addErrorMessage ( fgHitCountErrorMessage ) ; return ; } if ( hitCount < 1 ) { addErrorMessage ( fgHitCountErrorMessage ) ; } else { removeErrorMessage ( fgHitCountErrorMessage ) ; } } | Validates the current state of the hit count editor . Hit count value must be a positive integer . |
38,433 | protected void createEnabledButton ( Composite parent ) throws CoreException { fEnabledButton = createCheckButton ( parent , "Enable" ) ; fEnabledButton . setSelection ( getBreakpoint ( ) . isEnabled ( ) ) ; } | Creates the button to toggle enablement of the breakpoint |
38,434 | protected Text createText ( Composite parent , String initialValue ) { Text t = SWTFactory . createText ( parent , SWT . SINGLE | SWT . BORDER , 1 ) ; t . setText ( initialValue ) ; return t ; } | Creates a fully configured text editor with the given initial value |
38,435 | protected Composite createComposite ( Composite parent , int numColumns ) { return SWTFactory . createComposite ( parent , parent . getFont ( ) , numColumns , 1 , GridData . FILL_HORIZONTAL , 0 , 0 ) ; } | Creates a fully configured composite with the given number of columns |
38,436 | protected Button createCheckButton ( Composite parent , String text ) { return SWTFactory . createCheckButton ( parent , text , null , false , 1 ) ; } | Creates a fully configured check button with the given text . |
38,437 | protected Label createLabel ( Composite parent , String text ) { return SWTFactory . createLabel ( parent , text , 1 ) ; } | Creates a fully configured label with the given text . |
38,438 | protected Button createRadioButton ( Composite parent , String text ) { return SWTFactory . createRadioButton ( parent , text ) ; } | Creates a fully configured radio button with the given text . |
38,439 | public boolean performCancel ( ) { try { if ( getBreakpoint ( ) . getMarker ( ) . getAttribute ( ATTR_DELETE_ON_CANCEL ) != null ) { getBreakpoint ( ) . delete ( ) ; } } catch ( CoreException e ) { } return super . performCancel ( ) ; } | Check to see if the breakpoint should be deleted . |
38,440 | public void handleDebugEvents ( DebugEvent [ ] events ) { for ( int i = 0 ; i < events . length ; i ++ ) { DebugEvent event = events [ i ] ; if ( event . getSource ( ) . equals ( getProcess ( ) ) ) { if ( event . getKind ( ) == DebugEvent . TERMINATE ) { closeStreams ( ) ; DebugPlugin . getDefault ( ) . removeDebugEventListener ( this ) ; } resetName ( ) ; } } } | Notify listeners when name changes . |
38,441 | private void resetName ( ) { UIJob job = new UIJob ( "Activating Console" ) { public IStatus runInUIThread ( IProgressMonitor monitor ) { warnOfContentChange ( ) ; return Status . OK_STATUS ; } } ; job . setSystem ( true ) ; job . schedule ( ) ; } | resets the name of this console to the original computed name |
38,442 | private void warnOfContentChange ( ) { IConsole [ ] consoles = ConsolePlugin . getDefault ( ) . getConsoleManager ( ) . getConsoles ( ) ; for ( IConsole iConsole : consoles ) { if ( iConsole instanceof VdmDebugConsole ) { VdmDebugConsole vdmC = ( VdmDebugConsole ) iConsole ; vdmC . activate ( ) ; } } } | send notification of a change of content in this console |
38,443 | protected LexNameToken idToName ( LexIdentifierToken id ) { LexNameToken name = new LexNameToken ( reader . currentModule , id ) ; return name ; } | Convert an identifier into a name . A name is an identifier that has a module name qualifier so this method uses the current module to convert the identifier passed in . |
38,444 | protected void checkFor ( VDMToken tok , int number , String message ) throws LexException , ParserException { if ( lastToken ( ) . is ( tok ) ) { nextToken ( ) ; } else { throwMessage ( number , message ) ; } } | If the last token is as expected advance else raise an error . |
38,445 | protected boolean ignore ( VDMToken tok ) throws LexException { if ( lastToken ( ) . is ( tok ) ) { nextToken ( ) ; return true ; } else { return false ; } } | If the last token is the one passed advance by one else do nothing . |
38,446 | protected void report ( LocatedException error , VDMToken [ ] after , VDMToken [ ] upto ) { VDMError vdmerror = new VDMError ( error ) ; errors . add ( vdmerror ) ; if ( errors . size ( ) >= MAX - 1 ) { errors . add ( new VDMError ( 9 , "Too many syntax errors" , error . location ) ) ; throw new InternalException ( 9 , "Too many syntax errors" ) ; } List < VDMToken > afterList = Arrays . asList ( after ) ; List < VDMToken > uptoList = Arrays . asList ( upto ) ; try { VDMToken tok = lastToken ( ) . type ; while ( ! uptoList . contains ( tok ) && tok != VDMToken . EOF ) { if ( afterList . contains ( tok ) ) { nextToken ( ) ; break ; } tok = nextToken ( ) . type ; } } catch ( LexException le ) { errors . add ( new VDMError ( le ) ) ; } } | Raise a syntax error and attempt to recover . The error is added to the errors list and if this exceeds 100 errors the parser is aborted . The after and upto lists of token types are then used to control the advance of the parser to skip beyond the error . Tokens are read until one occurs in either list or EOF is reached . If the token is in the after list one more token is read before returning ; if it is in the upto list the last token is left pointing to the token before returning . If EOF is reached the method returns . |
38,447 | protected void warning ( int no , String msg , ILexLocation location ) { VDMWarning vdmwarning = new VDMWarning ( no , msg , location ) ; warnings . add ( vdmwarning ) ; if ( warnings . size ( ) >= MAX - 1 ) { errors . add ( new VDMError ( 9 , "Too many warnings" , location ) ) ; throw new InternalException ( 9 , "Too many warnings" ) ; } } | Report a warning . Unlike errors this does no token recovery . |
38,448 | public void printErrors ( PrintWriter out ) { for ( VDMError e : getErrors ( ) ) { out . println ( e . toString ( ) ) ; } } | Print errors and warnings to the PrintWriter passed . |
38,449 | public < T > void contextSet ( Class < T > key , T value ) { synchronized ( TypeCheckInfo . class ) { Stack < T > contextStack = lookupListForType ( key ) ; if ( contextStack == null ) { contextStack = new Stack < T > ( ) ; context . put ( key , contextStack ) ; } contextStack . push ( value ) ; } } | Associates the given key with the given value . |
38,450 | public < T > T contextRem ( Class < T > key ) { synchronized ( TypeCheckInfo . class ) { Stack < T > contextStack = lookupListForType ( key ) ; if ( contextStack != null ) { return contextStack . pop ( ) ; } } return null ; } | Returns the value associated with key and removes that binding from the context . |
38,451 | private boolean isSelectionCommented ( ISelection selection ) { if ( ! ( selection instanceof ITextSelection ) ) return false ; ITextSelection textSelection = ( ITextSelection ) selection ; if ( textSelection . getStartLine ( ) < 0 || textSelection . getEndLine ( ) < 0 ) return false ; IDocument document = getTextEditor ( ) . getDocumentProvider ( ) . getDocument ( getTextEditor ( ) . getEditorInput ( ) ) ; try { IRegion block = getTextBlockFromSelection ( textSelection , document ) ; ITypedRegion [ ] regions = TextUtilities . computePartitioning ( document , fDocumentPartitioning , block . getOffset ( ) , block . getLength ( ) , false ) ; int [ ] lines = new int [ regions . length * 2 ] ; for ( int i = 0 , j = 0 ; i < regions . length ; i ++ , j += 2 ) { lines [ j ] = getFirstCompleteLineOfRegion ( regions [ i ] , document ) ; int length = regions [ i ] . getLength ( ) ; int offset = regions [ i ] . getOffset ( ) + length ; if ( length > 0 ) offset -- ; lines [ j + 1 ] = ( lines [ j ] == - 1 ? - 1 : document . getLineOfOffset ( offset ) ) ; } for ( int i = 0 , j = 0 ; i < regions . length ; i ++ , j += 2 ) { String [ ] prefixes = ( String [ ] ) fPrefixesMap . get ( regions [ i ] . getType ( ) ) ; if ( prefixes != null && prefixes . length > 0 && lines [ j ] >= 0 && lines [ j + 1 ] >= 0 ) if ( ! isBlockCommented ( lines [ j ] , lines [ j + 1 ] , prefixes , document ) ) return false ; } return true ; } catch ( BadLocationException x ) { VdmUIPlugin . log ( x ) ; } return false ; } | Is the given selection single - line commented? |
38,452 | public String getFullPredString ( ) { if ( valuetree . getPredicate ( ) == null ) { return "" ; } String result = valuetree . getPredicate ( ) . toString ( ) ; return result ; } | string as it exists in the current version |
38,453 | protected PMultipleBind getMultipleSetBind ( PExp setExp , ILexNameToken ... patternNames ) { ASetMultipleBind setBind = new ASetMultipleBind ( ) ; List < PPattern > patternList = new Vector < PPattern > ( ) ; for ( ILexNameToken patternName : patternNames ) { AIdentifierPattern pattern = new AIdentifierPattern ( ) ; pattern . setName ( patternName . clone ( ) ) ; patternList . add ( pattern ) ; } setBind . setPlist ( patternList ) ; setBind . setSet ( setExp . clone ( ) ) ; return setBind ; } | Create a multiple set bind with a varargs list of pattern variables like a b c in set S . This is used by several obligations . |
38,454 | protected AEqualsBinaryExp getEqualsExp ( PExp left , PExp right ) { return AstExpressionFactory . newAEqualsBinaryExp ( left . clone ( ) , right . clone ( ) ) ; } | Generate an AEqualsBinaryExp |
38,455 | protected AVariableExp getVarExp ( ILexNameToken name ) { AVariableExp var = new AVariableExp ( ) ; var . setName ( name . clone ( ) ) ; var . setOriginal ( name . getFullName ( ) ) ; return var ; } | Generate an AVariableExp |
38,456 | protected AVariableExp getVarExp ( ILexNameToken name , PType type ) { AVariableExp var = getVarExp ( name ) ; var . setType ( type . clone ( ) ) ; return var ; } | Generate a Var Exp with associated type . |
38,457 | protected AVariableExp getVarExp ( ILexNameToken name , PDefinition vardef ) { AVariableExp var = new AVariableExp ( ) ; var . setName ( name . clone ( ) ) ; var . setOriginal ( name . getFullName ( ) ) ; var . setVardef ( vardef . clone ( ) ) ; return var ; } | Generate AVariableExp with corresponding definition |
38,458 | protected AVariableExp getVarExp ( ILexNameToken name , PDefinition vardef , PType type ) { AVariableExp var = getVarExp ( name , vardef ) ; var . setType ( type ) ; return var ; } | Generate Var Exp with everything! |
38,459 | protected AApplyExp getApplyExp ( PExp root , PExp ... arglist ) { return getApplyExp ( root , Arrays . asList ( arglist ) ) ; } | Generate an AApplyExp with varargs arguments |
38,460 | protected AApplyExp getApplyExp ( PExp root , List < PExp > arglist ) { AApplyExp apply = new AApplyExp ( ) ; apply . setRoot ( root . clone ( ) ) ; List < PExp > args = new Vector < PExp > ( ) ; for ( PExp arg : arglist ) { args . add ( arg . clone ( ) ) ; } apply . setArgs ( args ) ; return apply ; } | Generate an AApplyExp |
38,461 | protected AIntLiteralExp getIntLiteral ( long i ) { AIntLiteralExp number = new AIntLiteralExp ( ) ; ILexIntegerToken literal = new LexIntegerToken ( i , null ) ; number . setValue ( literal ) ; return number ; } | Generate an AIntLiteral from a long . |
38,462 | protected PExp makeAnd ( PExp root , PExp e ) { if ( root != null ) { AAndBooleanBinaryExp a = new AAndBooleanBinaryExp ( ) ; a . setLeft ( root . clone ( ) ) ; a . setOp ( new LexKeywordToken ( VDMToken . AND , null ) ) ; a . setType ( new ABooleanBasicType ( ) ) ; a . setRight ( e . clone ( ) ) ; return a ; } else { return e ; } } | Chain an AND expression onto a root or just return the new expression if the root is null . Called in a loop this left - associates an AND tree . |
38,463 | protected PExp makeOr ( PExp root , PExp e ) { if ( root != null ) { AOrBooleanBinaryExp o = new AOrBooleanBinaryExp ( ) ; o . setLeft ( root . clone ( ) ) ; o . setOp ( new LexKeywordToken ( VDMToken . OR , null ) ) ; o . setType ( new ABooleanBasicType ( ) ) ; o . setRight ( e . clone ( ) ) ; return o ; } else { return e ; } } | Chain an OR expression onto a root or just return the new expression if the root is null . Called in a loop this left - associates an OR tree . |
38,464 | private Object readResolve ( ) throws ObjectStreamException { LexLocation existing = uniqueLocations . get ( this ) ; if ( existing == null ) { return this ; } else { return existing ; } } | Method to resolve existing locations during de - serialise - as used during deep copy . This is to avoid problems with coverage . |
38,465 | public String toProblemString ( ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( message ) ; sb . append ( "." ) ; for ( String d : details ) { sb . append ( " " ) ; sb . append ( d ) ; } return sb . toString ( ) ; } | view with details but without the file location and number . |
38,466 | protected String autoFillBaseSettings ( ) { ISelection selection = PlatformUI . getWorkbench ( ) . getActiveWorkbenchWindow ( ) . getSelectionService ( ) . getSelection ( ) ; if ( selection instanceof TreeSelection ) { TreeSelection tSelection = ( TreeSelection ) selection ; if ( tSelection . getFirstElement ( ) != null && tSelection . getFirstElement ( ) instanceof IProject ) { String name = ( ( IProject ) tSelection . getFirstElement ( ) ) . getName ( ) ; if ( name != null && name . trim ( ) . length ( ) > 0 ) { fProjectText . setText ( name ) ; String launchConfigName = DebugPlugin . getDefault ( ) . getLaunchManager ( ) . generateLaunchConfigurationName ( name ) ; return launchConfigName ; } } } return null ; } | Gets the last selected project in the platform if selection is tree selection |
38,467 | public void processExports ( AModuleModules m ) { if ( m . getExports ( ) != null ) { m . getExportdefs ( ) . clear ( ) ; if ( ! m . getIsDLModule ( ) ) { m . getExportdefs ( ) . addAll ( getDefinitions ( m . getExports ( ) , m . getDefs ( ) ) ) ; } else { m . getExportdefs ( ) . addAll ( getDefinitions ( m . getExports ( ) ) ) ; } } } | Generate the exportdefs list of definitions . The exports list of export declarations is processed by searching the defs list of locally defined objects . The exportdefs field is populated with the result . |
38,468 | public SExpIR caseABooleanConstExp ( ABooleanConstExp node , IRInfo question ) throws AnalysisException { PType type = node . getType ( ) ; boolean value = node . getValue ( ) . getValue ( ) ; STypeIR typeCg = type . apply ( question . getTypeVisitor ( ) , question ) ; ABoolLiteralExpIR boolLitCg = new ABoolLiteralExpIR ( ) ; boolLitCg . setType ( typeCg ) ; boolLitCg . setValue ( value ) ; return boolLitCg ; } | setValue at the current time of writing . |
38,469 | private void verifyBufferSize ( int sz ) { if ( sz > buf . length ) { byte [ ] old = buf ; buf = new byte [ Math . max ( sz , 2 * buf . length ) ] ; System . arraycopy ( old , 0 , buf , 0 , old . length ) ; old = null ; } } | Ensures that we have a large enough buffer for the given size . |
38,470 | public Value execute ( File file ) throws Exception { BufferedReader br = new BufferedReader ( new FileReader ( file ) ) ; StringBuilder sb = new StringBuilder ( ) ; String line = br . readLine ( ) ; while ( line != null ) { sb . append ( line ) ; line = br . readLine ( ) ; } br . close ( ) ; Value result = execute ( sb . toString ( ) , null ) ; BasicSchedulableThread . terminateAll ( ) ; return result ; } | Parse the content of the file passed type check it and evaluate it as an expression in the initial context . |
38,471 | public String getSourceLine ( File file , int line , String sep ) { SourceFile source = sourceFiles . get ( file ) ; if ( source == null ) { try { source = new SourceFile ( file ) ; sourceFiles . put ( file , source ) ; } catch ( IOException e ) { return "Cannot open source file: " + file ; } } return line + sep + source . getLine ( line ) ; } | Get a line of a source file by its location . |
38,472 | public SourceFile getSourceFile ( File file ) throws IOException { SourceFile source = sourceFiles . get ( file ) ; if ( source == null ) { source = new SourceFile ( file ) ; sourceFiles . put ( file , source ) ; } return source ; } | Get an entire source file object . |
38,473 | public Breakpoint setTracepoint ( PStm stmt , String trace ) throws Exception { BreakpointManager . setBreakpoint ( stmt , new Tracepoint ( stmt . getLocation ( ) , ++ nextbreakpoint , trace ) ) ; breakpoints . put ( nextbreakpoint , BreakpointManager . getBreakpoint ( stmt ) ) ; return BreakpointManager . getBreakpoint ( stmt ) ; } | Set a statement tracepoint . A tracepoint does not stop execution but evaluates and displays an expression before continuing . |
38,474 | public Breakpoint setTracepoint ( PExp exp , String trace ) throws ParserException , LexException { BreakpointManager . setBreakpoint ( exp , new Tracepoint ( exp . getLocation ( ) , ++ nextbreakpoint , trace ) ) ; breakpoints . put ( nextbreakpoint , BreakpointManager . getBreakpoint ( exp ) ) ; return BreakpointManager . getBreakpoint ( exp ) ; } | Set an expression tracepoint . A tracepoint does not stop execution but evaluates an expression before continuing . |
38,475 | public Breakpoint setBreakpoint ( PStm stmt , String condition ) throws ParserException , LexException { BreakpointManager . setBreakpoint ( stmt , new Stoppoint ( stmt . getLocation ( ) , ++ nextbreakpoint , condition ) ) ; breakpoints . put ( nextbreakpoint , BreakpointManager . getBreakpoint ( stmt ) ) ; return BreakpointManager . getBreakpoint ( stmt ) ; } | Set a statement breakpoint . A breakpoint stops execution and allows the user to query the environment . |
38,476 | public Breakpoint setBreakpoint ( PExp exp , String condition ) throws ParserException , LexException { BreakpointManager . setBreakpoint ( exp , new Stoppoint ( exp . getLocation ( ) , ++ nextbreakpoint , condition ) ) ; breakpoints . put ( nextbreakpoint , BreakpointManager . getBreakpoint ( exp ) ) ; return BreakpointManager . getBreakpoint ( exp ) ; } | Set an expression breakpoint . A breakpoint stops execution and allows the user to query the environment . |
38,477 | public Breakpoint clearBreakpoint ( int bpno ) { Breakpoint old = breakpoints . remove ( bpno ) ; if ( old != null ) { PStm stmt = findStatement ( old . location . getFile ( ) , old . location . getStartLine ( ) ) ; if ( stmt != null ) { BreakpointManager . setBreakpoint ( stmt , new Breakpoint ( stmt . getLocation ( ) ) ) ; } else { PExp exp = findExpression ( old . location . getFile ( ) , old . location . getStartLine ( ) ) ; assert exp != null : "Cannot locate old breakpoint?" ; BreakpointManager . setBreakpoint ( exp , new Breakpoint ( exp . getLocation ( ) ) ) ; } } return old ; } | Clear the breakpoint given by the number . |
38,478 | public static void typeCheck ( INode classdef , Interpreter interpreter , CallSequence test , Environment outer ) throws AnalysisException , Exception { FlatEnvironment env = null ; if ( classdef instanceof SClassDefinition ) { env = new FlatEnvironment ( interpreter . getAssistantFactory ( ) , classdef . apply ( interpreter . getAssistantFactory ( ) . getSelfDefinitionFinder ( ) ) , outer ) ; } else { List < PDefinition > defs = new Vector < > ( ) ; if ( classdef instanceof AModuleModules ) { defs . addAll ( ( ( AModuleModules ) classdef ) . getDefs ( ) ) ; } env = new FlatEnvironment ( interpreter . getAssistantFactory ( ) , defs , outer ) ; } for ( int i = 0 ; i < test . size ( ) ; i ++ ) { PStm statement = test . get ( i ) ; if ( statement instanceof TraceVariableStatement ) { ( ( TraceVariableStatement ) statement ) . typeCheck ( env , NameScope . NAMESANDSTATE ) ; } else { statement = statement . clone ( ) ; test . set ( i , statement ) ; interpreter . typeCheck ( statement , env ) ; } } } | type check a test |
38,479 | private int getMaxPartCount ( ) { int max = 0 ; for ( Object k : super . fWords . keySet ( ) ) { String key = k . toString ( ) ; int count = key . split ( "\\s+?" ) . length ; if ( count > max ) { max = count ; } } return max ; } | Calculates the maximum number of parts in the largest word in the rule scanner |
38,480 | public static String [ ] charArrayToStringArray ( char [ ] [ ] charArrays ) { if ( charArrays == null ) { return null ; } int length = charArrays . length ; if ( length == 0 ) { return NO_STRINGS ; } String [ ] strings = new String [ length ] ; for ( int i = 0 ; i < length ; i ++ ) { strings [ i ] = new String ( charArrays [ i ] ) ; } return strings ; } | Returns the char arrays as an array of Strings |
38,481 | public static final char [ ] [ ] deepCopy ( char [ ] [ ] toCopy ) { int toCopyLength = toCopy . length ; char [ ] [ ] result = new char [ toCopyLength ] [ ] ; for ( int i = 0 ; i < toCopyLength ; i ++ ) { char [ ] toElement = toCopy [ i ] ; int toElementLength = toElement . length ; char [ ] resultElement = new char [ toElementLength ] ; System . arraycopy ( toElement , 0 , resultElement , 0 , toElementLength ) ; result [ i ] = resultElement ; } return result ; } | Answers a deep copy of the toCopy array . |
38,482 | final static public String [ ] toStrings ( char [ ] [ ] array ) { if ( array == null ) { return NO_STRINGS ; } int length = array . length ; if ( length == 0 ) { return NO_STRINGS ; } String [ ] result = new String [ length ] ; for ( int i = 0 ; i < length ; i ++ ) { result [ i ] = new String ( array [ i ] ) ; } return result ; } | Answers an array of strings from the given array of char array . |
38,483 | public PExp caseARecordPattern ( ARecordPattern node ) throws AnalysisException { AMkTypeExp mkExp = new AMkTypeExp ( ) ; mkExp . setTypeName ( node . getTypename ( ) . clone ( ) ) ; List < PExp > args = new Vector < PExp > ( ) ; for ( PPattern p : node . getPlist ( ) ) { args . add ( p . apply ( this ) . clone ( ) ) ; } addPossibleType ( mkExp , node ) ; mkExp . setArgs ( args ) ; return mkExp ; } | Now compound patterns involve recursive calls to expand their pattern components to expressions . |
38,484 | public List < PDefinition > checkDuplicatePatterns ( PDefinition d , List < PDefinition > defs ) { Set < PDefinition > noDuplicates = new HashSet < PDefinition > ( ) ; for ( PDefinition d1 : defs ) { for ( PDefinition d2 : defs ) { if ( d1 != d2 && d1 . getName ( ) != null && d2 . getName ( ) != null && d1 . getName ( ) . equals ( d2 . getName ( ) ) ) { if ( ! af . getTypeComparator ( ) . compatible ( d1 . getType ( ) , d2 . getType ( ) ) ) { TypeCheckerErrors . report ( 3322 , "Duplicate patterns bind to different types" , d . getLocation ( ) , d ) ; TypeCheckerErrors . detail2 ( d1 . getName ( ) . getName ( ) , d1 . getType ( ) , d2 . getName ( ) . getName ( ) , d2 . getType ( ) ) ; } } } noDuplicates . add ( d1 ) ; } return new Vector < PDefinition > ( noDuplicates ) ; } | Check a DefinitionList for incompatible duplicate pattern definitions . |
38,485 | protected void genIrStatus ( List < IRStatus < PIR > > statuses , INode node ) throws AnalysisException { IRStatus < PIR > status = generator . generateFrom ( node ) ; if ( status != null ) { statuses . add ( status ) ; } } | This method translates a VDM node into an IR status . |
38,486 | public static List < AModuleModules > getModules ( List < INode > ast ) { List < AModuleModules > modules = new LinkedList < > ( ) ; for ( INode n : ast ) { if ( n instanceof AModuleModules ) { modules . add ( ( AModuleModules ) n ) ; } } return modules ; } | Convenience method for extracting the VDM module definitions from a list of VDM nodes . |
38,487 | public static List < SClassDefinition > getClasses ( List < INode > ast ) { List < SClassDefinition > classes = new LinkedList < > ( ) ; for ( INode n : ast ) { if ( n instanceof SClassDefinition ) { classes . add ( ( SClassDefinition ) n ) ; } } return classes ; } | Convenience method for extracting the VDM class definitions from a list of VDM nodes . |
38,488 | public static List < INode > getNodes ( List < ? extends INode > ast ) { List < INode > nodes = new LinkedList < > ( ) ; nodes . addAll ( ast ) ; return nodes ; } | Convenience method for converting a VDM AST into a list of nodes . |
38,489 | protected List < INode > getUserModules ( List < ? extends INode > ast ) { List < INode > userModules = new LinkedList < INode > ( ) ; for ( INode node : ast ) { if ( ! getInfo ( ) . getDeclAssistant ( ) . isLibrary ( node ) ) { userModules . add ( node ) ; } } return userModules ; } | This method extracts the user modules or classes from a VDM AST . |
38,490 | protected void removeUnreachableStms ( List < ? extends INode > ast ) throws AnalysisException { UnreachableStmRemover remover = new UnreachableStmRemover ( ) ; for ( INode node : ast ) { node . apply ( remover ) ; } } | This method removes unreachable statements from the VDM AST . |
38,491 | protected void simplifyLibrary ( INode module ) { List < PDefinition > defs = null ; if ( module instanceof SClassDefinition ) { defs = ( ( SClassDefinition ) module ) . getDefinitions ( ) ; } else if ( module instanceof AModuleModules ) { defs = ( ( AModuleModules ) module ) . getDefs ( ) ; } else { return ; } for ( PDefinition def : defs ) { if ( def instanceof SOperationDefinition ) { SOperationDefinition op = ( SOperationDefinition ) def ; op . setBody ( new ANotYetSpecifiedStm ( ) ) ; op . setPrecondition ( null ) ; op . setPostcondition ( null ) ; } else if ( def instanceof SFunctionDefinition ) { SFunctionDefinition func = ( SFunctionDefinition ) def ; func . setBody ( new ANotYetSpecifiedExp ( ) ) ; func . setPrecondition ( null ) ; func . setPostcondition ( null ) ; } } } | Simplifies a VDM standard library class or module by removing sub - nodes that are likely not to be of interest during the generation of the IR . |
38,492 | protected void handleOldNames ( List < ? extends INode > vdmAst ) throws AnalysisException { OldNameRenamer oldNameRenamer = new OldNameRenamer ( ) ; for ( INode module : vdmAst ) { module . apply ( oldNameRenamer ) ; } } | Processes old names by replacing the tilde sign ~ with an underscore . |
38,493 | protected boolean shouldGenerateVdmNode ( INode vdmNode ) { DeclAssistantIR declAssistant = getInfo ( ) . getDeclAssistant ( ) ; if ( declAssistant . isLibrary ( vdmNode ) ) { return false ; } else { return true ; } } | Determines whether a VDM module or class should be code generated or not . |
38,494 | protected GeneratedModule genIrModule ( MergeVisitor mergeVisitor , IRStatus < ? extends PIR > status ) throws org . overture . codegen . ir . analysis . AnalysisException { if ( status . canBeGenerated ( ) ) { mergeVisitor . init ( ) ; StringWriter writer = new StringWriter ( ) ; status . getIrNode ( ) . apply ( mergeVisitor , writer ) ; boolean isTestCase = isTestCase ( status ) ; GeneratedModule generatedModule ; if ( mergeVisitor . hasMergeErrors ( ) ) { generatedModule = new GeneratedModule ( status . getIrNodeName ( ) , status . getIrNode ( ) , mergeVisitor . getMergeErrors ( ) , isTestCase ) ; } else if ( mergeVisitor . hasUnsupportedTargLangNodes ( ) ) { generatedModule = new GeneratedModule ( status . getIrNodeName ( ) , new HashSet < VdmNodeInfo > ( ) , mergeVisitor . getUnsupportedInTargLang ( ) , isTestCase ) ; } else { generatedModule = new GeneratedModule ( status . getIrNodeName ( ) , status . getIrNode ( ) , formatCode ( writer ) , isTestCase ) ; generatedModule . setTransformationWarnings ( status . getTransformationWarnings ( ) ) ; } return generatedModule ; } else { return new GeneratedModule ( status . getIrNodeName ( ) , status . getUnsupportedInIr ( ) , new HashSet < IrNodeInfo > ( ) , isTestCase ( status ) ) ; } } | This method translates an IR module or class into target language code . |
38,495 | protected Generated genIrExp ( IRStatus < SExpIR > expStatus , MergeVisitor mergeVisitor ) throws org . overture . codegen . ir . analysis . AnalysisException { StringWriter writer = new StringWriter ( ) ; SExpIR expCg = expStatus . getIrNode ( ) ; if ( expStatus . canBeGenerated ( ) ) { mergeVisitor . init ( ) ; expCg . apply ( mergeVisitor , writer ) ; if ( mergeVisitor . hasMergeErrors ( ) ) { return new Generated ( mergeVisitor . getMergeErrors ( ) ) ; } else if ( mergeVisitor . hasUnsupportedTargLangNodes ( ) ) { return new Generated ( new HashSet < VdmNodeInfo > ( ) , mergeVisitor . getUnsupportedInTargLang ( ) ) ; } else { String code = writer . toString ( ) ; return new Generated ( code ) ; } } else { return new Generated ( expStatus . getUnsupportedInIr ( ) , new HashSet < IrNodeInfo > ( ) ) ; } } | Translates an IR expression into target language code . |
38,496 | public static void emitCode ( File outputFolder , String fileName , String code ) { emitCode ( outputFolder , fileName , code , "UTF-8" ) ; } | Emits generated code to a file . The file will be encoded using UTF - 8 . |
38,497 | public static void emitCode ( File outputFolder , String fileName , String code , String encoding ) { try { File javaFile = new File ( outputFolder , File . separator + fileName ) ; javaFile . getParentFile ( ) . mkdirs ( ) ; javaFile . createNewFile ( ) ; PrintWriter writer = new PrintWriter ( new OutputStreamWriter ( new FileOutputStream ( javaFile , false ) , encoding ) ) ; BufferedWriter out = new BufferedWriter ( writer ) ; out . write ( code ) ; out . close ( ) ; } catch ( IOException e ) { log . error ( "Error when saving class file: " + fileName ) ; e . printStackTrace ( ) ; } } | Emits generated code to a file . |
38,498 | protected GeneratedData genVdmToTargetLang ( List < IRStatus < PIR > > statuses ) throws AnalysisException { GeneratedData r = new GeneratedData ( ) ; try { for ( IRStatus < PIR > status : statuses ) { StateInit stateInit = new StateInit ( getInfo ( ) ) ; generator . applyPartialTransformation ( status , stateInit ) ; GroupMutRecs groupMR = new GroupMutRecs ( ) ; generator . applyTotalTransformation ( status , groupMR ) ; if ( status . getIrNode ( ) instanceof AModuleDeclIR ) { AModuleDeclIR cClass = ( AModuleDeclIR ) status . getIrNode ( ) ; SortDependencies sortTrans = new SortDependencies ( cClass . getDecls ( ) ) ; generator . applyPartialTransformation ( status , sortTrans ) ; } } r . setClasses ( prettyPrint ( statuses ) ) ; } catch ( org . overture . codegen . ir . analysis . AnalysisException e ) { throw new AnalysisException ( e ) ; } return r ; } | Main entry point into the Isabelle Translator component . Takes an AST and returns corresponding Isabelle Syntax . |
38,499 | private static boolean hasBreakpointAtCurrentPosition ( VdmThread thread ) { try { thread . updateStack ( ) ; if ( thread . hasStackFrames ( ) ) { final IStackFrame top = thread . getTopStackFrame ( ) ; if ( top instanceof IVdmStackFrame && top . getLineNumber ( ) > 0 ) { final IVdmStackFrame frame = ( IVdmStackFrame ) top ; if ( frame . getSourceURI ( ) != null ) { final String location = frame . getSourceURI ( ) . getPath ( ) ; final IDbgpBreakpoint [ ] breakpoints = thread . getDbgpSession ( ) . getCoreCommands ( ) . getBreakpoints ( ) ; for ( int i = 0 ; i < breakpoints . length ; ++ i ) { if ( breakpoints [ i ] instanceof IDbgpLineBreakpoint ) { final IDbgpLineBreakpoint bp = ( IDbgpLineBreakpoint ) breakpoints [ i ] ; if ( frame . getLineNumber ( ) == bp . getLineNumber ( ) ) { try { if ( new URI ( bp . getFilename ( ) ) . getPath ( ) . equals ( location ) ) { return true ; } } catch ( URISyntaxException e ) { if ( VdmDebugPlugin . DEBUG ) { e . printStackTrace ( ) ; } } } } } } } } } catch ( DebugException e ) { if ( VdmDebugPlugin . DEBUG ) { e . printStackTrace ( ) ; } } catch ( DbgpException e ) { if ( VdmDebugPlugin . DEBUG ) { e . printStackTrace ( ) ; } } return false ; } | Tests if the specified thread has breakpoint at the same line |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.