xtractExts :: UExpr -> [ExtVars]
extractExts UExpr { uExprExpr = expr } 
  = go expr

  where
  go :: Expr a -> [ExtVars]
  go e =
    case e of
      Const _ _                    -> []
      Drop _ _ _                   -> []
      Local _ _ _ e0 e1            -> go e0 ++ go e1
      Var _ _                      -> []
      ExternVar t name mvals       -> 
        case mvals of
          Nothing   -> impossible "extractExts" "copilot-c99/Test" 
          Just vals -> [(name, toDynF t vals)]
      ExternFun _ _ es _ _         -> concatMap extractExts es
      ExternArray _ _ _ _ idx _ _  -> go idx
      Op1 _ e0                     -> go e0
      Op2 _ e0 e1                  -> go e0 ++ go e1
      Op3 _ e0 e1 e2               -> go e0 ++ go e1 ++ go e2

--------------------------------------------------------------------------------

extractExts :: UExpr -> [ExtVars]
extractExts UExpr { uExprExpr = expr } 
  = go expr

  where
  go :: Expr a -> [ExtVars]
  go e =
    case e of
      Const _ _                    -> []
      Drop _ _ _                   -> []
      Local _ _ _ e0 e1            -> go e0 ++ go e1
      Var _ _                      -> []
      ExternVar t name mvals       -> 
        case mvals of
          Nothing   -> impossible "extractExts" "copilot-c99/Test" 
          Just vals -> [(name, toDynF t vals)]
      ExternFun _ _ es _ _         -> concatMap extractExts es
      ExternArray _ _ _ _ idx _ _  -> go idx
      Op1 _ e0                     -> go e0
      Op2 _ e0 e1                  -> go e0 ++ go e1
      Op3 _ e0 e1 e2               -> go e0 ++ go e1 ++ go e2

--------------------------------------------------------------------------------
extractExts UExpr { uExprExpr = expr } 
  = go expr

  where
  go :: Expr a -> [ExtVars]
  go e =
    case e of
      Const _ _                    -> []
      Drop _ _ _                   -> []
      Local _ _ _ e0 e1            -> go e0 ++ go e1
      Var _ _                      -> []
      ExternVar t name mvals       -> 
        case mvals of
          Nothing   -> impossible "extractExts" "copilot-c99/Test" 
          Just vals -> [(name, toDynF t vals)]
      ExternFun _ _ es _ _         -> concatMap extractExts es
      ExternArray _ _ _ _ idx _ _  -> go idx
      Op1 _ e0                     -> go e0
      Op2 _ e0 e1                  -> go e0 ++ go e1
      Op3 _ e0 e1 e2               -> go e0 ++ go e1 ++ go e2

--------------------------------------------------------------------------------