symbolLinkingExpr db imps su (NewObject tp args dp) = if atsFailed then typeLinkingFailure' $ "NewObject types of Args " ++ (show ats) else
                                                         case [TypeClass (Name nm) | TypeClass (Name nm) <- lookUpDB db imps su (typeToName tp)] of
                                                             [] -> typeLinkingFailure' $ "New Object []: " ++ (show tp) ++ (show args) ++ (show imps)
                                                             [(TypeClass (Name nm))]-> let Just tn = getTypeEntry db nm
                                                                                           cons = [node | node@(TN (FUNC mds ls _ pt _) _) <- subNodes tn, elem "cons" mds, ls == nm, accessibleSymbol db cname (symbol node), argsMatching (concat ats) pt]
                                                                                           cons' = if accessibleType db cname (symbol tn) then cons else [node | node <- cons, not $ elem "protected" ((symbolModifiers . symbol) node)]--error $ "using non protect accessible types" ++ (show (symbol tn))
                                                                                        in if elem "abstract" ((symbolModifiers . symbol) tn)
                                                                                             then typeLinkingFailure' $ "New Object: cannot create abstract class object" ++ (show nm)
                                                                                             else if cons' == []
                                                                                                     then typeLinkingFailure' $ "New Object: no matching constructor for " ++ (show ats) ++ (show [node | node@(TN (FUNC mds _ _ pt _) _) <- subNodes tn, elem "cons" mds])
                                                                                                     else map symbol cons'
                                                             tcs -> typeLinkingFailure' $ "New Object multi: " ++ (show tcs) ++ (show tp) ++ (show args)
  where
      cname = (typeToName . lookUpThis) su
      ats = map (typeLinkingExpr db imps su) args
      atsFailed = or $ map null ats
symbolLinkingExpr db imps su (NewObject tp args dp) = if atsFailed then typeLinkingFailure' $ "NewObject types of Args " ++ (show ats) else
                                                         case [TypeClass (Name nm) | TypeClass (Name nm) <- lookUpDB db imps su (typeToName tp)] of
                                                             [] -> typeLinkingFailure' $ "New Object []: " ++ (show tp) ++ (show args) ++ (show imps)
                                                             [(TypeClass (Name nm))]-> let Just tn = getTypeEntry db nm
                                                                                           cons = [node | node@(TN (FUNC mds ls _ pt _) _) <- subNodes tn, elem "cons" mds, ls == nm, accessibleSymbol db cname (symbol node), argsMatching (concat ats) pt]
                                                                                           cons' = if accessibleType db cname (symbol tn) then cons else [node | node <- cons, not $ elem "protected" ((symbolModifiers . symbol) node)]--error $ "using non protect accessible types" ++ (show (symbol tn))
                                                                                        in if elem "abstract" ((symbolModifiers . symbol) tn)
                                                                                             then typeLinkingFailure' $ "New Object: cannot create abstract class object" ++ (show nm)
                                                                                             else if cons' == []
                                                                                                     then typeLinkingFailure' $ "New Object: no matching constructor for " ++ (show ats) ++ (show [node | node@(TN (FUNC mds _ _ pt _) _) <- subNodes tn, elem "cons" mds])
                                                                                                     else map symbol cons'
                                                             tcs -> typeLinkingFailure' $ "New Object multi: " ++ (show tcs) ++ (show tp) ++ (show args)
  where
      cname = (typeToName . lookUpThis) su
      ats = map (typeLinkingExpr db imps su) args
      atsFailed = or $ map null ats
symbolLinkingExpr db imps su (NewObject tp args dp) = if atsFailed then typeLinkingFailure' $ "NewObject types of Args " ++ (show ats) else
                                                         case [TypeClass (Name nm) | TypeClass (Name nm) <- lookUpDB db imps su (typeToName tp)] of
                                                             [] -> typeLinkingFailure' $ "New Object []: " ++ (show tp) ++ (show args) ++ (show imps)
                                                             [(TypeClass (Name nm))]-> let Just tn = getTypeEntry db nm
                                                                                           cons = [node | node@(TN (FUNC mds ls _ pt _) _) <- subNodes tn, elem "cons" mds, ls == nm, accessibleSymbol db cname (symbol node), argsMatching (concat ats) pt]
                                                                                           cons' = if accessibleType db cname (symbol tn) then cons else [node | node <- cons, not $ elem "protected" ((symbolModifiers . symbol) node)]--error $ "using non protect accessible types" ++ (show (symbol tn))
                                                                                        in if elem "abstract" ((symbolModifiers . symbol) tn)
                                                                                             then typeLinkingFailure' $ "New Object: cannot create abstract class object" ++ (show nm)
                                                                                             else if cons' == []
                                                                                                     then typeLinkingFailure' $ "New Object: no matching constructor for " ++ (show ats) ++ (show [node | node@(TN (FUNC mds _ _ pt _) _) <- subNodes tn, elem "cons" mds])
                                                                                                     else map symbol cons'
                                                             tcs -> typeLinkingFailure' $ "New Object multi: " ++ (show tcs) ++ (show tp) ++ (show args)
  where
      cname = (typeToName . lookUpThis) su
      ats = map (typeLinkingExpr db imps su) args
      atsFailed = or $ map null ats