diff options
| author | Martial Simon <msimon_fr@hotmail.com> | 2025-09-15 01:07:58 +0200 |
|---|---|---|
| committer | Martial Simon <msimon_fr@hotmail.com> | 2025-09-15 01:07:58 +0200 |
| commit | 967be9e750221ab2ab783f95df79bb26d290a45e (patch) | |
| tree | 6802900a5e975f9f68b169f0f503f040056d6952 /tiger-compiler/tcsh/src/swig_real_type.hh | |
Diffstat (limited to 'tiger-compiler/tcsh/src/swig_real_type.hh')
| -rw-r--r-- | tiger-compiler/tcsh/src/swig_real_type.hh | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/tiger-compiler/tcsh/src/swig_real_type.hh b/tiger-compiler/tcsh/src/swig_real_type.hh new file mode 100644 index 0000000..9420bf9 --- /dev/null +++ b/tiger-compiler/tcsh/src/swig_real_type.hh @@ -0,0 +1,67 @@ +#ifndef SWIG_REAL_TYPE_HH +#define SWIG_REAL_TYPE_HH + +#include "helper.hh" + +namespace { + using namespace ast; + class SwigAstTypeVisitor : public ConstVisitor + { + public: + PyObject *result; + SwigAstTypeVisitor() : GenVisitor<misc::constify_traits>() {} + ~SwigAstTypeVisitor() {} + +#define STHELPER(TYPE) STCONVERT(TYPE, p_ast__ ## TYPE) + STHELPER(ArrayExp) + STHELPER(ArrayTy) + STHELPER(AssignExp) + STHELPER(Ast) + STHELPER(BreakExp) + STHELPER(CallExp) + STHELPER(CastExp) + STHELPER(ChunkList) + STHELPER(ClassTy) + STHELPER(Field) + STHELPER(FieldInit) + STHELPER(FieldVar) + STHELPER(ForExp) + STHELPER(FunctionDec) + STHELPER(IfExp) + STHELPER(IntExp) + STHELPER(LetExp) + STHELPER(MethodCallExp) + STHELPER(MethodDec) + STHELPER(NameTy) + STHELPER(NilExp) + STHELPER(ObjectExp) + STHELPER(OpExp) + STHELPER(RecordExp) + STHELPER(RecordTy) + STHELPER(SeqExp) + STHELPER(SimpleVar) + STHELPER(StringExp) + STHELPER(SubscriptVar) + STHELPER(TypeDec) + STHELPER(VarDec) + STHELPER(WhileExp) +#undef STHELPER + +#define STCHUNKHELPER(TYPE) \ + STCONVERT(TYPE ## Chunk, p_ast__ChunkT_ast__ ## TYPE ## Dec_t) + STCHUNKHELPER(Function) + STCHUNKHELPER(Method) + STCHUNKHELPER(Type) + STCHUNKHELPER(Var) +#undef STCHUNKHELPER + }; +} // namespace + +PyObject *get_swig_real_ast_type(const ast::Ast& e) +{ + SwigAstTypeVisitor stv; + e.accept(stv); + return stv.result; +} + +#endif /* ! SWIG_REAL_TYPE_HH */ |
