Support passing of objects to functions
This commit is contained in:
parent
05f3fd7c6e
commit
30686d8550
|
|
@ -1789,6 +1789,7 @@ private:
|
|||
}
|
||||
} else if (nodep->isIO()
|
||||
&& !(VN_IS(nodep->dtypeSkipRefp(), BasicDType)
|
||||
|| VN_IS(nodep->dtypeSkipRefp(), ClassRefDType)
|
||||
|| VN_IS(nodep->dtypeSkipRefp(), NodeArrayDType)
|
||||
|| VN_IS(nodep->dtypeSkipRefp(), NodeUOrStructDType))) {
|
||||
nodep->v3warn(E_UNSUPPORTED,
|
||||
|
|
|
|||
|
|
@ -19,6 +19,11 @@ class ClsArg;
|
|||
function int geta;
|
||||
return imembera;
|
||||
endfunction
|
||||
static function ClsArg create6;
|
||||
ClsArg obj;
|
||||
obj = new(6 - 1);
|
||||
return obj;
|
||||
endfunction
|
||||
endclass
|
||||
|
||||
module t (/*AUTOARG*/);
|
||||
|
|
@ -33,6 +38,10 @@ module t (/*AUTOARG*/);
|
|||
if (c2.imembera != 3) $stop;
|
||||
if (c2.geta() != 3) $stop;
|
||||
|
||||
c2 = ClsArg::create6();
|
||||
if (c2.imembera != 6) $stop;
|
||||
if (c2.geta() != 6) $stop;
|
||||
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
end
|
||||
|
|
|
|||
|
|
@ -16,17 +16,34 @@ class Cls;
|
|||
if (x != 23) $stop;
|
||||
return 42;
|
||||
endfunction
|
||||
|
||||
endclass : Cls
|
||||
|
||||
class OCls;
|
||||
int i;
|
||||
static function OCls create();
|
||||
OCls o = new;
|
||||
o.i = 42;
|
||||
return o;
|
||||
endfunction
|
||||
static task test_obj(OCls o);
|
||||
if (o.i != 42) $stop;
|
||||
endtask
|
||||
endclass
|
||||
|
||||
module t (/*AUTOARG*/);
|
||||
|
||||
initial begin
|
||||
int x;
|
||||
OCls oc;
|
||||
|
||||
Cls::static_task(16);
|
||||
x = Cls::static_function(23);
|
||||
$write("Static function result: %d\n", x);
|
||||
if (x != 42) $stop;
|
||||
|
||||
oc = OCls::create();
|
||||
OCls::test_obj(oc);
|
||||
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue