зеркало из https://github.com/microsoft/ivy.git
class creation might be working
This commit is contained in:
Родитель
664ad20e93
Коммит
40fe06a0c5
|
@ -0,0 +1,30 @@
|
|||
#include "udp_test.h"
|
||||
#include <iostream>
|
||||
|
||||
/*
|
||||
|
||||
To compile:
|
||||
|
||||
ivy_to_cpp target=class isolate=iso_impl build=true udp_test.ivy
|
||||
g++ -g udp_class_test.cpp udp_test.o -o udp_class_test -pthread
|
||||
|
||||
|
||||
*/
|
||||
|
||||
/* To implement the imported actions, we subclass udp_test. Notice
|
||||
imported actions begin with 'imp__', and '__' replaces '.', so
|
||||
foo.send becomes imp__foo__send.
|
||||
*/
|
||||
|
||||
class myclass : public udp_test {
|
||||
virtual void imp__foo__recv(int dst, int v) {
|
||||
std::cout << "process " << dst << " received " << v << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
/* In the main, we create an instance and call its exported methods. */
|
||||
|
||||
int main(int argc, const char **argv) {
|
||||
myclass obj;
|
||||
obj.ext__foo__send(0,1,1);
|
||||
}
|
|
@ -2037,7 +2037,7 @@ class z3_thunk : public thunk<D,R> {
|
|||
close_scope(impl)
|
||||
|
||||
|
||||
if target.get() in ["repl","test"]:
|
||||
if target.get() in ["repl","test"] and emit_main:
|
||||
emit_repl_imports(header,impl,classname)
|
||||
emit_repl_boilerplate1(header,impl,classname)
|
||||
|
||||
|
@ -4023,7 +4023,7 @@ public:
|
|||
};
|
||||
""".replace('classname',classname))
|
||||
|
||||
target = iu.EnumeratedParameter("target",["impl","gen","repl","test"],"gen")
|
||||
target = iu.EnumeratedParameter("target",["impl","gen","repl","test","class"],"gen")
|
||||
opt_classname = iu.Parameter("classname","")
|
||||
opt_build = iu.BooleanParameter("build",False)
|
||||
opt_trace = iu.BooleanParameter("trace",False)
|
||||
|
@ -4033,6 +4033,7 @@ opt_main = iu.Parameter("main","main")
|
|||
opt_stdafx = iu.BooleanParameter("stdafx",False)
|
||||
opt_outdir = iu.Parameter("outdir","")
|
||||
|
||||
emit_main = True
|
||||
|
||||
def main():
|
||||
ia.set_determinize(True)
|
||||
|
@ -4045,6 +4046,10 @@ def main():
|
|||
else:
|
||||
iu.set_parameters({'keep_destructors':'true'})
|
||||
|
||||
if target.get() == 'class':
|
||||
target.set('repl')
|
||||
global emit_main
|
||||
emit_main = False
|
||||
|
||||
|
||||
with im.Module():
|
||||
|
@ -4123,7 +4128,10 @@ def main():
|
|||
else:
|
||||
_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
paths = '-I {} -L {} -Wl,-rpath={}'.format(_dir,_dir,_dir)
|
||||
cmd = "g++ {} -g -o {} {}.cpp".format(paths,basename,basename)
|
||||
if emit_main:
|
||||
cmd = "g++ {} -g -o {} {}.cpp".format(paths,basename,basename)
|
||||
else:
|
||||
cmd = "g++ {} -c {}.cpp".format(paths,basename)
|
||||
if target.get() in ['gen','test']:
|
||||
cmd = cmd + ' -lz3'
|
||||
cmd += ' -pthread'
|
||||
|
|
Загрузка…
Ссылка в новой задаче