1 /*
2  * Copyright (c) 1999-2019 Stephen Williams (steve@icarus.com)
3  *
4  *    This source code is free software; you can redistribute it
5  *    and/or modify it in source code form under the terms of the GNU
6  *    General Public License as published by the Free Software
7  *    Foundation; either version 2 of the License, or (at your option)
8  *    any later version.
9  *
10  *    This program 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
13  *    GNU General Public License for more details.
14  *
15  *    You should have received a copy of the GNU General Public License
16  *    along with this program; if not, write to the Free Software
17  *    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19 
20 # include "config.h"
21 # include  "PTask.h"
22 # include  <cassert>
23 
PTaskFunc(perm_string n,LexicalScope * p)24 PTaskFunc::PTaskFunc(perm_string n, LexicalScope*p)
25 : PScope(n,p), this_type_(0), ports_(0)
26 {
27 }
28 
~PTaskFunc()29 PTaskFunc::~PTaskFunc()
30 {
31 }
32 
var_init_needs_explicit_lifetime() const33 bool PTaskFunc::var_init_needs_explicit_lifetime() const
34 {
35       return default_lifetime == STATIC;
36 }
37 
set_ports(vector<pform_tf_port_t> * p)38 void PTaskFunc::set_ports(vector<pform_tf_port_t>*p)
39 {
40       assert(ports_ == 0);
41       ports_ = p;
42 }
43 
set_this(class_type_t * type,PWire * this_wire)44 void PTaskFunc::set_this(class_type_t*type, PWire*this_wire)
45 {
46       assert(this_type_ == 0);
47       this_type_ = type;
48 
49 	// Push a synthesis argument that is the "this" value.
50       if (ports_==0)
51 	    ports_ = new vector<pform_tf_port_t>;
52 
53       size_t use_size = ports_->size();
54       ports_->resize(use_size + 1);
55       for (size_t idx = use_size ; idx > 0 ; idx -= 1)
56 	    ports_->at(idx) = ports_->at(idx-1);
57 
58       ports_->at(0) = pform_tf_port_t(this_wire);
59 }
60 
PTask(perm_string name,LexicalScope * parent,bool is_auto__)61 PTask::PTask(perm_string name, LexicalScope*parent, bool is_auto__)
62 : PTaskFunc(name, parent), statement_(0)
63 {
64       is_auto_ = is_auto__;
65 }
66 
~PTask()67 PTask::~PTask()
68 {
69 }
70 
set_statement(Statement * s)71 void PTask::set_statement(Statement*s)
72 {
73       assert(statement_ == 0);
74       statement_ = s;
75 }
76 
symbol_type() const77 PNamedItem::SymbolType PTask::symbol_type() const
78 {
79       return TASK;
80 }
81