authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-09-01 14:39:17-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-09-01 14:39:17-04:00
log80d75cf3bf2a1ec72e1ca2e03c599a72261e9604
tree5a8ed92e7d729a0714ecf0679512daf225c989d6
parent60bdbe540538867315038305c6f41020b44036c2

here, have trans_qual_type


1 files changed, 182 insertions(+), 0 deletions(-)

src/parseh.cpp+182
......@@ -43,7 +43,10 @@ struct Context {
4343 ZigList<ErrorMsg *> *errors;
4444 bool warnings_on;
4545 VisibMod visib_mod;
46
4647 HashMap<Buf *, TypeTableEntry *, buf_hash, buf_eql_buf> global_type_table;
48 HashMap<Buf *, AstNode *, buf_hash, buf_eql_buf> global_type_table2;
49
4750 HashMap<Buf *, TypeTableEntry *, buf_hash, buf_eql_buf> struct_type_table;
4851 HashMap<Buf *, TypeTableEntry *, buf_hash, buf_eql_buf> enum_type_table;
4952 HashMap<const void *, TypeTableEntry *, ptr_hash, ptr_eq> decl_table;
......@@ -666,6 +669,185 @@ static bool c_is_float(Context *c, QualType qt) {
666669
667670static AstNode * trans_stmt(Context *c, Stmt *stmt);
668671
672static AstNode *trans_type_with_table(Context *c, const Type *ty, const SourceLocation &source_loc,
673 HashMap<Buf *, AstNode *, buf_hash, buf_eql_buf> *type_table)
674{
675 switch (ty->getTypeClass()) {
676 case Type::Builtin:
677 {
678 const BuiltinType *builtin_ty = static_cast<const BuiltinType*>(ty);
679 switch (builtin_ty->getKind()) {
680 case BuiltinType::Void:
681 zig_panic("TODO void type");
682 case BuiltinType::Bool:
683 zig_panic("TODO bool type");
684 case BuiltinType::Char_U:
685 case BuiltinType::UChar:
686 case BuiltinType::Char_S:
687 zig_panic("TODO u8 type");
688 case BuiltinType::SChar:
689 zig_panic("TODO i8 type");
690 case BuiltinType::UShort:
691 zig_panic("TODO c_ushort type");
692 case BuiltinType::UInt:
693 zig_panic("TODO c_uint type");
694 case BuiltinType::ULong:
695 zig_panic("TODO c_ulong type");
696 case BuiltinType::ULongLong:
697 zig_panic("TODO c_ulonglong type");
698 case BuiltinType::Short:
699 zig_panic("TODO c_short type");
700 case BuiltinType::Int:
701 zig_panic("TODO c_int type");
702 case BuiltinType::Long:
703 zig_panic("TODO c_long type");
704 case BuiltinType::LongLong:
705 zig_panic("TODO c_longlong type");
706 case BuiltinType::UInt128:
707 zig_panic("TODO u128 type");
708 case BuiltinType::Int128:
709 zig_panic("TODO i128 type");
710 case BuiltinType::Float:
711 zig_panic("TODO f32 type");
712 case BuiltinType::Double:
713 zig_panic("TODO f64 type");
714 case BuiltinType::Float128:
715 zig_panic("TODO f128 type");
716 case BuiltinType::LongDouble:
717 zig_panic("TODO c_longdouble type");
718 case BuiltinType::WChar_U:
719 case BuiltinType::Char16:
720 case BuiltinType::Char32:
721 case BuiltinType::WChar_S:
722 case BuiltinType::Half:
723 case BuiltinType::NullPtr:
724 case BuiltinType::ObjCId:
725 case BuiltinType::ObjCClass:
726 case BuiltinType::ObjCSel:
727 case BuiltinType::OMPArraySection:
728 case BuiltinType::Dependent:
729 case BuiltinType::Overload:
730 case BuiltinType::BoundMember:
731 case BuiltinType::PseudoObject:
732 case BuiltinType::UnknownAny:
733 case BuiltinType::BuiltinFn:
734 case BuiltinType::ARCUnbridgedCast:
735
736 case BuiltinType::OCLImage1dRO:
737 case BuiltinType::OCLImage1dArrayRO:
738 case BuiltinType::OCLImage1dBufferRO:
739 case BuiltinType::OCLImage2dRO:
740 case BuiltinType::OCLImage2dArrayRO:
741 case BuiltinType::OCLImage2dDepthRO:
742 case BuiltinType::OCLImage2dArrayDepthRO:
743 case BuiltinType::OCLImage2dMSAARO:
744 case BuiltinType::OCLImage2dArrayMSAARO:
745 case BuiltinType::OCLImage2dMSAADepthRO:
746 case BuiltinType::OCLImage2dArrayMSAADepthRO:
747 case BuiltinType::OCLImage3dRO:
748 case BuiltinType::OCLImage1dWO:
749 case BuiltinType::OCLImage1dArrayWO:
750 case BuiltinType::OCLImage1dBufferWO:
751 case BuiltinType::OCLImage2dWO:
752 case BuiltinType::OCLImage2dArrayWO:
753 case BuiltinType::OCLImage2dDepthWO:
754 case BuiltinType::OCLImage2dArrayDepthWO:
755 case BuiltinType::OCLImage2dMSAAWO:
756 case BuiltinType::OCLImage2dArrayMSAAWO:
757 case BuiltinType::OCLImage2dMSAADepthWO:
758 case BuiltinType::OCLImage2dArrayMSAADepthWO:
759 case BuiltinType::OCLImage3dWO:
760 case BuiltinType::OCLImage1dRW:
761 case BuiltinType::OCLImage1dArrayRW:
762 case BuiltinType::OCLImage1dBufferRW:
763 case BuiltinType::OCLImage2dRW:
764 case BuiltinType::OCLImage2dArrayRW:
765 case BuiltinType::OCLImage2dDepthRW:
766 case BuiltinType::OCLImage2dArrayDepthRW:
767 case BuiltinType::OCLImage2dMSAARW:
768 case BuiltinType::OCLImage2dArrayMSAARW:
769 case BuiltinType::OCLImage2dMSAADepthRW:
770 case BuiltinType::OCLImage2dArrayMSAADepthRW:
771 case BuiltinType::OCLImage3dRW:
772 case BuiltinType::OCLSampler:
773 case BuiltinType::OCLEvent:
774 case BuiltinType::OCLClkEvent:
775 case BuiltinType::OCLQueue:
776 case BuiltinType::OCLReserveID:
777 zig_panic("TODO more c type");
778 }
779 break;
780 }
781 case Type::Pointer:
782 zig_panic("TODO pointer");
783 case Type::Typedef:
784 zig_panic("TODO typedef");
785 case Type::Elaborated:
786 zig_panic("TODO elaborated");
787 case Type::FunctionProto:
788 zig_panic("TODO FunctionProto");
789 case Type::Record:
790 zig_panic("TODO Record");
791 case Type::Enum:
792 zig_panic("TODO Enum");
793 case Type::ConstantArray:
794 zig_panic("TODO ConstantArray");
795 case Type::Paren:
796 zig_panic("TODO Paren");
797 case Type::Decayed:
798 zig_panic("TODO Decayed");
799 case Type::Attributed:
800 zig_panic("TODO Attributed");
801 case Type::BlockPointer:
802 case Type::LValueReference:
803 case Type::RValueReference:
804 case Type::MemberPointer:
805 case Type::IncompleteArray:
806 case Type::VariableArray:
807 case Type::DependentSizedArray:
808 case Type::DependentSizedExtVector:
809 case Type::Vector:
810 case Type::ExtVector:
811 case Type::FunctionNoProto:
812 case Type::UnresolvedUsing:
813 case Type::Adjusted:
814 case Type::TypeOfExpr:
815 case Type::TypeOf:
816 case Type::Decltype:
817 case Type::UnaryTransform:
818 case Type::TemplateTypeParm:
819 case Type::SubstTemplateTypeParm:
820 case Type::SubstTemplateTypeParmPack:
821 case Type::TemplateSpecialization:
822 case Type::Auto:
823 case Type::InjectedClassName:
824 case Type::DependentName:
825 case Type::DependentTemplateSpecialization:
826 case Type::PackExpansion:
827 case Type::ObjCObject:
828 case Type::ObjCInterface:
829 case Type::Complex:
830 case Type::ObjCObjectPointer:
831 case Type::Atomic:
832 case Type::Pipe:
833 case Type::ObjCTypeParam:
834 case Type::DeducedTemplateSpecialization:
835 zig_panic("TODO more c type aoeu");
836 }
837 zig_unreachable();
838}
839
840static AstNode * trans_qual_type_with_table(Context *c, QualType qt, const SourceLocation &source_loc,
841 HashMap<Buf *, AstNode *, buf_hash, buf_eql_buf> *type_table)
842{
843 return trans_type_with_table(c, qt.getTypePtr(), source_loc, type_table);
844}
845
846static AstNode * trans_qual_type(Context *c, QualType qt, const SourceLocation &source_loc) {
847 return trans_qual_type_with_table(c, qt, source_loc, &c->global_type_table2);
848}
849
850
669851static AstNode * trans_expr(Context *c, Expr *expr) {
670852 return trans_stmt(c, expr);
671853}