LibreOffice Module basic (master)
1
basic
source
comp
sbcomp.cxx
Go to the documentation of this file.
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
* This file is part of the LibreOffice project.
4
*
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/.
8
*
9
* This file incorporates work covered by the following license notice:
10
*
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 .
18
*/
19
20
21
#include <
basic/sbmeth.hxx
>
22
#include <
basic/sbstar.hxx
>
23
#include <
basic/sbx.hxx
>
24
#include <parser.hxx>
25
#include <image.hxx>
26
#include <
sbintern.hxx
>
27
#include <
sbobjmod.hxx
>
28
#include <memory>
29
30
// This routine is defined here, so that the
31
// compiler can be loaded as a discrete segment.
32
33
bool
SbModule::Compile
()
34
{
35
if
(
pImage
)
36
return
true
;
37
StarBASIC
* pBasic =
dynamic_cast<
StarBASIC
*
>
(
GetParent
() );
38
if
( !pBasic )
39
return
false
;
40
SbxBase::ResetError
();
41
42
SbModule
* pOld =
GetSbData
()->
pCompMod
;
43
GetSbData
()->
pCompMod
=
this
;
44
45
auto
pParser = std::make_unique<SbiParser>( pBasic,
this
);
46
while
( pParser->Parse() ) {}
47
if
( !pParser->GetErrors() )
48
pParser->aGen.Save();
49
pParser.reset();
50
// for the disassembler
51
if
(
pImage
)
52
pImage
->aOUSource =
aOUSource
;
53
54
GetSbData
()->
pCompMod
= pOld;
55
56
// compiling a module, the module-global
57
// variables of all modules become invalid
58
bool
bRet =
IsCompiled
();
59
if
( bRet )
60
{
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
++)
66
{
67
SbMethod
*
p
=
dynamic_cast<
SbMethod
*
>
(
pMethods
->Get(
i
));
68
if
(
p
)
69
p
->ClearStatics();
70
}
71
72
// #i31510 Init other libs only if Basic isn't running
73
if
(
GetSbData
()->
pInst
== nullptr )
74
{
75
SbxObject
* pParent_ = pBasic->
GetParent
();
76
if
( pParent_ )
77
pBasic =
dynamic_cast<
StarBASIC
*
>
( pParent_ );
78
if
( pBasic )
79
pBasic->
ClearAllModuleVars
();
80
}
81
}
82
83
return
bRet;
84
}
85
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SbMethod
Definition:
sbmeth.hxx:31
SbModule
Definition:
sbmod.hxx:49
SbModule::Compile
bool Compile()
Definition:
sbcomp.cxx:33
SbModule::pImage
std::unique_ptr< SbiImage > pImage
Definition:
sbmod.hxx:66
SbModule::IsCompiled
bool IsCompiled() const
Definition:
sbxmod.cxx:454
SbModule::aOUSource
OUString aOUSource
Definition:
sbmod.hxx:64
SbModule::RemoveVars
SAL_DLLPRIVATE void RemoveVars()
Definition:
sbxmod.cxx:1279
SbObjModule
Definition:
sbobjmod.hxx:31
SbxBase::ResetError
static void ResetError()
Definition:
sbxbase.cxx:128
SbxObject
Definition:
sbxobj.hxx:31
SbxObject::pMethods
SbxArrayRef pMethods
Definition:
sbxobj.hxx:34
SbxVariable::GetParent
const SbxObject * GetParent() const
Definition:
sbxvar.hxx:296
StarBASIC
Definition:
sbstar.hxx:38
StarBASIC::ClearAllModuleVars
void ClearAllModuleVars()
Definition:
sbxmod.cxx:1373
p
void * p
i
int i
GetSbData
SbiGlobals * GetSbData()
Definition:
sbintern.cxx:26
sbintern.hxx
sbmeth.hxx
sbobjmod.hxx
sbstar.hxx
sbx.hxx
SbiGlobals::pInst
SbiInstance * pInst
Definition:
sbintern.hxx:108
SbiGlobals::pCompMod
SbModule * pCompMod
Definition:
sbintern.hxx:123
Generated on Sun Jul 30 2023 04:39:05 for LibreOffice Module basic (master) by
1.9.3