1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <basic/sbmeth.hxx>
22 #include <basic/sbstar.hxx>
23 #include <basic/sbx.hxx>
26 #include <sbintern.hxx>
27 #include <sbobjmod.hxx>
30 // This routine is defined here, so that the
31 // compiler can be loaded as a discrete segment.
33 bool SbModule::Compile()
37 StarBASIC
* pBasic
= dynamic_cast<StarBASIC
*>( GetParent() );
40 SbxBase::ResetError();
42 SbModule
* pOld
= GetSbData()->pCompMod
;
43 GetSbData()->pCompMod
= this;
45 auto pParser
= std::make_unique
<SbiParser
>( pBasic
, this );
46 while( pParser
->Parse() ) {}
47 if( !pParser
->GetErrors() )
50 // for the disassembler
52 pImage
->aOUSource
= aOUSource
;
54 GetSbData()->pCompMod
= pOld
;
56 // compiling a module, the module-global
57 // variables of all modules become invalid
58 bool bRet
= IsCompiled();
61 if( dynamic_cast<const SbObjModule
*>( this) == nullptr )
62 pBasic
->ClearAllModuleVars();
63 RemoveVars(); // remove 'this' Modules variables
64 // clear all method statics
65 for (sal_uInt32 i
= 0; i
< pMethods
->Count(); i
++)
67 SbMethod
* p
= dynamic_cast<SbMethod
*>(pMethods
->Get(i
));
72 // #i31510 Init other libs only if Basic isn't running
73 if( GetSbData()->pInst
== nullptr )
75 SbxObject
* pParent_
= pBasic
->GetParent();
77 pBasic
= dynamic_cast<StarBASIC
*>( pParent_
);
79 pBasic
->ClearAllModuleVars();
85 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */