~ubuntu-branches/ubuntu/precise/plib/precise

« back to all changes in this revision

Viewing changes to src/psl/pslProgram.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Philipp Frauenfelder
  • Date: 2004-08-26 23:31:16 UTC
  • mfrom: (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20040826233116-vqusvk3ytn6lq3rl
Tags: 1.8.3-2
* Corrected C++ syntax in ssgAux/ssgaSky.h. Thanks to
  neuro.harald AT surfeu.at for the patch. Closes: #260355
* Build-Depends on libx11-dev, libxmu-dev instead of xlibs-dev
* Removed build depends on g++, libc6.
* Changed (build) depends on libgl-dev to xlibmesa-gl-dev | libgl-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
     PLIB - A Suite of Portable Game Libraries
 
3
     Copyright (C) 1998,2002  Steve Baker
 
4
 
 
5
     This library is free software; you can redistribute it and/or
 
6
     modify it under the terms of the GNU Library General Public
 
7
     License as published by the Free Software Foundation; either
 
8
     version 2 of the License, or (at your option) any later version.
 
9
 
 
10
     This library is distributed in the hope that it will be useful,
 
11
     but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
     Library General Public License for more details.
 
14
 
 
15
     You should have received a copy of the GNU Library General Public
 
16
     License along with this library; if not, write to the Free Software
 
17
     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 
18
 
 
19
     For further information visit http://plib.sourceforge.net
 
20
 
 
21
     $Id: pslProgram.cxx,v 1.17 2003/01/06 05:10:14 sjbaker Exp $
 
22
*/
 
23
 
 
24
 
 
25
#include "pslLocal.h"
 
26
 
 
27
pslProgram::pslProgram ( const pslExtension *ext, const char *_prgnm )
 
28
{
 
29
  if ( ! _pslInitialised )
 
30
    ulSetError ( UL_FATAL,
 
31
          "PSL: You didn't call pslInit() before using PSL functions." ) ;
 
32
 
 
33
  code = new pslOpcode [ MAX_CODE ] ;
 
34
 
 
35
  extensions = ext ;
 
36
 
 
37
  progName = NULL ;
 
38
 
 
39
  if ( _prgnm == NULL ) _prgnm = "PSLprogram" ;
 
40
 
 
41
  setProgName ( _prgnm ) ;
 
42
 
 
43
  compiler = new pslCompiler ( this, code, ext, getProgName () ) ;
 
44
  context  = new pslContext ( this ) ;
 
45
 
 
46
  compiler-> init  () ;
 
47
  context -> reset () ;
 
48
 
 
49
  const char *force_trace_env = getenv ( "PSL_TRACE" ) ;
 
50
  const char *force_stack_env = getenv ( "PSL_STACK" ) ;
 
51
 
 
52
  force_trace = ( force_trace_env != NULL &&
 
53
                  ulStrEqual ( force_trace_env, "always" ) ) ;
 
54
  force_stacktrace = ( force_stack_env != NULL &&
 
55
                  ulStrEqual ( force_stack_env, "always" ) ) ;
 
56
 
 
57
  if ( force_trace )
 
58
    compiler -> generateLineNumbers () ;
 
59
}
 
60
 
 
61
 
 
62
pslProgram::pslProgram ( pslProgram *src, const char *_prgnm )
 
63
{
 
64
  progName = NULL ;
 
65
 
 
66
  if ( _prgnm == NULL ) _prgnm = src -> getProgName () ;
 
67
 
 
68
  setProgName ( _prgnm ) ;
 
69
 
 
70
  /* This will fail if this pslProgram is ever deleted */
 
71
  /* We need ref-counting on code/compiler */
 
72
 
 
73
  code       = src -> getCode       () ;
 
74
  compiler   = src -> getCompiler   () ;
 
75
  extensions = src -> getExtensions () ;
 
76
  userData   = src -> getUserData   () ;
 
77
 
 
78
  context = new pslContext ( this ) ;
 
79
  context -> reset () ;
 
80
}
 
81
 
 
82
 
 
83
pslProgram::~pslProgram ()
 
84
{
 
85
  /* This will fail if this pslProgram was copy-constructed */
 
86
  /* We need ref-counting on code/compiler */
 
87
  /* DEBUG-ME! */
 
88
  delete [] progName ;
 
89
  delete    compiler ;
 
90
  delete    context  ;
 
91
  delete [] code     ;
 
92
}
 
93
 
 
94
 
 
95
void       pslProgram::dump  () const {        compiler-> dump  () ; }
 
96
void       pslProgram::reset ()       {        context -> reset () ; }
 
97
pslResult  pslProgram::step  ()       { return force_trace ?
 
98
                                               context -> trace () :
 
99
                                               context -> step  () ; }
 
100
pslResult  pslProgram::trace ()       { return context -> trace () ; }
 
101
 
 
102
 
 
103
 
 
104
int pslProgram::compile ( const char *memptr, const char *fname )
 
105
{
 
106
  if ( strcmp ( getProgName(), "PSLprogram" ) == 0 )
 
107
    setProgName ( fname ) ;
 
108
 
 
109
  return compiler -> compile ( memptr, fname ) ;
 
110
}
 
111
 
 
112
 
 
113
int pslProgram::compile ( const char *fname )
 
114
{
 
115
  if ( strcmp ( getProgName(), "PSLprogram" ) == 0 )
 
116
    setProgName ( fname ) ;
 
117
 
 
118
  return compiler -> compile ( fname ) ;
 
119
}
 
120
 
 
121
 
 
122
int pslProgram::compile ( FILE *fd )
 
123
{
 
124
  return compiler -> compile ( fd ) ;
 
125
}
 
126
 
 
127
 
 
128